Sir Robin wrote:In this line of code I'm spawning a cursor as a puff that exists for only 1 frame. I do this to mark where the LineTrace hit. A few issues with this:
On certain walls (seems to be only 1-sided walls) the puff doesn't show up at all. I haven't been able to determine what walls it works with and what it doesn't - it doesn't seem to be related to direction or height or anything else I can figure out. I can have 2 linedefs, attacked to the same sector, at the same angles, and one works and the other doesn't.
On certain walls (seems to be only 2-sided walls where it hit a lower texture) the actor crawls up the wall, even though the puff vertical speed is set to 0.
What's causing these issues and how to correct them?
It probably has to do something with the way your
UW_CursorPuff class is coded, so if you could post its code here, I might be able to tell you what's wrong with it.
Sir Robin wrote:Other thing: the actor is always drawn perpendicular to the player. Is there an automatic way to change it's pitch and rotation to match what it hit so that it looks "plastered on"? I think a decal can do this but (from what I'm reading, I haven't tried implementing this yet) decals only apply to walls, not floors or ceilings. I know the long by-hand way would be to determine what was hit and calculate the angles based on that, but is there any build-in function in ZScript for doing that?
You are right, decals do not work on floors or ceilings, so you will have to go the hard way. I am unaware of any built-in ZScript functions that would work for your scenario. You will have to use the
HitLine field of the trace results to determine the angle. I've never done this myself, but I think you need to use the following formula:
Code: Select all
let l = TargetLook.HitLine;
double angle = atan2(l.v1.p.y - l.v2.p.y, l.v1.p.x - l.v2.p.x)
NB: the above code assumes that
HitLine is not null, which may not always be the case. This will get you the angle of the line itself; you have to either add or subtract 90 degrees from it depending on which side was hit (field
LineSide of the trace results equals either
Line.front or
Line.back). I don't have the means to test these formulas now, so you will have to experiment a bit, or wait for someone else to clarify them.
As for the pitch - do you really need to calculate it for your actor? I'm not sure it would have any visual effect... Though I think there is a way to do it, I can look it up if you want.
Sir Robin wrote:A question about functions:
I want to write a function that takes a value between 0.0 and 1.0 and converts it to chars 'A'..'Z'
Pseudocode looks like this: char(toInt(min(max(value,0.0),1.0)*25)+65)
First, does ZScript have a char type or do I just use 1-length strings?
If I remember right, you have to use
int for single-bit chars, e.g.
int ch = "A". To convert them to a string, use
String.format("%c", ch). ZScript code equivalent to your pseudocode would be:
(int)(Clamp(value, 0.0, 1.0) * 25 + 65)
Sir Robin wrote:Second what are the function equivalents in ZScript? [wiki=ZScript_builtin_functions]this page[/wiki] is currently blank, is there a better resource?
I think most, if not all, [wiki]DECORATE expressions[/wiki] are supported. In addition to that, there are ZScript-exclusive functions too. Most of them can be found in gzdoom.pk3, e.g. zscript/actors/actor.zs for actor-specific functions. There is really a lot of them, so if you're looking for anything specific, don't be afraid to ask. You may also be able to find more info
here, particularly in the "ZScript API" section.
Sir Robin wrote:Finally, where can I get the world tick count?
Level.maptime