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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany

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

Post by Tormentor667 »

Hey fellow Doomers,

for simplifying a trap script, I did the following script:

Code: Select all

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
KeksDose
 
 
Posts: 596
Joined: Thu Jul 05, 2007 6:13 pm
Location: my laboratory

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

Post by KeksDose »

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 all

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
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany

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

Post by Tormentor667 »

That did the job, thanks kindly :)

Return to “Scripting”