"Haha you tripped"

Discussions about Coding and Scripting
Post Reply
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

"Haha you tripped"

Post by zacman »

The map I'm working on, I'm trying to give a creepy feel, and there are certain areas where I don't want the players sprinting around like headless chickens, since it kinda spoils the effect. I thought up a way of changing this, I decided to write 2 triggers, one that only goes off if the player is running when they hit it, the second is one that makes the instigator Feign Death when they hit it. I haven't started the "running" trigger (I think that one should be easier, pretty sure it's just a check for the boolean that checks player running?) But the second one, All I've succeeded in is one trigger that locks up the players controls, and one that does nothing but give access nones.

These are my 2 attempts:

Code: Select all

Class Tripper extends triggers;

//Didn't work, just locked up player movement and gave a log error because state doesn't exist

function Trigger( actor Other, pawn EventInstigator )
{
if ( EventInstigator.bIsPlayer)
	EventInstigator.GotoState('PlayFeignDeath');
Else
	Return;
}
//http://pastebin.com/Nhww0fgz


Class Tripper extends triggers;

//Does nothing whatsoever except give access none

function Trigger( actor Other, Pawn EventInstigator )
{
local Tournamentplayer T;

if ( EventInstigator.bIsPlayer)
	T.PlayFeignDeath();
Else
	Return;
}

//http://pastebin.com/Nhww0fgz
Any help appreciated.
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: "Haha you tripped"

Post by Feralidragon »

The engine itself is explaining to you what's happenning very accuratelly, I would advise you to actually read them and check what they're actually saying:

In your first trigger code, the engine says that state you're trying to call does NOT exist at all, and it's right, the state you're calling does not exist.
The state you want to call is however: FeigningDeath. This state however only exists in PlayerPawn, so if you try to call it from any pawn that is not a PlayerPawn, the same error will be given.

In your second trigger code, the engine also says that a reference/actor/object you're accessing and calling from is None (null, non-existent), and it's right as well.
So looking at it, you just have 3 possible references: Other, EventInstigator and T.

Let's analyze it:
- Other isn't even used here, so it's not the cause;
- The only one used and NOT validated at all are T and EventInstigator.

Now let's look a bit further: you don't even assign T, so in your code T is always None, so calling anything from T will ALWAYS result in an Accessed None.
EventInstigator is never validated, so it can be None or not.

Therefore:
1) You have to assign T and validate it (aka making T = something and check if T != None)
2) You have to validate EventInstigator (aka check if EventInstigator != None)
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Re: "Haha you tripped"

Post by zacman »

<EDIT> Bleeder91NL helped me with the last bit, got the accessed nones gone, works perfectly now \o/

Code: Select all

function Trigger( actor Other, Pawn EventInstigator )
{
if ( PlayerPawn(EventInstigator)!=none)
        PlayerPawn(EventInstigator).FeignDeath()
Else
        Return;
}
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: "Haha you tripped"

Post by Feralidragon »

The one causing that accessed none is PendingWeapon.
If PendingWeapon is none, it will give that error (and it's not that difficult for a PendingWeapon being null in-game, but Epic didn't think about that).

In this particular case, there's nothing much you can do other than call the feigningdeath the "right way" like if it was the player himself calling it. Check this under the state of PlayerWalking for instance:

Code: Select all

exec function FeignDeath()
    {
        if ( Physics == PHYS_Walking )
        {
            ServerFeignDeath();
            Acceleration = vect(0,0,0);
            GotoState('FeigningDeath');
        }
    }
Basically you have to call the same thing, or simple FeignDeath() directly from the player and it should work without accessed nones (unless the player doesn't have any weapon at all).

EDIT: Didn't check your last edit, well done. Btw, that "else return" is not doing a thing, you can remove it from your code.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: "Haha you tripped"

Post by JackGriffin »

I tried doing this in Survival. I wanted the winner to stand tall and the losers to all "feign death" as a way of showing clearly who won. No matter what I tried it wouldn't work online. The feigned player saw the correct lower view but the other players did not. They appeared normal in the third-person view. I finally scrapped it as an engine bug. I'd be very interested if you got it worked out for online play because I couldn't get it done.
So long, and thanks for all the fish
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: "Haha you tripped"

Post by Feralidragon »

Did you call it from each client relative their own respective playerpawn?
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: "Haha you tripped"

Post by JackGriffin »

Yeah, both Dane and I tried. It worked fine offline but the online replication of the state wouldn't go. I finally gave up as some weird engine thing, but I've been thinking on it this morning after reading this post. I was calling it on game end and dammit that's why it wasn't working. The call was probably discarded since it was in state GameEnded, which is handled differently online.
Argh, now I have to know. Can I test this map privately online?
So long, and thanks for all the fish
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Re: "Haha you tripped"

Post by zacman »

Hopefully it does work online, thats one of my worries, that it just won't

Now I'm trying to get the trigger that sets it off going. I don't get any errors, this one again just doesn't work :lol:

Code: Select all

Class RunTrigger extends Trigger;

function Touch( actor Other )

{
	local actor A;
if ( PlayerPawn(Instigator)!=none)
{
	if ( !PlayerPawn(Instigator).biswalking && !PlayerPawn(Instigator).bisCrouching)
{
	if( IsRelevant( Other ) )
	{
		if ( ReTriggerDelay > 0 )
		{
			if ( Level.TimeSeconds - TriggerTime < ReTriggerDelay )
				return;
			TriggerTime = Level.TimeSeconds;
		}
		// Broadcast the Trigger message to all matching actors.
		if( Event != '' )
			foreach AllActors( class 'Actor', A, Event )
				A.Trigger( Other, Instigator);

		if ( Other.IsA('Pawn') && (Pawn(Other).SpecialGoal == self) )
			Pawn(Other).SpecialGoal = None;
				
		if( Message != "" )
			// Send a string message to the toucher.
			Other.Instigator.ClientMessage( Message );

		if( bTriggerOnceOnly )
			// Ignore future touches.
			SetCollision(False);
		else if ( RepeatTriggerTime > 0 )
			SetTimer(RepeatTriggerTime, false);
}
}
}
Else
	Return;
}
Basically, just checks if the player is walking or crouching, and if not is supposed to set of an event... Only it doesn't :loool:
Image[url=steam://friends/add/76561198048595886]Image[/url]
Post Reply