ZScript Documentation

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
User avatar
Cherepoc
Posts: 60
Joined: Wed Sep 08, 2004 1:26 pm
Location: Russia

Re: ZScript Documentation

Post by Cherepoc »

It probably should be mentioned in PostBeginPlay description that it is not always executed before state functions, so in some cases can not be used for one-time setups. See this.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48324
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Documentation

Post by Graf Zahl »

You should use BeginPlay for those anyway because it is guaranteed to be called before the newly spawed actor is starting to interact with the world.
User avatar
Cherepoc
Posts: 60
Joined: Wed Sep 08, 2004 1:26 pm
Location: Russia

Re: ZScript Documentation

Post by Cherepoc »

Unfortunately, it's called before target pointer is assigned for the projectile, and I want to assign it's value to master. Neither function work in this case.
User avatar
Major Cooke
Posts: 8081
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Documentation

Post by Major Cooke »

Try giving it NOINTERACTION and NOBLOCKMAP, then have it turn off those flags in (Post)BeginPlay before calling the super function. That could at least ensure those processing things aren't interrupted at the very least.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48324
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Documentation

Post by Graf Zahl »

That won't help much. CheckMissileSpawn, which explodes a projectile without space does not care about those flags at all.
If you absolutely need to modify a projectile after spawn, the only way to do it is using the low level interface to spawn it and modify it on the spawner's side.
User avatar
Major Cooke
Posts: 8081
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Documentation

Post by Major Cooke »

D2JK
Posts: 537
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Documentation

Post by D2JK »

That reminds me: is there a function that takes a classname, and counts the total number of them at the time of the call?
User avatar
Major Cooke
Posts: 8081
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Documentation

Post by Major Cooke »

You can use a ThinkerIterator for that.
User avatar
Major Cooke
Posts: 8081
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Documentation

Post by Major Cooke »

Added ZScript variables, but it could use some validation as I'm not sure what all is actually correct.
User avatar
Major Cooke
Posts: 8081
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Documentation

Post by Major Cooke »

With GZDoom 2.3's release, I think it's time to redouble the efforts on documenting all this. Graf has removed the -zscript requirement, so it's official now.
User avatar
Major Cooke
Posts: 8081
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Documentation

Post by Major Cooke »

Wiki updated.
  • Added the two remaining iterators.
  • Added information about extending classes inside ZScript classes.
User avatar
Major Cooke
Posts: 8081
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Documentation

Post by Major Cooke »

Added a warning about overriding a player's Tick function. See here for details.
D2JK
Posts: 537
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Documentation

Post by D2JK »

I was wondering: if I have a known actor such as "Actor X", is it somehow possible to call GetAngle() using X in it directly, instead of having to first assign eg. "tracer = X;", then followed by GetAngle(1, AAPTR_TRACER)?

For example, GetAngle(1, X) doesn't work (expects a numeric type).
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48324
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Documentation

Post by Graf Zahl »

X.GetAngle(1)
D2JK
Posts: 537
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Documentation

Post by D2JK »

Hmm, no, that should be equivalent to "Get X's (relative) angle to its current target", which isn't what I'm after here.

Let me post some code illustrating what I'm trying to do for now:

Code: Select all

ThinkerIterator Searcher = ThinkerIterator.Create("MonsterBase");
Actor X;
while (X = MonsterBase(Searcher.Next()))
 {
  A_LogInt(GetAngle(1, X));
  // tracer = X;
  // A_LogInt(GetAngle(1, AAPTR_TRACER));
 }
This is called by a projectile, and actor X has no knowledge of the said projectile at the time of the call. I want to get the projectile's relative angle to X, so is my only option to simply use the commented-out lines of code?

Return to “Tutorials”