Using DECORATE variable 'Z' in ZSCRIPT function...

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!)
User avatar
SPZ1
Posts: 365
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois

Using DECORATE variable 'Z' in ZSCRIPT function...

Post by SPZ1 »

If I attempt to use the DECORATE variable 'z' in my ZSCRIPT function, it gives me a warning in the console saying that it is deprecated since 3.2.0. Is there a way around this?

Basically, I am trying to find out if a enemy that is attacking me is above or below me for A_ThrowGrenade() ! I've tried exact numbers and it seems to work but not for up/down dynamically! :bang:
Blue Shadow
Posts: 5032
Joined: Sun Nov 14, 2010 12:59 am

Re: Using DECORATE variable 'Z' in ZSCRIPT function...

Post by Blue Shadow »

An actor's position is stored as a vector which is named Pos. So you want to use Pos.z, in your case. Of course, the same goes for when you want to access x an y.
User avatar
SPZ1
Posts: 365
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois

Re: Using DECORATE variable 'Z' in ZSCRIPT function...

Post by SPZ1 »

Thank You, I was able to come up with this bit of code which was what I was seeking:

Code: Select all

Actor p_Player = GetPointer(AAPTR_PLAYER1);

if (self.Pos.z > p_Player.Pos.z){
	A_Print("Monster is Higher");
} else {
	A_Print("Player is Higher");
}
:mrgreen:

Return to “Scripting”