/// <summary> /// this makes our faction change its relation levels after a zone gift /// if the gift somehow affected it /// </summary> /// <param name="ourFacID"></param> /// <param name="attackerFacs"></param> /// <param name="attackedFacID"></param> public static void FacReactToZoneGift(int ourFacID, int IDGiftingFac, int IDGiftedFac) { GameInfo gData = GameController.CurGameData; Faction ourFac = GameController.GetFactionByID(ourFacID); if (ourFacID == IDGiftingFac) { return; //the gifted fac will handle increasing relations } else if (IDGiftedFac >= 0 && IDGiftingFac >= 0) { if (ourFacID == IDGiftedFac) { ourFac.AddRelationWith(IDGiftingFac, GetRelGainReceivedZoneGift()); } else { //we're not giving nor receiving in this event; //there's no positive effect in our relations then. //we should still frown at the event if one of them is an enemy, //in order to prevent zone giving from being too OP if (ourFac.GetStandingWith(IDGiftingFac) == GameFactionRelations.FactionStanding.enemy) { ourFac.AddRelationWith(IDGiftedFac, GetRelDmgReceivedZoneFromEnemy()); } if (ourFac.GetStandingWith(IDGiftedFac) == GameFactionRelations.FactionStanding.enemy) { ourFac.AddRelationWith(IDGiftingFac, GetRelDmgGaveZoneToEnemy()); } } } }
/// <summary> /// this makes our faction change its relation levels after an attack /// if the attack somehow affected it (attacked faction was an ally, for example) /// </summary> /// <param name="ourFacID"></param> /// <param name="attackerFacs"></param> /// <param name="attackedFacID"></param> public static void FacReactToAttack(int ourFacID, List <int> attackerFacs, int attackedFacID) { GameInfo gData = GameController.CurGameData; Faction ourFac = GameController.GetFactionByID(ourFacID); if (ourFacID == attackedFacID) { gData.factionRelations.AddRelationBetweenFactions(ourFacID, attackerFacs, GetRelDmgAttacked(), false); } else if (attackedFacID >= 0) { if (!attackerFacs.Contains(ourFacID)) { Faction attackedFac = GameController.GetFactionByID(attackedFacID); GameFactionRelations.FactionStanding standingWithAttacked = attackedFac.GetStandingWith(ourFacID); if (standingWithAttacked == GameFactionRelations.FactionStanding.enemy) { ourFac.AddRelationWith(attackerFacs, GetRelGainEnemyAttacked()); } else { if (standingWithAttacked == GameFactionRelations.FactionStanding.ally) { ourFac.AddRelationWith(attackerFacs, GetRelDmgAllyAttacked()); } //add some relation to the attacked if at least one of the attackers is an enemy of ours bool attackersContainEnemy = false; foreach (int facID in attackerFacs) { if (ourFac.GetStandingWith(facID) == GameFactionRelations.FactionStanding.enemy) { attackersContainEnemy = true; break; } } if (attackersContainEnemy) { ourFac.AddRelationWith(attackedFac, GetRelGainAttackedByEnemy()); } } //and worsen relations ourFac.AddRelationWith(attackerFacs, GetRelDmgAggressiveBehaviour()); } else { foreach (int atkerFacID in attackerFacs) { if (atkerFacID != ourFacID) { ourFac.AddRelationWith(atkerFacID, GetRelGainJoinAttack()); } } } } }
/// <summary> /// reactingFaction enhances or degrades relations with factionReactedAgainst, according to /// reactingFaction's relation with theirNewAlly /// </summary> /// <param name="reactingFaction"></param> /// <param name="IDfactionReactedAgainst"></param> /// <param name="IDtheirNewAlly"></param> public static void FactionReactToAlliance(Faction reactingFaction, int IDfactionReactedAgainst, int IDtheirNewAlly) { switch (reactingFaction.GetStandingWith(IDtheirNewAlly)) { case GameFactionRelations.FactionStanding.enemy: //frown at factionReactedAgainst! reactingFaction.AddRelationWith(IDfactionReactedAgainst, GetRelDmgAlliedToEnemy()); break; case GameFactionRelations.FactionStanding.ally: //get closer to factionReactedAgainst! reactingFaction.AddRelationWith(IDfactionReactedAgainst, GetRelGainAlliedToAlly()); break; default: //if we're neutral to theirNewAlly, don't care much about this alliance break; } }