"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?"
Is it possible to use the BlockingMobj pointer in the A_Warp function somehow? If I try using it directly, eg. A_Warp(BlockingMobj); , I get an error saying a numeric type is expected. Same with A_Warp(GetPointer(BlockingMobj));.
I'm asking because I was wondering if I can now replace the old +HITMASTER/TARGET/TRACER flags.
I'm asking because I was wondering if I can now replace the old +HITMASTER/TARGET/TRACER flags.
-
- Posts: 111
- Joined: Wed Jun 15, 2016 2:49 pm
Re: "How do I ZScript?"
Is it preferable to put all player processing* into an EventHandler or simply into the player's Tick().
*It's for reading player input for a stamina bar
EDIT: Is it possible to have custom actor properties store their values in a struct?
*It's for reading player input for a stamina bar
EDIT: Is it possible to have custom actor properties store their values in a struct?
- 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?"
D2JK: The pointer is not going to be the same sort of pointer A_Warp is looking for. Is there any reason why you have to use A_Warp and not SetOrigin?
ZippeyKeys: If you're just reading input from a player, it seems like you could just have the checks take place in the status bar itself. (I don't know how status bars work but if you can check a custom variable in a playerpawn then surely players.mo.getplayerinput() should work as well).
ZippeyKeys: If you're just reading input from a player, it seems like you could just have the checks take place in the status bar itself. (I don't know how status bars work but if you can check a custom variable in a playerpawn then surely players.mo.getplayerinput() should work as well).
Re: "How do I ZScript?"
"Is there any reason why you have to use A_Warp and not SetOrigin?"
I think A_Warp is easier to work with when you need a relative position/angle. Plus, I think SetOrigin does not interpolate? I could be wrong though.
I think A_Warp is easier to work with when you need a relative position/angle. Plus, I think SetOrigin does not interpolate? I could be wrong though.
Re: "How do I ZScript?"
SetOrigin has a second argument where you can set whether you want interpolation on or off.
Re: "How do I ZScript?"
Gah. For some reason I always assumed the "moving" argument meant whether to keep existing velocities after the move, or to nullify them.
- Caligari87
- Admin
- Posts: 6174
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: "How do I ZScript?"
Is there any way to check if a way to check if a certain sound is playing? My weapon has some "automatic" sound functions (slide movement) and I don't want to play them if the gunshot sound is already playing, sounds weird.
Alternatively, any way to NOT play a sound if the channel is occupied, instead of overriding it? Seems like that could be a useful flag for A_Playsound().
Alternatively, any way to NOT play a sound if the channel is occupied, instead of overriding it? Seems like that could be a useful flag for A_Playsound().
-
- Posts: 111
- Joined: Wed Jun 15, 2016 2:49 pm
Re: "How do I ZScript?"
Vaecrius wrote:ZippeyKeys: If you're just reading input from a player, it seems like you could just have the checks take place in the status bar itself. (I don't know how status bars work but if you can check a custom variable in a playerpawn then surely players.mo.getplayerinput() should work as well).
Thanks, I was just wondering if there was a best practice;
EDIT: Spelling, rip;
Re: "How do I ZScript?"
Is there any way I can possibly get an actor's current "sprite texture"?
I'm trying to obtain its real "height" so to speak, as in, an Arch-Vile has a set Height of 56, however its sprites can go up to 76 in some cases, that's the value I'm after.
Consider the following code in the Tick() override for an actor:
It works alright and returns the proper height for "VILEA1D1" (76), but I couldn't find a way to get whichever the actor is using at that exact moment.
Is there perhaps another (easier) way to accomplish this and I'm over-complicating things?
I'm trying to obtain its real "height" so to speak, as in, an Arch-Vile has a set Height of 56, however its sprites can go up to 76 in some cases, that's the value I'm after.
Consider the following code in the Tick() override for an actor:
Code: Select all
TextureID SpriteTexture = TexMan.CheckForTexture("VILEA1D1", TexMan.TYPE_Any);
Int SpriteTexHeight = TexMan.CheckRealHeight(SpriteTexture);
Is there perhaps another (easier) way to accomplish this and I'm over-complicating things?
Re: "How do I ZScript?"
Actor's current state holds it IIRC.
Re: "How do I ZScript?"
I have some weapons that are throwable, and won't give more ammo when picked up again. Currently, I do this by setting "AmmoGive" to zero in the actual weapon pickup, and then creating a custom pickup which gives both the weapon and the supposedly included ammo.
But I was wondering: is it possible to customize the ammo give property in a spawned weapon pickup somehow, such as:
tracer.ammogive or tracer.weapon.ammogive didn't seem to work.
I also cannot do Class EmptyShotgun : Shotgun { Default { Weapon.AmmoGive 0; } }, because this class would become a new weapon.
But I was wondering: is it possible to customize the ammo give property in a spawned weapon pickup somehow, such as:
Code: Select all
A_SpawnItemEx("Shotgun", flags: SXF_ISTRACER);
if (tracer)
tracer.<?CODE?> = X;
I also cannot do Class EmptyShotgun : Shotgun { Default { Weapon.AmmoGive 0; } }, because this class would become a new weapon.
Re: "How do I ZScript?"
Thank you so much!ZzZombo wrote:Actor's current state holds it IIRC.
You pointed exactly in the right direction, here's what I ended up with:
Code: Select all
Int SpriteTexHeight;
TextureID SpriteTexture; Bool SpriteFlip; Vector2 SpriteScale;
[SpriteTexture, SpriteFlip, SpriteScale] = ownerRef.CurState.GetSpriteTexture(ownerRef.SpriteRotation);
SpriteTexHeight = TexMan.CheckRealHeight(SpriteTexture);
Re: "How do I ZScript?"
No problem. @D2JK, you have to cast the actor in question to the appropriate type, i. e. Weapon in this case. Then you'll be able to access weapon-specific fields.
Re: "How do I ZScript?"
Ah, so casting again then. Thanks, I'll try that.
Re: "How do I ZScript?"
It has come to my attention something is wrong when using SetOrigin in actors on top of player activated elevators: actor's Pos.Z will be set to the platform floor no matter what.
Seems to work okay when the platform's raising/lowering is activated automatically, with no player interaction.
(Sorry if my wording is not clear enough, I'll try recording some footage showing this strange behavior)
Seems to work okay when the platform's raising/lowering is activated automatically, with no player interaction.
(Sorry if my wording is not clear enough, I'll try recording some footage showing this strange behavior)