[Zscript] Checking mobility for choosing turn direction

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!)
Uberkreatur
Posts: 27
Joined: Fri Dec 26, 2014 10:54 am
Location: Russia

[Zscript] Checking mobility for choosing turn direction

Post by Uberkreatur »

Case:
Monster (red square) with CHF_DONTTURN flag was walking to his target and bumped into wall or obstacle. The monster can rotate on a limited angle by a step. It must choose optimal direction to turn. Best way to do this is to check 2 positions with Y offset by 1 and -1 relative to the monster. If one position is unreachable, the monster turns in the opposite direction.

How to do this in Zscript? Functions are still documented badly compared to the decorate. if(TryMove) cant do this without physically moving a monster (also I didnt find, how "FCheckPosition" parameter works). SetXYZ+CheckBlock works strange, giving inadequate results.
You do not have the required permissions to view the files attached to this post.
Uberkreatur
Posts: 27
Joined: Fri Dec 26, 2014 10:54 am
Location: Russia

Re: [Zscript] Checking mobility for choosing turn direction

Post by Uberkreatur »

Upd: solved by rude way.

Code: Select all

				vector3 oldpos = pos;
				if (!TryMove(Vec2Angle(speed,angle+90), false))
					{
					A_PrintBold("RIGHT");
				    }
				SetXYZ(oldpos);
				if (!TryMove(Vec2Angle(speed,angle-90), false))
					{
					A_PrintBold("LEFT");
				    }
				SetXYZ(oldpos);	

Return to “Scripting”