"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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

Why do you feel the need to cheat with sprite names? Even when using just letters and numbers you have 1679616 distinct sprite names available.
There's just no need to add such hacks to the engine.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "How do I ZScript?"

Post by Nash »

Graf Zahl wrote:Why do you feel the need to cheat with sprite names? Even when using just letters and numbers you have 1679616 distinct sprite names available.
There's just no need to add such hacks to the engine.
While I am not justifying kodi's hack attempt, the answer to that question is simple, really: for organizing and readability purposes, using long filenames is 100000x easier to work with than cryptic 4-letter abbreviations.

"human - caucasian - body - walking001 - 0.png" is much easier to identify than "HCBAA0.png". :P
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

Everything in the project is animated in 35 fps to allow walking-while-firing frames in a custom chase state, and also to govern frame duration for everything with A_SetTics and time factor lookup. Sprite names and frame numbers are chosen from an array each tick as well depending on a variable that represents where the character is in a particular frame cycle, so everything is primed for global or localized speeding up or slowing down of time.

TL;DR: lots of frames, lots of four letter words abbreviations. Nevermind the proposed hack, I'll manage with aspirin :)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

Sorry, but the sprite system is not fixable without breaking it.
User avatar
Rachael
Posts: 13542
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: "How do I ZScript?"

Post by Rachael »

And breaking it certainly would not be fixing it, in the strictest sense of the word. ;)

Sorry, I just had to put that in there... don't mind me... >_>
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

I didn't want to explicitly state the conundrum here... :mrgreen:
User avatar
zrrion the insect
Posts: 2411
Joined: Thu Jun 25, 2009 1:58 pm
Location: Time Station 1: Moon of Glendale

Re: "How do I ZScript?"

Post by zrrion the insect »

If you really need long filenames you could use TEXTURES
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 »

Saving everything as sprite sheets and then parsing them with TEXTURES [EDIT: and realizing I can (a) add comments to my TEXTURES lump and (b) leave TEXTURES open in a background window that stays visible next to my working ZScript file] has been such a headache-saver for me...
Last edited by Matt on Tue Oct 10, 2017 5:40 pm, edited 1 time in total.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

Since I'm setting the sprites with zscript functions anyway, I'll be using some form of nicer name reference/lookup table or whatever.
User avatar
ZoDX32
Posts: 20
Joined: Sat Oct 14, 2017 5:49 pm

Re: "How do I ZScript?"

Post by ZoDX32 »

It seems the projectile pitch doesn't change while flying, but only angle. So i want to know how to find projectile's momentum pitch in zscript?
I saw flag PITCHFROMMOMENTUM from modeldef, it actually find pitch of projectile, but how get that pitch in zscript?

Code: Select all

projectile.angle //works
projectile.pitch //equals to 0
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

ZoDX32 wrote:It seems the projectile pitch doesn't change while flying, but only angle. So i want to know how to find projectile's momentum pitch in zscript?

Code: Select all

override void PostBeginPlay()
	{
		A_SetPitch(-atan2(vel.z,sqrt((vel.x*vel.x) + (vel.y*vel.y)))); 
		Super.PostBeginPlay(); 
	}
You can also use A_FaceMovementDirection, but it doesn't work in PostBeginPlay so is unusable for some particular things. Or at least was a few months ago.
User avatar
ZoDX32
Posts: 20
Joined: Sat Oct 14, 2017 5:49 pm

Re: "How do I ZScript?"

Post by ZoDX32 »

OMG Big Thanks!!! I wanna say this is i do for collision code with CanCollideWith()
here PRE-Results:
Image
with your pitch find algorythm, i think i can do precise collision of Sphere(basketball) with Circle(ring) in zscript!

p.s.:sry for img size, i thought i sent small size when i saw img post on discord(
Last edited by ZoDX32 on Sun Oct 15, 2017 3:23 am, edited 2 times in total.
User avatar
ZoDX32
Posts: 20
Joined: Sat Oct 14, 2017 5:49 pm

Re: "How do I ZScript?"

Post by ZoDX32 »

Also how to find vector pitch from invoker actor to another actor?
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: "How do I ZScript?"

Post by Accensus »

Please read this. Thank you.
User avatar
ramon.dexter
Posts: 1529
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 »

How do I use random number in Damage property of projectile? When i put in 'random(1,10);', it returns error, that even numbers has to be used :(
Locked

Return to “Scripting”