"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!)
User avatar
Nash
 
 
Posts: 17455
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Major Cooke wrote:Huh. Interesting... I didn't know you could access the default properties...

Code: Select all

Speed = Default.Speed;
That's a neat trick!
Oh WOW, thanks for making me realize I'd coded so much redundancy with regards to dynamically altering properties temporarily and restoring it to the defaults at a later time!

(I had to record the defaults somewhere else!)
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

Re: "How do I ZScript?"

Post by Matt »

:shock: !!!!!!

Is this static? Like, can I call Clip.Default.MaxAmount without making sure there's a Clip actor somewhere to reference?


EDIT: Totally unrelated question, what does the damage argument do in SpawnBlood()?
Blue Shadow
Posts: 5022
Joined: Sun Nov 14, 2010 12:59 am

Re: "How do I ZScript?"

Post by Blue Shadow »

Vaecrius wrote:Is this static? Like, can I call Clip.Default.MaxAmount without making sure there's a Clip actor somewhere to reference?
You can use GetDefaultByType:

Code: Select all

int clipma = GetDefaultByType("Clip").MaxAmount;
User avatar
ramon.dexter
Posts: 1558
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: "How do I ZScript?"

Post by ramon.dexter »

Well, not exactly how do I zscript, but zscript related...

How do I make it so the actors definde in zscript appear as the same as the actors defined in decorate? I assigned doomed numbers in mapinfo, even created "blank" actors in decorate so I can classify and sort them, but I can only show sprite with this. Most of my items and weapons use voxels/models, so I want to see voxels or models in editor also. Is is possible with zscript?

Better said, the decorate defined actors appear in editor with their spawn frame. Sprite/model/voxel either. The zcsript actors appear only as blank/missing icon, and all sorted under "user defined" section, when defined with doomed numbers in mapinfo. How do I make them appear in my sections? Is this possible? Should I make a feature suggestion?
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

Is it possible to make a 3d model actor that billboards to view just like a sprite?
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: "How do I ZScript?"

Post by gwHero »

ramon.dexter wrote:Well, not exactly how do I zscript, but zscript related...

How do I make it so the actors definde in zscript appear as the same as the actors defined in decorate? I assigned doomed numbers in mapinfo, even created "blank" actors in decorate so I can classify and sort them, but I can only show sprite with this. Most of my items and weapons use voxels/models, so I want to see voxels or models in editor also. Is is possible with zscript?

Better said, the decorate defined actors appear in editor with their spawn frame. Sprite/model/voxel either. The zcsript actors appear only as blank/missing icon, and all sorted under "user defined" section, when defined with doomed numbers in mapinfo. How do I make them appear in my sections? Is this possible? Should I make a feature suggestion?
Assuming you are using GZDB bugfix, it could be that the GZDoom.pk3 is not added as resource to your wad in the editor. I had the same issue some while ago when I converted some of my Decorate actors to ZScript (sprites only, no models or voxels). Beware that if this is indeed the issue, you add the resource with the option "exclude this resource from testing parameters" checked, otherwise GZDoom will throw errors.
User avatar
Nash
 
 
Posts: 17455
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

kodi wrote:Is it possible to make a 3d model actor that billboards to view just like a sprite?
That has to be done in the engine's model drawers... it's not something you'd want to ZScript your way around...
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

@nash
I didn't know if there was a simple function override or flag I didn't know of that would accomplish it.
User avatar
Jaxxoon R
Posts: 772
Joined: Sun May 04, 2014 7:22 pm

Re: "How do I ZScript?"

Post by Jaxxoon R »

Isn't there a way to fire a short hitscan and return if it hit anything?
User avatar
Nash
 
 
Posts: 17455
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Yo how do I colourize a text according to the user's "item pickup" colour preference?
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

What's the most efficient way to get the (x,y) angle between two vector3 positions?
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 »

Something like this:

Code: Select all

Vector3 diffVec = vecB - vecA;
double diffAngle = atan2(diffVec.y, diffVec.x);
Though it's worth noting that if you need the angle from an actor to another actor, you should really use AngleTo (that also goes for getting the distance/vector to another actor - use Distance2/3D and Vec2/3To, respectively) since its portal aware.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

I figured it'd save some performance not spawning intermediate actors just to measure to, but portal awareness is a really good point. Thanks for both the formula (wasn't sure if there was some faster built in method) and the tip.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49141
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

kodi wrote:Is it possible to make a 3d model actor that billboards to view just like a sprite?

Short answer: no.

Long answer: It makes no sense. Billboarding is just an attempt to place a 2D object in 3D space while ensuring it can adjust to the actual viewpoint.
A model is already 3D so any vertex will have a well defined 3D coordinate associated with it, regardless from where you look at it.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

@graf
I understand that. The idea was to cheat around sprite name limitations. For a weapon at least I should be able to use a non-existent BLAP A 1 frame for every single muzzle flash frame for every weapon and then use modeldefs to apply a flat plane 3d model with long name textures of my choice for each of them. Or that was the idea; I've not tried it.

Return to “Scripting”