"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!)
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: "How do I ZScript?"
And that is why I stated I can't really improve on the lightning effects in D4D in terms of interpolation.
Re: "How do I ZScript?"
Gez wrote:What if the monster is out of reach? Like that imp just before the exit door in MAP01? Or the imps in the center cage in E1M9?JPL wrote:- choose a random monster from the level's population, give it a special key (dropped on death) and some stat boosts that make it visually distinct and harder to kill.
Yep, this is what I was thinking would be needed to turn it into a proper mod. Thanks again for the help starting!Nash wrote:Fire a line trace to let the player telekinetically pick the key up?
Or maybe some fancy effect where the key homes in on you like the Revenant's missile, except it goes through walls and other Actors.
- 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?"
How do you return (or, if possible, alter) the maximum amount of an inventory or ammo item carryable by the player?
Re: "How do I ZScript?"
Code: Select all
<Actor>.FindInventory("class name").MaxAmount;
- 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?"
Is this only available after 3.0.1?Oh, right, it's not a read-only function, no parentheses.Unknown function MaxAmount
Thanks!
Last edited by Matt on Mon May 22, 2017 2:55 pm, edited 1 time in total.
Re: "How do I ZScript?"
MaxAmount isn't a function, it's an int on the Inventory class.
Re: "How do I ZScript?"
In ZScript, is it generally possible for a monster to commit aimed line/projectile/rail attacks against shootable actors other than its current target? In one such a case for a rail attack, I temporarily stored the current target in a new pointer and restored it afterwards, but I was wondering if a more direct way to do this exists, or if one is planned in the future.
Edit:
Another quick question: is it not possible to override the Tick() function for selected weapons? I'm asking because this doesn't seem to work:
Edit:
Another quick question: is it not possible to override the Tick() function for selected weapons? I'm asking because this doesn't seem to work:
Code: Select all
Override Void Tick()
{
if (GetPlayerInput(INPUT_BUTTONS) & BT_SPEED)
A_LogInt(level.maptime);
Super.Tick();
}
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: "How do I ZScript?"
For rails, not sure I can really help there but I know you can do LineAttack.
Don't use Tick on the weapon. Instead, make an overlay.
Don't use Tick on the weapon. Instead, make an overlay.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: "How do I ZScript?"
If a weapon has non-constant variables (i.e. int MyVar), do they reset when the weapon is switched away from or are they kept?
If reset, that means I'll have to use a thinker for it. Hmmm...
If reset, that means I'll have to use a thinker for it. Hmmm...
- 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?"
This doesn't work because in that function "self" means the weapon, so getplayerinput will not return anything.D2JK wrote:Another quick question: is it not possible to override the Tick() function for selected weapons? I'm asking because this doesn't seem to work:Code: Select all
Override Void Tick() { if (GetPlayerInput(INPUT_BUTTONS) & BT_SPEED) A_LogInt(level.maptime); Super.Tick(); }
You'll have to check for an owner, then get owner.getplayerinput, something like this:
Code: Select all
Override Void Tick()
{
if (owner && owner.GetPlayerInput(INPUT_BUTTONS) & BT_SPEED)
A_LogInt(level.maptime);
Super.Tick();
}
EDIT: example re: bees:
Spoiler:Edited per MC's comment below - this version will continue to regenerate ammo even while the weapon is dropped (using DoEffect() here would cause regeneration to happen only while the weapon was being carried - which could be what you want, if you're making a weapon that's charged by your life force or something).
Last edited by Matt on Wed May 24, 2017 2:23 pm, edited 4 times in total.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: "How do I ZScript?"
Except you should be using DoEffect() instead, last I checked. Every inventory actor has this, and it's always called for owned inventory. Weapon inherits from StateProvider which inherits from Inventory after all.
Re: "How do I ZScript?"
Ran into a crash (segfault) with the mod I'm working on, and I made a tiny test case (PK3 attached) with nothing but the behavior that's crashing. I've only been working with ZScript for a few days so I'm fairly sure it's a simple mistake.
Basically I have a HUD mod that does this:
Basically I have a HUD mod that does this:
Spoiler:and an EventHandler that does this:
Spoiler:As you can see I declare the UI's testMonster variable in the "play" scope because it can't be read from the UI scope... is there a simpler way to do this? And what's the correct way to create and destroy such references from EventHandler code? I couldn't find any code examples or documentation specifically about this on the wiki. BTW the docs on the wiki are really coming along, they've been very useful to me so far, keep up the good work!
- Attachments
-
- hudtest.pk3
- (1.31 KiB) Downloaded 18 times
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: "How do I ZScript?"
You cannot access statusbar like that at all. Instead, the world function should give the player a pointer for the statusbar to constantly check upon, and then have the statusbar retrieve it from the player instead.
...Or you could send a network event. That is one of the very few functions that has the ability to cross the UI and Play boundaries.
And, thanks!
...Or you could send a network event. That is one of the very few functions that has the ability to cross the UI and Play boundaries.
And, thanks!
Re: "How do I ZScript?"
Can this be done without creating a PlayerPawn subclass? Thus far I've been able to do everything with the EventHandler and StatusBar...Major Cooke wrote:You cannot access statusbar like that at all. Instead, the world function should give the player a pointer for the statusbar to constantly check upon, and then have the statusbar retrieve it from the player instead.
I see the code here describes how to talk to EventHandler from UI, but what about the other way round? I want the UI to know about the position of an object in the world....Or you could send a network event. That is one of the very few functions that has the ability to cross the UI and Play boundaries.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: "How do I ZScript?"
Give CPlayer.mo an inventory item with custom properties. Then do CPlayer.mo.FindInventory and dig for its contents in there. That's one way.