Player Speed - Stop input

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Player Speed - Stop input

Postby Caleb377 » Sun Feb 21, 2021 5:22 pm

Hi, I'm trying to lower the speed of the player character.

A few things to note and explain myself better:

1- This change is global for the entire game, and the speed of the player character is never changed.
2- I'm using a Hub map. (I don't think that matters but...)
3- Basically I need to half the player movement speed, (So that now running is like walking).
4- I'm using Doom 2 as the base for my mod.

I found a few different ways to do this:

with ACS and "SetActorProperty"

script 1 ENTER
{
SetActorProperty(0, APROP_SPEED, 0.50);
}

If I understand this correctly that would be more suitable If I wanted to alter the speed during some portions of the map, or to slow down an actor. (like a freezing monster or something)
https://zdoom.org/wiki/SetActorProperty

The other way I think is in MAPINFO under the "Gameinfo" definition
with the "NormSideMove" and "NormForwardMove" properties.
But that doesn't seem to work at all, probably because I need to create a new PlayerClass? I don't know.
https://zdoom.org/wiki/MAPINFO/GameInfo_definition

It's a simple question but I want to know wich option is the best to set this up and encounter the least bugs possible.

Finally, this is vaguely related but I wanted to know a way to freeze the player completely in place,
like for a cutscene, so that movement can be resumed after a certain amount of tics.
Canceling any player input until the "action" is done.

Any help with this would be much appreciated,
Thanks.
User avatar
Caleb377
 
Joined: 28 Jan 2020

Re: Player Speed - Stop input

Postby Virathas » Mon Feb 22, 2021 1:47 am

I think it all depends what are you exactly planning to do, and what kind of mod are you making.
Personally speaking, i would avoid using the SetActorProperty for speed - Afaik it can conflict with other mods when everyone is using similar scripts.,

I see two easy methods to slow the player permanently. One is creating a new PlayerClass, with reduced speeds:

Code: Select allExpand view
Actor SlowPlayer : DoomPlayer
{
Player.ForwardMove 0.5,1.0
Player.SideMove 0.5,1.0
}

Alternatively, you could just give a PowerSpeed item to the player on first entering
Code: Select allExpand view
ACTOR PowerSpeed : Powerup native
{
  Powerup.Duration -999999
  Speed 0.5
  +POWERSPEED.NOTRAIL
  +INVENTORY.HUBPOWER
}


For the player freezing you can actually use the SetPlayerProperty function to set the TOTALLYFROZEN flag. There is an actual example for that there.
User avatar
Virathas
 
Joined: 10 Aug 2017

Re: Player Speed - Stop input

Postby Caleb377 » Mon Feb 22, 2021 10:18 am

That's it, It worked!
I created a new PlayerClass like you suggested, and this way it's implemented throughout the entire game.
The mod is the "Bioshock TC" and if you played the original game you know that the main character moves very slowly,
especially compared to the Doom guy who runs like a cheetah.

For future reference this is how it works (in case someone wants to do this exactly)

1- Create and edit the DECORATE and MAPINFO Lumps respectively.

2- The DECORATE code is:
Code: Select allExpand view
Actor SlowPlayer : DoomPlayer
{
Player.ForwardMove 0.5,0.5
Player.SideMove 0.5,0.5
Player.viewbob 0.5
}

(I just added the much needed reduced headbob, otherwise you'll get motion sickness)

3- The MAPINFO code is:
Code: Select allExpand view
GameInfo
{
   PlayerClasses = "SlowPlayer"
}


I checked the "SetPlayerProperty - TOTALLYFROZEN" and should also do what I need,
Thanks. :D
User avatar
Caleb377
 
Joined: 28 Jan 2020

Re: Player Speed - Stop input

Postby Blue Shadow » Wed Feb 24, 2021 9:06 am

Caleb377 wrote:The other way I think is in MAPINFO under the "Gameinfo" definition
with the "NormSideMove" and "NormForwardMove" properties.
But that doesn't seem to work at all, probably because I need to create a new PlayerClass? I don't know.

No. They don't need a new player class to be defined. The question is: how were you using them (the code, what did it look like)? You say it doesn't work. Do you get an error or warning in the console on start-up, or do the properties just have no effect? Also, what GZDoom version are you using?
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Player Speed - Stop input

Postby Caleb377 » Thu Feb 25, 2021 11:41 am

If I remember correctly the code I tried was something like this:
Code: Select allExpand view
gameinfo
{
    NormSideMove =  14.0,20.0
    NormForwardMove = 12.0,25.0
}


I didn't get any errors, it just didn't slow the player character down.
That's definetly something I missed, since I don't ever mess with those paremeters.

I'm using the latest GZDoom 4.5.0.
But again, it's not an issue with the engine, but my lack of knowledge on these functions. :?
In any case It's working now, thanks to Virathas solution.
User avatar
Caleb377
 
Joined: 28 Jan 2020


Return to Scripting

Who is online

Users browsing this forum: JohnnyTheWolf, Mikk-, Thorir1993 and 1 guest