"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.

"How do I ZScript?"

Postby Matt » Wed Jan 25, 2017 3:02 pm

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 allExpand view
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
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

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

Postby sonic_HD87 » Wed Jan 25, 2017 3:28 pm

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
sonic_HD87
Intel GM45 Master Race
 
Joined: 23 Mar 2013
Location: Venezuela

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

Postby Graf Zahl » Wed Jan 25, 2017 4:24 pm

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
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby sonic_HD87 » Wed Jan 25, 2017 6:37 pm

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
sonic_HD87
Intel GM45 Master Race
 
Joined: 23 Mar 2013
Location: Venezuela

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

Postby Beed28 » Wed Jan 25, 2017 6:43 pm

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 allExpand view
Class BulletPuff2 : BulletPuff replaces BulletPuff
{
   Default
   {
      +BLOODLESSIMPACT
      +ALWAYSPUFF
      -ALLOWPARTICLES
   }
   States
   {
   Spawn:
      TNT1 A 0 NoDelay A_GiveToTarget("HitscanFlag", 1);
      Stop;
   }
}
User avatar
Beed28
Making entire worlds bounce up and down.
 
Joined: 24 Feb 2013
Location: United Kingdom

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

Postby sonic_HD87 » Wed Jan 25, 2017 6:52 pm

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 allExpand view
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
sonic_HD87
Intel GM45 Master Race
 
Joined: 23 Mar 2013
Location: Venezuela

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

Postby Nash » Wed Jan 25, 2017 6:53 pm

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
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

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

Postby sonic_HD87 » Wed Jan 25, 2017 6:57 pm

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
sonic_HD87
Intel GM45 Master Race
 
Joined: 23 Mar 2013
Location: Venezuela

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

Postby Beed28 » Wed Jan 25, 2017 7:58 pm

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 allExpand view
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
Beed28
Making entire worlds bounce up and down.
 
Joined: 24 Feb 2013
Location: United Kingdom

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

Postby Matt » Wed Jan 25, 2017 8:49 pm

User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

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

Postby Beed28 » Thu Jan 26, 2017 1:07 am

Vaecrius wrote:+PUFFGETSOWNER

I forgot that existed! That did the trick wonderfully! :D
User avatar
Beed28
Making entire worlds bounce up and down.
 
Joined: 24 Feb 2013
Location: United Kingdom

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

Postby Major Cooke » Thu Jan 26, 2017 9:48 am

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
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

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

Postby Graf Zahl » Thu Jan 26, 2017 9:56 am

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
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Major Cooke » Thu Jan 26, 2017 10:14 am

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
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

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

Postby Ed the Bat » Thu Jan 26, 2017 11:38 am

Going back to this topic...
Would anyone be able to teach me how to make a variant of A_RailAttack that honors autoaim?
User avatar
Ed the Bat
I'm tired. I want to go home.
 
Joined: 03 May 2012
Location: Maryland, US

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest