"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!)

Re: "How do I ZScript?"

Postby Nash » Thu Sep 28, 2017 9:40 am

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

Code: Select allExpand view
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
Nash
AKA Nash Muhandes! Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby Matt » Thu Sep 28, 2017 7:59 pm

: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()?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: "How do I ZScript?"

Postby Blue Shadow » Thu Sep 28, 2017 8:55 pm

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 allExpand view
int clipma = GetDefaultByType("Clip").MaxAmount;
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
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?"

Postby ramon.dexter » Sat Sep 30, 2017 9:33 am

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
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: "How do I ZScript?"

Postby kodi » Sun Oct 01, 2017 2:57 am

Is it possible to make a 3d model actor that billboards to view just like a sprite?
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: "How do I ZScript?"

Postby gwHero » Sun Oct 01, 2017 4:07 am

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
gwHero
Be your own Siddhartha
 
Joined: 08 May 2017
Location: The Netherlands
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: Intel with Vulkan Support

Re: "How do I ZScript?"

Postby Nash » Sun Oct 01, 2017 4:30 am

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
Nash
AKA Nash Muhandes! Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby kodi » Sun Oct 01, 2017 5:23 am

@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
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: "How do I ZScript?"

Postby Jaxxoon R » Mon Oct 02, 2017 6:44 am

Isn't there a way to fire a short hitscan and return if it hit anything?
User avatar
Jaxxoon R
 
Joined: 04 May 2014

Re: "How do I ZScript?"

Postby Nash » Mon Oct 02, 2017 8:48 am

Yo how do I colourize a text according to the user's "item pickup" colour preference?
User avatar
Nash
AKA Nash Muhandes! Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby kodi » Sun Oct 08, 2017 11:58 am

What's the most efficient way to get the (x,y) angle between two vector3 positions?
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: "How do I ZScript?"

Postby Gutawer » Sun Oct 08, 2017 2:24 pm

Something like this:
Code: Select allExpand view
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
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: "How do I ZScript?"

Postby kodi » Sun Oct 08, 2017 4:29 pm

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
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: "How do I ZScript?"

Postby Graf Zahl » Mon Oct 09, 2017 7:59 am

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: "How do I ZScript?"

Postby kodi » Mon Oct 09, 2017 8:04 am

@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.
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: Ravick and 0 guests