logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Issue #71. Waking a sitting Titan up may become impossible (Read 90 times)
Masterkent
Developer Team
Offline



Posts: 1269
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Issue #71. Waking a sitting Titan up may become impossible
May 8th, 2019 at 11:11am
Print Post  
The check for EventInstigator.bIsPlayer in function UnrealI.Titan.Sitting.Trigger doesn't look reasonable and sometimes produces real troubles.

Code
Select All
state Sitting
{
	ignores SeePlayer, HearNoise, Bump, TakeDamage;

	function Trigger( actor Other, pawn EventInstigator )
	{
		if ( EventInstigator.bIsPlayer )
		{
			AttitudeToPlayer = ATTITUDE_Hate;
			Enemy = EventInstigator;
			GotoState('Sitting', 'GetUp');
		}
		Disable('Trigger');
	}

	function BeginState()
	{
		bProjTarget = false;
	}

GetUp:
	bProjTarget = true;
	PlayAnim('TGetUp');
	FinishAnim();
	SetCollisionSize(0, Default.CollisionHeight);
	SetPhysics(PHYS_Walking);
	DesiredSpeed = 1.0;
	Acceleration = vector(Rotation) * AccelRate;
	PlayAnim('TWalk001');
	FinishAnim();
	SetCollisionSize(Default.CollisionRadius, Default.CollisionHeight);
	GotoState('Attacking');

Begin:
	TweenAnim('TSit', 0.05);
	SetPhysics(PHYS_None);
} 


Firstly, it can't reliably work in a network game when function Trigger is called by a Dispatcher with a delay, because the player who initiated the event may leave the game and the corresponding PlayerPawn actor may be destroyed and garbage-collected during the pause before the delayed event issued by the Dispatcher, then parameter EventInstigator becomes a none reference and the check for EventInstigator.bIsPlayer fails as an erroneous attempt to access none. Since Disable('Trigger') is invoked, there will be no second chance to wake the Titan up and then kill him. This may lead to a trouble if players have to kill him in order to finish the map.

Secondly, if a non-player pawn triggers a sitting Titan somehow (e.g. by hitting a Trigger with TriggerType == TT_Shoot which then eventually invokes function Titan.Sitting.Trigger), then, again, players don't have a chance to wake the Titan up later.

At this moment I can recall only two maps with sitting Titans: VeloraEnd and Jones-05-TemplePart3. Both maps can't be finished if the check for EventInstigator.bIsPlayer fails for any reason (and I saw how such things happened in online game - this is why I had to find out where the given issue originates from). From my point of view, this check is inherently wrong by design and probably many mappers are not aware of it, so it should be just removed. If we move Disable('Trigger') to the if-block instead, there would still be a big chance that retriggering won't be possible because it would have to be initiated by something that can be triggered at most once (e.g. by a Trigger with bTriggerOnceOnly == true - as in case of the two aforementioned maps).

Mappers who want to prevent triggering by non-players should use more reliable and reasonable methods. In particular, mappers should either make sure that the decision is made before the event instigator could be entirely destroyed or properly handle possible none references. For example, if a TT_Shoot Trigger is supposed to trigger a Dispatcher which is supposed to trigger a sitting Titan, then it's possible to insert an intermediate filter between the Trigger and the Dispatcher so that the Dispatcher would be triggered only when the shooter is known to be a player:

Code
Select All
// Transforms an incoming event designated by Tag to an outcoming event designated by Event.
// The outcoming event is issued only if the instigator of the incoming event is known to be a player.
class PlayerEventTransformer expands Triggers;

var() bool bTriggerOnceOnly;

event Trigger(Actor A, Pawn EventInstigator)
{
	// if the instigator is none/unknown or not a player, then ignore the incoming event
	if (EventInstigator == none || EventInstigator.PlayerReplicationInfo == none)
		return;

	Disable('Trigger'); // recursive calls to Trigger are not allowed
	TriggerEvent(Event, self, EventInstigator);
	if (!bTriggerOnceOnly)
		Enable('Trigger');
} 


Code
Select All
Trigger
    Event == 'TriggerIsShot'

PlayerEventTransformer
    Tag == 'TriggerIsShot'
    Event == 'TriggerIsShotByPlayer'

Dispatcher
    Tag == 'TriggerIsShotByPlayer'
    OutEvents[0] == 'WakeTitan'

Titan
    Tag == 'WakeTitan' 



Suggested changes to UnrealI.Titan.Sitting.Trigger:

Code
Select All
	function Trigger( actor Other, pawn EventInstigator )
	{
-		if ( EventInstigator.bIsPlayer )
-		{
-			AttitudeToPlayer = ATTITUDE_Hate;
-			Enemy = EventInstigator;
-			GotoState('Sitting', 'GetUp');
-		}
+		AttitudeToPlayer = ATTITUDE_Hate;
+		if (EventInstigator != none && EventInstigator.bIsPlayer)
+			Enemy = EventInstigator;
+		GotoState('Sitting', 'GetUp');
		Disable('Trigger');
	} 


Since the state WalkOut has a similar code, I'd suggest to change it in the same way:

Code
Select All
	function Trigger( actor Other, pawn EventInstigator )
	{
-		if ( EventInstigator.bIsPlayer )
-		{
-			AttitudeToPlayer = ATTITUDE_Hate;
-			Enemy = EventInstigator;
-			GotoState('WalkOut', 'Walk');
-		}
+		AttitudeToPlayer = ATTITUDE_Hate;
+		if (EventInstigator != none && EventInstigator.bIsPlayer)
+			Enemy = EventInstigator;
+		GotoState('WalkOut', 'Walk');
		Disable('Trigger');
	} 

« Last Edit: May 9th, 2019 at 9:36am by Masterkent »  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7901
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Issue #71. Waking a sitting Titan up may become impossible
Reply #1 - May 8th, 2019 at 3:28pm
Print Post  
great find, indeed explains some things Smiley
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo