"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?"
That means it's in a ZDoom dev version (and forever will be, with ZDoom's death), GZDoom has had it in stable for a while now.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49066
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "How do I ZScript?"
The Wiki is a bit behind, it still lists ZDoom 2.8.1 as the baseline.
- 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?"
For future reference, if in doubt, click on the number to get to the changelog post, and check the date, and compare it to the date of the latest GZDoom release.sonic_HD87 wrote:It doesn't matter if it says "development version only"?
Re: "How do I ZScript?"
How can I easily check current state of an actor? ACS have "CheckActorState", but I didn't find anything in ZScript or Decorate.
Re: "How do I ZScript?"
krokots wrote:How can I easily check current state of an actor? ACS have "CheckActorState", but I didn't find anything in ZScript or Decorate.
Code: Select all
if (CurState == ResolveState("See")) {
// ...
}
Re: "How do I ZScript?"
Thanks, exactly what I needed.Gutawer wrote:krokots wrote:How can I easily check current state of an actor? ACS have "CheckActorState", but I didn't find anything in ZScript or Decorate.To get other actors' states, you can use pointers as always.Code: Select all
if (CurState == ResolveState("See")) { // ... }
Actually, there seems to be some problems with this method.
Making a blind spell, which set monster state to "blinded" on it's spawn state, and then on active state it checks if the monster is still on "blinded" state.
The spell's target is the monster.
Code: Select all
Spawn:
S010 A 0 NoDelay
{
A_PlaySound ("Spells/Blind");
target.setStateLabel("Blinded");
if(target.curState==target.resolveState("Blinded"))
{
A_Log("Target is blinded");
}
}
Active:
TNT1 A 0
{
if(target.CurState != target.ResolveState("Blinded"))
{
A_Log("Not blinded anymore");
return ResolveState("Null");
}
return ResolveState("Active");
}
Fortunately tho, I found (in this thread) another method which works:
Code: Select all
if(!(inStateSequence(target.Curstate, target.resolvestate("Blinded"))))
Re: "How do I ZScript?"
How to GetUDMF*** in ZScript? I mean, what are the parameters? GetUDMF***("SomeCustomUDMFValueNameHere"); ?
- Arctangent
- Posts: 1235
- Joined: Thu Nov 06, 2014 1:53 pm
- Contact:
Re: "How do I ZScript?"
So, I'm trying to think out how to do a third person thing, preferably using ZScript, and one thing I want to do is to make the player move in the direction they're moving while keeping the camera always pointed in the way they're aiming - with extra points if the player has a turn speed, as what I'm planning would have typical attack animations long enough for such turning to only give a minor amount of "circling" when going from moving 180 degrees and otherwise just be a nice visual effect.
Issue is, of course, is making it so that the player - the one getting the actual turn inputs - doesn't have their angle be immediately affected, but the camera instead. I figure one way to do it might be making the camera the player with the actual body being a true pawn, but I dunno how I feel about how proper that is, especially considering that would mean shoving +NOINTERACTION on a player.
Also, not quite ZScript related, but what's a good camera angle for a shooting thing, anyway? Over-the-shoulder is a natural choice, but that has the issue of having projectiles not actually follow the crosshair over long distances. As far as behind-the-back goes, I've had issues making sure that the crosshair can actually be in the center of the screen without the player's body blocking it.
Issue is, of course, is making it so that the player - the one getting the actual turn inputs - doesn't have their angle be immediately affected, but the camera instead. I figure one way to do it might be making the camera the player with the actual body being a true pawn, but I dunno how I feel about how proper that is, especially considering that would mean shoving +NOINTERACTION on a player.
Also, not quite ZScript related, but what's a good camera angle for a shooting thing, anyway? Over-the-shoulder is a natural choice, but that has the issue of having projectiles not actually follow the crosshair over long distances. As far as behind-the-back goes, I've had issues making sure that the crosshair can actually be in the center of the screen without the player's body blocking it.
Re: "How do I ZScript?"
RE: which camera angle to use (can't help with the first part, sorry) -
With over-the-shoulder, presuming you can get the view angle & pitch of the camera (hopefully possible, depending on how you implement the camera), you can then use LineAttack to do a raytracer (as described by Nash a page back) and determine where the player is actually aiming. From there, you can use trigonometry to offset projectiles & hitscans so they hit where the player is actually aiming. That will make attacks follow the crosshair even in over-the shoulder.
With over-the-shoulder, presuming you can get the view angle & pitch of the camera (hopefully possible, depending on how you implement the camera), you can then use LineAttack to do a raytracer (as described by Nash a page back) and determine where the player is actually aiming. From there, you can use trigonometry to offset projectiles & hitscans so they hit where the player is actually aiming. That will make attacks follow the crosshair even in over-the shoulder.
- 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?"
Arctangent: We'll talk on Discord.
- 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?"
What does "exact" do in FindState?
- sonic_HD87
- Posts: 287
- Joined: Sat Mar 23, 2013 4:32 pm
- Location: Venezuela
Re: "How do I ZScript?"
It seems that InStateSequence is used to check if an actor's state (arg1) matches the given state (arg2), since is a bool function. I think that using target.CurState == Target.ResolveState("Blind") is doing something else.krokots wrote:Fortunately tho, I found (in this thread) another method which works:I don't know why this works and other does not.Code: Select all
if(!(inStateSequence(target.Curstate, target.resolvestate("Blinded"))))
And if i got it wrong, well that's good since there's no documentation for those functions.
Re: "How do I ZScript?"
This is probably ultra basic and I'm just dumb but:
How do I normalize GetPlayerInput's INPUT_FORWARDMOVE and SIDEMOVE's output into range [-1.0, 1.0]? I mean, I want to use values between -1.0 to 1.0, not -/+10k++ or whatever it usually is.
EDIT: nvm got it
How do I normalize GetPlayerInput's INPUT_FORWARDMOVE and SIDEMOVE's output into range [-1.0, 1.0]? I mean, I want to use values between -1.0 to 1.0, not -/+10k++ or whatever it usually is.
EDIT: nvm got it
Code: Select all
double input = GetPlayerInput(INPUT_SIDEMOVE);
double normalizedInput = 1.f * input / 10240.;
- 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?"
Code: Select all
// Slowing down?
if ((udirget & BT_SPEED) || uwings)
{
// Forwards or backwards?
udirforward = GetPlayerInput(MODINPUT_FORWARDMOVE) / 6400.0;
// Left or right?
udirside = -GetPlayerInput(MODINPUT_SIDEMOVE) / 6144.0;
}
else
{
// Forwards or backwards?
udirforward = GetPlayerInput(MODINPUT_FORWARDMOVE) / 12800.0;
// Left or right?
udirside = -GetPlayerInput(MODINPUT_SIDEMOVE) / 10240.0;
}
Re: "How do I ZScript?"
Is there any equivalent of PickActor on ZScript?