Announcement

Collapse
No announcement yet.

Automatic Turrets

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    ahh....makes sense thank you, got a magic cure on how you can make sure they dont try to shoot someone farther away then the weapon can reach? probaby a distance calibrator thingy in the gun pawn....

    Leave a comment:


  • replied
    In the vehicle's DrivingStatusChanged and DriverDied events, add or remove the AutoTurretController.

    Leave a comment:


  • replied
    Wow, for a second I thought T-Shinzon just came back all of a sudden

    Leave a comment:


  • replied
    NecroBumping

    i know what vehicle this is
    anyway thank you for solving it, i was wondering how to make it work, also a short question...

    how do you make it not shoot while the vehicle is empty? and how do you make it so the thing dont fire across the map? (kinda want it to not go to far away, or i'll have to nerf it)
    probably some kind of check or something but it is kind of confusing for me...

    Leave a comment:


  • replied
    I solved it, simply by deleting the code I added to the pawn above default properties and changing:

    Code:
    AutoTurretControllerClass=Class'UnrealGame.TurretController'
    to

    Code:
    AutoTurretControllerClass=Class'Onslaught.ONSTurretController'
    Silly me. :noob:

    Leave a comment:


  • started a topic Automatic Turrets

    Automatic Turrets

    Well, I am making a very large-scale vehicle with more gunner positions than is practical for an 8 or even 16-person team. Therefore I have decided to make the bulk of these turrets automatic, as in AI-controlled. I also would like to make sure that you cannot enter these AI turrets, but that is just a side thing.

    Okay, so first I began by looking at the AI turrets of the Mothership, you know, the automatic ones. I looked at Assault.ASTurret.uc.

    I see something interesting in the Default Properties:

    Code:
    bAutoTurret=True
    AutoTurretControllerClass=Class'UnrealGame.TurretController'
    I assume AutoTurret means, well, auto turret. AutoTurretControllerClass looks like a portable bot or something, so I take a look at TurretController and see this:

    Code:
    // FIXME -- Implement this in Pawn to support ONS weapon system.
    function bool IsTurretFiring()
    {
    	if ( (Pawn.Weapon != None) && Pawn.Weapon.IsFiring() )
    		return true;
    
    	return false;
    }
    
    auto state Searching
    {
    	event SeePlayer(Pawn SeenPlayer)
    	{
    		if ( IsTargetRelevant( SeenPlayer ) )
    		{
    			Enemy = SeenPlayer;
    			GotoState('Engaged');
    		}	
    	}
    
    	function ScanRotation()
    	{
    		local actor HitActor;
    		local vector HitLocation, HitNormal, Dir;
    		local float BestDist, Dist;
    		local rotator Pick;
    		
    		DesiredRotation.Yaw = 0;
    		DesiredRotation.Pitch = Rotation.Pitch + 16384 + Rand(32768); 
    		Dir = vector(DesiredRotation);
    		
    		// check new pitch not a blocked direction
    		HitActor = Trace(HitLocation,HitNormal,Pawn.Location + 2000 * Dir,Pawn.Location,false);
    		if ( HitActor == None )
    			return;
    		BestDist = vsize(HitLocation - Pawn.Location);
    		Pick = DesiredRotation;
    		
    		DesiredRotation.Pitch += 32768;
    		Dir = vector(DesiredRotation);
    		// check new pitch not a blocked direction
    		HitActor = Trace(HitLocation,HitNormal,Pawn.Location + 2000 * Dir,Pawn.Location,false);
    		if ( HitActor == None )
    			return;
    		Dist = vsize(HitLocation - Pawn.Location);
    		if ( Dist > BestDist )
    		{
    			BestDist = Dist;
    			Pick = DesiredRotation;
    		}
    		
    		DesiredRotation.Pitch += 16384;
    		Dir = vector(DesiredRotation);
    		// check new pitch not a blocked direction
    		HitActor = Trace(HitLocation,HitNormal,Pawn.Location + 2000 * Dir,Pawn.Location,false);
    		if ( HitActor == None )
    			return;
    		Dist = vsize(HitLocation - Pawn.Location);
    		if ( Dist > BestDist )
    		{
    			BestDist = Dist;
    			Pick = DesiredRotation;
    		}
    
    		DesiredRotation.Pitch += 32768;
    		Dir = vector(DesiredRotation);
    		// check new pitch not a blocked direction
    		HitActor = Trace(HitLocation,HitNormal,Pawn.Location + 2000 * Dir,Pawn.Location,false);
    		if ( HitActor == None )
    			return;
    		Dist = vsize(HitLocation - Pawn.Location);
    		if ( Dist > BestDist )
    		{
    			BestDist = Dist;
    			Pick = DesiredRotation;
    		}
    		
    		DesiredRotation = Pick;
    	}	
    
    	function BeginState()
    	{
    		Enemy = None;
    		Focus = None;
    		StopFiring();
    	}
    	
    Begin:
    	ScanRotation();	
    	FocalPoint = Pawn.Location + 1000 * vector(DesiredRotation);
    	Sleep(2 + 3*FRand());
    	Goto('Begin');
    }
    
    
    state Engaged
    {
    	function EnemyNotVisible()
    	{
    		if ( IsTargetRelevant( Enemy ) )
    		{
    			Focus = None;
    			FocalPoint = LastSeenPos;
    			GotoState('WaitForTarget');
    			return;
    		}
    		GotoState('Searching');
    	}
    
    	function BeginState()
    	{
    		Focus = Enemy.GetAimTarget();
    		Target = Enemy;
    		bFire = 1;
    		if ( Pawn.Weapon != None )	
    			Pawn.Weapon.BotFire(false);
    	}
    	
    Begin:
    	Sleep(1.0);
    	if ( !IsTargetRelevant( Enemy ) || !IsTurretFiring() )
    		GotoState('Searching');
    	Goto('Begin');
    }
    
    State WaitForTarget
    {
    	event SeePlayer(Pawn SeenPlayer)
    	{
    		if ( IsTargetRelevant( SeenPlayer ) )
    		{
    			Enemy = SeenPlayer;
    			GotoState('Engaged');
    		}	
    	}
    
    	function BeginState()
    	{
    		Target = Enemy;
    		bFire = 1;
    		if ( Pawn.Weapon != None )	
    			Pawn.Weapon.BotFire(false);
    	}
    
    Begin:
    	Sleep( GetWaitForTargetTime() );
    	GotoState('Searching'); 
    }
    
    function float GetWaitForTargetTime()
    {
    	return (3 + 5 * FRand());
    }
    
    defaultproperties
    {
         bSlowerZAcquire=False
         RotationRate=(Pitch=32768,Yaw=60000,Roll=0)
    }
    I stick everything under "// FIXME -- Implement this in Pawn to support ONS weapon " into my Turret Pawn class. I also stick this:

    Code:
    bAutoTurret=True
    AutoTurretControllerClass=Class'UnrealGame.TurretController'
    into the automatic turret pawn's default properties.

    Here is my rationale for that:
    The ASVehicle is inherited from Vehicle, which is also what SVehicle is inherited from. The AutoTurret / TurretController class stuff is located in Vehicle, therefore I rationalize that the AutoTurret / TurretController stuff applies to both Assault AND Onslaught vehicles. But this is not for turrets? Wrong. ONSWeaponPawn is derived from Vehicle as well, therefore all this also applies to ONS Turret pawns as well!

    But when compiling, I get an error:

    Code:
    C:\UT2004\TIMVehicles\Classes\HyperionAutomaticTurretPawn.uc(141) : Error, 'Target': Bad command or expression
    That stated line is part of what was pasted from TurretController by commented instructions:

    Code:
    Target = Enemy;
    :bulb:

    What is wrong here? And if you're confused as to what I am asking, how do you make automatic turrets?
Working...
X