From 66bee62a250c8995911554e899759ffd98a64bdb Mon Sep 17 00:00:00 2001 From: XProger Date: Tue, 29 Aug 2017 05:13:29 +0300 Subject: [PATCH] #14 enemies use flipmap info for pathfinding --- src/character.h | 7 ++++++- src/enemy.h | 5 ----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/character.h b/src/character.h index e02a7f6..e65be94 100644 --- a/src/character.h +++ b/src/character.h @@ -29,6 +29,8 @@ struct Character : Controller { vec3 velocity; float angleExt; float speed; + int stepHeight; + int dropHeight; int zone; int box; @@ -38,6 +40,9 @@ struct Character : Controller { Collision collision; Character(IGame *game, int entity, float health) : Controller(game, entity), health(health), tilt(0.0f), stand(STAND_GROUND), lastInput(0), velocity(0.0f), angleExt(0.0f) { + stepHeight = 256; + dropHeight = -256; + animation.initOverrides(); rotHead = rotChest = quat(0, 0, 0, 1); @@ -56,7 +61,7 @@ struct Character : Controller { } uint16* getZones() { - return flying ? level->zones[0].fly : level->zones[0].ground1; + return flying ? level->zones[level->isFlipped].fly : (stepHeight == 256 ? level->zones[level->isFlipped].ground1 : level->zones[level->isFlipped].ground2); } void rotateY(float delta) { diff --git a/src/enemy.h b/src/enemy.h index 80c1ab5..2640d66 100644 --- a/src/enemy.h +++ b/src/enemy.h @@ -57,8 +57,6 @@ struct Enemy : Character { float length; // dist from center to head (jaws) float aggression; int radius; - int stepHeight; - int dropHeight; Character *target; Path *path; @@ -73,9 +71,6 @@ struct Enemy : Character { bool targetCanAttack; Enemy(IGame *game, int entity, float health, int radius, float length, float aggression) : Character(game, entity, health), ai(AI_RANDOM), mood(MOOD_SLEEP), wound(false), nextState(0), targetBox(-1), thinkTime(1.0f / 30.0f), length(length), aggression(aggression), radius(radius), target(NULL), path(NULL) { - stepHeight = 256; - dropHeight = -256; - jointChest = jointHead = -1; targetDist = +INF;