"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!)
- 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: ZScript-only "How do I..." thread
They never needed to be, nor should have been, in quotes when defining a state.
Xaser: Yes, that was what I had been asking - I was still stuck in the bad old days when A_CheckSight could only check if the calling actor was within sight of a player!
Thanks for that and the BlockThingsIterator!
Xaser: Yes, that was what I had been asking - I was still stuck in the bad old days when A_CheckSight could only check if the calling actor was within sight of a player!
Thanks for that and the BlockThingsIterator!
Last edited by Matt on Tue Jan 31, 2017 6:17 pm, edited 1 time in total.
Re: ZScript-only "How do I..." thread
is there a way to convert an enum to int in zscript?
like:
enum onoff
{
off,
on,
};
onoff XX;
....
XX = CheckSight(...); // XX = (int) CheckSight(...); doesn't work :S
like:
enum onoff
{
off,
on,
};
onoff XX;
....
XX = CheckSight(...); // XX = (int) CheckSight(...); doesn't work :S
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49056
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript-only "How do I..." thread
CheckSight returns a bool, so use a bool variable and not some homegrown substitute.
Enums are not fully implemented, so you'll run into some issues. For the time being, do not use enum type variables, it may well be that your mod may break once they are being made functional.
Enums are not fully implemented, so you'll run into some issues. For the time being, do not use enum type variables, it may well be that your mod may break once they are being made functional.
- 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: ZScript-only "How do I..." thread
Are A_Explode, A_RadiusThrust and A_RadiusGive equivalent to BlockThingsIterator or ThinkerIterator or something else entirely in terms of how they go through what things should be affected?
Re: ZScript-only "How do I..." thread
They all use BlockThingsIterator internally (the native-code version of it, at least).
The wiki does currently have a big fat warning about BlockThingsIterator being less performant than the other iterator types, but that's really only gonna be an issue if you use a crazy-large radius... or play somebody's ridiculous map that crams 10,000 zombiemen in a 128-unit radius.
[It's probably worth also-disclaiming that the scripted versions of things do have a lot more overhead than their native counterparts, but that again only matters if you're really trying to push the limits for some wacky reason.]
The wiki does currently have a big fat warning about BlockThingsIterator being less performant than the other iterator types, but that's really only gonna be an issue if you use a crazy-large radius... or play somebody's ridiculous map that crams 10,000 zombiemen in a 128-unit radius.
[It's probably worth also-disclaiming that the scripted versions of things do have a lot more overhead than their native counterparts, but that again only matters if you're really trying to push the limits for some wacky reason.]
- 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: ZScript-only "How do I..." thread
I really should do something about that mancubus fireball in Hideous Destructor that explodes every see frame... and the chaingun bullets that all A_RadiusGive an inventory flag... and... yeah...
Another question: I want to do something like this:where "blahblah" is a variable defined in "Blah". But I keep getting an error that says it can't be done.
Is there any way to make it "known" to the calling actor somehow, so I don't have to find some existing unused property (accuracy, stamina, etc.) to exploit?
Another question: I want to do something like this:
Code: Select all
actor blahblahblah=spawn("Blah",self.pos);
blahblahblah.blahblah=5;
Is there any way to make it "known" to the calling actor somehow, so I don't have to find some existing unused property (accuracy, stamina, etc.) to exploit?
- Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
- Contact:
Re: ZScript-only "How do I..." thread
You made blahblahblah an actor, when you should make it a Blah, so the caller knows it has the blahblah variable in it.
- 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: ZScript-only "How do I..." thread
So I could just define any "Blah" and do this?
Even then it doesn't quite work for some other things I have in mind, though - like a static function that can be called by a fastprojectile or a monster or a puff.
EDIT: I think I have my answer in here with "let". Thanks for the help anyway, Ed!
Code: Select all
Blah blahblahblah=spawn("Blah"...
EDIT: I think I have my answer in here with "let". Thanks for the help anyway, Ed!
Last edited by Matt on Tue Jan 31, 2017 8:57 pm, edited 1 time in total.
- Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
- Contact:
Re: ZScript-only "How do I..." thread
Static functions can be called from anyone, though. I don't see how making blahblahblah into a Blah instead of an Actor (Blah is a descendant of Actor anyway, right? It'll have everything Actor has) would impede that.
"Let" is a way to automatically determine the type. In the cases that it works, it's a great shortcut. I've run into a few edge cases where it didn't give me what I truly wanted, though, so there's still merit to manually typing your objects in some instances.
"Let" is a way to automatically determine the type. In the cases that it works, it's a great shortcut. I've run into a few edge cases where it didn't give me what I truly wanted, though, so there's still merit to manually typing your objects in some instances.
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript-only "How do I..." thread
It fucked me over a couple times myself, though they were rare. I never could figure out what the hell was going on because it crashed a long time ago when trying to get the class but I think it's been fixed since then.
- 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: ZScript-only "How do I..." thread
I'm trying to see if I can do a really bare-bones stripped-down actor for debris.
What is it that's called to keep something on a moving platform (some of which lower faster than a thing spawned in midair would drop, but the things on them lower without incident anyway) or conveyer?
Also, is there a ZScript function that grabs the first actor that's blocking a line extending from one point to another? A_CheckLOF is aggravating to use for reasons.
EDIT: Is there a built-in way to sort an array (alphabetical, descending, etc.), or does that need to be coded explicitly?
What is it that's called to keep something on a moving platform (some of which lower faster than a thing spawned in midair would drop, but the things on them lower without incident anyway) or conveyer?
Also, is there a ZScript function that grabs the first actor that's blocking a line extending from one point to another? A_CheckLOF is aggravating to use for reasons.
EDIT: Is there a built-in way to sort an array (alphabetical, descending, etc.), or does that need to be coded explicitly?
Re: ZScript-only "How do I..." thread
Question; is it possible for an actor using A_Explode to hurt and only hurt actors that have the +OLDRADIUSDMG flag?
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49056
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript-only "How do I..." thread
No. For that you'd have to replace P_RadiusAttack, i.e. rewrite that function to do what you want.
Re: ZScript-only "How do I..." thread
I want an actor to store the player in a custom pointer when he or she walks up to it and presses the Use key. Preferably without messing with the standard activation flags if that's possible.
Spoiler:The above (definition for the SwitchableDecoration actor) didn't give me any clue, but perhaps it might help someone else help me
Re: ZScript-only "How do I..." thread
About This
Second: Here's the updated test wad: https://1drv.ms/u/s!AurELTq1jbljkZBjQg-M6YrdvJR79A, each skill has a different object, and as you can see, both acs and zscript version of checksight return different patterns in some cases.
So I then repeat my question, how do I make the zscript code return the same thing as the acs code without calling acs scripts???????
Also the code is here in case you do not want to download the test wad
patterns found:
MAPSPOT: return as random(0,1); On acs it's Always 1
HATETARGET: return 0 on the first tic and later Always 1. On acs it's Always 1
CANDLESTICK return 0 on the first tic and later Always 1. On acs it's Always 1
INVISIBLEBRIDGE: return 0 on the first tic and later Always 1. On acs it's Always 1
EDIT: Maybe on the first tic it's zero because the zscript didn't send his checksight value at that tic
First: what the heck is SF_IGNOREINVISIBILITY that I cannot even find into the fórum/wiki neither the source code O__________O ????Graf wrote: No bug here. If you want to get reliable results for invisible things you have to pass SF_IGNOREINVISIBILITY for the flags parameter.
Second: Here's the updated test wad: https://1drv.ms/u/s!AurELTq1jbljkZBjQg-M6YrdvJR79A, each skill has a different object, and as you can see, both acs and zscript version of checksight return different patterns in some cases.
So I then repeat my question, how do I make the zscript code return the same thing as the acs code without calling acs scripts???????
Also the code is here in case you do not want to download the test wad
Code: Select all
class SightChecker : Actor
{
Default
{
}
Actor Act;
States
{
Spawn:
TNT1 A 1;
TNT1 A 1 FindActors();
goto Myloop;
Myloop:
TNT1 A 1 ACS_Execute(2,0,CheckVisibility());
Goto Myloop;
}
void FindActors()// or FindLightSourcePointers
{
ActorIterator It;
class<Actor> _type = "Actor";
It = ActorIterator.create(666,_type);
Act = It.Next();
}
bool CheckVisibility()
{
return CheckSight(Act);
}
}
MAPSPOT: return as random(0,1); On acs it's Always 1
HATETARGET: return 0 on the first tic and later Always 1. On acs it's Always 1
CANDLESTICK return 0 on the first tic and later Always 1. On acs it's Always 1
INVISIBLEBRIDGE: return 0 on the first tic and later Always 1. On acs it's Always 1
EDIT: Maybe on the first tic it's zero because the zscript didn't send his checksight value at that tic