"How do I ZScript?"
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!)
Re: "How do I ZScript?"
If I'm not mistaken, "action" is there to mark the function as an action special, so that it can be called from states.
I've solved the issue by putting "invoker." in front of the user var.
I've solved the issue by putting "invoker." in front of the user var.
- 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?"
That seems so weird that you'd need invoker for that o_O It's just an actor, not an inventory item or weapon!
Re: "How do I ZScript?"
What Vaecrius said... I'm pretty sure that's only required for weapons.Gez wrote:If I'm not mistaken, "action" is there to mark the function as an action special, so that it can be called from states.
I've solved the issue by putting "invoker." in front of the user var.
I know for 100% certain that for a function within a normal actor, you don't need the action declaration.
Re: "How do I ZScript?"
Try it and see what happens? :D That code was lifted directly from my project, which works.Vaecrius wrote:Nash: I have some vague recollection of trying that last night and it didn't compile. Are event handlers fully supported in 3.0.1?
- 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?"
It doesn't work for me.
Does it have to be defined in Mapinfo as well?
EDIT: right, that.
Does it have to be defined in Mapinfo as well?
EDIT: right, that.
Code: Select all
gameinfo{
eventhandlers="MyHandler"
}
Re: "How do I ZScript?"
Probably better to use in most cases, it prevents the game from overwriting all other handlers with your one, heavily increasing mod compatibility with other mods that use their own EventHandlers.
Code: Select all
AddEventHandlers="MyHandler"
Re: "How do I ZScript?"
Alright, got rid of action and invoker. and it indeed works.
New question now: I want to make a waterproof firemace. The normal projectiles are destroyed when they hit water, so that's annoying. For the first three MaceFX, just giving them the CANBOUNCEWATER flag is enough; but MaceFX4 is more annoying because its A_DeathBallImpact kills it when it hits water. So I've got to override that. But it's not virtual so it's not overridable. I guess there's no other choice than to make a clone of the function (without the annoying bit) with a different name and replaces the state that call it.
New question now: I want to make a waterproof firemace. The normal projectiles are destroyed when they hit water, so that's annoying. For the first three MaceFX, just giving them the CANBOUNCEWATER flag is enough; but MaceFX4 is more annoying because its A_DeathBallImpact kills it when it hits water. So I've got to override that. But it's not virtual so it's not overridable. I guess there's no other choice than to make a clone of the function (without the annoying bit) with a different name and replaces the state that call it.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "How do I ZScript?"
This is not correct. The terminology may be a bit confusing because this was the original intent but isn't correct anymore.Gez wrote:If I'm not mistaken, "action" is there to mark the function as an action special, so that it can be called from states.
What 'action' does is to mark the function as usable from non-actor states, like weapons, overlays and custom inventories, so that it can pass the invoker pointer. In any other context 'action' should not be used at all!
- Caligari87
- Admin
- Posts: 6233
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: "How do I ZScript?"
Since we're on the subject, I think I'm having some kind of scope issues and/or misunderstandings. I've got a weapon, and it seems I can't get or manipulate certain variables in Tick(). Like, GetPlayerInput doesn't seem to return anything, I can't use variables like angle/pitch, etc. It seems those things only work in either anonymous or action functions?


Re: "How do I ZScript?"
Is there any way to achieve the same effect as the different modes of ACS' Thing_Hate with ZScript? I know you can set the target pointer directly, but that isn't really helpful in this case since I'd like the actor being modified to switch target to the player in the case that the player starts attacking them, like with Thing_Hate type 1 or 2. So, is there any way to set this sort of logic through ZScript?
Re: "How do I ZScript?"
Yeah, I was under the same impression as Gez here. The keyword "action" no longer maps 1:1 with the DECORATE notion of "action function", which is never going to not confuse anyone. :/Graf Zahl wrote:This is not correct. The terminology may be a bit confusing because this was the original intent but isn't correct anymore.Gez wrote:If I'm not mistaken, "action" is there to mark the function as an action special, so that it can be called from states.
What 'action' does is to mark the function as usable from non-actor states, like weapons, overlays and custom inventories, so that it can pass the invoker pointer. In any other context 'action' should not be used at all!
I'm not really sure what to suggest here, aside from providing a synonym keyword for "action" (suggestions welcome, I guess) so the docs can simply state "'action functions' are just called 'functions' now" and use some new keyword to describe the "usable from non-actor states" concept.
Re: "How do I ZScript?"
"proxy"? The function belongs to a weapon, but it's actually the player who uses it, so the weapon is kind of a proxy? Or "indirect" perhaps.
- Major Cooke
- Posts: 8209
- 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
- Contact:
Re: "How do I ZScript?"
Yup. You can't use direct assignment without it being inside of a function, anonymous or otherwise.Caligari87 wrote:Since we're on the subject, I think I'm having some kind of scope issues and/or misunderstandings. I've got a weapon, and it seems I can't get or manipulate certain variables in Tick(). Like, GetPlayerInput doesn't seem to return anything, I can't use variables like angle/pitch, etc. It seems those things only work in either anonymous or action functions?
Few options.Gutawer wrote:Is there any way to achieve the same effect as the different modes of ACS' Thing_Hate with ZScript? I know you can set the target pointer directly, but that isn't really helpful in this case since I'd like the actor being modified to switch target to the player in the case that the player starts attacking them, like with Thing_Hate type 1 or 2. So, is there any way to set this sort of logic through ZScript?
1. Use an iterator and perform sight checking.
+ Gives you total control.
- You'll have to set this one up yourself though, check for things like if it's a monster and if it's alive.
- Can lag if done too much and/or too often.
2. Use the now-fixed RoughMonsterSearch.
- I have no words of wisdom on this one.
3. If it's only when damaged, override the DamageMobj function, check if it's a player kicking them in the pants and retaliate.
- Careful though, you'll need to turn off the FRIENDLY flag AND SET THE DESIGNATEDTEAM variable to a team the player's not on.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "How do I ZScript?"
Give me a better keyword and we're in business. BTW, the 'action' keyword was required for any action function until I realized that I only needed to make a minimal change to the code to lift the restrictionXaser wrote:Yeah, I was under the same impression as Gez here. The keyword "action" no longer maps 1:1 with the DECORATE notion of "action function", which is never going to not confuse anyone. :/Graf Zahl wrote:This is not correct. The terminology may be a bit confusing because this was the original intent but isn't correct anymore.Gez wrote:If I'm not mistaken, "action" is there to mark the function as an action special, so that it can be called from states.
What 'action' does is to mark the function as usable from non-actor states, like weapons, overlays and custom inventories, so that it can pass the invoker pointer. In any other context 'action' should not be used at all!
I'm not really sure what to suggest here, aside from providing a synonym keyword for "action" (suggestions welcome, I guess) so the docs can simply state "'action functions' are just called 'functions' now" and use some new keyword to describe the "usable from non-actor states" concept.
Re: "How do I ZScript?"
Is there a way to access zscript variables via ACS?