From 535953a2450e54e9968d52fe510d5f949e068d85 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Thu, 19 Jun 2014 08:15:17 -0700 Subject: [PATCH] Simplify random walk routine --- README.md | 8 -------- moonlight/js/moonlight-skulk.js | 20 ++------------------ 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index cc38d71..dfa4292 100644 --- a/README.md +++ b/README.md @@ -12,18 +12,10 @@ This stuff is just for me to keep track, since I'm afraid using GitHub's issue t The AI should, in their default states, wander around the map aimlessly. They should restrict themselves to normal pedestrian traffic lanes, which will likely require the marking of such lanes in TilED. -## TODO : AI that chases you on the map - -There needs to be 2 classes of AI : AI that runs from you, and AI that chases you. At this point the "run from you" AI should just continually try to escape you. The "chase you" AI should continually try to reach you. - ## TODO : "Run away" AI reports you to "Chase" AI types The "Run Away" AI type should continue running away until it finds a "Chase" AI type to report you to, or until a certain amount of time has passed since the last time they saw you -## TODO : "Chase" AI should lose track of you after a certain time - -The Chase AI should stop chasing you if it has not seen you for a certain amount of time - ## TODO : "Chase" AI should actively "look" for you after it loses you, for a certain amount of time See above, once the Chase AI loses you, it should look for you for some time before giving up diff --git a/moonlight/js/moonlight-skulk.js b/moonlight/js/moonlight-skulk.js index d58a3f4..6749c98 100644 --- a/moonlight/js/moonlight-skulk.js +++ b/moonlight/js/moonlight-skulk.js @@ -1072,24 +1072,8 @@ var AISprite = function(game, x, y, key, frame) { } if ( game.rnd.integerInRange(0, 100) < 95 ) return; - switch ( game.rnd.integerInRange(0, 4) ) { - case 0: { - newstate = newstate | (STATE_FACE_RIGHT | STATE_MOVING); - break; - } - case 1: { - newstate = newstate | (STATE_FACE_LEFT | STATE_MOVING); - break; - } - case 2: { - newstate = newstate | (STATE_FACE_UP | STATE_MOVING); - break; - } - case 3: { - newstate = newstate | (STATE_FACE_DOWN | STATE_MOVING); - } - } - setMovingState(this, newstate); + this.turnUnseenDirection(); + setMovingState(this, this.state | STATE_MOVING); } this.update = function()