Page 1 of 1

Monster changing player speed

Posted: Mon Jan 12, 2015 6:20 pm
by RobbyPants
So, I'm working on a rough concept with a friend for a horror mod. One aspect involves something that slowly pursues the player and will kill him if it catches him. If shot, it retreats.

Anyway, the closer it gets, the more it is supposed to slow the player down. I've had luck modifying the player's speed in past mods in DECORATE by calling ACS scripts in the appropriate places using a tID of 0. Now, I'm trying to have something else do this, and it isn't working.

Here's the relevant code:

In DECORATE, the See state jumps based on proximity.

Code: Select all

See:
    SPOS A 0 A_Jumpifcloser(256, "CloseSee")
    SPOS A 0 A_Jumpifcloser(512, "NearSee")
    SPOS A 0 A_Jumpifcloser(1024, "MedSee")
    Goto FarSee
			
FarSee:
    TNT1 A 0 ACS_Execute(202, 0, 0, 0, 0)
    TNT1 A 0 A_SetTranslucent(0.40)
    SHAD AABBCC 3 A_Chase
    Goto See
			
MedSee:
    TNT1 A 0 ACS_Execute(203, 0, 0, 0, 0)
    TNT1 A 0 A_SetTranslucent(0.50)
    SHAD AABBCC 3 A_Chase
    Goto See
			
NearSee:
    TNT1 A 0 ACS_Execute(204, 0, 0, 0, 0)
    TNT1 A 0 A_SetTranslucent(0.60)
    SHAD AABBCC 3 A_Chase
    Goto See
			
CloseSee:
    TNT1 A 0 ACS_Execute(205, 0, 0, 0, 0)
    TNT1 A 0 A_SetTranslucent(0.70)
    SHAD DDEEFF 3 A_Chase
    Goto See

Scripts:

Code: Select all

Script 1 ENTER
{
	Thing_ChangeTID(0, (1000 + PlayerNumber())); 
}

//set speed 100%
script 202 (void) 
{
	SetActorProperty((1000 + PlayerNumber()), APROP_Speed, 1.0);
}


//set speed 75%
script 203 (void)
{
	SetActorProperty((1000 + PlayerNumber()), APROP_Speed, 0.75);
}


//set speed 50%
script 204 (void) 
{
	SetActorProperty((1000 + PlayerNumber()), APROP_Speed, 0.5);
}


//set speed 25%
script 205 (void) 
{
	SetActorProperty((1000 + PlayerNumber()), APROP_Speed, 0.25);
}
So, that's the general idea. I'm not sure if this is fundamentally flawed, or if I'm missing something. Thanks in advance!

RE: Monster changing player speed

Posted: Thu Jan 15, 2015 2:52 pm
by RobbyPants
So, is this sort of thing not doable, then?

Is there possibly a way to make an actor give the player custom inventory items either via ACS or DECORATE? I could use those to adjust speed, although it'd be a pain.

RE: Monster changing player speed

Posted: Thu Jan 15, 2015 3:29 pm
by Ænima
I would use A_GiveToTarget in the monster's code and make it give the player a certain amount of an inventory item based on how slow theyre supposed to be. Then make an ENTER script that constantly loops and adjusts the player's speed based on how much "SlowAmount" (or whatever name you use) they have. Also make it take all SlowAmount automatically after like 20 tics just incase the monster dies you won't get stuck being slow.


However this only works with one player because a monster can only target one player at a time. You could also try giving the monster an A_Explode state with different radii and a custom pain type and giving the player a custom pain state that does no damage but makes him call the script or give him the SlowAmount. BUT you must remember to make all other monsters immune to this damagetype or this monster will kill them all. :p

RE: Monster changing player speed

Posted: Thu Jan 15, 2015 5:10 pm
by RobbyPants
Thanks! That A_Explode idea is interesting, and I hadn't thought of it.

Either way, the idea is there will only ever be one of these monsters and one player in this mod, so a simplistic approach could still work. I'll let you know the results, later.

RE: Monster changing player speed

Posted: Thu Jan 15, 2015 7:02 pm
by RobbyPants
Perfect! A A_GiveToTarget/A_TakeFromTarget approach worked just fine. Also, I was able to consolidate this all into one script at one place. A much nicer solution!

RE: Monster changing player speed

Posted: Thu Jan 15, 2015 10:50 pm
by Ænima
You're welcome! And yeah generally it's good to just have one script that changes the player's speed instead of several, because you might get conflicts otherwise. :p