"How do I ZScript?"

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Locked
User avatar
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:

"How do I ZScript?"

Post by Matt »

I think it's a good idea to start a new "How do I..." thread just for ZScript.

My reasoning:

1. More of these threads dedicated to a specific topic is probably not a bad idea. A lot of people's questions get quickly bumped into obscurity because of all the activity on the thread and it's hard to keep the motivation to dig through many unsorted irrelevant posts in the hopes of possibly finding your answer.

2. A lot of ZScript stuff is subject to change, so advice that ends up in that main thread may become obsolete or counterproductive.

3. One problem I've noticed from the documentation/wiki discussion is that the people who know how to do things don't know what it is that other people don't know. A thread with these questions might help show where people need the most help, or which ZScript features are not well known or or understood by the userbase. (Some people's answers might also reveal widespread misconceptions that may need to be further addressed in the documentation.)

3.1. If the same solutions keep coming up we might add them to the "Standard Library" too.


So I'll start:

How do you set up a custom property so that all descendants can define it like so:

Code: Select all

class Custom2:Custom1{
  default{
    customproperty "string";
  }
}
or accessed through something like "Custom2.customproperty"?

EDIT: Since this post the answer to this particular question has been well established in the wiki.
Last edited by Matt on Wed Jul 05, 2017 4:42 pm, edited 3 times in total.
User avatar
sonic_HD87
Posts: 287
Joined: Sat Mar 23, 2013 4:32 pm
Location: Venezuela

Re: ZScript-only "How do I..." thread

Post by sonic_HD87 »

I have one that always bothers me: ZScript has special keywords referring to the engine (vel, pos...), is there a list containing most, if not, all of them? I always think i'm missing something...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript-only "How do I..." thread

Post by Graf Zahl »

Those are not special keywords but variables of the class actor. You will find all of them in the internal definition of that class
User avatar
sonic_HD87
Posts: 287
Joined: Sat Mar 23, 2013 4:32 pm
Location: Venezuela

Re: ZScript-only "How do I..." thread

Post by sonic_HD87 »

Graf Zahl wrote:Those are not special keywords but variables of the class actor. You will find all of them in the internal definition of that class
Hmmm... And last thing: Some of the engine is "scriptified" so we can make weird stuff without touching the GZDoom sourcecode, so what kind of things is possible to toy with without touching actors, if possible?
User avatar
Beed28
Posts: 598
Joined: Sun Feb 24, 2013 4:07 pm
Location: United Kingdom

Re: ZScript-only "How do I..." thread

Post by Beed28 »

In a mod of mine, I'm wanting the BulletPuff actor to give a flag item to any monster that uses a hitscan attack. But it doesn't seem to work. The monster in question doesn't get the flag item it needs, as checking with the "TargetInv" console command proves. What am I missing?

Code: Select all

Class BulletPuff2 : BulletPuff replaces BulletPuff
{
	Default
	{
		+BLOODLESSIMPACT
		+ALWAYSPUFF
		-ALLOWPARTICLES
	}
	States
	{
	Spawn:
		TNT1 A 0 NoDelay A_GiveToTarget("HitscanFlag", 1);
		Stop;
	}
}
User avatar
sonic_HD87
Posts: 287
Joined: Sat Mar 23, 2013 4:32 pm
Location: Venezuela

Re: ZScript-only "How do I..." thread

Post by sonic_HD87 »

Beed28 wrote:In a mod of mine, I'm wanting the BulletPuff actor to give a flag item to any monster that uses a hitscan attack. But it doesn't seem to work. The monster in question doesn't get the flag item it needs, as checking with the "TargetInv" console command proves. What am I missing?

Code: Select all

Class BulletPuff2 : BulletPuff replaces BulletPuff
{
	Default
	{
		+BLOODLESSIMPACT
		+ALWAYSPUFF
		-ALLOWPARTICLES
	}
	States
	{
	Spawn:
		TNT1 A 0 NoDelay A_GiveToTarget("HitscanFlag", 1);
		Stop;
	}
}
Maybe i'm wrong here, but BulletPuffs doesn't have a target when they spawn. So, when you give an item to a target, no one will get it.
User avatar
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: ZScript-only "How do I..." thread

Post by Nash »

sonic_HD87 wrote:I have one that always bothers me: ZScript has special keywords referring to the engine (vel, pos...), is there a list containing most, if not, all of them? I always think i'm missing something...
Open gzdoom.pk3, look inside zscript/actor.txt. (Almost) everything you'll have access to is under class Actor.
User avatar
sonic_HD87
Posts: 287
Joined: Sat Mar 23, 2013 4:32 pm
Location: Venezuela

Re: ZScript-only "How do I..." thread

Post by sonic_HD87 »

Nash wrote:
sonic_HD87 wrote:I have one that always bothers me: ZScript has special keywords referring to the engine (vel, pos...), is there a list containing most, if not, all of them? I always think i'm missing something...
Open gzdoom.pk3, look inside zscript/actor.txt. (Almost) everything you'll have access to is under class Actor.
Yeah, thanks for that. :wub:

But it seems like a not-user-friendly documentation. Should i add those thing on the wiki or the wiki already has it?
User avatar
Beed28
Posts: 598
Joined: Sun Feb 24, 2013 4:07 pm
Location: United Kingdom

Re: ZScript-only "How do I..." thread

Post by Beed28 »

sonic_HD87 wrote:
Beed28 wrote:In a mod of mine, I'm wanting the BulletPuff actor to give a flag item to any monster that uses a hitscan attack. But it doesn't seem to work. The monster in question doesn't get the flag item it needs, as checking with the "TargetInv" console command proves. What am I missing?

Code: Select all

Class BulletPuff2 : BulletPuff replaces BulletPuff
{
	Default
	{
		+BLOODLESSIMPACT
		+ALWAYSPUFF
		-ALLOWPARTICLES
	}
	States
	{
	Spawn:
		TNT1 A 0 NoDelay A_GiveToTarget("HitscanFlag", 1);
		Stop;
	}
}
Maybe i'm wrong here, but BulletPuffs doesn't have a target when they spawn. So, when you give an item to a target, no one will get it.
There must be a way somehow. I did manage to edit the hitscan functions themselves, but Graf heavily advised against that. So for my new method, I'm trying to detect whether they're firing a hitscan or not, but I haven't had any luck so far.
User avatar
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

Post by Matt »

User avatar
Beed28
Posts: 598
Joined: Sun Feb 24, 2013 4:07 pm
Location: United Kingdom

Re: ZScript-only "How do I..." thread

Post by Beed28 »

Vaecrius wrote:+PUFFGETSOWNER
I forgot that existed! That did the trick wonderfully! :D
User avatar
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

Post by Major Cooke »

So I made this suggestion and received this response:
Graf Zahl wrote:You already have full access to the slope's plane equation, from which all of this can be derived.
Great! So now the big question is, how? I want to roll an actor's flat sprite based on the slope and angle their facing.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript-only "How do I..." thread

Post by Graf Zahl »

I can't help you with the precise math you need. For that I'd have to get out my old math schoolbook to tell you the exact formulas.
User avatar
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

Post by Major Cooke »

Well, in particular, finding the vertices is what I'm after. I think I can handle the rest, and they're all triangles. What function can I use to find them?

Image
User avatar
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

Post by Ed the Bat »

Going back to this topic...
Would anyone be able to teach me how to make a variant of A_RailAttack that honors autoaim?
Locked

Return to “Scripting”