Page 1 of 97

"How do I ZScript?"

PostPosted: Wed Jan 25, 2017 3:02 pm
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 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.

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

PostPosted: Wed Jan 25, 2017 3:28 pm
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...

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

PostPosted: Wed Jan 25, 2017 4:24 pm
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

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

PostPosted: Wed Jan 25, 2017 6:37 pm
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?

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

PostPosted: Wed Jan 25, 2017 6:43 pm
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 allExpand view
Class BulletPuff2 : BulletPuff replaces BulletPuff
{
   Default
   {
      +BLOODLESSIMPACT
      +ALWAYSPUFF
      -ALLOWPARTICLES
   }
   States
   {
   Spawn:
      TNT1 A 0 NoDelay A_GiveToTarget("HitscanFlag", 1);
      Stop;
   }
}

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

PostPosted: Wed Jan 25, 2017 6:52 pm
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 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.

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

PostPosted: Wed Jan 25, 2017 6:53 pm
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.

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

PostPosted: Wed Jan 25, 2017 6:57 pm
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?

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

PostPosted: Wed Jan 25, 2017 7:58 pm
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 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.

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

PostPosted: Wed Jan 25, 2017 8:49 pm
by Matt

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

PostPosted: Thu Jan 26, 2017 1:07 am
by Beed28
Vaecrius wrote:+PUFFGETSOWNER

I forgot that existed! That did the trick wonderfully! :D

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

PostPosted: Thu Jan 26, 2017 9:48 am
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.

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

PostPosted: Thu Jan 26, 2017 9:56 am
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.

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

PostPosted: Thu Jan 26, 2017 10:14 am
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

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

PostPosted: Thu Jan 26, 2017 11:38 am
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?