Why doesn't the movement in this script work?

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Mini--Joe
Posts: 96
Joined: Sun Jul 27, 2014 10:25 am

Why doesn't the movement in this script work?

Post by Mini--Joe »

Code: Select all

script "PlayerManager" Enter
{
	int x = 1;
	while(x==1)
	{
		if(CheckActorProperty(0,APROP_Waterlevel,3) && (CheckInventory("isUnderwater")==0 ) )
		{ SetActorProperty(0,APROP_SPEED,3); GiveInventory("isUnderwater",1); }
		if(CheckActorProperty(0,APROP_Waterlevel,0) && (CheckInventory("isUnderwater")==1 ) )
		{ SetActorProperty(0,APROP_SPEED,1); TakeInventory("isUnderwater",1); }
		GiveInventory("cohChainsawammo",1);
		GiveInventory("cohFistammo",1);
		Delay(5);
	}
	
}
I don't understand why this doesn't work. The inventory portion of it DOES work, but the movement modifiers do not.

When the player is submerged, they are supposed to get a triple speed buff, but they instead lose all ability to move in any direction.

When the player is fully out of water, they are supposed to get the regular move speed back. The player still doesn't get any move speed.
Jarewill
 
 
Posts: 1766
Joined: Sun Jul 21, 2019 8:54 am

Re: Why doesn't the movement in this script work?

Post by Jarewill »

Speed property is a fixed point value, so you have to add ".0" for it to work.
For example instead of SetActorProperty(0,APROP_SPEED,3); you have to do SetActorProperty(0,APROP_SPEED,3.0);
User avatar
Mini--Joe
Posts: 96
Joined: Sun Jul 27, 2014 10:25 am

Re: Why doesn't the movement in this script work?

Post by Mini--Joe »

That fixed it, thank you so much!
Post Reply

Return to “Scripting”