daily pastebin goal
24%
SHARE
TWEET

morale

a guest May 30th, 2016 16 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         if ($combatworthygroups>1) {
  2.             if ($battle->getDefenseBonus() > 0) {
  3.                 $this->log(10, "Defense Bonus / Fortification: ".$battle->getDefenseBonus()."\n");
  4.             }
  5.  
  6.             foreach ($battle->getGroups() as $group) {
  7.                 $mysize = $group->getVisualSize();
  8.                 if ($group->isDefender() && $battle->getDefenseBonus()) {
  9.                     // if we're on defense, we feel like we're more
  10.                     $mysize *= 1 + ($battle->getDefenseBonus()/200);
  11.                 }
  12.                 $enemy = $group->getEnemy();
  13.                 if ($enemy) {
  14.                     $enemysize = $enemy->getVisualSize();
  15.                     $mod = sqrt($mysize / $enemysize);
  16.                 } else {
  17.                     // FIXME: strange, we don't know our enemy?
  18.                     $mod = 1.0;
  19.                 }
  20.                 $this->log(3, "Group #".$group->getId().", visual size $mysize.\n");
  21.  
  22.                 $this->battlesize = min($mysize, $enemysize);
  23.                 foreach ($group->getCharacters() as $char) {
  24.                     $this->character_manager->addAchievement($char, 'battlesize', $this->battlesize);
  25.                 }
  26.  
  27.                 $base_morale = 50;
  28.                 // defense bonuses:
  29.                 if ($group->isDefender()) {
  30.                     if ($battle->getDefenseBonus()) {
  31.                         $base_morale += $battle->getDefenseBonus()/2;
  32.                     }
  33.                     if ($battle->getSettlement()) {
  34.                         $base_morale += 10; // note: this will always be true if the above is true, as for the moment we have fortifications only at settlements
  35.                     }
  36.                 }
  37.                 $this->log(10, "Base morale: $base_morale, mod = $mod\n");
  38.  
  39.                 foreach ($group->getSoldiers() as $soldier) {
  40.                     // starting morale: my power, defenses and relative sizes
  41.                     $power = $soldier->RangedPower() + $soldier->MeleePower() + $soldier->DefensePower();
  42.  
  43.                     if ($group->isDefender() && $battle->getDefenseBonus()) {
  44.                         $soldier->setFortified(true);
  45.                     }
  46.                     if ($soldier->isNoble()) {
  47.                         $this->character_manager->addAchievement($soldier->getCharacter(), 'battles');
  48.                         $morale = $base_morale * 1.5;
  49.                     } else {
  50.                         $this->history->addToSoldierLog($soldier, 'battle', array("%link-battle%"=>$this->report->getId()));
  51.                         $morale = $base_morale;
  52.                     }
  53.                     if ($soldier->getDistanceHome() > 10000) {
  54.                         // 50km = -10 / 100 km = -14 / 200 km = -20 / 500 km = -32
  55.                         $distance_mod = sqrt(($soldier->getDistanceHome-10000)/500);
  56.                     } else {
  57.                         $distance_mod = 0;
  58.                     }
  59.                     $soldier->setMorale(($morale + $power) * $mod - $distance_mod);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top