Connection ErrorBad RequestSession ExpiredSign in requiredForbiddenNot FoundToo Many RequestsServer ErrorBad GatewayService UnavailableGateway TimeoutHTTP Version Not Supported
Session Expired
Your session has expired. Please log in to continue.
Sign in required
You need an account to do that. Sign in or create one — it only takes a minute.
Request Failed
We encountered an issue while processing your request.
Please check your internet connection and try again.
Here's a shortened version from my map; only the computer-controlled unit chases the player, so it might not look exactly as you'd expect. `hero` is the computer's hero, and `player_hero` is the player's hero. Run it as a thread. The computer tries to move towards the player at the beginning of each turn, and if the player moves away quickly during that time, it will also be handled correctly.
function MainKnightSavedHeroReturnWithPlayerThread()
local hero = quest_main_knight.AttackParam('hero'); local start_date = GetDate(ABSOLUTE_DAY); local move_date = 0; local curr_date; local hx_last, hy_last, hf_last = -1, -1, -1; local hx_curr, hy_curr, hf_curr;
while(1) do if(IsObjectExists(hero)) then
if(IsObjectExists(player_hero)) then hx_curr, hy_curr, hf_curr = GetObjectPosition(player_hero); if((hx_last ~= hx_curr) or (hy_last ~= hy_curr) or (hf_last ~= hf_curr)) then hx_last, hy_last, hf_last = hx_curr, hy_curr, hf_curr; MoveHeroRealTime(hero, hx_curr, hy_curr, hf_curr); end end
-- movement points are added at the beginning of each turn curr_date = GetDate(ABSOLUTE_DAY); if(move_date ~= curr_date) then move_date = curr_date; ChangeHeroStat(hero, STAT_MOVE_POINTS, 2500); sleep(1); if(IsObjectExists(player_hero)) then hx_curr, hy_curr, hf_curr = GetObjectPosition(player_hero); MoveHeroRealTime(hero, hx_curr, hy_curr, hf_curr); end end