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

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?

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

Thu Jan 26, 2017 12:08 pm

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

Image

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

Thu Jan 26, 2017 1:23 pm

Ugh.

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

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

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.

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

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.

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

Thu Jan 26, 2017 1:46 pm

I got as far as College Algebra in math. Beyond that, I cannot help you.

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

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.

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

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,

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

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?

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

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.

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

Thu Jan 26, 2017 5:48 pm

How can I change A_SkullAttack so that Lost Souls will not hurt themselves when charging?

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

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.

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

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:
override bool Slam(Actor victim)
{
   if (victim.GetSpecies() == self.GetSpecies())
      return false;
   Super.Slam(victim);
   return false;
}

This works. Thanks!

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

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?

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

Thu Jan 26, 2017 8:30 pm

Try pming zombiekiller about it directly. I don't have the file anymore myself.