ZScript Discussion
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!)
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!)
-
- Lead GZDoom+Raze Developer
- Posts: 49225
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
The VM time will still be far less than the normal movement code. Test I made show that stuff like one call of P_TryMove costs as much as 10 small-sized VM calls, not to mention stuff like P_CheckSight or projectile spawning. At the moment VM execution time doesn't look like a problem, but scriptifying the monster AI is probably not the brightest idea without a JIT implementation. The inventory stuff I did during the last few days is completely uncritical because it doesn't contain much continuously running code and never has much of an impact.
-
- Posts: 8208
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
Re: ZScript Discussion
Yeah. Load up D4D + New Gothic Movement 2's map... 16? 17? Something like that. It's the final map of this slaughtermap series.Xaser wrote:Well, that doesn't suck at all.
A second stress test may be putting together a wad which Replaces all Doom monsters with ones which override Tick() and then load up a slaughtermap. I bring this up because I'm planning on doing exactly that for a thing. Welp.
Immediately, your gameplay will slow to a fucking crawl of 1. ONE.
And that map? It has tens of thousands of ammo placements, Graf.
If you thought ZDCMP is bad...
-
- Posts: 8208
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
Re: ZScript Discussion
Only curious Graf, but how would a JIT compiler help alleviate these issues? I've never understood what that's about.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
JIT generally means that the VM bytecode is translated to CPU-friendly bytecode and executed directly, while also optimizing and skipping certain operations.
This frees some time from the VM processing loop and makes it a bit faster — but when there's a lot of code, it can turn out to be a lot faster as the result
Especially in an almost-unchecked language like ZScript, something like LLVM's optimizing dynamic compilation might result in almost same code as the stuff written in C, working with approximately the same speed. In an ideal world though.
This frees some time from the VM processing loop and makes it a bit faster — but when there's a lot of code, it can turn out to be a lot faster as the result

Especially in an almost-unchecked language like ZScript, something like LLVM's optimizing dynamic compilation might result in almost same code as the stuff written in C, working with approximately the same speed. In an ideal world though.
-
- Posts: 8208
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
Re: ZScript Discussion
Then I say we give it a shot! Because D4D suffers some serious slow-downs in some maps, and AEoD would DEFINITELY benefit from this.
-
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
Re: ZScript Discussion
I notice that, sometime in the past few days, A_ClearReFire got moved from Weapon to CustomInventory, meaning a few of my weapons now prevent the game from loading. Could anyone share some insight with me about this change? Thoughts/reasons behind it, what I should do differently, etc.?
-
- Posts: 317
- Joined: Mon Jul 16, 2012 2:02 am
Re: ZScript Discussion
That would be a bug for sure, why would a weapon function be restricted to CustomInventory? Perhaps they meant to move it to just Inventory?
-
-
- Posts: 17487
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
Would like a confirmation too on whether this is broken or intended, before I push out a new GZDoom-GPL binary.Ed the Bat wrote:I notice that, sometime in the past few days, A_ClearReFire got moved from Weapon to CustomInventory, meaning a few of my weapons now prevent the game from loading. Could anyone share some insight with me about this change? Thoughts/reasons behind it, what I should do differently, etc.?
///////////////////////////
I really need help with something. I want to port my weather system to ZScript.
A quick glance at the ZScript API shows that all the functions I need are already available and call-able within ZScript, except ReplaceTextures (which I plan to either just wrap around a CallACS call, or Feature Request/PR it).
The only part that confuses me now is the Entry Point.
Bumi is basically one gigantic, infinitely-looping OPEN (world context) script. So how would I replicate this Entry Point in ZScript? Do I spawn an Actor in the world at 0, 0, 0, Unreal Engine 4 style? Do I make a Thinker? I tried looking at making a Thinker but I have no idea how to make it functional, because Spawn()'ing it into the world does not work.
This is the only help I need. I just need to know how to create the Entry Point similar to an OPEN script. Everything else, I am 99% confident I can do on my own with little help.
-
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
Re: ZScript Discussion
This is what I've been doing, and it gets me what I need, but I'm certain there is (or will be) a more proper way. I feel like I'm gross-hacking when I do this. But, stupid ol' me is just thankful when my things work at all, so...Nash wrote:Do I spawn an Actor in the world at 0, 0, 0, Unreal Engine 4 style?
-
-
- Posts: 17487
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
Who do you spawn it from, AKA whose context would the actor be in? Who do you get from "self" before it is spawned?Ed the Bat wrote:This is what I've been doing, and it gets me what I need, but I'm certain there is (or will be) a more proper way. I feel like I'm gross-hacking when I do this. But, stupid ol' me is just thankful when my things work at all, so...Nash wrote:Do I spawn an Actor in the world at 0, 0, 0, Unreal Engine 4 style?
-
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
Re: ZScript Discussion
I'm spawning it with an OPEN script in ACS, meaning I'm not 100% free of that insanity...
-
- Posts: 772
- Joined: Mon May 17, 2010 9:45 am
Re: ZScript Discussion
So I need to trigger a function from the player every time they exit a level. Is there a safe way to do it?
-
- Lead GZDoom+Raze Developer
- Posts: 49225
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
ZzZombo wrote:That would be a bug for sure, why would a weapon function be restricted to CustomInventory? Perhaps they meant to move it to just Inventory?
It just got copied into the wrong place when I removed the native version of it.
-
- Admin
- Posts: 6229
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
Re: ZScript Discussion
Just a quick tangent here. I haven't delved into ZScript for my own projects yet so I'm curious: What can't ZScript do? My project is still very small code-wise, but has a decent chunck of ACS I'd like to refactor into the ZScript equivalent if possible, but I don't want to start yet if I'm just gonna run into some roadblock.


-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
UI, networkingCaligari87 wrote:What can't ZScript do?