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

Re: ZScript-only "How do I..." thread

Postby Graf Zahl » Thu Jan 26, 2017 11:54 am

Major Cooke wrote:Well, in particular, finding the vertices is what I'm after. I think I can handle the rest, and they're all triangles. What function can I use to find them?

Image


The only way to find the vertices is to check all linedefs belonging to a sector and look at their vertices. What are you trying to do here?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript-only "How do I..." thread

Postby Major Cooke » Thu Jan 26, 2017 12:08 pm

I'm trying to roll sprites along a slope like this. (This is from Darwinia)

Image
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript-only "How do I..." thread

Postby Graf Zahl » Thu Jan 26, 2017 1:23 pm

Ugh.

No idea how to express that in yaw/pitch/roll...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript-only "How do I..." thread

Postby Rachael » Thu Jan 26, 2017 1:30 pm

This may be a bit hacky but it's the easiest way I know of to do this: (and please don't ask me for the code, you know ZScript better than I do so you're on your own)

Each actor has two "check" actors that they spawn as children. One that's one pixel ahead, and one that's one pixel to the side. These checks are relative to the main actor's yaw, so if the actor rotates it rotates along with it. These check actors have the +FLOORHUGGER property in order to be in an absolute position on the floor.

Since these checks are only one pixel offset, it's pretty easy to just get the arctangents:

For the ahead actor, do arctan(me.zheight-check1.zheight) - that's your forward facing angle.
For the side actor, do arctan(me.zheight-check2.zheight) - that's your roll.

Multiply the angles by *-1 if they do not look right.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
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: ZScript-only "How do I..." thread

Postby Graf Zahl » Thu Jan 26, 2017 1:36 pm

The proper way should of course be to read the current floor's normal and transform it into a set of angles. It's just that I do not know the math for that.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript-only "How do I..." thread

Postby Rachael » Thu Jan 26, 2017 1:46 pm

I got as far as College Algebra in math. Beyond that, I cannot help you.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
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: ZScript-only "How do I..." thread

Postby Major Cooke » Thu Jan 26, 2017 2:33 pm

Graf Zahl wrote:Ugh.

No idea how to express that in yaw/pitch/roll...


And I just remembered I own the darwinia source code. The rendering is done via a Matrix34 (it uses OpenGL as well), looking more into the details on that...

In the mean time, doesn't bouncing have some manner of recalculating which direction to go? Maybe I could use that...

I can handle the yaw/pitch/roll myself, I just need to find out how steep it can dip, and at what angle. That's why I'm trying to get all three vertices.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript-only "How do I..." thread

Postby Graf Zahl » Thu Jan 26, 2017 2:37 pm

Bouncing just uses the plane normal with a few multiplications. The problem you are facing is different: Finding what you need to set the angles to to get the desired orientation,
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript-only "How do I..." thread

Postby kodi » Thu Jan 26, 2017 3:17 pm

Correct me if I'm wrong, but wouldn't it be better to measure the height at each corner of the actor and calculate the normal between those points, allowing you to smoothly angle the sprite over sharp edges rather than snapping instantly while also allowing you to angle the sprite on stairs if you so wish?
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: ZScript-only "How do I..." thread

Postby Major Cooke » Thu Jan 26, 2017 3:59 pm

I feel like this is where Trace could be of use in a way...

Anyway I did some digging into the Darwinia source code. I wouldn't be surprised if it's not of any help.

Spoiler: How Darwinia grabs Z (used for calculating speeds)


Spoiler: Some rendering setup


Spoiler: Some vector functions


@kodi unfortunately I've tried doing a bunch of hacks to find lower and upper places where things consider floorz at but unfortunately, I've had no luck.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript-only "How do I..." thread

Postby krokots » Thu Jan 26, 2017 5:48 pm

How can I change A_SkullAttack so that Lost Souls will not hurt themselves when charging?
User avatar
krokots
 
Joined: 19 Jan 2010

Re: ZScript-only "How do I..." thread

Postby Graf Zahl » Thu Jan 26, 2017 5:50 pm

You can't. A_SkullAttack only adds some velocity to the Lost Soul.
The only option you have is to override the virtual Slam method in ZScript in a child class.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript-only "How do I..." thread

Postby krokots » Thu Jan 26, 2017 6:51 pm

Graf Zahl wrote:You can't. A_SkullAttack only adds some velocity to the Lost Soul.
The only option you have is to override the virtual Slam method in ZScript in a child class.

Code: Select allExpand view
override bool Slam(Actor victim)
{
   if (victim.GetSpecies() == self.GetSpecies())
      return false;
   Super.Slam(victim);
   return false;
}

This works. Thanks!
User avatar
krokots
 
Joined: 19 Jan 2010

Re: ZScript-only "How do I..." thread

Postby Agentbromsnor » Thu Jan 26, 2017 8:24 pm

I know I've asked this before, but I couldn't really figure out how to go about this. I'm trying to get a smooth player-animation for my 2D platform-game, because ever since I converted my DECORATE code to ZScript the player's animation has been looking very choppy. Major Cooke replied to this question before, but I couldn't figure out where to go from there. Can anyone explain to me what I need to do fix this?
User avatar
Agentbromsnor
 
Joined: 28 Mar 2012

Re: ZScript-only "How do I..." thread

Postby Major Cooke » Thu Jan 26, 2017 8:30 pm

Try pming zombiekiller about it directly. I don't have the file anymore myself.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests