DECORATE: Using Angles or Detecting Nearest Linedef

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.

DECORATE: Using Angles or Detecting Nearest Linedef

Postby heehoo » Mon Nov 06, 2017 7:27 am

tl;dr: In DECORATE, what values does the Angle variable hold, are there any flags/operations that can apply offsets relative to the calling actor's angle (for example, a non-relative y-offset would be considered an x-offset to something facing east or west), and are there any operations that can compare the position of the calling actor to the position of the nearest linedef?

Apologies if this has a simple solution, as I'm pretty new to DECORATE. I wanted to make a projectile that, on impact, would explode into a cloud of smaller projectiles. I used A_SpawnItemEx in order to apply the offsets required to spawn the smaller projectiles outside of the surface that they hit and the velocities to make them move at the appropriate angles. My readings on the wiki didn't find me any sort of flags or parameters that could be used to make this operation relative to the larger projectile's direction, so I instead made different states that would give the smaller projectiles the appropriate spawn offsets and velocities for the different directions (North, South, East, West, NE, NW, SE, SW).

I changed the Death state to perform non-anonymous A_JumpIf operations based on the larger projectile's angle, with each of the resulting states spawning the projectiles and Goto-ing a new state that was identical to the original Death state. For testing purposes, I assigned very visibly different projectiles to the different directions, which revealed very strange behavior. I'm fairly certain that my angle checks were set up correctly, but even so, I redid/revised them, with each set of checks exhibiting similar odd behavior. I also tried three different possible sets of returned values for the angle, as I don't know which one DECORATE uses. I tried the usual standard (0 ->360 degrees), the kind used by GetAngle (-180 -> 180 degrees) and the byte angle values (0 -> 255). Each of these also only yielded the strange behavior.

I actually didn't use GetAngle, as I don't think there are any flags that I could use that would make the measurement with only the larger projectile itself in mind, rather than the angle from the projectile to some target assigned by the flag. The checks looked something like this:

A_JumpIf(Angle < 45 | Angle > 315, "SplodeToTheWest") for hitting a surface after flying east
A_JumpIf(Angle > 45 & Angle < 135, "SplodeToTheSouth") for hitting a surface after flying north
etc...

I would like to be informed of the important details that I've missed here, such as what values the Angle variable uses or certain flags/alternative operations that I could've used to spawn the smaller projectiles relative to the larger one and its direction. Alternatively, I would like to know if there are any expressions I could use to jump to the projectile-spawning states based on the larger projectile's position relative to the nearest linedef, since I could use something like that instead. I've looked through the wiki, but haven't found anything that would help me achieve this. I figured the more experienced Doom gurus might know of something that I missed or some set of other operations that would do the same thing as what I need.

ADDITIONAL DETAILS THAT MAY OR MAY NOT BE IMPORTANT:

- The larger projectiles are spawned from A_FatAttack3, which is aimed at the player
- The Death state and projectile-spawning states have been properly separated, as the Death state ends with Stop after the angle checks
- The projectile-spawning states are also separated from each other and the actual Death state, as they all end by Goto-ing the real Death state
- If the angle of the larger projectile is set manually by way of A_SetAngle, the checks work, so I figured the problem might be the values given naturally
- A_SpawnProjectile cannot be used, as it spawns the projectiles in the wall and cannot apply the offsets required to prevent that

Thank you in advance :)
heehoo
 
Joined: 06 Nov 2017

Re: DECORATE: Using Angles or Detecting Nearest Linedef

Postby Arctangent » Mon Nov 06, 2017 8:54 am

A_SpawnItemEx's parameter after all the velocity ones with exactly what you want for this. Without the SXF_ABSOLUTE* flags, A_SpawnItemEx will by default use the angle parameter as angle offset relative to the caller's angle for the sake of determining the angle of the spawned actor, and then use that angle to determine the actual velocity. The xvel and yvel parameters are a bit of a lie without a certain flag, as they actually are "forwardvel" and "sidevel" as the actual xvel and yvel are determined based off of them and the spawned actor's angle.

Actually, same for the x and y parameters - they'd be better described as "forwardoffset" and "sideoffset," again without the use of a flag.
User avatar
Arctangent
squawky
 
Joined: 06 Nov 2014
Discord: SquawkyAtan#2371

Re: DECORATE: Using Angles or Detecting Nearest Linedef

Postby heehoo » Mon Nov 06, 2017 9:53 am

Arctangent wrote:A_SpawnItemEx's parameter after all the velocity ones with exactly what you want for this. Without the SXF_ABSOLUTE* flags, A_SpawnItemEx will by default use the angle parameter as angle offset relative to the caller's angle for the sake of determining the angle of the spawned actor, and then use that angle to determine the actual velocity. The xvel and yvel parameters are a bit of a lie without a certain flag, as they actually are "forwardvel" and "sidevel" as the actual xvel and yvel are determined based off of them and the spawned actor's angle.

Actually, same for the x and y parameters - they'd be better described as "forwardoffset" and "sideoffset," again without the use of a flag.


Tried this out and it works perfectly! This is much better. Thanks again :D
heehoo
 
Joined: 06 Nov 2017


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest