"How do I ZScript?"

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!)
Locked
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "How do I ZScript?"

Post by Nash »

krokots wrote:Is there any equivalent of PickActor on ZScript?

LineAttack and AimLineAttack. I just posted an example a few pages back about a Demon who goes around looking for things to use.

Generally speaking you can open up gzdoom.pk3 and look inside the ZScript folder to see what's available to you.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

If you are using TIDs, there's also ActorIterator if you're not looking for a line target.
User avatar
krokots
Posts: 266
Joined: Tue Jan 19, 2010 5:07 pm

Re: "How do I ZScript?"

Post by krokots »

Holy crap, if I would start making my mod now I could probably use way more ZScript. But I'm deep down into ACS right now so I won't bother changing all the PickActors, variables etc.
So if I see correctly, LineAttack returns an actor if it hits one.
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: "How do I ZScript?"

Post by Gutawer »

Nah, LineAttack returns the bullet puff actor that was spawned from the hitscan. If no puff is spawned it returns null.
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "How do I ZScript?"

Post by Nash »

Look at my example. t.LineTarget is returning directly the Actor that hit the ray.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: "How do I ZScript?"

Post by Ed the Bat »

Perhaps LineAttack or LineTarget can help with the autoaim railgun I'm still pondering over...?

Anyway, for now, is there a known method for setting the Bright keyword on the current frame, so that it can be done conditionally? Likewise, can a dynamic light be attached with a function? It seems like it would be cleaner than having to jump to different frames or states if that's all I want to change. If the current sprite can be changed, I just thought perhaps the Bright or the Light could also be changed?

Came up with another question... is there yet an established method for ZScript to perform actions upon starting the level? Like an analogue to ACS OPEN scripts?
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "How do I ZScript?"

Post by Nash »

Screen.DrawText/Texture question:

Is it possible to position something in the same resolution as whatever the current user's resolution is, BUT have the graphic always RENDER at a fixed resolution, say 320x200? So for example, if the user is using 1920x1080, the draw canvas would have more precision for you to position the object, but the graphic that's blitted to the screen should always look blocky like as if the screen was 320x200.

Which Draw Tag should I use to achieve this?
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: "How do I ZScript?"

Post by ZZYZX »

Use VirtualWidth and VirtualHeight, and just calculate fractional offsets based on the real resolution. (x,y are doubles, as well as VirtualWidthF/VirtualHeightF)
Note: don't forget to DTA_KeepRatio.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: "How do I ZScript?"

Post by Matt »

Is there a place where all this screen draw stuff is documented? I don't even know where to begin to look for any of it...
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

If you mean the wiki: Nope, and I have no intention of doing any until the next GZDoom version is released. But you can find examples of it scattered throughout the menu code.
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "How do I ZScript?"

Post by Nash »

Vaecrius: everything in the menu code uses that stuff (everything inside zscript/menu/ and DrawTextureTags inside zscript/base.txt )... as for HOW to actually use them... well, trial and error I guess. >_<

Unfortunately the only way to draw things correctly is either through Menus or through a Powerup. If you try to draw from an actor, your text will flicker because the actor tick only runs at 35Hz.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: "How do I ZScript?"

Post by Matt »

Thanks!

So to bump an earlier question: how do you get something to target a dead player even after the player has respawned and not switch over to the respawned player?

EDIT: How do you use the Used() virtual function? It doesn't seem to do anything when I try to "use" a modified actor and I have no idea what else needs to be added.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: "How do I ZScript?"

Post by ZZYZX »

Try +USESPECIAL.
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "How do I ZScript?"

Post by Nash »

Changelog says
added a virtual 'used' method that gets called when the player presses use on an actor. This method will only be called if the actor does not have the USESPECIAL flag - that one will be handled as before.
So maybe remove the USESPECIAL flag, if it has one?
User avatar
4thcharacter
Posts: 1183
Joined: Tue Jun 02, 2015 7:54 am

Re: "How do I ZScript?"

Post by 4thcharacter »

I've been really wanting to ask this. How powerful is ZScript? Is it able to manipulate the monsters' movements instead of them going straightly towards the player while walking on left to right a little and shoot from time to time?

Can someone please tell what notable things ZScript can do? Thanks.
Locked

Return to “Scripting”