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
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Kinsie wrote:
Major Cooke wrote:Easiest way to tell is if they have no Z velocity.
In my past experiences with Reelism, actors can hit the point of having 0 Z velocity in mid-air for a frame or so when at the peak of their arc of upward momentum (ie. when thrusted into the air).
Yeah I forgot about that, so a check performed for two tics instead aught to suffice. It's what D4D has to do for resetting the extra jumping.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49142
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Arctangent wrote:
cambertian wrote:Did ZScript finally clear up the whole "Players can't have animations for both melee and ranged attacks" thing that bugged me so much back in the days of DECORATE? Like how Quake's Ranger switches to an axe in both first AND third person?
I mean, there were ways to do that in Decorate.
The thing here is, it's the weapon's attack function that is responsible for setting the player's attack state. Feel free to set it to whatever you like.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm

Re: ZScript Discussion

Post by Arctangent »

Yeah, I can imagine ZScript make it a lot easier. Just, I'm not really sure if cambertian is asking what he wants to ask.
User avatar
Cherepoc
Posts: 60
Joined: Wed Sep 08, 2004 1:26 pm
Location: Russia

Re: ZScript Discussion

Post by Cherepoc »

Game crashes with Access Violation when I use action functions inside non-action functions (I know this is something I should not do). Are these crashes intended, or should I report a bug?
EDIT: just read Graf's post from another thread where he said "you'll get a crash if a null pointer gets here", so I guess crashes are intended.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49142
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

If you get a crash log, report a bug. A genuine crash is always a bug. If you just get a console message about accessing address zero, ask again.
User avatar
Cherepoc
Posts: 60
Joined: Wed Sep 08, 2004 1:26 pm
Location: Russia

Re: ZScript Discussion

Post by Cherepoc »

Graf Zahl wrote:A genuine crash is always a bug.
Ok, got it.
Turned out it's not action function fault. The crash was caused by setting the sprite to one that was not used before. Same issue as this one, except I get no console spam, it always crashes.
User avatar
VICE
Posts: 405
Joined: Wed Mar 28, 2012 4:03 am
Location: The Shadow Realm (no cap)

Re: ZScript Discussion

Post by VICE »

I'm looking to re-define an actor from another WAD.
What I want to do is have a new Zscript actor that uses the same name as another, existing Zscript actor.

If you tried something like this in Decorate, you'd get an error message at launch but the game would still run and the actor that loaded last would be the one that the engine ends up using (so it would "work" as long as the intended actor was loaded last).

I'm hoping that there's some ClearActor function or something of that sorts that I'm unaware of that I can use to do this without having to rename my new actor. Is that possible?
If not, could it be made possible in a future version of Zscript?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49142
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

VICE wrote:I'm looking to re-define an actor from another WAD.
What I want to do is have a new Zscript actor that uses the same name as another, existing Zscript actor.
It is not possible to have two classes of the same name. The game cannot deal with this situation.
While DECORATE will rename the duplicate, to keep old mods which accidentally did this working, ZScript will error out and not allow it at all.
VICE wrote: I'm hoping that there's some ClearActor function or something of that sorts that I'm unaware of that I can use to do this without having to rename my new actor. Is that possible?
If not, could it be made possible in a future version of Zscript?
Won't happen. You never know if something else may reference that actor later and choke on a bad replacement.
ZzZombo
Posts: 317
Joined: Mon Jul 16, 2012 2:02 am

Re: ZScript Discussion

Post by ZzZombo »

Why it's not possible to extend a class/override a function implementation, again?
User avatar
VICE
Posts: 405
Joined: Wed Mar 28, 2012 4:03 am
Location: The Shadow Realm (no cap)

Re: ZScript Discussion

Post by VICE »

Graf Zahl wrote: It is not possible to have two classes of the same name. The game cannot deal with this situation.
Well, that wasn't my intention (I suspected the engine does something with the old actor, but I thought it just purged it).

In fact,
Graf Zahl wrote:While DECORATE will rename the duplicate, to keep old mods which accidentally did this working
It would be great if there was some way to do exactly that ^, a way to rename the duplicate myself, somehow, but in advance so the engine understands that it's purposeful and doesn't spit out an error.
Graf Zahl wrote:Won't happen. You never know if something else may reference that actor later and choke on a bad replacement.
I agree with the logic here, obviously, but I think that is ultimately the modder's responsibility.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49142
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

I meant it will rename the DUPLICATE, i.e. YOUR class.
You cannot throw out a defined class because you have no idea what still needs this class and the data owned by it. And the name needs to be unique because otherwise some stuff, like state pointers cannot be restored from a savegame.
User avatar
VICE
Posts: 405
Joined: Wed Mar 28, 2012 4:03 am
Location: The Shadow Realm (no cap)

Re: ZScript Discussion

Post by VICE »

Graf Zahl wrote:I meant it will rename the DUPLICATE, i.e. YOUR class
I see. My experience with this was different though:
I replaced a weapon in this way, and ACS scripts that referred to the original weapon by name started applying to the new one and stopped working with the old (I checked the old with IDFA), and the console "give" command gave me the new one correctly. That's why I thought that the old one was made inaccessible internally but its information was kept somewhere for inheritance etc. That was in GZDoom 2.2.0, though, I guess that could be irrelevant now.

And just to be perfectly clear, I wasn't looking to completely throw the old actor out, or to have two actors with the same actor name existing at once (duh). I was interested to see if there was a way to resolve a name conflict in advance without it getting to a point of spitting out errors.

Specifically, I wanted to see if there was now a way to modify weapons in a certain mod, such that it doesn't affect the ACS scripts that they were designed to work with.
I needed to do this without modifying the base mod, so that I could do my changes from a separate file. (Zombo's use of the word "extend" was probably more appropriate here).



I guess that's probably still not possible with Zscript, but I thought I'd ask in case it were. Anyway, thanks for the help.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49142
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

That won't work anymore, even from DECORATE.
And since this came with a console warning from the beginning, my only answer can be, that ZDoom takes no guarantee whatsoever that mods which are not warning-free will continue to work.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: ZScript Discussion

Post by Ghastly »

With the advent of this, how close to actor (specifically projectile) collision detection can we get in ZScript? For example, could we have functions for when we're colliding with an actor, and return true if we want it to result in a collision or false if we want to pass through?

Also, do we have a way of interacting with the children of a given actor?
User avatar
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Bam.

Read CanCollideWith carefully. I left very explicit instructions on how to use it. Because WYSIWYG.

If you want to get around to doing some true collision working, have your actors be solid and set up your custom conditions inside the virtual. Those that pass through all actors should immediately return false.

Careful though. This can be expensive if done too much.

Return to “Scripting”