[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!)

[Zscript] Checking mobility for choosing turn direction

Postby Uberkreatur » Mon Nov 13, 2017 11:12 am

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
 
Joined: 26 Dec 2014
Location: Russia

Re: [Zscript] Checking mobility for choosing turn direction

Postby Uberkreatur » Mon Nov 13, 2017 11:50 am

Upd: solved by rude way.

Code: Select allExpand view
            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);   
Uberkreatur
 
Joined: 26 Dec 2014
Location: Russia


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest