Example #1
0
void VillageControl::launchAttack(Villain& villain, vector<Creature*> attackers) {
  optional<int> ransom;
  int hisGold = villain.collective->numResource(CollectiveResourceId::GOLD);
  if (villain.ransom && hisGold >= villain.ransom->second)
    ransom = max<int>(villain.ransom->second,
        (Random.getDouble(villain.ransom->first * 0.6, villain.ransom->first * 1.5)) * hisGold);
  villain.collective->addAttack(CollectiveAttack(getCollective(), attackers, ransom));
  TeamId team = getCollective()->getTeams().createPersistent(attackers);
  getCollective()->getTeams().activate(team);
  getCollective()->freeTeamMembers(team);
  for (Creature* c : attackers)
    getCollective()->setTask(c, villain.getAttackTask(this));
  attackSizes[team] = attackers.size();
}
Example #2
0
void VillageControl::launchAttack(vector<Creature*> attackers) {
  if (Collective* enemy = getEnemyCollective()) {
    for (Creature* c : attackers)
//      if (getCollective()->getGame()->canTransferCreature(c, enemy->getLevel()->getModel()))
        getCollective()->getGame()->transferCreature(c, enemy->getLevel()->getModel());
    optional<int> ransom;
    int hisGold = enemy->numResource(CollectiveResourceId::GOLD);
    if (villain->ransom && hisGold >= villain->ransom->second)
      ransom = max<int>(villain->ransom->second,
          (Random.getDouble(villain->ransom->first * 0.6, villain->ransom->first * 1.5)) * hisGold);
    enemy->addAttack(CollectiveAttack(getCollective(), attackers, ransom));
    TeamId team = getCollective()->getTeams().createPersistent(attackers);
    getCollective()->getTeams().activate(team);
    getCollective()->freeTeamMembers(team);
    for (Creature* c : attackers)
      getCollective()->setTask(c, villain->getAttackTask(this));
    attackSizes[team] = attackers.size();
  }
}