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.

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

Postby SPZ1 » Mon Dec 11, 2017 2:28 pm

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:
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

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

Postby Blue Shadow » Mon Dec 11, 2017 7:24 pm

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
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: ATI/AMD (Modern GZDoom)

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

Postby SPZ1 » Tue Dec 12, 2017 12:31 pm

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


Code: Select allExpand view
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:
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest