Monster changing player speed

Discuss all aspects related to modding Zandronum here.
Post Reply
RobbyPants
 
Posts: 37
Joined: Wed Mar 13, 2013 12:53 am

Monster changing player speed

#1

Post by RobbyPants » Mon Jan 12, 2015 6:20 pm

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!

RobbyPants
 
Posts: 37
Joined: Wed Mar 13, 2013 12:53 am

RE: Monster changing player speed

#2

Post by RobbyPants » Thu Jan 15, 2015 2:52 pm

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.

User avatar
Ænima
Addicted to Zandronum
Posts: 3583
Joined: Tue Jun 05, 2012 6:12 pm

RE: Monster changing player speed

#3

Post by Ænima » Thu Jan 15, 2015 3:29 pm

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
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

RobbyPants
 
Posts: 37
Joined: Wed Mar 13, 2013 12:53 am

RE: Monster changing player speed

#4

Post by RobbyPants » Thu Jan 15, 2015 5:10 pm

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.

RobbyPants
 
Posts: 37
Joined: Wed Mar 13, 2013 12:53 am

RE: Monster changing player speed

#5

Post by RobbyPants » Thu Jan 15, 2015 7:02 pm

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!

User avatar
Ænima
Addicted to Zandronum
Posts: 3583
Joined: Tue Jun 05, 2012 6:12 pm

RE: Monster changing player speed

#6

Post by Ænima » Thu Jan 15, 2015 10:50 pm

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
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Post Reply