ZScript Discussion

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49098
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

The Loremaster uses DoSpecialDamage.

The difference is, DoSpecialDamage is called when it is decided that the projectile actually should damage the target, after it has already collided. SpecialMissileHit is for performing special actions BEFORE the projectile is exploded. This is used by a few Hexen projectiles that perform special actions on collision and do not explode, like the lightining attack. Do not confuse this with collision exclusion. It may sound similar on the surface but really is not.
User avatar
Major Cooke
Posts: 8190
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Does it take the HIT* pointer flags into account before SpecialMissileHit function is checked?
Blue Shadow
Posts: 4962
Joined: Sun Nov 14, 2010 12:59 am

Re: ZScript Discussion

Post by Blue Shadow »

MaxED wrote:Can ZScript class be inherited from DECORATE actor?
Graf Zahl wrote:No. Since DECORATE is parsed last the info is not available.
This is important and should emphasized, because this means that if you have mod A, which uses ZSCRIPT, and mod B, which uses DECORATE, and you want mod A to inherit classes from mod B, well, you won't be able to do that.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49098
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Major Cooke wrote:Does it take the HIT* pointer flags into account before SpecialMissileHit function is checked?
Can't say. SpecialMissileHit gets called right before deciding if ExplodeMissile needs to be callsed.
User avatar
Major Cooke
Posts: 8190
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Oh wait, I don't need those. It takes an actor called victim instead which is all I needed.

To clarify about this recent new addition of 'let p = Classtype(objectvar)'... If 'p' is not, say, MinotaurFriend like the change you made, would it return null even though it exists as something else? That is, if it's a different class instead of minotaurfriend. Would p be null?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49098
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Yes. That's the entire point of a dynamic cast - it prevents that you access an incompatible object through a pointer.
User avatar
Major Cooke
Posts: 8190
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Okay, so what other 'special' words are there besides 'is' and 'let'? It's time to start adding these all to the wiki again.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49098
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Take a look at sc_man_scanner.re That contains all the reserved words, although many of them are just reserved but not used. Or do you only want to know the ones that do something? That list is in zcc_parser.cpp.
User avatar
Major Cooke
Posts: 8190
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

The latter. And okay. Now I need clarification on what the following are:
  • until
  • in
  • out
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49098
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

'until' is sometimes used as a negative 'while'. Although being parsed it's currently not being processed by the compiler.
In and Out are qualifiers for function parameters, 'out' causes a parameter being passed by reference. 'In' can be added as well, but has no function, it merely serves as means of documentation.
User avatar
Major Cooke
Posts: 8190
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Alright.

Next question, how does GetSpriteIndex work? Does it convert the frame's A-Z (or whatever limit it is, I forgot) from 0 to that limit? Is the 'sprite' property what we use to compare/find what sprite an actor currently has?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49098
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

No, it takes the four character name and returns the internal index for it.
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm

Re: ZScript Discussion

Post by Xaser »

Oh, that's interesting. Could that function be used to set an actor's sprite property directly via something like:

Code: Select all

self.sprite = GetSpriteIndex("SHTG");
?

(Can't test that code presently but that seems to be way thingdef_states.cpp is using said function internally. This would be extremely useful for a thing I'm planning on making).
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49098
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Yes, that should work.
D2JK
Posts: 543
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Discussion

Post by D2JK »

Suggestion: could someone please make a wiki page or section about iterators, documenting any of the following:

- brief introduction, their purpose, and how they work
- iterator types (ActorIterator, ThinkerIterator, anything else?)
- what sort of task does each type excel at
- perhaps a brief explanation of the performance cost
- usage instructions, the options available, example code

Return to “Scripting”