Results 1 to 5 of 5
  1. #1
    Marrow Fiend
    Join Date
    Nov 2007
    Location
    Lithuania
    Posts
    4,385

    Default Team is aggressive to deployables

    I'm currently creating deployable turrets, and a strange thing happens. When deployed, the turrets are assigned to the Instigator's team. The colour of the deployable also changes due to this. The strange thing is that after deploying, even though the deployed turret's colour matches the team colour of the instigator, all bots in the game try to kill the turret, including the Instigator himself. Here's what happens when you fire the deploy weapon:

    Code:
    function bool Deploy( vector DeployLocation, rotator DeployRotation, bool bAltActivate )
    {
    	local Actor A;
    
    	// make sure owner won't be gibbed by item (e.g. if near wall & this causes item to move into player)
    	Instigator.SetCollision( false, false, false );
    	if( bIgnoreOwnerYaw )
    		DeployRotation.Yaw = 0;
    
    	A = Spawn( DeployClass, , , DeployLocation, DeployRotation ); //GE: No owner, because it's set later (KillerController).
    
    
    	Instigator.SetCollision( Instigator.default.bCollideActors, Instigator.default.bBlockActors, Instigator.default.bBlockPlayers );
    
    	if( A == None )
    		return false;
    
    	// if the spawn succeeds, complete the deployment
    
    	// common initialization
    	UseSkill( DeploySkillCost );
        A.SetPhysics( PHYS_Falling );
    	A.Instigator = Instigator;
    	if( Instigator!=none )
    	{
    		if ( U2DeployedUnit(A)!=none )
    			U2DeployedUnit(A).SetKillerController( Instigator.Controller );
    		else if ( U2MineBase(A) != none )
    			U2MineBase(A).SetKillerController( Instigator.Controller );
    	}
    	if( bTossProjectiles )
    		TossDeployed( A, Instigator );
    
    	// custom initialization
    	PostDeploy( A, bAltActivate );
    
    	return true;
    }
    
    
    //-----------------------------------------------------------------------------
    
    function PostDeploy( Actor DeployedActor, bool bAltActivate )
    {
    	local U2DeployedUnit DU;
    
    	assert( Instigator != None );
    
    	DU = U2DeployedUnit(DeployedActor);
    	if( DU!=none )
    	{
    		DU.SetActive( false );
    		DU.SetTeam( Instigator.GetTeamNum() );
    		DU.Initialize( bAltActivate );
    	}
    }
    Here's what happens when it tries to set the team, in a subclass of Pawn:
    Code:
    simulated function SetTeam(int NewTeam)
    {
    	if( U2StationaryPawnController(Controller)!=none )
    		U2StationaryPawnController(Controller).SetTeam( NewTeam );
    	else if ( (PlayerReplicationInfo != None) && (PlayerReplicationInfo.Team != None) )
    		PlayerReplicationInfo.Team.TeamIndex = NewTeam;
    	else
    		TeamIndex = NewTeam;
    	ClientTeamIndex = NewTeam;
    	SetTeamSkin(Self, NewTeam); // hack
    }
    I've tried changing else ifs in the last function to just ifs, but it's the same.
    Anyone knows what's wrong?
    Last edited by GreatEmerald; 04-18-2009 at 05:00 PM.

  2. #2
    Marrow Fiend
    Join Date
    Nov 2007
    Location
    Lithuania
    Posts
    4,385

    Default

    Aha, I got it. It seems that even if a controller's team number is the same as the team of bots, bots will still attack the pawn. To make them friendly, the pawn must have both TeamNum and Team (TeamInfo) set correctly.

    However, I have problems with this. Team is held in PlayerReplicationInfo; but deployables aren't technically players. By using PRI, deployables have player tags on them and also appear in the player list. While seeing their health is a good thing, but names "Player" aren't very good to look at. So, is there a way to make a pawn a member of a team without it having a PRI? Or maybe make PRI not register the deployable as a player?

  3. #3
    Skaarj
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    19

    Default

    Hmm... For Ballistic Weapon's deployable turrets they made the deployed weapon a subclass of vehicles, which resulted in the player's name being assigned to the turret (if manning it) if I'm not mistaken, but not in any player list.

    Though the problem with that is that enemies will try and attack the deployed machine gun before they hit you, but I don't know if that's necessarily a bad thing in your case, and I'm not sure if this route would be of much help to you.
    Last edited by Captain Xavious; 05-06-2009 at 04:10 PM.
    RuneStorm lackey.

  4. #4

    Default

    That should work without assigning a PRI. For vehicles without PRI, the default logic compares the Vehicle.Team variable to the bot's team index and assumes friendly on equal team numbers.
    Wormbo's UT/UT2004/UT3 mods | PlanetJailbreak | Unreal Wiki | Liandri Archives

    <elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
    <TNSe> nono
    <TNSe> its always funny to find code a week later you dont even remember writing
    <Pfhoenix> what's worse is when you have a Star Wars moment
    <Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
    Note that your questions via PMs will be ignored if they actually belong in the forum.

  5. #5
    Marrow Fiend
    Join Date
    Nov 2007
    Location
    Lithuania
    Posts
    4,385

    Default

    Awesome! Vehicles, of course! There's even more to it: they even have in-built support for deployables, like bAutoTurret, bNonHumanControl, AutoTurretControllerClass! Thank you very much!


 

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.