Results 1 to 2 of 2
  1. #1
    MSgt. Shooter Person
    Join Date
    Sep 2006
    Location
    Up your butt...
    Posts
    255
    Gamer IDs

    Gamertag: xAce1208x

    Question Decoding "Bot Fire" Funcions.

    Can someone specifically tell me how the following functions tell the AI bot how to use the shockrifle? I recently made a weapon that Work like the shockrifle, but the primary fire shoots the ball, and the secondary fire shoots the beam. I just want someone to explain how the 'BestMode()', 'RangedAttackTime()', 'StartFire(byte FireModeNum)', DoCombo(),...etc. on the following list.

    Code:
    function float GetAIRating()
    {
    	local UTBot B;
    
    	B = UTBot(Instigator.Controller);
    	if ( (B == None) || (B.Enemy == None) || Pawn(B.Focus) == None )
    		return AIRating;
    
    	if ( bWaitForCombo )
    		return 1.5;
    	if ( !B.ProficientWithWeapon() )
    		return AIRating;
    	if ( B.Stopped() )
    	{
    		if ( !B.LineOfSightTo(B.Enemy) && (VSize(B.Enemy.Location - Instigator.Location) < 5000) )
    			return (AIRating + 0.5);
    		return (AIRating + 0.3);
    	}
    	else if ( VSize(B.Enemy.Location - Instigator.Location) > 1600 )
    		return (AIRating + 0.1);
    	else if ( B.Enemy.Location.Z > B.Location.Z + 200 )
    		return (AIRating + 0.15);
    
    	return AIRating;
    }
    
    function SetComboTarget(UTProj_ShockBall S)
    {
    	if ( !bRegisterTarget || (UTBot(Instigator.Controller) == None) || (Instigator.Controller.Enemy == None) )
    		return;
    
    	bRegisterTarget = false;
    	bWaitForCombo = true;
    	ComboStart = Instigator.Location;
    	ComboTarget = S;
    	ComboTarget.Monitor(UTBot(Instigator.Controller).Enemy);
    }
    
    function float RangedAttackTime()
    {
    	local UTBot B;
    
    	B = UTBot(Instigator.Controller);
    	if ( (B == None) || (B.Enemy == None) )
    		return 0;
    
    	if ( B.CanComboMoving() )
    		return 0;
    
    	return FMin(2,0.3 + VSize(B.Enemy.Location - Instigator.Location)/class'UTProj_ShockBall'.default.Speed);
    }
    
    simulated function StartFire(byte FireModeNum)
    {
    	if ( bWaitForCombo && (UTBot(Instigator.Controller) != None) )
    	{
    		if ( (ComboTarget == None) || ComboTarget.bDeleteMe )
    			bWaitForCombo = false;
    		else
    			return;
    	}
    	Super.StartFire(FireModeNum);
    }
    
    function DoCombo()
    {
    	if ( bWaitForCombo )
    	{
    		bWaitForCombo = false;
    		if ( (Instigator != None) && (Instigator.Weapon == self) )
    		{
    			StartFire(0);
    		}
    	}
    }
    
    /* BestMode()
    choose between regular or alt-fire
    */
    function byte BestMode()
    {
    	local float EnemyDist;
    	local UTBot B;
    	local UTPawn EnemyPawn;
    
    	bWaitForCombo = false;
    	B = UTBot(Instigator.Controller);
    	if ( (B == None) || (B.Enemy == None) )
    		return 0;
    
    	if (B.IsShootingObjective())
    		return 0;
    
    	if ( !B.LineOfSightTo(B.Enemy) )
    	{
    		if ( (ComboTarget != None) && !ComboTarget.bDeleteMe && B.CanCombo() )
    		{
    			bWaitForCombo = true;
    			return 0;
    		}
    		ComboTarget = None;
    		if ( B.CanCombo() && B.ProficientWithWeapon() )
    		{
    			bRegisterTarget = true;
    			return 1;
    		}
    		return 0;
    	}
    
    	if ( UTSlowVolume(B.Enemy.PhysicsVolume) != None )
    	{
    		return 1;
    	}
    	EnemyPawn = UTPawn(B.Enemy);
    	if ( (EnemyPawn != None) && EnemyPawn.bHasSlowField )
    	{
    		return 1;
    	}
    
    	EnemyDist = VSize(B.Enemy.Location - Instigator.Location);
    
    	if ( (EnemyDist > 4*class'UTProj_ShockBall'.default.Speed) || (EnemyDist < 150) )
    	{
    		ComboTarget = None;
    		return 0;
    	}
    
    	if ( (ComboTarget != None) && !ComboTarget.bDeleteMe && B.CanCombo() )
    	{
    		bWaitForCombo = true;
    		return 0;
    	}
    
    	ComboTarget = None;
    
    	if ( (EnemyDist > 2500) && (FRand() < 0.5) )
    		return 0;
    
    	if ( B.CanCombo() && B.ProficientWithWeapon() )
    	{
    		bRegisterTarget = true;
    		return 1;
    	}
    
    	// consider using altfire to block incoming enemy fire
    	if (EnemyDist < 1000.0 && B.Enemy.Weapon != None && B.Enemy.Weapon.Class != Class && B.ProficientWithWeapon())
    	{
    		return (FRand() < 0.3) ? 0 : 1;
    	}
    	else
    	{
    		return (FRand() < 0.7) ? 0 : 1;
    	}
    }
    
    simulated function rotator GetAdjustedAim( vector StartFireLoc )
    {
    	local rotator ComboAim;
    
    	// if ready to combo, aim at shockball
    	if (UTBot(Instigator.Controller) != None && CurrentFireMode == 0 && ComboTarget != None && !ComboTarget.bDeleteMe)
    	{
    		// use bot yaw aim, so bots with lower skill/low rotation rate may miss
    		ComboAim = rotator(ComboTarget.Location - StartFireLoc);
    		ComboAim.Yaw = Instigator.Rotation.Yaw;
    		return ComboAim;
    	}
    
    	return Super.GetAdjustedAim(StartFireLoc);
    }
    Unreal Tournament 3:
    Unreal Army Vehicles
    Atom Ripper
    Geiger Cannon V2NEW!!!
    UT2004:
    Special Skaarj Pack:
    SpecialSkaarPackv4
    My Weapons:
    Flarebolt Cannon
    SOLG Painter

  2. #2
    MSgt. Shooter Person
    Join Date
    Sep 2009
    Location
    Arlington, TX
    Posts
    372

    Default

    from what I can tell...
    Code:
    function float GetAIRating()
    {
    	//airating (whether the bot uses/continues to use the weapon?)
    	//depending on whether bot sees an enemy/how far away it is, whether there is a combo pending
    }
    
    function SetComboTarget(UTProj_ShockBall S)
    {
    //if any of the three conditions are true, start the monitor function in the shockball class which was passed to this function, and turn on bwaitforcombo here, also.
    }
    
    function float RangedAttackTime()
    {
    //times the shockball shot if there is an enemy.
    }
    
    simulated function StartFire(byte FireModeNum)						//this is when I fire either mode
    {
    	if ( bWaitForCombo && (UTBot(Instigator.Controller) != None) )  //if I, weapon, am waiting to finish a combo, and the bot still is firing me... 
    	{
    		if ( (ComboTarget == None) || ComboTarget.bDeleteMe )		//and I dont abort for losing the targeted shockball
    			bWaitForCombo = false;									//and lose interest in the idea of doing so until another opportunity comes along									
    		else
    			return;													//get outta here											
    	}
    	Super.StartFire(FireModeNum);									//call the startfire function in the parent class and pass the same firemode which was passed to startfire in this class 
    }
    
    function DoCombo()													//really gonna shombo now
    {
    	if ( bWaitForCombo )											//last check, in case change my mind from something
    	{
    		bWaitForCombo = false;										//I am only going to do this once.
    		if ( (Instigator != None) && (Instigator.Weapon == self) )	//as long as me and my gun are still here...
    		{
    			StartFire(0);											//fire firemodenum 0, the beam ewft instant hit
    		}
    	}
    }
    
    /* BestMode()
    choose between regular or alt-fire									//here is were you are likely to do much 0/1 swapping	
    */
    function byte BestMode()											
    {
    	local float EnemyDist;
    	local UTBot B;
    	local UTPawn EnemyPawn;
    
    	bWaitForCombo = false;											//reset every time.
    	B = UTBot(Instigator.Controller);
    	if ( (B == None) || (B.Enemy == None) )
    		return 0;													//set beam as best
    
    	if (B.IsShootingObjective())
    		return 0;													//setting beam again
    
    	if ( !B.LineOfSightTo(B.Enemy) )								//maybe the enemy is around a corner or something?
    	{
    		if ( (ComboTarget != None) && !ComboTarget.bDeleteMe && B.CanCombo() )		//so if I already have a ball out
    		{
    			bWaitForCombo = true;									//going to set this true for the other functions	
    			return 0;												//and get ready to beam			
    		}
    		ComboTarget = None;											//or maybe I am not ready to shoot at any specific ball with a beam.  
    		if ( B.CanCombo() && B.ProficientWithWeapon() )				//but, ok, as long as I my bot is apt and fortunate enough to try and shombo	
    		{
    			bRegisterTarget = true;
    			return 1;												//I'll say to shoot a ball
    		}
    		return 0;													//barring none of those other conditions, ready the beam
    	}
    
    	if ( UTSlowVolume(B.Enemy.PhysicsVolume) != None )				//not sure why on this one(maybe just better immersion, but..	
    	{
    		return 1;													//gonna shoot ball
    	}
    	EnemyPawn = UTPawn(B.Enemy);
    	if ( (EnemyPawn != None) && EnemyPawn.bHasSlowField )			//anyone running around with this slow field is invulnerable to instant hit stuff, afaik		
    	{
    		return 1;													//bot better use the projectile	
    	}
    
    	EnemyDist = VSize(B.Enemy.Location - Instigator.Location);
    
    	if ( (EnemyDist > 4*class'UTProj_ShockBall'.default.Speed) || (EnemyDist < 150) )
    	{
    		ComboTarget = None;
    		return 0;													//ready to shoot beam because the enemy will just dodge balls
    	}
    
    	if ( (ComboTarget != None) && !ComboTarget.bDeleteMe && B.CanCombo() )
    	{
    		bWaitForCombo = true;
    		return 0;													//okay no balls flying around, which are targeted, but there is a ball, and I can combo, so ready the beam
    	}
    
    	ComboTarget = None;												//okay none of the previous conditions were met, or I would have returned outta here.  dont need combo target for the rest of the decisions
    
    	if ( (EnemyDist > 2500) && (FRand() < 0.5) )					//enemy is like, across Deck, flip a coin. 
    		return 0;													//okay for beams
    
    	if ( B.CanCombo() && B.ProficientWithWeapon() )					//know how to shombo, and also have good chance...
    	{
    		bRegisterTarget = true;										//got you now, buddy
    		return 1;													//gonna shoot the first part, the ball
    	}
    
    	// consider using altfire to block incoming enemy fire				
    	if (EnemyDist < 1000.0 && B.Enemy.Weapon != None && B.Enemy.Weapon.Class != Class && B.ProficientWithWeapon())
    	{
    		return (FRand() < 0.3) ? 0 : 1;								//I forgot how these statements work, but you'll probably want to switch the zeros and ones for your stuff
    	}
    	else
    	{
    		return (FRand() < 0.7) ? 0 : 1;								
    	}
    }
    
    simulated function rotator GetAdjustedAim( vector StartFireLoc )	//bot should turn and aim.  if they are an easy bot, it looks so very creepy and slow. checks that the bot is trying to shoot a beam at the ball, again with firemode 0/1


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.