Does "GetActorAngle" not work on "Map Spot"?

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.

Does "GetActorAngle" not work on "Map Spot"?

Postby Tormentor667 » Mon Feb 26, 2018 12:36 pm

Hey fellow Doomers,

for simplifying a trap script, I did the following script:
Code: Select allExpand view
int fire_direction=215;
int fire_counter=0;

script "Fire_Traps" (void)
{
   while(fire_counter<5)
   {
      Thing_Projectile2(fire_direction, 222, GetActorAngle(fire_direction), random(48,56), 0, 0, 0);
      delay(random(1,6));
      fire_counter++;
   }

   fire_direction=random(215,218);
   fire_counter=0;

   delay(35);

   restart;
}


So what does it do?
It randomly chooses between a map spot (215 to 218), gets the actors angle to determine in which direction to shoot the fire attack and then fires it. After 5 bursts have been dealt, it starts over again with a new map spot. The problem is: The attack always goes in the eastern direction (angle 0). Does a map spot not have an angle or does the GetActorAngle function not read its angle?
User avatar
Tormentor667
needs more detail
 
Joined: 16 Jul 2003
Location: Germany

Re: Does "GetActorAngle" not work on "Map Spot"?

Postby KeksDose » Mon Feb 26, 2018 1:10 pm

GetActorAngle returns an angle between 0 inclusive and 1.0 not inclusive, while Thing_Projectile takes a byte angle, range 0 to 255 inclusive.

Since 1.0 is fixed point (1.0 is actually 65536), you can divide the GetActorAngle result by 256 or shift right >> by 8 to get it into the byte angle range. That's an issue for sure. Then make sure your map spots exist. If you're unsure whether your angles are read correctly, add this to your script and look at the output:

Code: Select allExpand view
Log(s:"Angle of spot ", i:fire_direction, s:" is ", f:GetActorAngle(fire_direction) ); 


My guess: You are unlucky and all the angles it can choose from happen to be a multiple of 256.
User avatar
KeksDose
Praise Mima and the Moon
 
 
 
Joined: 05 Jul 2007

Re: Does "GetActorAngle" not work on "Map Spot"?

Postby Tormentor667 » Tue Feb 27, 2018 2:09 pm

That did the job, thanks kindly :)
User avatar
Tormentor667
needs more detail
 
Joined: 16 Jul 2003
Location: Germany


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest