/* * Not feeling too spectaculary well today, want to get this started though. * Will have to come back and do a lot of fixing at a guess. 03-24-2021 */ /****************************************************************************** * Made a method for this as it was sidelining me a bit. * * Finds the next most valuable system/target to attack * It is part of the old combat code that is buried in resources. * Yet it is pretty important. * ******************************************************************************/ internal void FindMostValubleTarget(SystemStatus system, DeathListTracker deathListTracker) { //contracts--code------- var factionRep = Globals.Sim.GetRawReputation(Globals.FactionValues.Find(x => x.Name == warFaction.faction)); var maxContracts = HotSpots.ProcessReputation(factionRep); //end------contracts---code----- //Hatred--------------------------this could almost just be a segment on it's own var hatred = deathListTracker.deathList[system.owner]; var targetWarFaction = Globals.WarStatusTracker.warFactionTracker.Find(x => x.faction == system.owner); //Continue from here have to go out. //Find most valuable target for attacking for later. Used in HotSpots.---------------------- if (hatred >= Globals.Settings.PriorityHatred && system.DifficultyRating <= maxContracts && system.DifficultyRating >= maxContracts - 4) { system.PriorityAttack = true; //another item i'm not so sure on, have to dig some to find out. if (!system.CurrentlyAttackedBy.Contains(warFaction.faction)) //does a check to see if the opposing system is currently beiing attacked { //by this faction system.CurrentlyAttackedBy.Add(warFaction.faction); } if (!Globals.WarStatusTracker.PrioritySystems.Contains(system.starSystem.Name)) { Globals.WarStatusTracker.PrioritySystems.Add(system.starSystem.Name); } } //end hatred-------------------------------------------------------------------------------- }
private static void AddNewStarSystems() { for (var index = 0; index < Globals.Sim.StarSystems.Count; index++) { var system = Globals.Sim.StarSystems[index]; if (Globals.Settings.ImmuneToWar.Contains(Globals.Sim.StarSystems[index].OwnerValue.Name) || Globals.WarStatusTracker.Systems.Any(x => x.StarSystem == system)) { continue; } LogDebug($"Trying to add {system.Name}, owner {system.OwnerValue.Name}."); var systemStatus = new SystemStatus(system, system.OwnerValue.Name); Globals.WarStatusTracker.Systems.Add(systemStatus); if (system.Tags.Contains("planet_other_pirate")) { Globals.WarStatusTracker.FullPirateSystems.Add(system.Name); PiratesAndLocals.FullPirateListSystems.Add(systemStatus); } if (system.Tags.Contains("planet_region_hyadesrim") && !Globals.WarStatusTracker.FlashpointSystems.Contains(system.Name) && (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "Locals")) { Globals.WarStatusTracker.HyadesRimGeneralPirateSystems.Add(system.Name); } } }
public Combat(string systemName, string faction, SystemStatus nSystems, Resource resource) { sysName = systemName; sysFaction = faction; sysResource = resource; warFaction = Globals.WarStatusTracker.warFactionTracker.Find(x => x.faction == sysFaction); }
/* * Thinking may just let systems do a full swing (everything they have atk * wise) above their base attack. * * Just to see what happens, im assumeing a lot of systems are going to have no defence afterwards. * Going to try a different approach to others being when a system attacks another * The attacking system loses attack resources and the defending system loses defence reources. * * atk vs atk could happen but def vs def makes no sense to me. atk vs def would be the most consistant. * best case scenario if the system swinging hits for more then the enemies def, check if the enemy has attack * and reduce that value first. or just do a check if TAr == 0 then go ham on the TDr * * Was thinking of having an overflow, havent thought of how to impliment it though. * But the idea is, when the enemy system has no resources if someone attacks it they get an overflow value * for their faction towards that system and that may get added * to the influence calculations in the influence class, when influence is processed. * * ^^ may not happen it is just an idea, currently just wiring everything to work. * */ internal void SpendAttackResources(SystemStatus system, float aRToAttackNeighborWith) { float excess = system.systemResources.AttackResources - aRToAttackNeighborWith; if (excess >= 0f) { //remove attack from neighbor systems attack and total resources. } else if (excess < 0 && system.systemResources.DefenceResources >= Math.Abs(excess)) { // set neighbors atk to 0 // subtract excess from neighbors defence resources // subtract aRToAttackNeighborWith from neighbors total resources } else { // set both neighbor atk and def values to zero // pretty sure im missing something here, need to have a break for a bit. //----------------Potential--------------influence-----idea-------will-not-be-coded-here---- // potential excess (invasion/occupying forces) to mess with. Not sure if this will be used. // maybe excess from factions gets compaired to each other (if there is more then one faction with excess) // the faction that has excess remaining gets an influence boost (remaining opposing factions in system duke it out) //-------------end------potential-----influence-----idea------------------------------------- } //remove attack from self and selfs total resources }
public WarStatus() { Logger.LogDebug("WarStatus ctor"); if (Globals.Settings.ISMCompatibility) { Globals.Settings.IncludedFactions = new List <string>(Globals.Settings.IncludedFactions_ISM); } CurSystem = Globals.Sim.CurSystem.Name; TempPRGain = 0; HotBoxTravelling = false; HotBox = new List <string>(); if (Globals.Settings.HyadesRimCompatible) { InactiveTHRFactions = Globals.Settings.HyadesAppearingPirates; FlashpointSystems = Globals.Settings.HyadesFlashpointSystems; NeverControl = Globals.Settings.HyadesNeverControl; } //initialize all WarFactions, DeathListTrackers, and SystemStatuses foreach (var faction in Globals.Settings.IncludedFactions) { var warFaction = new WarFaction(faction); var d = new DeathListTracker(faction) { WarFaction = warFaction }; warFaction.DeathListTracker = d; warFactionTracker.Add(warFaction); deathListTracker.Add(d); } foreach (var system in Globals.GaWSystems) { if (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "AuriganPirates") { AbandonedSystems.Add(system.Name); } var warFaction = warFactionTracker.Find(x => x.faction == system.OwnerValue.Name); if (Globals.Settings.DefensiveFactions.Contains(warFaction.faction) && Globals.Settings.DefendersUseARforDR) { warFaction.DefensiveResources += GetTotalAttackResources(system); } else { warFaction.AttackResources += GetTotalAttackResources(system); } warFaction.DefensiveResources += GetTotalDefensiveResources(system); } Logger.LogDebug("WarFaction AR/DR set."); var maxAR = warFactionTracker.Select(x => x.AttackResources).Max(); var maxDR = warFactionTracker.Select(x => x.DefensiveResources).Max(); foreach (var faction in Globals.Settings.IncludedFactions) { var warFaction = warFactionTracker.Find(x => x.faction == faction); if (Globals.Settings.DefensiveFactions.Contains(faction) && Globals.Settings.DefendersUseARforDR) { if (!Globals.Settings.ISMCompatibility) { warFaction.DefensiveResources = maxAR + maxDR + Globals.Settings.BonusAttackResources[faction] + Globals.Settings.BonusDefensiveResources[faction]; } else { warFaction.DefensiveResources = maxAR + maxDR + Globals.Settings.BonusAttackResources_ISM[faction] + Globals.Settings.BonusDefensiveResources_ISM[faction]; } warFaction.AttackResources = 0; } else { if (!Globals.Settings.ISMCompatibility) { warFaction.AttackResources = maxAR + Globals.Settings.BonusAttackResources[faction]; warFaction.DefensiveResources = maxDR + Globals.Settings.BonusDefensiveResources[faction]; } else { warFaction.AttackResources = maxAR + Globals.Settings.BonusAttackResources_ISM[faction]; warFaction.DefensiveResources = maxDR + Globals.Settings.BonusDefensiveResources_ISM[faction]; } } } Logger.LogDebug("WarFaction bonus AR/DR set."); if (!Globals.Settings.ISMCompatibility) { PirateResources = maxAR * Globals.Settings.FractionPirateResources + Globals.Settings.BonusPirateResources; } else { PirateResources = maxAR * Globals.Settings.FractionPirateResources_ISM + Globals.Settings.BonusPirateResources_ISM; } MinimumPirateResources = PirateResources; StartingPirateResources = PirateResources; Logger.LogDebug("SystemStatus mass creation..."); systems = new List <SystemStatus>(Globals.GaWSystems.Count); for (var index = 0; index < Globals.Sim.StarSystems.Count; index++) { var system = Globals.Sim.StarSystems[index]; if (Globals.Settings.ImmuneToWar.Contains(system.OwnerValue.Name)) { continue; } var systemStatus = new SystemStatus(system, system.OwnerValue.Name); systems.Add(systemStatus); if (system.Tags.Contains("planet_other_pirate") && !system.Tags.Contains("planet_region_hyadesrim")) { FullPirateSystems.Add(system.Name); PiratesAndLocals.FullPirateListSystems.Add(systemStatus); } if (system.Tags.Contains("planet_region_hyadesrim") && !FlashpointSystems.Contains(system.Name) && (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "Locals")) { HyadesRimGeneralPirateSystems.Add(system.Name); } } Logger.LogDebug("Full pirate systems created."); systems = systems.OrderBy(x => x.name).ToList(); systemsByResources = systems.OrderBy(x => x.TotalResources).ToList(); PrioritySystems = new List <string>(systems.Count); Logger.LogDebug("SystemStatus ordered lists created."); }
public WarStatus() { Logger.LogDebug("WarStatus ctor"); if (Globals.Settings.ISMCompatibility) { Globals.Settings.IncludedFactions = new List <string>(Globals.Settings.IncludedFactions_ISM); } CurSystem = Globals.Sim.CurSystem.Name; TempPRGain = 0; HotBoxTravelling = false; HotBox = new List <string>(); if (Globals.Settings.HyadesRimCompatible) { InactiveTHRFactions = Globals.Settings.HyadesAppearingPirates; FlashpointSystems = Globals.Settings.HyadesFlashpointSystems; NeverControl = Globals.Settings.HyadesNeverControl; } //initialize all WarFactions, DeathListTrackers, and SystemStatuses foreach (var faction in Globals.Settings.IncludedFactions) { var warFaction = new WarFaction(faction); var d = new DeathListTracker(faction) { WarFaction = warFaction }; warFaction.DeathListTracker = d; warFactionTracker.Add(warFaction); deathListTracker.Add(d); } foreach (var system in Globals.GaWSystems) { if (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "AuriganPirates") { AbandonedSystems.Add(system.Name); } var warFaction = warFactionTracker.Find(x => x.faction == system.OwnerValue.Name); /*if (Globals.Settings.DefensiveFactions.Contains(warFaction.faction) && Globals.Settings.DefendersUseARforDR) * warFaction.DefensiveResources += GetTotalAttackResources(system); * else*/ warFaction.AttackResources += GetTotalAttackResources(system); warFaction.DefensiveResources += GetTotalDefensiveResources(system); } Logger.LogDebug("WarFaction AR/DR set."); /*var maxAR = warFactionTracker.Select(x => x.AttackResources).Max(); * var maxDR = warFactionTracker.Select(x => x.DefensiveResources).Max(); * * foreach (var faction in Globals.Settings.IncludedFactions) * { * var warFaction = warFactionTracker.Find(x => x.faction == faction); * if (Globals.Settings.DefensiveFactions.Contains(faction) && Globals.Settings.DefendersUseARforDR) * { * if (!Globals.Settings.ISMCompatibility) * warFaction.DefensiveResources = maxAR + maxDR + Globals.Settings.BonusAttackResources[faction] + * Globals.Settings.BonusDefensiveResources[faction]; * else * warFaction.DefensiveResources = maxAR + maxDR + Globals.Settings.BonusAttackResources_ISM[faction] + * Globals.Settings.BonusDefensiveResources_ISM[faction]; * * warFaction.AttackResources = 0; * } * else * { * if (!Globals.Settings.ISMCompatibility) * { * warFaction.AttackResources = maxAR + Globals.Settings.BonusAttackResources[faction]; * warFaction.DefensiveResources = maxDR + Globals.Settings.BonusDefensiveResources[faction]; * } * else * { * warFaction.AttackResources = maxAR + Globals.Settings.BonusAttackResources_ISM[faction]; * warFaction.DefensiveResources = maxDR + Globals.Settings.BonusDefensiveResources_ISM[faction]; * } * } * }*/ Logger.LogDebug("WarFaction bonus AR/DR set."); /*if (!Globals.Settings.ISMCompatibility) * PirateResources = maxAR * Globals.Settings.FractionPirateResources + Globals.Settings.BonusPirateResources; * else * PirateResources = maxAR * Globals.Settings.FractionPirateResources_ISM + Globals.Settings.BonusPirateResources_ISM; * * MinimumPirateResources = PirateResources; * StartingPirateResources = PirateResources;*/ Logger.LogDebug("SystemStatus mass creation..."); systems = new List <SystemStatus>(Globals.GaWSystems.Count); for (var index = 0; index < Globals.Sim.StarSystems.Count; index++) { var system = Globals.Sim.StarSystems[index]; if (Globals.Settings.ImmuneToWar.Contains(system.OwnerValue.Name)) { continue; } SystemStatus systemStatus = new SystemStatus(system, system.OwnerValue.Name); //--new-block------------------------ systemStatus.absPosX = Math.Abs(0 - system.Position.x); systemStatus.absPosY = Math.Abs(0 - system.Position.y); systemStatus.systemsDistanceFromZero = (float)Math.Sqrt((systemStatus.absPosX * systemStatus.absPosX) + (systemStatus.absPosY * systemStatus.absPosY)); systems.Add(systemStatus); foreach (SystemStatus curSystem in systems) { curSystem.InitializeContracts(); } //---end-new-block------------------- if (system.Tags.Contains("planet_other_pirate") && !system.Tags.Contains("planet_region_hyadesrim")) { FullPirateSystems.Add(system.Name); PiratesAndLocals.FullPirateListSystems.Add(systemStatus); } if (system.Tags.Contains("planet_region_hyadesrim") && !FlashpointSystems.Contains(system.Name) && (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "Locals")) { HyadesRimGeneralPirateSystems.Add(system.Name); } } Logger.LogDebug("Full pirate systems created."); systems = systems.OrderBy(x => x.name).ToList(); systemsByResources = systems.OrderBy(x => x.systemResources.TotalResources).ToList(); PrioritySystems = new List <string>(systems.Count); /* * an attempt at sorting the systems in a way that is good for resource distrobution. * Sort by faction, then by systems distance from 0 (zero), decending. */ systems.Sort((f1, f2) => { int result = string.Compare(f1.owner, f2.owner, StringComparison.Ordinal); return(result == 0 ? f2.systemsDistanceFromZero.CompareTo(f1.systemsDistanceFromZero) : result); }); Logger.LogDebug("SystemStatus ordered lists created."); }
static public void Deconstruct(this KeyValuePair <string, SystemStatus> valuePair, out string target, out SystemStatus system) { target = valuePair.Key; system = valuePair.Value; }