From df94babad6dc49977c815a78df04351023e876c4 Mon Sep 17 00:00:00 2001 From: yi12345 Date: Wed, 14 Aug 2013 13:32:41 +0300 Subject: [PATCH] fix starvation, now should work 100% --- GameEngine/Automation.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 7043f9d0..4d316dbc 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -4124,6 +4124,7 @@ $wallimg = "modifyEnforce($enf, $maxtype, $killunits, 0); + if($maxtype == "hero" && $maxcount > 0){ + $heroid = $database->getHeroField($database->getVillageField($enf_vill,"owner"),"heroid"); + $database->modifyHero("dead", 1, $heroid); + } $database->setVillageField($starv['wref'], 'starv', $upkeep); $database->setVillageField($starv['wref'], 'starvupdate', $time); }else{ @@ -4177,6 +4182,8 @@ $wallimg = "getHeroField($database->getVillageField($enf_vill,"owner"),"heroid"); + $database->modifyHero("dead", 1, $heroid); $database->deleteReinf($enf); $killunits -= $maxcount; } @@ -4188,11 +4195,18 @@ $wallimg = "modifyUnit($starv['wref'], array($maxtype), array($killunits), array(0)); $killunits = 0; + if($maxtype == "hero" && $maxcount > 0){ + $heroid = $database->getHeroField($database->getVillageField($starv['wref'],"owner"),"heroid"); + $database->modifyHero("dead", 1, $heroid); + } $database->setVillageField($starv['wref'], 'starv', $upkeep); $database->setVillageField($starv['wref'], 'starvupdate', $time); }else{ - $database->modifyUnit($starv['wref'], array($maxtype), array($killunits), array(0)); + $database->modifyUnit($starv['wref'], array($maxtype), array($maxcount), array(0)); + if($maxtype != "hero"){ $killunits -= $maxcount; + $unitarray['u'.$maxtype] = 0; + $maxcount = 0; for($i = 0 ; $i <= 50 ; $i++){ $units = $unitarray['u'.$i]; if($unitarray['u'.$i] > $maxcount){ @@ -4205,6 +4219,13 @@ $wallimg = " 0){ + $heroid = $database->getHeroField($database->getVillageField($starv['wref'],"owner"),"heroid"); + $database->modifyHero("dead", 1, $heroid); + } + $killunits = 0; + } $database->setVillageField($starv['wref'], 'starv', $upkeep); $database->setVillageField($starv['wref'], 'starvupdate', $time); }