summary refs log tree commit diff
path: root/src/GameTick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GameTick.cpp')
-rw-r--r--src/GameTick.cpp66
1 files changed, 29 insertions, 37 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index dfc84de..af64a25 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -739,6 +739,9 @@ void tackle(Game* game, XYZ flatfacing)
 void bleed(Game* game, size_t i)
 {
 	auto& person = game->person[i];
+	if (person.health < 100.0f && person.type != zombietype)
+		person.health -= multiplier * 120.0f;
+
 	if (person.health < 0.0f && person.longdead < 0.0f
 	    && !person.firstlongdead && person.type != zombietype) {
 		int x = person.whichblockx, y = person.whichblocky;
@@ -769,7 +772,7 @@ void bleed(Game* game, size_t i)
 	if (person.bleeding <= 0.0f)
 		return;
 	person.bleeding -= multiplier;
-	person.bleeddelay -= multiplier * 10;
+	person.bleeddelay -= multiplier * 10.0f;
 	if (person.bleeddelay > 0.0f)
 		return;
 	person.bleeddelay = 1.0f;
@@ -780,6 +783,29 @@ void bleed(Game* game, size_t i)
 		{}, person.bleeding * 3.0f);
 }
 
+void heal(Game* game, size_t i)
+{
+	auto& zombie = game->person[i];
+	if (zombie.type != zombietype)
+		return;
+	zombie.maxhealth = std::min(100.0f,
+		zombie.maxhealth + multiplier * 2.0f);
+	zombie.health = std::min(zombie.maxhealth,
+		zombie.health + multiplier * 10.0f);
+
+	float slow = 0.6f, fast = 0.7f + game->difficulty * 0.2f;
+	if (zombie.health < 40.0f)
+		zombie.speedmult = std::max(slow,
+			zombie.speedmult - multiplier * 0.05f);
+	else
+		zombie.speedmult = std::min(fast,
+			zombie.speedmult + multiplier * 0.025f);
+	if (zombie.speedmult < slow)
+		zombie.killtarget = -1;
+	else if (zombie.speedmult > fast)
+		zombie.killtarget = 1;
+}
+
 void recoil(Game* game, size_t i)
 {
 	auto& person = game->person[i];
@@ -968,43 +994,9 @@ void Game::Tick()
 	float toofar;
 
 	//People
-	for(int i=0;i<numpeople;i++){
-		if(person[i].health<100&&person[i].type!=zombietype){
-				person[i].health-=multiplier*120;
-		}
-
-		if(person[i].health<100&&person[i].type==zombietype){
-				person[i].health+=multiplier*10;
-				if(person[i].health>person[i].maxhealth)person[i].health=person[i].maxhealth;
-		}
-
-		if(person[i].health<100&&person[i].type==zombietype&&person[i].skeleton.free==1){
-				person[i].health+=multiplier*10;
-				if(person[i].health>person[i].maxhealth)person[i].health=person[i].maxhealth;
-		}
-
-		if(person[i].health<40&&person[i].type==zombietype){
-				person[i].speedmult-=multiplier/20;
-				if(person[i].speedmult<.6){
-					person[i].speedmult=.6;
-					person[i].killtarget=-1;
-				}
-		}
-
-		if(person[i].health>=40&&person[i].type==zombietype){
-				person[i].speedmult+=multiplier/40;
-				if(person[i].speedmult>.7+difficulty*.2){
-					person[i].speedmult=.7+difficulty*.2;
-					person[i].killtarget=1;
-				}
-		}
-
-		if(person[i].maxhealth<100&&person[i].type==zombietype){
-				person[i].maxhealth+=multiplier*2;
-				if(person[i].maxhealth>100)person[i].maxhealth=100;
-		}
-
+	for (size_t i = 0; i < numpeople; ++i) {
 		bleed(this, i);
+		heal(this, i);
 		if (!person[i].skeleton.free) {
 			recoil(this, i);