"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!)
ZippeyKeys12
Posts: 111
Joined: Wed Jun 15, 2016 2:49 pm

Re: "How do I ZScript?"

Post by ZippeyKeys12 »

Changing the height of an actor in ZScript only affect actor-to-actor collisions, correct?
If so, does that mean I have to morph an actor into another actor to change the height of collision with level architecture?

Also, bump:
ZippeyKeys12 wrote:Is it possible to detect multiple simultaneous key-presses inside of InputProcess?

Also is it possible to register an EventHandler while the game is running? I recall seeing ZZYZX mention this, but I can't seem to figure it out. :?

Any help would be appreciated :)

EDIT: Also, is it not possible to put a constant array in a struct?
EDIT 5: Can I access a variable in an EventHandler from my StatusBar?
Please let me know if I'm not supposed to do ^
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: "How do I ZScript?"

Post by Gutawer »

You can detect simulataneous key pressed with an EventHandler by keeping track of the keys you need to track as booleans (or a bitfield, if you have a very large amount of them), and testing if both of the booleans are true. The event handler should simply set and unset the booleans. You need to do this since an event handler doesn't give you which keys are pressed currently, only that they've been pressed or released.
User avatar
Rip and Tear
Posts: 186
Joined: Tue May 02, 2017 3:54 pm

Re: "How do I ZScript?"

Post by Rip and Tear »

Hmm, I see. However, I still fail to understand what the actual applications of this would be. Predicable randomness seems to be missing the point.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: "How do I ZScript?"

Post by Apeirogon »

How make monster dont shoot if between monster and his target stand some actor? Like, chaingunner dont shooting if between him and player walk another former human.
Blue Shadow
Posts: 5018
Joined: Sun Nov 14, 2010 12:59 am

Re: "How do I ZScript?"

Post by Blue Shadow »

It looks like you want [wiki]A_CheckLOF[/wiki].
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: "How do I ZScript?"

Post by Apeirogon »

And if i want actor thet prevent shooting, if it block line of sight of any monster?
Like, i want to smoke grenade. And i want to make it into PWAD to play with guncaster/high noon driver/demonsteel/etc. or custom monsters pack. And I too lazy and stupid to edit every actor, that potentialy can shoot me, with a_checkLOF.
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: "How do I ZScript?"

Post by Gutawer »

What's the cleanest way to send out a hitscan from a position in 3d space? Spawning an actor to send out the hitscan seems to work nicely, but I can't figure out how to make it transfer the target to the actor that is "supposed" to have sent out the hitscan.
ZzZombo
Posts: 317
Joined: Mon Jul 16, 2012 2:02 am

Re: "How do I ZScript?"

Post by ZzZombo »

Isn't P_AimLineAttack() and/or related stuff exposed?
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: "How do I ZScript?"

Post by Apeirogon »

In definition of CanCollideWith write (Actor other, bool passive)
So if I wish make "false" to all projectile and hitscan in game, it means that must write check for all projectile/hitscan by name? Llike

Code: Select all

class some_thing: actor
{
    override bool CanCollideWith (Actor other, bool passive)
    {
        if(actor.imp_fireball)
        {
            false;
        }

        if(actor.chainguy_hitscan_puff)
        {
            false;
        }
        if...
       ...
       ...
       ...
       and so on
    }
}
ZippeyKeys12
Posts: 111
Joined: Wed Jun 15, 2016 2:49 pm

Re: "How do I ZScript?"

Post by ZippeyKeys12 »

Code: Select all

if(other.bMissile)
    return false;
Of course if there's an entirely reasonable chance of projectiles not using the +Missile flag. Also I'm not sure how to access flags so I just guessed.

For hitscans IDK.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: "How do I ZScript?"

Post by Apeirogon »

Yes, it can look at the flag of collide actor.
About hitscan...Im just add to actor spectral flag and add check dont collide with projectile with spectral flag.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: "How do I ZScript?"

Post by Apeirogon »

SpecialMissileHit used as ripper expansion?
ZippeyKeys12
Posts: 111
Joined: Wed Jun 15, 2016 2:49 pm

Re: "How do I ZScript?"

Post by ZippeyKeys12 »

Apeirogon wrote:SpecialMissileHit used as ripper expansion?
Umm, excuse me? :?
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: "How do I ZScript?"

Post by Apeirogon »

int SpecialMissileHit (Actor victim)

Called when a missile impacts an actor. Returning 1 tells the missile to keep going instead of exploding, while -1 signifies the missile to die.
When return 1 it means "pierce/fly through actor"?
User avatar
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

Apeirogon wrote:When return 1 it means "pierce/fly through actor"?
Yes.

Return to “Scripting”