ZScript Discussion

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
Beed28
Posts: 598
Joined: Sun Feb 24, 2013 4:07 pm
Location: United Kingdom

Re: ZScript Discussion

Post by Beed28 »

That's a shame. I was hoping to change hitscan attacks into projectile attacks without having to replace the monsters themselves (mostly for DeHackEd compatibility).
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

By the way Graf you said that CustomSprite "is not used by anyone", but that's before it was zscriptified :P
Now it's basically a way to assign ARBITRARY graphic to an actor, from what I can see. Without it needing to be a sprite. Although not sure if such actor should derive from CustomSprite or setting picnum works everywhere.
In practice, this means that we can now (especially with my pull request) do an arbitrarily positioned clipped and postprocessed (using shader) cameratexture! HL2-like portals confirmed? Time to update portal gun mod.
Oh, also if I understand it correctly, we can now also use shaded cameratexture that refers to own actor and relates to player[consoleplayer].camera, in order to for example create air flickering near hot surfaces effect, or zoom stuff.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Customsprite had been able to do that for all those years it existed. I changed nothing about it. Its purpose has been to give it a texture number and use the Build texture with the given name as its sprite image. It's just that apparenly nobody ever did.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Graf Zahl wrote:Customsprite had been able to do that for all those years it existed.
Well multiple other features did not exist, namely shaders on cameratextures and proper flatsprites.

Also, any reason why this wouldn't work?
Spoiler:
It spawns, but doesn't log anything (i.e. it's a success), but the sprite is not visible.
Does it explicitly check for Build type? If so, why?
Last edited by ZZYZX on Sat Jan 21, 2017 2:58 pm, edited 1 time in total.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Changed to this
Spoiler:
It logs "ok" after creation, and it logs picnum>=0 in both tick and beginplay.
According to GZDoom source code, whenever picnum is valid, it should be applied instead of sprite.
The picture is still not displayed though.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Perhaps you need to define a spawn state. I tried doing something similar and assigning a sprite/frame using (post)beginplay via experimentation but it never gave me anything but a missing symbol.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Actually, for that you do not even need CustomSprite, you can inherit directly from Actor.
All CustomSprite does is setting picnum and a few renderflags from the args, it has nothing built in to display the sprite. Picnum works for any actor.

What I can't say is if I ever implemented handling for this in the GL renderer, because it's such an obscure feature.
Last edited by Graf Zahl on Sat Jan 21, 2017 3:02 pm, edited 1 time in total.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Hahahah! It works in software renderer. Apparently OpenGL renderer ignores picnum altogether. Bug confirmed? (if yes, I can try to go and understand what causes this and make a PR, as pretty much the only person that's interested)
Last edited by ZZYZX on Sat Jan 21, 2017 3:06 pm, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Looks like picnum is never checked indeed.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ZScript Discussion

Post by Nash »

ZZYZX wrote: Now it's basically a way to assign ARBITRARY graphic to an actor, from what I can see.
This can almost be used to avoid the archaic 8-character sprite naming convention, except the problem is calculating the rotation angle and have it affect only the camera who's viewing it...
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

It's will be broken with portals, because for doing it properly you have to calculate camera position during exact rendering step, not using playsim camera position/angles.
i.e. in portals camera is warped around, it's angle changed, etc. Will break.
Another use for my event system — preprocess the actor before rendering, say, set picnum or move around shadow actors so that they are always exactly behind the main actor :)
If for example we need that actor is drawn in a special way depending on where it is viewed from, OR FOR CUSTOM INTERPOLATION, since it's called on each frame.
Since portals and cameratextures are always using almost full rendering pipeline, it should be possible to move actors around before rendering something in a portal, without breaking BSP stuff.

This is probably what I'm going to do as a proof-of-concept implementation.
Gez
 
 
Posts: 17934
Joined: Fri Jul 06, 2007 3:22 pm

Re: ZScript Discussion

Post by Gez »

Graf Zahl wrote:Customsprite had been able to do that for all those years it existed. I changed nothing about it. Its purpose has been to give it a texture number and use the Build texture with the given name as its sprite image. It's just that apparenly nobody ever did.
Documentation says arg1 can be used as the high byte and that doesn't seem to be true anymore.

Looking into the file's history, that was changed back in 2014. Well I don't think anybody ever used them with a number greater than 255 in a Hexen map, so I suppose the simplest is to update the documentation to remove the bit about arg1.
User avatar
Agentbromsnor
Posts: 265
Joined: Wed Mar 28, 2012 2:27 am

Re: ZScript Discussion

Post by Agentbromsnor »

Major Cooke wrote:
ZZYZX wrote:UI
Soon.
ZZYZX wrote:networking
Never.
Agentbromsnor wrote:What should I be looking for there? Sorry, but I haven't followed any of the discussion up till now, so I don't have any idea about the context of what tackles this issue.
base_player.zs, function UpdateLegsAndBody, line 61. This code smooths player movements and compensates for whenever the player tries to move into an unreachable place.
I've looked over the code multiple times but I can't figure out how it all functions and how I can apply it to my game. Could you perhaps break it down for me so I can learn what to do? Thanks for your help.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: ZScript Discussion

Post by Ed the Bat »

Graf Zahl wrote:No. Once a function is defined it cannot be changed. That would be far too dangerous because its injecting foreign code into existing classes without their knowledge.
Makes sense. Guess I'll keep doing the brute-force method for now.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ZScript Discussion

Post by Nash »

ZZYZX wrote:It's will be broken with portals, because for doing it properly you have to calculate camera position during exact rendering step, not using playsim camera position/angles.
i.e. in portals camera is warped around, it's angle changed, etc. Will break.
Another use for my event system — preprocess the actor before rendering, say, set picnum or move around shadow actors so that they are always exactly behind the main actor :)
If for example we need that actor is drawn in a special way depending on where it is viewed from, OR FOR CUSTOM INTERPOLATION, since it's called on each frame.
Since portals and cameratextures are always using almost full rendering pipeline, it should be possible to move actors around before rendering something in a portal, without breaking BSP stuff.

This is probably what I'm going to do as a proof-of-concept implementation.
Your custom event idea sounds very promising. I've made a modular character system for my project, which naturally requires a TON of graphics. This is the atrocity I had to come up with to work with 8 letters for sprite frames...

Code: Select all

Player Part Documentation
-------------------------

SPRITE NAMING CONVENTION:

xxxyza

All parts' class names must be 3 words max.

xxx
----------
3-letter ID; the abbreviated name of the part. Please use UPPERCASE.

Eg:

CMB = Caucasian Male Body
UPF = Under Pants Female
WCB = Weapon Crowbar
SHM = Shirt Male
... etc etc etc

yz
----------
Animation ID. Can be A to Z, 0 to 9, and [ ^ ], giving each part a total of 1521
frames of animation. (26 + 10 + 3)². Please use lowercase.

a
----------
Direction/angle value. Follow standard ZDoom convention (see Angles, middle ring
at http://zdoom.org/wiki/Sprite for details).

... sometimes I wish I could just name the graphics "Caucasian male body-000-1.png". In the format: <long descriptive name of the body part>-<3-digit animation frame>-<angle>.png. Each critical part would be separated by a - delimiter.

Return to “Scripting”