"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
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: 4349
Joined: Sun Feb 06, 2005 6:39 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
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: 49056
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
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

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: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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: 8170
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 »

User avatar
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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!
Attachments
use zombieman.pk3
(291 Bytes) Downloaded 54 times
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

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
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

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: 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: "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: 8170
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 »

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: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

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: 8170
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 »

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
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

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

Return to “Scripting”