"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!)
4thcharacter
Posts: 1183
Joined: Tue Jun 02, 2015 7:54 am

Re: "How do I ZScript?"

Post by 4thcharacter »

That seems like it would take a lot of time but still it is really amazing.
User avatar
Ryan Cordell
Posts: 4347
Joined: Sun Feb 06, 2005 6:39 am
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Modern GZDoom)
Location: Capital of Explodistan

Re: "How do I ZScript?"

Post by Ryan Cordell »

ZZYZX wrote:Mmm, 1138 line tada... I wouldn't use that to persuade people into using ZScript really. :roll:


Nobody said it was an example on ZScript's ease-of-use. :P
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 47962
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

That thing is a really bad example because it had to replicate some shitty coding by Raven that was compounded by a horrendous conversion into classes by Randi. The ZScript version is just a 1:1 translation of the old C++ code with no attempt to make it easier to use (as that would most likely have broken the whole thing.)
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: "How do I ZScript?"

Post by Ed the Bat »

How can I check, for example, if FastMonsters is currently in play? I see there's a SKILLP_FastMonsters constant, but I don't know how or where to apply this.
User avatar
Nash
 
 
Posts: 17281
Joined: Mon Oct 27, 2003 12:07 am
Twitch ID: nashmuhandes
Github ID: nashmuhandes
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Vaecrius wrote:+usespecial does nothing whether I enable it or not.

Code: Select all

class usetest:actor{
   default{
      +usespecial;
      +solid;
   }
   override bool used(actor user){
      A_Log("YAY");
      return false;
   }
   states{
   spawn:
      BEXP B -1;
      stop;
   }
}


Did you manage to get this to work? If not, can you make a bug report, please? I don't have time to take a look at this currently and I feel this should be reported if it isn't working
User avatar
Major Cooke
Posts: 8055
Joined: Sun Jan 28, 2007 3:55 pm

Re: "How do I ZScript?"

Post by Major Cooke »

User avatar
Nash
 
 
Posts: 17281
Joined: Mon Oct 27, 2003 12:07 am
Twitch ID: nashmuhandes
Github ID: nashmuhandes
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Code: Select all


class UseZombieMan 
: ZombieMan replaces ZombieMan
{
    override bool Used(Actor user)
    {
        // supposed to kill the zombieman and give you health bonus
        user.A_GiveInventory("HealthBonus", 1);
        A_Die();
        return true;
    }
}


Hmm actually it doesn't work, this simple test actor doesn't work, will make a bug report

ALSO Vaecrius, I don't know if you practice this but I saw semicolons on your flags in the Default block. You don't need those. If you've been doing those, I'd remove them, they might break in future. Nothing in GZDoom uses semicolons for flags.
User avatar
Nash
 
 
Posts: 17281
Joined: Mon Oct 27, 2003 12:07 am
Twitch ID: nashmuhandes
Github ID: nashmuhandes
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Bug has been fixed in c150f9d have fun stealth-killing the first 2 zombiemen in Doom 2 map01!
You do not have the required permissions to view the files attached to this post.
User avatar
Blue Shadow
Posts: 4901
Joined: Sun Nov 14, 2010 12:59 am
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: "How do I ZScript?"

Post by Blue Shadow »

Ed the Bat wrote:How can I check, for example, if FastMonsters is currently in play? I see there's a SKILLP_FastMonsters constant, but I don't know how or where to apply this.

Unless I'm wrong, The SKILLP_* constants are used with the G_SkillProperty* functions, which return info about the skill property you pass.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: "How do I ZScript?"

Post by Ed the Bat »

Looks like you've got it, Blue Shadow.

Code: Select all

G_SkillPropertyInt(SKILLP_FastMonsters)
returns true if FastMonsters is in play. Simple as that! Thank you!
User avatar
Matt
Posts: 9663
Joined: Sun Jan 04, 2004 5:37 pm
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: "How do I ZScript?"

Post by Matt »

Nash wrote:
Spoiler:


Did you manage to get this to work? If not, can you make a bug report, please? I don't have time to take a look at this currently and I feel this should be reported if it isn't working
I gave up on it shortly after because what I wanted to use it for had some unfortunate side effects (e.g., the thing in question could be in front of a switch or door, preventing the player from using said switch/door).

Major Cooke:
+usespecial does nothing whether I enable it or not.
ZZYX suggested it and the wiki does occasionally contain wrong information.
User avatar
Major Cooke
Posts: 8055
Joined: Sun Jan 28, 2007 3:55 pm

Re: "How do I ZScript?"

Post by Major Cooke »

Well Nash found out it was completely broken from the getgo. Also, I wrote that wiki part. It actually does work. The function simply wasn't triggering like it was supposed to due to a bug in the engine.
User avatar
Xaser
 
 
Posts: 10771
Joined: Sun Jul 20, 2003 12:15 pm

Re: "How do I ZScript?"

Post by Xaser »

So, it worked except for the fact that it didn't? :P
User avatar
Major Cooke
Posts: 8055
Joined: Sun Jan 28, 2007 3:55 pm

Re: "How do I ZScript?"

Post by Major Cooke »

Meh, time contexts. Back then it didn't, it does now. I'm just pointing out that +USESPECIAL must not be on an actor if the Used function is to be utilized. I was also making sure everyone saw what the wiki on it, and I know it's correct because Graf's commit message said so.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: "How do I ZScript?"

Post by Ed the Bat »

In case anyone's interested, I found a solution for my question from Page 1:

By giving A_RailAttack the RGF_EXPLICITANGLE flag, and setting the spread_z parameter to BulletSlope()-pitch, I now have a railgun that respects autoaim.

Return to “Scripting”