diff options
-rw-r--r-- | src/GameTick.cpp | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 04502d5..0f883ad 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -849,6 +849,49 @@ void recoil(Game* game, size_t i) person.recoil = 0; } +void controlZombie(Game* game, size_t i) +{ + auto& zombie = game->person[i]; + if (zombie.type != zombietype) + return; + auto& vip = game->person[1]; + if (findDistancefast(zombie.playercoords, vip.playercoords) > 20000 + || zombie.speedmult < 0.7f) { + zombie.killtarget = -1; + return; + } else if (game->enemystate == 2) { + zombie.killtarget = 1; + } + + auto& target = game->person[zombie.killtarget]; + if (zombie.targetanimation != zombieeatanim || target.eaten != i) + return; + auto& target_joints = target.skeleton.joints; + target_joints[head].locked = true; + target_joints[rightshoulder].locked = true; + + auto& zombie_joints = zombie.skeleton.joints; + target_joints[head].position = zombie.playercoords + + DoRotation(zombie_joints[righthand].position, + 0.0f, zombie.playerrotation, 0.0f); + target_joints[head].velocity = {}; + target_joints[rightshoulder].position = zombie.playercoords + + DoRotation(zombie_joints[lefthand].position, + 0.0f, zombie.playerrotation, 0.0f); + target_joints[rightshoulder].velocity = {}; + target.skeleton.DoConstraints(); + + size_t x = zombie.whichblockx, y = zombie.whichblocky; + auto& collide = game->blocksimplecollide[game->citytype[x][y]]; + XYZ tmp; + auto rotation = game->cityrotation[x][y] * 90.0f; + target.skeleton.DoConstraints(&collide, &tmp, rotation); + + target.skeleton.joints[rightshoulder].locked = false; + target.skeleton.joints[head].locked = false; + target.longdead = 1.0f; +} + void renderLaser(Game* game) { auto& player = game->person[0]; @@ -998,36 +1041,7 @@ void Game::Tick() heal(this, i); if (!person[i].skeleton.free) { recoil(this, i); - - //Zombie eat - if(i > 0 - && person[i].targetanimation == zombieeatanim - && person[person[i].killtarget].eaten == i) { - person[person[i].killtarget].skeleton.joints[head].locked=1; - person[person[i].killtarget].skeleton.joints[rightshoulder].locked=1; - - for(int k=0;k<2;k++){ - person[person[i].killtarget].skeleton.joints[head].position=DoRotation(person[i].skeleton.joints[righthand].position,0,person[i].playerrotation,0)+person[i].playercoords; - person[person[i].killtarget].skeleton.joints[head].velocity = {}; - person[person[i].killtarget].skeleton.joints[rightshoulder].position=DoRotation(person[i].skeleton.joints[lefthand].position,0,person[i].playerrotation,0)+person[i].playercoords; - person[person[i].killtarget].skeleton.joints[rightshoulder].velocity = {}; - person[person[i].killtarget].skeleton.DoConstraints(); - person[person[i].killtarget].skeleton.DoConstraints(&blocksimplecollide[citytype[person[i].whichblockx][person[i].whichblocky]],&move,cityrotation[person[i].whichblockx][person[i].whichblocky]*90); - } - - person[person[i].killtarget].skeleton.joints[head].locked=0; - person[person[i].killtarget].skeleton.joints[rightshoulder].locked=0; - person[person[i].killtarget].longdead=1; - } - - if(i>0&&enemystate!=1&&person[i].type==zombietype&&person[i].speedmult>.7){ - if(findDistancefast(person[i].playercoords,person[1].playercoords)<20000)person[i].killtarget=1; - else person[i].killtarget=-1; - } - - if(i>0&&enemystate!=1&&person[i].type==zombietype&&person[i].speedmult<.7){ - person[i].killtarget=-1; - } + controlZombie(this, i); bool realcheck = false; @@ -1323,7 +1337,7 @@ void Game::Tick() person[i].lastdistancevictim=200000; person[i].pathnum=-1; - if (person[i].type != zombietype && person[i].whichgun == nogun) { + if (person[i].whichgun == nogun) { person[i].whichgun=possiblegun[randUint(numpossibleguns)]; person[i].reloads[person[i].whichgun]=1; if(person[i].whichgun==knife)person[i].speedmult=.8+.5*difficulty; |