//added by gremlin Domission from devek mod. public void DoMission(Empire Owner) { spyMute = AgentComponent.SpyMute; Planet target; Empire Target = EmpireManager.GetEmpireByName(this.TargetEmpire); AgentMission startingmission = this.Mission; #region EmpireDefeated if (Target != null && Target.data.Defeated) { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; return; } #endregion #region New DiceRoll float DiceRoll = RandomMath.RandomBetween(this.Level * ResourceManager.AgentMissionData.MinRollPerLevel, ResourceManager.AgentMissionData.MaxRoll); float DefensiveRoll = 0f; DiceRoll += (float)this.Level * RandomMath.RandomBetween(1f, ResourceManager.AgentMissionData.RandomLevelBonus); DiceRoll += Owner.data.SpyModifier; DiceRoll += Owner.data.OffensiveSpyBonus; if (Target != null) { for (int i = 0; i < Target.data.AgentList.Count; i++) { if (Target.data.AgentList[i].Mission == AgentMission.Defending) { DefensiveRoll += (float)Target.data.AgentList[i].Level * ResourceManager.AgentMissionData.DefenceLevelBonus; } } DefensiveRoll /= Owner.GetPlanets().Count / 3 + 1; DefensiveRoll += Target.data.SpyModifier; DefensiveRoll += Target.data.DefensiveSpyBonus; DiceRoll -= DefensiveRoll; } #endregion switch (this.Mission) { #region Training case AgentMission.Training: { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; if (DiceRoll >= ResourceManager.AgentMissionData.TrainingRollPerfect) { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.TrainingExpPerfect, Owner); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6025)), Owner); this.Training++; break; } else if (DiceRoll > ResourceManager.AgentMissionData.TrainingRollGood) { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.TrainingExpGood, Owner); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6026)), Owner); this.Training++; break; } else if (DiceRoll < ResourceManager.AgentMissionData.TrainingRollBad) { if (DiceRoll >= ResourceManager.AgentMissionData.TrainingRollWorst) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6027)), Owner); this.AssignMission(AgentMission.Recovering, Owner, ""); this.PrevisousMission = AgentMission.Training; break; } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6028)), Owner); Owner.data.AgentList.QueuePendingRemoval(this); break; } else { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6029)), Owner); break; } } #endregion #region Infiltrate easy case AgentMission.Infiltrate: { if (Target == null || Target.GetPlanets().Count == 0) { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; return; } if (DiceRoll >= ResourceManager.AgentMissionData.InfiltrateRollGood) { this.Mission = AgentMission.Undercover; this.MissionNameIndex = 2201; //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.InfiltrateExpGood, Owner); Mole m = Mole.PlantMole(Owner, Target); this.TargetGUID = m.PlanetGuid; if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6030), " ", Ship.universeScreen.PlanetsDict[m.PlanetGuid].Name, Localizer.Token(6031)), Owner); this.Infiltrations++; break; } else if (DiceRoll < ResourceManager.AgentMissionData.InfiltrateRollBad) { if (DiceRoll >= ResourceManager.AgentMissionData.InfiltrateRollWorst) { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6032)), Owner); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6033), " ", Owner.data.Traits.Name), Target); } this.AssignMission(AgentMission.Recovering, Owner, ""); this.PrevisousMission = AgentMission.Infiltrate; this.PreviousTarget = this.TargetEmpire; break; } this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6034)), Owner); Owner.data.AgentList.QueuePendingRemoval(this); if (Target != EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { break; } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6035), " ", Owner.data.Traits.Name), Target); break; } else { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.InfiltrateExp, Owner); this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6036)), Owner); if (Target != EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { break; } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6033), " ", Owner.data.Traits.Name), Target); break; } } #endregion #region Assassinate hard case AgentMission.Assassinate: { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; if (Target == null || Target.data.AgentList.Count == 0) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6038)), Owner); return; } if (DiceRoll >= ResourceManager.AgentMissionData.AssassinateRollPerfect) { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.AssassinateExpPerfect, Owner); Agent m = Target.data.AgentList[HelperFunctions.GetRandomIndex(Target.data.AgentList.Count)]; Target.data.AgentList.Remove(m); if (m.Mission == AgentMission.Undercover) { foreach (Mole mole in Owner.data.MoleList) { if (mole.PlanetGuid != m.TargetGUID) { continue; } Owner.data.MoleList.QueuePendingRemoval(mole); break; } } Owner.data.MoleList.ApplyPendingRemovals(); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { //if (!GremlinAgentComponent.AutoTrain) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat("One of our Agents was mysteriously assassinated: ", m.Name), Target); } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6039), " ", m.Name, Localizer.Token(6040)), Owner); this.Assassinations++; break; } else if (DiceRoll >= ResourceManager.AgentMissionData.AssassinateRollGood) { Agent m = Target.data.AgentList[HelperFunctions.GetRandomIndex(Target.data.AgentList.Count)]; Target.data.AgentList.Remove(m); if (m.Mission == AgentMission.Undercover) { foreach (Mole mole in Owner.data.MoleList) { if (mole.PlanetGuid != m.TargetGUID) { continue; } Owner.data.MoleList.QueuePendingRemoval(mole); break; } } //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.AssassinateExpGood, Owner); Owner.data.MoleList.ApplyPendingRemovals(); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6037), " ", m.Name, Localizer.Token(6041), " ", Owner.data.Traits.Name), Target); } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6039), " ", m.Name, Localizer.Token(6042)), Owner); this.Assassinations++; break; } else if (DiceRoll < ResourceManager.AgentMissionData.AssassinateRollBad) { if (DiceRoll >= ResourceManager.AgentMissionData.AssassinateRollWorst) { if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6043), " ", Owner.data.Traits.Name), Target); } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6044)), Owner); this.AssignMission(AgentMission.Recovering, Owner, ""); this.PrevisousMission = AgentMission.Assassinate; this.PreviousTarget = this.TargetEmpire; break; } this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6045), " ", Owner.data.Traits.Name), Target); } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6046)), Owner); Owner.data.AgentList.QueuePendingRemoval(this); break; } else { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.AssassinateExp, Owner); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6043), " ", Owner.data.Traits.Name), Target); } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6047)), Owner); break; } } #endregion #region Sabotage easy case AgentMission.Sabotage: { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; if (Target==null || Target.GetPlanets().Count == 0) { return; } target = EmpireManager.GetEmpireByName(this.TargetEmpire).GetPlanets()[HelperFunctions.GetRandomIndex(EmpireManager.GetEmpireByName(this.TargetEmpire).GetPlanets().Count)]; this.TargetGUID = target.guid; if (DiceRoll >= ResourceManager.AgentMissionData.SabotageRollPerfect) { Planet crippledTurns = target; crippledTurns.Crippled_Turns = crippledTurns.Crippled_Turns + 5 + this.Level * 5; if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6048), " ", target.Name), Target); } NotificationManager notificationManager = Ship.universeScreen.NotificationManager; string[] name = new string[] { this.Name, " " + Localizer.Token(6084) + " ", null, null, null, null }; int num = 5 + this.Level * 5; name[2] = num.ToString(); name[3] = " " + Localizer.Token(6085) + " "; name[4] = target.Name; name[5] = Localizer.Token(6031); if (!spyMute) notificationManager.AddAgentResultNotification(true, string.Concat(name), Owner); //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.SabotageExpPerfect, Owner); this.Sabotages++; break; } else if (DiceRoll > ResourceManager.AgentMissionData.SabotageRollGood) { Planet planet = target; planet.Crippled_Turns = planet.Crippled_Turns + 5 + this.Level * 3; if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6048), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } NotificationManager notificationManager1 = Ship.universeScreen.NotificationManager; string[] str = new string[] { this.Name, " " + Localizer.Token(6084) + " ", null, null, null, null }; int num1 = 5 + this.Level * 3; str[2] = num1.ToString(); str[3] = " " + Localizer.Token(6085) + " "; str[4] = target.Name; str[5] = Localizer.Token(6031); if (!spyMute) notificationManager1.AddAgentResultNotification(true, string.Concat(str), Owner); //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.SabotageExpGood, Owner); this.Sabotages++; break; } else if (DiceRoll < ResourceManager.AgentMissionData.SabotageRollBad) { if (DiceRoll >= ResourceManager.AgentMissionData.SabotageRollWorst) { if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6051), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6052), " ", target.Name), Owner); this.AssignMission(AgentMission.Recovering, Owner, ""); this.PrevisousMission = AgentMission.Sabotage; this.PreviousTarget = this.TargetEmpire; break; } if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!AgentComponent.AutoTrain) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6053), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6054)), Owner); Owner.data.AgentList.QueuePendingRemoval(this); break; } else { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.SabotageExp, Owner); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6051)," ", target.Name, Localizer.Token(6049)," ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6055), " ", target.Name), Owner); break; } } #endregion #region StealTech hard case AgentMission.StealTech: { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; if (Target == null) return; List<string> PotentialUIDs = new List<string>(); foreach (KeyValuePair<string, TechEntry> entry in Target.GetTDict()) { //Added by McShooterz: Root nodes cannot be stolen if (!entry.Value.Unlocked || !Owner.HavePreReq(entry.Value.UID) || Owner.GetTDict()[entry.Value.UID].Unlocked || entry.Value.GetTech().RootNode == 1) { continue; } PotentialUIDs.Add(entry.Value.UID); } string theUID = ""; if (PotentialUIDs.Count != 0) { theUID = PotentialUIDs[HelperFunctions.GetRandomIndex(PotentialUIDs.Count)]; if (DiceRoll >= ResourceManager.AgentMissionData.StealTechRollPerfect) { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.StealTechExpPerfect, Owner); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, Localizer.Token(6056), Target); } //Added by McShooterz: new acquire method, unlocks targets bonuses as well //Owner.UnlockTech(theUID); Owner.AcquireTech(theUID, Target); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6057), " ", Localizer.Token(ResourceManager.TechTree[theUID].NameIndex), Localizer.Token(6031)), Owner); this.TechStolen++; break; } else if (DiceRoll > ResourceManager.AgentMissionData.StealTechRollGood) { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.StealTechExpGood, Owner); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6058), " ", Localizer.Token(ResourceManager.TechTree[theUID].NameIndex), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } //Added by McShooterz: new acquire method, unlocks targets bonuses as well //Owner.UnlockTech(theUID); Owner.AcquireTech(theUID, Target); Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6057), " ", Localizer.Token(ResourceManager.TechTree[theUID].NameIndex), Localizer.Token(6042)), Owner); this.TechStolen++; break; } else if (DiceRoll < ResourceManager.AgentMissionData.StealTechRollBad) { if (DiceRoll >= ResourceManager.AgentMissionData.StealTechRollWorst) { if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6059), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6050)), Owner); this.AssignMission(AgentMission.Recovering, Owner, ""); this.PrevisousMission = AgentMission.StealTech; this.PreviousTarget = this.TargetEmpire; break; } if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6060), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6061)), Owner); Owner.data.AgentList.QueuePendingRemoval(this); break; } else { if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6059), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6062)), Owner); break; } } else { this.AddExperience(ResourceManager.AgentMissionData.StealTechExp, Owner); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6063), " ", (ResourceManager.AgentMissionData.StealTechCost / 2).ToString(), " ", Localizer.Token(6064)), Owner); Empire owner = Owner; owner.Money += ResourceManager.AgentMissionData.StealTechCost / 2; break; } } #endregion #region Robbery case AgentMission.Robbery: { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; if (Target == null) return; int amount = (int)(RandomMath.RandomBetween(1f, (float)Target.GetPlanets().Count * 10f) * (float)this.Level); if ((float)amount > Target.Money && Target.Money > 0f) { amount = (int)Target.Money; } else if (Target.Money <= 0f) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6066), " ", this.TargetEmpire, Localizer.Token(6067)), Owner); return; } if (DiceRoll >= ResourceManager.AgentMissionData.RobberyRollPerfect) { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.RobberyExpPerfect, Owner); Empire money = Target; money.Money = money.Money - (float)amount; Empire empire = Owner; empire.Money = empire.Money + (float)amount; NotificationManager notificationManager2 = Ship.universeScreen.NotificationManager; object[] objArray = new object[] { this.Name, " ", Localizer.Token(6068), " ", amount, " ", Localizer.Token(6069), " ", this.TargetEmpire, Localizer.Token(6031) }; if (!spyMute) notificationManager2.AddAgentResultNotification(true, string.Concat(objArray), Owner); if (Target != EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { break; } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(amount, " ", Localizer.Token(6065)), Target); this.Robberies++; break; } else if (DiceRoll > ResourceManager.AgentMissionData.RobberyRollGood) { //Added by McShooterz this.AddExperience(ResourceManager.AgentMissionData.RobberyExpGood, Owner); Empire money1 = Target; money1.Money = money1.Money - (float)amount; Empire owner1 = Owner; owner1.Money = owner1.Money + (float)amount; if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(amount, " ", Localizer.Token(6070), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); NotificationManager notificationManager3 = Ship.universeScreen.NotificationManager; object[] name1 = new object[] { this.Name, " ", Localizer.Token(6068), " ", amount, " ", Localizer.Token(6069), " ", this.TargetEmpire, Localizer.Token(6042) }; if (!spyMute) notificationManager3.AddAgentResultNotification(true, string.Concat(name1), Owner); this.Robberies++; break; } else if (DiceRoll < ResourceManager.AgentMissionData.RobberyRollBad) { if (DiceRoll >= ResourceManager.AgentMissionData.RobberyRollWorst) { if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!AgentComponent.AutoTrain && !spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6071), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) if (!AgentComponent.AutoTrain) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6072)), Owner); this.AssignMission(AgentMission.Recovering, Owner, ""); this.PrevisousMission = AgentMission.Robbery; this.PreviousTarget = this.TargetEmpire; break; } if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6073), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6074), " ", this.TargetEmpire), Owner); Owner.data.AgentList.QueuePendingRemoval(this); break; } else { this.AddExperience(ResourceManager.AgentMissionData.RobberyExp, Owner); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!AgentComponent.AutoTrain && !spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6071), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) if (!AgentComponent.AutoTrain) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6075)), Owner); break; } } #endregion #region Rebellion case AgentMission.InciteRebellion: { this.Mission = AgentMission.Defending; this.MissionNameIndex = 2183; if (Target == null) return; if (Target.GetPlanets().Count == 0) { return; } target = EmpireManager.GetEmpireByName(this.TargetEmpire).GetPlanets()[HelperFunctions.GetRandomIndex(EmpireManager.GetEmpireByName(this.TargetEmpire).GetPlanets().Count)]; if (DiceRoll >= ResourceManager.AgentMissionData.RebellionRollPerfect) { this.AddExperience(ResourceManager.AgentMissionData.RebellionExpPerfect, Owner); if (!EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebellionLaunched) { Empire rebels = CreatingNewGameScreen.CreateRebelsFromEmpireData(EmpireManager.GetEmpireByName(this.TargetEmpire).data, EmpireManager.GetEmpireByName(this.TargetEmpire)); rebels.data.IsRebelFaction = true; rebels.data.Traits.Name = EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebelName; rebels.data.Traits.Singular = EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebelSing; rebels.data.Traits.Plural = EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebelPlur; rebels.isFaction = true; foreach (Empire e in EmpireManager.EmpireList) { e.GetRelations().Add(rebels, new Relationship(rebels.data.Traits.Name)); rebels.GetRelations().Add(e, new Relationship(e.data.Traits.Name)); } EmpireManager.EmpireList.Add(rebels); EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebellionLaunched = true; } Empire darebels = EmpireManager.GetEmpireByName(EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebelName); for (int i = 0; i < 4; i++) { foreach (KeyValuePair<string, Troop> troop in ResourceManager.TroopsDict) { if (!EmpireManager.GetEmpireByName(this.TargetEmpire).WeCanBuildTroop(troop.Key)) { continue; } Troop t = ResourceManager.CreateTroop(troop.Value, darebels); t.Name = Localizer.Token(darebels.data.TroopNameIndex); t.Description = Localizer.Token(darebels.data.TroopDescriptionIndex); target.AssignTroopToTile(t); break; } } if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6078), " ", target.Name), Target); } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6077), " ", target.Name, Localizer.Token(6031)), Owner); this.Rebellions++; break; } else if (DiceRoll > ResourceManager.AgentMissionData.RebellionRollGood) { this.AddExperience(ResourceManager.AgentMissionData.RebellionExpGood, Owner); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6078), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6077), " ", target.Name, Localizer.Token(6079)), Owner); this.Rebellions++; break; } else if (DiceRoll < ResourceManager.AgentMissionData.RebellionRollBad) { if (DiceRoll >= ResourceManager.AgentMissionData.RebellionRollWorst) { if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6076), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6080), " ", target.Name), Owner); this.AssignMission(AgentMission.Recovering, Owner, ""); this.PrevisousMission = AgentMission.InciteRebellion; this.PreviousTarget = this.TargetEmpire; break; } if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6081), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6082), " ", target.Name), Owner); Owner.data.AgentList.QueuePendingRemoval(this); break; } else { this.AddExperience(ResourceManager.AgentMissionData.RebellionExp, Owner); if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6076), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target); } Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null); if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6083), " ", target.Name), Owner); break; } } #endregion #region Recovery case AgentMission.Recovering : { this.Mission = AgentMission.Defending; startingmission = this.PrevisousMission; this.TargetEmpire = this.PreviousTarget; this.MissionNameIndex = 2183; if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6086)), Owner); break; } #endregion } #region Mission Repeat if (Owner == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty) && Mission == AgentMission.Defending && Owner.Money > 500 && AgentComponent.AutoTrain == true && (startingmission != AgentMission.Training || (startingmission == AgentMission.Training && this.Level < 10))) { this.AssignMission(startingmission, Owner, this.TargetEmpire); return; } this.TargetEmpire = ""; #endregion }
private float GetScientificStr(Empire e) { float scientificStr = 0f; foreach (KeyValuePair<string, TechEntry> Technology in e.GetTDict()) { if (!Technology.Value.Unlocked) { continue; } scientificStr = scientificStr + ResourceManager.TechTree[Technology.Key].Cost; } return scientificStr; }
public void TriggerOutcome(Empire Triggerer, Outcome triggeredOutcome) { if (triggeredOutcome.SecretTechDiscovered != null) { if (GlobalStats.ActiveModInfo != null && GlobalStats.ActiveModInfo.overrideSecretsTree) { Triggerer.GetTDict()[triggeredOutcome.SecretTechDiscovered].Discovered = true; } else { Triggerer.GetTDict()["Secret"].Discovered = true; Triggerer.GetTDict()[triggeredOutcome.SecretTechDiscovered].Discovered = true; } } if (triggeredOutcome.BeginArmageddon) { GlobalStats.RemnantArmageddon = true; } if (triggeredOutcome.GrantArtifact) { List<Ship_Game.Artifact> Potentials = new List<Ship_Game.Artifact>(); foreach (KeyValuePair<string, Ship_Game.Artifact> Artifact in ResourceManager.ArtifactsDict) { if (Artifact.Value.Discovered) { continue; } Potentials.Add(Artifact.Value); } if (Potentials.Count <= 0) { triggeredOutcome.MoneyGranted = 500; } else { int ranart = (int)RandomMath.RandomBetween(0f, (float)Potentials.Count + 0.8f); if (ranart > Potentials.Count - 1) { ranart = Potentials.Count - 1; } Triggerer.data.OwnedArtifacts.Add(Potentials[ranart]); ResourceManager.ArtifactsDict[Potentials[ranart].Name].Discovered = true; triggeredOutcome.SetArtifact(Potentials[ranart]); if (triggeredOutcome.GetArtifact().DiplomacyMod > 0f) { RacialTrait traits = Triggerer.data.Traits; traits.DiplomacyMod = traits.DiplomacyMod + (triggeredOutcome.GetArtifact().DiplomacyMod + triggeredOutcome.GetArtifact().DiplomacyMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().FertilityMod > 0f) { EmpireData triggerer = Triggerer.data; triggerer.EmpireFertilityBonus = triggerer.EmpireFertilityBonus + triggeredOutcome.GetArtifact().FertilityMod; foreach (Planet planet in Triggerer.GetPlanets()) { Planet fertility = planet; fertility.Fertility = fertility.Fertility + (triggeredOutcome.GetArtifact().FertilityMod + triggeredOutcome.GetArtifact().FertilityMod * Triggerer.data.Traits.Spiritual); } } if (triggeredOutcome.GetArtifact().GroundCombatMod > 0f) { RacialTrait groundCombatModifier = Triggerer.data.Traits; groundCombatModifier.GroundCombatModifier = groundCombatModifier.GroundCombatModifier + (triggeredOutcome.GetArtifact().GroundCombatMod + triggeredOutcome.GetArtifact().GroundCombatMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ModuleHPMod > 0f) { RacialTrait modHpModifier = Triggerer.data.Traits; modHpModifier.ModHpModifier = modHpModifier.ModHpModifier + (triggeredOutcome.GetArtifact().ModuleHPMod + triggeredOutcome.GetArtifact().ModuleHPMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().PlusFlatMoney > 0f) { EmpireData flatMoneyBonus = Triggerer.data; flatMoneyBonus.FlatMoneyBonus = flatMoneyBonus.FlatMoneyBonus + (triggeredOutcome.GetArtifact().PlusFlatMoney + triggeredOutcome.GetArtifact().PlusFlatMoney * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ProductionMod > 0f) { RacialTrait productionMod = Triggerer.data.Traits; productionMod.ProductionMod = productionMod.ProductionMod + (triggeredOutcome.GetArtifact().ProductionMod + triggeredOutcome.GetArtifact().ProductionMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ReproductionMod > 0f) { RacialTrait reproductionMod = Triggerer.data.Traits; reproductionMod.ReproductionMod = reproductionMod.ReproductionMod + (triggeredOutcome.GetArtifact().ReproductionMod + triggeredOutcome.GetArtifact().ReproductionMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ResearchMod > 0f) { RacialTrait researchMod = Triggerer.data.Traits; researchMod.ResearchMod = researchMod.ResearchMod + (triggeredOutcome.GetArtifact().ResearchMod + triggeredOutcome.GetArtifact().ResearchMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().SensorMod > 0f) { EmpireData sensorModifier = Triggerer.data; sensorModifier.SensorModifier = sensorModifier.SensorModifier + (triggeredOutcome.GetArtifact().SensorMod + triggeredOutcome.GetArtifact().SensorMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ShieldPenBonus > 0f) { EmpireData shieldPenBonusChance = Triggerer.data; shieldPenBonusChance.ShieldPenBonusChance = shieldPenBonusChance.ShieldPenBonusChance + (triggeredOutcome.GetArtifact().ShieldPenBonus + triggeredOutcome.GetArtifact().ShieldPenBonus * Triggerer.data.Traits.Spiritual); } } } if (triggeredOutcome.UnlockTech != null) { if (!Triggerer.GetTDict()[triggeredOutcome.UnlockTech].Unlocked) { Triggerer.UnlockTech(triggeredOutcome.UnlockTech); } else { triggeredOutcome.WeHadIt = true; } } Empire money = Triggerer; money.Money = money.Money + (float)triggeredOutcome.MoneyGranted; RacialTrait racialTrait = Triggerer.data.Traits; racialTrait.ResearchMod = racialTrait.ResearchMod + triggeredOutcome.ScienceBonus; RacialTrait traits1 = Triggerer.data.Traits; traits1.ProductionMod = traits1.ProductionMod + triggeredOutcome.IndustryBonus; PlanetGridSquare assignedtile = null; if (triggeredOutcome.SelectRandomPlanet) { List<Planet> Potentials = new List<Planet>(); foreach (SolarSystem s in UniverseScreen.SolarSystemList) { foreach (Planet p in s.PlanetList) { if (!p.habitable || p.Owner != null) { continue; } Potentials.Add(p); } } if (Potentials.Count > 0) { triggeredOutcome.SetPlanet(Potentials[HelperFunctions.GetRandomIndex(Potentials.Count)]); } if (triggeredOutcome.GetPlanet() != null) { assignedtile = triggeredOutcome.GetPlanet().TilesList[17]; if (triggeredOutcome.SpawnBuildingOnPlanet != null) { Building b = ResourceManager.GetBuilding(triggeredOutcome.SpawnBuildingOnPlanet); triggeredOutcome.GetPlanet().AssignBuildingToSpecificTile(b, assignedtile); } } } if (assignedtile != null && triggeredOutcome.GetPlanet() != null && triggeredOutcome.TroopsToSpawn != null) { foreach (string troopname in triggeredOutcome.TroopsToSpawn) { Troop t = ResourceManager.CreateTroop(ResourceManager.TroopsDict[troopname], EmpireManager.GetEmpireByName("Unknown")); t.SetOwner(EmpireManager.GetEmpireByName("The Remnant")); if (triggeredOutcome.GetPlanet().AssignTroopToNearestAvailableTile(t, assignedtile)) { continue; } triggeredOutcome.GetPlanet().AssignTroopToTile(t); } } }
public void TriggerPlanetEvent(Planet p, Empire Triggerer, PlanetGridSquare eventLocation, Empire PlayerEmpire, UniverseScreen screen) { int ranMax = 0; int ranMin = 0; foreach (Outcome outcome in this.PotentialOutcomes) { if (outcome.onlyTriggerOnce && outcome.alreadyTriggered && Triggerer.isPlayer) { continue; } else { ranMax += outcome.Chance; } } int Random = (int)RandomMath.RandomBetween(ranMin, ranMax); Outcome triggeredOutcome = new Outcome(); int cursor = 0; foreach (Outcome outcome in this.PotentialOutcomes) { if (outcome.onlyTriggerOnce && outcome.alreadyTriggered && Triggerer.isPlayer) { continue; } else { cursor = cursor + outcome.Chance; if (Random > cursor) { continue; } triggeredOutcome = outcome; if (Triggerer.isPlayer) { outcome.alreadyTriggered = true; } break; } } if (triggeredOutcome != null) { if (triggeredOutcome.GrantArtifact) { List<Ship_Game.Artifact> Potentials = new List<Ship_Game.Artifact>(); foreach (KeyValuePair<string, Ship_Game.Artifact> Artifact in ResourceManager.ArtifactsDict) { if (Artifact.Value.Discovered) { continue; } Potentials.Add(Artifact.Value); } if (Potentials.Count <= 0) { triggeredOutcome.MoneyGranted = 500; } else { int ranart = (int)RandomMath.RandomBetween(0f, (float)Potentials.Count + 0.8f); if (ranart > Potentials.Count - 1) { ranart = Potentials.Count - 1; } Triggerer.data.OwnedArtifacts.Add(Potentials[ranart]); ResourceManager.ArtifactsDict[Potentials[ranart].Name].Discovered = true; triggeredOutcome.SetArtifact(Potentials[ranart]); if (triggeredOutcome.GetArtifact().DiplomacyMod > 0f) { RacialTrait traits = Triggerer.data.Traits; traits.DiplomacyMod = traits.DiplomacyMod + (triggeredOutcome.GetArtifact().DiplomacyMod + triggeredOutcome.GetArtifact().DiplomacyMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().FertilityMod > 0f) { EmpireData triggerer = Triggerer.data; triggerer.EmpireFertilityBonus = triggerer.EmpireFertilityBonus + triggeredOutcome.GetArtifact().FertilityMod; foreach (Planet planet in Triggerer.GetPlanets()) { Planet fertility = planet; fertility.Fertility = fertility.Fertility + (triggeredOutcome.GetArtifact().FertilityMod + triggeredOutcome.GetArtifact().FertilityMod * Triggerer.data.Traits.Spiritual); } } if (triggeredOutcome.GetArtifact().GroundCombatMod > 0f) { RacialTrait groundCombatModifier = Triggerer.data.Traits; groundCombatModifier.GroundCombatModifier = groundCombatModifier.GroundCombatModifier + (triggeredOutcome.GetArtifact().GroundCombatMod + triggeredOutcome.GetArtifact().GroundCombatMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ModuleHPMod > 0f) { RacialTrait modHpModifier = Triggerer.data.Traits; modHpModifier.ModHpModifier = modHpModifier.ModHpModifier + (triggeredOutcome.GetArtifact().ModuleHPMod + triggeredOutcome.GetArtifact().ModuleHPMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().PlusFlatMoney > 0f) { EmpireData flatMoneyBonus = Triggerer.data; flatMoneyBonus.FlatMoneyBonus = flatMoneyBonus.FlatMoneyBonus + (triggeredOutcome.GetArtifact().PlusFlatMoney + triggeredOutcome.GetArtifact().PlusFlatMoney * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ProductionMod > 0f) { RacialTrait productionMod = Triggerer.data.Traits; productionMod.ProductionMod = productionMod.ProductionMod + (triggeredOutcome.GetArtifact().ProductionMod + triggeredOutcome.GetArtifact().ProductionMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ReproductionMod > 0f) { RacialTrait reproductionMod = Triggerer.data.Traits; reproductionMod.ReproductionMod = reproductionMod.ReproductionMod + (triggeredOutcome.GetArtifact().ReproductionMod + triggeredOutcome.GetArtifact().ReproductionMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ResearchMod > 0f) { RacialTrait researchMod = Triggerer.data.Traits; researchMod.ResearchMod = researchMod.ResearchMod + (triggeredOutcome.GetArtifact().ResearchMod + triggeredOutcome.GetArtifact().ResearchMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().SensorMod > 0f) { EmpireData sensorModifier = Triggerer.data; sensorModifier.SensorModifier = sensorModifier.SensorModifier + (triggeredOutcome.GetArtifact().SensorMod + triggeredOutcome.GetArtifact().SensorMod * Triggerer.data.Traits.Spiritual); } if (triggeredOutcome.GetArtifact().ShieldPenBonus > 0f) { EmpireData shieldPenBonusChance = Triggerer.data; shieldPenBonusChance.ShieldPenBonusChance = shieldPenBonusChance.ShieldPenBonusChance + (triggeredOutcome.GetArtifact().ShieldPenBonus + triggeredOutcome.GetArtifact().ShieldPenBonus * Triggerer.data.Traits.Spiritual); } } } if (triggeredOutcome.BeginArmageddon) { GlobalStats.RemnantArmageddon = true; } foreach (string ship in triggeredOutcome.FriendlyShipsToSpawn) { Triggerer.ForcePoolAdd(ResourceManager.CreateShipAt(ship, Triggerer, p, true)); } foreach (string ship in triggeredOutcome.RemnantShipsToSpawn) { Ship tomake = ResourceManager.CreateShipAt(ship, EmpireManager.GetEmpireByName("The Remnant"), p, true); tomake.GetAI().DefaultAIState = AIState.Exterminate; } if (triggeredOutcome.UnlockTech != null) { if (!Triggerer.GetTDict()[triggeredOutcome.UnlockTech].Unlocked) { Triggerer.UnlockTech(triggeredOutcome.UnlockTech); } else { triggeredOutcome.WeHadIt = true; } } if (triggeredOutcome.RemoveTrigger) { p.BuildingList.Remove(eventLocation.building); eventLocation.building = null; } if (!string.IsNullOrEmpty(triggeredOutcome.ReplaceWith)) { eventLocation.building = ResourceManager.GetBuilding(triggeredOutcome.ReplaceWith); p.BuildingList.Add(eventLocation.building); } Empire money = Triggerer; money.Money = money.Money + (float)triggeredOutcome.MoneyGranted; RacialTrait racialTrait = Triggerer.data.Traits; racialTrait.ResearchMod = racialTrait.ResearchMod + triggeredOutcome.ScienceBonus; RacialTrait traits1 = Triggerer.data.Traits; traits1.ProductionMod = traits1.ProductionMod + triggeredOutcome.IndustryBonus; if (triggeredOutcome.TroopsGranted != null) { foreach (string troopname in triggeredOutcome.TroopsGranted) { Troop t = ResourceManager.CreateTroop(ResourceManager.TroopsDict[troopname], Triggerer); t.SetOwner(Triggerer); if (p.AssignTroopToNearestAvailableTile(t, eventLocation)) { continue; } p.AssignTroopToTile(t); } } if (triggeredOutcome.TroopsToSpawn != null) { foreach (string troopname in triggeredOutcome.TroopsToSpawn) { Troop t = ResourceManager.CreateTroop(ResourceManager.TroopsDict[troopname], EmpireManager.GetEmpireByName("Unknown")); t.SetOwner(EmpireManager.GetEmpireByName("Unknown")); if (p.AssignTroopToNearestAvailableTile(t, eventLocation)) { continue; } p.AssignTroopToTile(t); } } } if (Triggerer == PlayerEmpire) { screen.ScreenManager.AddScreen(new EventPopup(screen, PlayerEmpire, this, triggeredOutcome)); AudioManager.PlayCue("sd_notify_alert"); } }
private Empire CreateEmpireFromEmpireSaveData(SavedGame.EmpireSaveData data) { Empire e = new Empire(); //TempEmpireData Tdata = new TempEmpireData(); if (data.IsFaction) { e.isFaction = true; } if (data.isMinorRace) { e.MinorRace = true; } if (data.empireData == null) { e.data.Traits = data.Traits; e.EmpireColor = new Color((byte)data.Traits.R, (byte)data.Traits.G, (byte)data.Traits.B); } else { e.data = new EmpireData(); //Tdata = data.empireData as TempEmpireData; foreach (string key in e.data.WeaponTags.Keys) { if(data.empireData.WeaponTags.ContainsKey(key)) continue; data.empireData.WeaponTags.Add(key,new WeaponTagModifier()); } e.data = data.empireData; // e.data. e.data.ResearchQueue = data.empireData.ResearchQueue; e.ResearchTopic = data.ResearchTopic; if (e.ResearchTopic == null) { e.ResearchTopic = ""; } e.dd = Ship_Game.ResourceManager.DDDict[e.data.DiplomacyDialogPath]; e.PortraitName = e.data.PortraitName; e.EmpireColor = new Color((byte)e.data.Traits.R, (byte)e.data.Traits.G, (byte)e.data.Traits.B); if (data.CurrentAutoScout != null) e.data.CurrentAutoScout = data.CurrentAutoScout; else e.data.CurrentAutoScout = e.data.StartingScout; if (data.CurrentAutoFreighter != null) e.data.CurrentAutoFreighter = data.CurrentAutoFreighter; else e.data.CurrentAutoFreighter = e.data.DefaultSmallTransport; if (data.CurrentAutoColony != null) e.data.CurrentAutoColony = data.CurrentAutoColony; else e.data.CurrentAutoColony = e.data.DefaultColonyShip; if (data.CurrentConstructor != null) e.data.CurrentConstructor = data.CurrentConstructor; else e.data.CurrentConstructor = e.data.DefaultConstructor; } e.Initialize(); e.Money = data.Money; e.Research = data.Research; e.GetGSAI().AreasOfOperations = data.AOs; foreach (TechEntry tech in data.TechTree) { if (!e.GetTDict().ContainsKey(tech.UID)) { continue; } if (tech.AcquiredFrom != null) e.GetTDict()[tech.UID].AcquiredFrom = tech.AcquiredFrom; if (tech.Unlocked) { e.UnlockTechFromSave(tech.UID); } e.GetTDict()[tech.UID].Progress = tech.Progress; e.GetTDict()[tech.UID].Discovered = tech.Discovered; e.GetTDict()[tech.UID].level = tech.level; } return e; }
public void AbsorbEmpire(Empire target) { foreach (Planet planet in target.GetPlanets()) { this.OwnedPlanets.Add(planet); planet.Owner = (Empire)null; planet.Owner = this; if (!planet.system.OwnerList.Contains(this)) { planet.system.OwnerList.Add(this); planet.system.OwnerList.Remove(target); } } foreach (KeyValuePair<Guid, SolarSystem> keyValuePair in Empire.universeScreen.SolarSystemDict) { foreach (Planet planet in keyValuePair.Value.PlanetList) { foreach (Troop troop in planet.TroopsHere) { if (troop.GetOwner() == target) troop.SetOwner(this); } } } target.GetPlanets().Clear(); foreach (Ship ship in (List<Ship>)target.GetShips()) { this.OwnedShips.Add(ship); ship.loyalty = this; ship.fleet = (Fleet)null; ship.GetAI().State = AIState.AwaitingOrders; ship.GetAI().OrderQueue.Clear(); } target.GetShips().Clear(); foreach (KeyValuePair<string, TechEntry> keyValuePair in target.GetTDict()) { if (keyValuePair.Value.Unlocked && !this.TechnologyDict[keyValuePair.Key].Unlocked) this.UnlockTech(keyValuePair.Key); } foreach (KeyValuePair<string, bool> keyValuePair in target.GetHDict()) { if (keyValuePair.Value) this.UnlockedHullsDict[keyValuePair.Key] = true; } foreach (KeyValuePair<string, bool> keyValuePair in target.GetTrDict()) { if (keyValuePair.Value) this.UnlockedTroopDict[keyValuePair.Key] = true; } foreach (Artifact artifact in target.data.OwnedArtifacts) { this.data.OwnedArtifacts.Add(artifact); this.AddArtifact(artifact); } target.data.OwnedArtifacts.Clear(); if ((double)target.Money > 0.0) { this.Money += target.Money; target.Money = 0.0f; } target.SetAsMerged(); this.ResetBorders(); this.UpdateShipsWeCanBuild(); if (this != EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)) { this.data.difficulty = Difficulty.Brutal; lock (GlobalStats.TaskLocker) { foreach (MilitaryTask item_7 in (List<MilitaryTask>)this.GSAI.TaskList) item_7.EndTask(); this.GSAI.TaskList.ApplyPendingRemovals(); } this.GSAI.DefensiveCoordinator.DefensiveForcePool.Clear(); this.GSAI.DefensiveCoordinator.DefenseDict.Clear(); this.ForcePool.Clear(); //foreach (Ship s in (List<Ship>)this.OwnedShips) //.OrderByDescending(experience=> experience.experience).ThenBy(strength=> strength.BaseStrength)) for (int i = 0; i < this.OwnedShips.Count; i++) { Ship s = ((List<Ship>)this.OwnedShips)[i]; //added by gremlin Do not include 0 strength ships in defensive force pool s.GetAI().OrderQueue.Clear(); s.GetAI().State = AIState.AwaitingOrders; this.ForcePoolAdd(s); } if (this.data.Traits.Cybernetic != 0) { foreach (Planet planet in this.OwnedPlanets) { List<Building> list = new List<Building>(); foreach (Building building in planet.BuildingList) { if ((double)building.PlusFlatFoodAmount > 0.0 || (double)building.PlusFoodPerColonist > 0.0 || (double)building.PlusTerraformPoints > 0.0) list.Add(building); } foreach (Building b in list) planet.ScrapBuilding(b); } } } foreach (Agent agent in (List<Agent>)target.data.AgentList) { this.data.AgentList.Add(agent); agent.Mission = AgentMission.Defending; agent.TargetEmpire = (string)null; } target.data.AgentList.Clear(); target.data.AbsorbedBy = this.data.Traits.Name; this.CalculateScore(); }