/* * 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 async Task <bool> ChangeHotSpot() { if (SpawnTimeout > 0 && DateTime.Now < startTime.AddSeconds(SpawnTimeout)) { return(false); } startTime = DateTime.Now; if (HotSpots != null) { if (!HotSpots.Next()) { Logger.Info(Localization.ExGather_FinishedLoop, ++loopCount, Loops); // If finished all loops, otherwise just incrementing loop count if (loopCount == Loops) { isDone = true; return(true); } // If not cyclic and it is on the last index if (!HotSpots.IsCyclic && HotSpots.Index == HotSpots.Count - 1) { HotSpots.Index = 0; } } } await Coroutine.Wait(2000, () => !Window <Gathering> .IsOpen && !GatheringMasterpiece.IsOpen); return(true); }
public override async Task <bool> MoveFromSpot(ExGatherTag tag) { tag.StatusText = "Moving from " + this; var result = true; if (ReturnToApproachLocation) { result &= await approachLocation.MoveToOnGround(); } #if RB_CN if (UnstealthAfter && Core.Player.HasAura((int)AbilityAura.Stealth)) { result &= await tag.CastAura(Ability.Stealth); } #else if (UnstealthAfter && Core.Player.HasAura((int)AbilityAura.Sneak)) { result &= await tag.CastAura(Ability.Sneak); } #endif //change the approach location for the next time we go to this node. approachLocation = HotSpots.Shuffle().First(); return(result); }
public int ReadFrom(byte[] Buffer, int StartIndex = 0) { int cursor = StartIndex; Width = BitConverter.ToUInt32(Buffer, cursor); cursor += TypeSizes.INT; Height = BitConverter.ToUInt32(Buffer, cursor); cursor += TypeSizes.INT; XOffset = BitConverter.ToInt32(Buffer, cursor); cursor += TypeSizes.INT; YOffset = BitConverter.ToInt32(Buffer, cursor); cursor += TypeSizes.INT; byte HotSpotCount = Buffer[cursor]; cursor++; HotSpots.Clear(); HotSpots.Capacity = HotSpotCount; for (int i = 0; i < HotSpotCount; i++) { BgfBitmapHotspot hotspot = new BgfBitmapHotspot(Buffer, cursor); cursor += hotspot.ByteLength; HotSpots.Add(hotspot); } isCompressed = BitConverter.ToBoolean(Buffer, cursor); cursor++; CompressedLength = BitConverter.ToInt32(Buffer, cursor); cursor += TypeSizes.INT; if (IsCompressed) { PixelData = new byte[CompressedLength]; Array.Copy(Buffer, cursor, PixelData, 0, CompressedLength); cursor += CompressedLength; } else { PixelData = new byte[UncompressedLength]; Array.Copy(Buffer, cursor, PixelData, 0, UncompressedLength); cursor += UncompressedLength; } return(ByteLength); }
public override async Task <bool> MoveToSpot(ExGatherTag tag) { tag.StatusText = "Moving to " + this; if (HotSpots == null || HotSpots.Count == 0) { return(false); } if (approachLocation == null) { approachLocation = HotSpots.Shuffle().First(); } var result = await approachLocation.MoveTo(dismountAtDestination : Stealth); if (!result) { return(false); } var landed = MovementManager.IsDiving || await NewNewLandingTask(); if (landed && Core.Player.IsMounted && !MovementManager.IsDiving) { ActionManager.Dismount(); } Navigator.Stop(); await Coroutine.Yield(); if (Stealth) { #if RB_CN await tag.CastAura(Ability.Stealth, AbilityAura.Stealth); #else await tag.CastAura(Ability.Sneak, AbilityAura.Sneak); #endif } result = await NodeLocation.MoveToOnGroundNoMount(tag.Distance, tag.Node.EnglishName, tag.MovementStopCallback); return(result); }
protected override void OnClick(ImageMapEventArgs e) { string[] args = e.PostBackValue.Split(':'); CurrentDepth = Convert.ToInt32(args[0]); CurrentCounty = String.Empty; CurrentCommunity = String.Empty; if (CurrentDepth == 0) { ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "HotSpotMapNorway.Fylker.jpg"); loadCountiesHotSpots(); } else if (CurrentDepth == 1) { CurrentCounty = args[1]; ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "HotSpotMapNorway." + CurrentCounty + ".jpg"); loadCountyHotSpots(); // The back hotspot PolygonHotSpot phs = new PolygonHotSpot(); phs.PostBackValue = "0"; phs.Coordinates = "0,0 20,0 20,20 0,20"; HotSpots.Add(phs); } else { CurrentCounty = args[1]; CurrentCommunity = args[2]; ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "HotSpotMapNorway." + CurrentCounty + ".jpg"); loadCountyHotSpots(); // The back hotspot PolygonHotSpot phs = new PolygonHotSpot(); phs.PostBackValue = "1:" + CurrentCounty; phs.Coordinates = "0,0 20,0 20,20 0,20"; HotSpots.Add(phs); } base.OnClick(e); }
public override async Task <bool> MoveFromSpot(ExGatherTag tag) { tag.StatusText = "Moving from " + this; var result = true; if (ReturnToApproachLocation) { result &= await approachLocation.MoveToNoMount(UseMesh, tag.MovementStopCallback); } if (UnstealthAfter && Core.Player.HasAura((int)AbilityAura.Stealth)) { result &= await tag.CastAura(Ability.Stealth); } //change the approach location for the next time we go to this node. approachLocation = HotSpots.Shuffle().First(); return(result); }
public override async Task <bool> MoveToSpot(ExGatherTag tag) { tag.StatusText = "Moving to " + this; if (approachLocation == Vector3.Zero) { if (HotSpots == null || HotSpots.Count == 0) { return(false); } approachLocation = HotSpots.Shuffle().First(); } var result = await approachLocation.MoveToPointWithin(dismountAtDestination : Stealth); if (result) { await Coroutine.Yield(); if (Stealth) { await tag.CastAura(Ability.Stealth, AbilityAura.Stealth); result = await NodeLocation.MoveToNoMount(UseMesh, tag.Distance, tag.Node.EnglishName, tag.MovementStopCallback); } else { result = await NodeLocation.MoveTo( UseMesh, radius : tag.Distance, name : tag.Node.EnglishName, stopCallback : tag.MovementStopCallback); } } return(result); }
protected void loadCountiesHotSpots() { HotSpots.Clear(); string hotSpotsXml = Page.ClientScript.GetWebResourceUrl(this.GetType(), "HotSpotMapNorway.HotSpots.xml"); hotSpotsXml = GetAbsolutePath(hotSpotsXml); XmlDocument hotSpots = new XmlDocument(); hotSpots.Load(hotSpotsXml); XmlNodeList nodes = hotSpots.SelectNodes("//county"); foreach (XmlElement node in nodes) { PolygonHotSpot phs = new PolygonHotSpot(); phs.PostBackValue = "1:" + node.GetAttribute("name"); phs.Coordinates = node.FirstChild.InnerText; HotSpots.Add(phs); } }
private static void Prefix() { LogDebug("OnDayPassed"); var starSystem = Globals.Sim.CurSystem; var contractEmployers = starSystem.Def.contractEmployerIDs; var contractTargets = starSystem.Def.contractTargetIDs; var owner = starSystem.OwnerValue; LogDebug($"{starSystem.Name} owned by {owner.Name}"); LogDebug($"Employers in {starSystem.Name}"); contractEmployers.Do(x => LogDebug($" {x}")); LogDebug($"Targets in {starSystem.Name}"); contractTargets.Do(x => LogDebug($" {x}")); Globals.Sim.GetAllCurrentlySelectableContracts().Do(x => LogDebug($"{x.Name,-25} {x.Difficulty} ({x.Override.GetUIDifficulty()})")); var systemStatus = Globals.WarStatusTracker.systems.Find(x => x.starSystem == starSystem); var employers = systemStatus.influenceTracker.OrderByDescending(x => x.Value).Select(x => x.Key).Take(2); foreach (var faction in Globals.Settings.IncludedFactions.Intersect(employers)) { LogDebug($"{faction} Enemies:"); FactionEnumeration.GetFactionByName(faction).factionDef?.Enemies.Distinct().Do(x => LogDebug($" {x}")); LogDebug($"{faction} Allies:"); FactionEnumeration.GetFactionByName(faction).factionDef?.Allies.Do(x => LogDebug($" {x}")); Log(""); } LogDebug("Player allies:"); foreach (var faction in Globals.Sim.AlliedFactions) { LogDebug($" {faction}"); } if (Globals.Sim.IsCampaign && !Globals.Sim.CompanyTags.Contains("story_complete")) { return; } Globals.WarStatusTracker.CurSystem = Globals.Sim.CurSystem.Name; if (Globals.WarStatusTracker.HotBox.Contains(Globals.Sim.CurSystem.Name) && !Globals.WarStatusTracker.HotBoxTravelling) { Globals.WarStatusTracker.EscalationDays--; if (!Globals.WarStatusTracker.Deployment) { if (Globals.WarStatusTracker.EscalationDays == 0) { HotSpots.CompleteEscalation(); } if (Globals.WarStatusTracker.EscalationOrder != null) { Globals.WarStatusTracker.EscalationOrder.PayCost(1); var activeItems = Globals.TaskTimelineWidget.ActiveItems; if (activeItems.TryGetValue(Globals.WarStatusTracker.EscalationOrder, out var taskManagementElement4)) { taskManagementElement4.UpdateItem(0); } } } else { if (Globals.WarStatusTracker.EscalationOrder != null) { Globals.WarStatusTracker.EscalationOrder.PayCost(1); var activeItems = Globals.TaskTimelineWidget.ActiveItems; if (activeItems.TryGetValue(Globals.WarStatusTracker.EscalationOrder, out var taskManagementElement4)) { taskManagementElement4.UpdateItem(0); } } if (Globals.WarStatusTracker.EscalationDays <= 0) { Globals.Sim.StopPlayMode(); Globals.Sim.CurSystem.activeSystemContracts.Clear(); Globals.Sim.CurSystem.activeSystemBreadcrumbs.Clear(); HotSpots.TemporaryFlip(Globals.Sim.CurSystem, Globals.WarStatusTracker.DeploymentEmployer); var maxHolder = Globals.Sim.CurSystem.CurMaxBreadcrumbs; var rand = Globals.Rng.Next(1, (int)Globals.Settings.DeploymentContracts); Traverse.Create(Globals.Sim.CurSystem).Property("CurMaxBreadcrumbs").SetValue(rand); Globals.Sim.GeneratePotentialContracts(true, null, Globals.Sim.CurSystem); Traverse.Create(Globals.Sim.CurSystem).Property("CurMaxBreadcrumbs").SetValue(maxHolder); Globals.Sim.QueueCompleteBreadcrumbProcess(true); Globals.SimGameInterruptManager.QueueTravelPauseNotification("New Mission", "Our Employer has launched an attack. We must take a mission to support their operation. Let's check out our contracts and get to it!", Globals.Sim.GetCrewPortrait(SimGameCrew.Crew_Darius), string.Empty, null, "Proceed"); } } } if (!Globals.WarStatusTracker.StartGameInitialized) { LogDebug("Reinitializing contracts because !StartGameInitialized"); var cmdCenter = Globals.Sim.RoomManager.CmdCenterRoom; Globals.Sim.CurSystem.GenerateInitialContracts(() => Traverse.Create(cmdCenter).Method("OnContractsFetched")); Globals.WarStatusTracker.StartGameInitialized = true; } }
public static void AllocateAttackResources(WarFaction warFaction) { int factionRep = -1; try { factionRep = Globals.Sim.GetRawReputation(Globals.FactionValues.Find(value => value.Name == warFaction.FactionName)); } catch (Exception ex) { LogDebug("warFaction.FactionName: " + warFaction.FactionName); Error(ex); } var maxContracts = HotSpots.ProcessReputation(factionRep); if (warFaction.WarFactionAttackResources.Count == 0) { return; } var warFactionAR = warFaction.WarFactionAttackResources; //Go through the different resources allocated from attacking faction to spend against each targetFaction var deathListTracker = warFaction.DeathListTracker; var attackFactions = warFactionAR.Keys.Intersect(warFaction.AttackTargets.Keys); foreach (var targetFaction in attackFactions) { var targetFar = warFactionAR[targetFaction]; var startingTargetFar = targetFar; var attackTargets = warFaction.AttackTargets[targetFaction]; var hatred = deathListTracker.DeathList[targetFaction]; var targetWarFaction = Globals.WarStatusTracker.WarFactionTracker.Find(x => x.FactionName == targetFaction); while (targetFar > 0 && attackTargets.Count > 0) { var systemStatus = attackTargets.GetRandomElement(); if (systemStatus.Owner == warFaction.FactionName || Globals.WarStatusTracker.FlashpointSystems.Contains(systemStatus.Name)) { attackTargets.Remove(systemStatus); return; } //Find most valuable target for attacking for later. Used in HotSpots. if (hatred >= Globals.Settings.PriorityHatred && systemStatus.DifficultyRating <= maxContracts && systemStatus.DifficultyRating >= maxContracts - 4) { systemStatus.PriorityAttack = true; if (!systemStatus.CurrentlyAttackedBy.Contains(warFaction.FactionName)) { systemStatus.CurrentlyAttackedBy.Add(warFaction.FactionName); } if (!Globals.WarStatusTracker.PrioritySystems.Contains(systemStatus.StarSystem.Name)) { Globals.WarStatusTracker.PrioritySystems.Add(systemStatus.StarSystem.Name); } } //Distribute attacking resources to systems. if (systemStatus.Contested || Globals.WarStatusTracker.HotBox.IsHot(systemStatus.Name)) { attackTargets.Remove(systemStatus); if (warFaction.AttackTargets[targetFaction].Count == 0 || !warFaction.AttackTargets.Keys.Contains(targetFaction)) { break; } continue; } var arFactor = Random.Range(Globals.Settings.MinimumResourceFactor, Globals.Settings.MaximumResourceFactor); var spendAR = Mathf.Min(startingTargetFar * arFactor, targetFar); spendAR = spendAR < 1 ? 1 : Math.Max(1 * Globals.SpendFactor, spendAR * Globals.SpendFactor); var maxValueList = systemStatus.InfluenceTracker.Values.OrderByDescending(x => x).ToList(); var pMaxValue = 200.0f; if (maxValueList.Count > 1) { pMaxValue = maxValueList[1]; } var itValue = systemStatus.InfluenceTracker[warFaction.FactionName]; var basicAR = (float)(11 - systemStatus.DifficultyRating) / 2; var bonusAR = 0f; if (itValue > pMaxValue) { bonusAR = (itValue - pMaxValue) * 0.15f; } var totalAR = basicAR + bonusAR + spendAR; if (targetFar > totalAR) { systemStatus.InfluenceTracker[warFaction.FactionName] += totalAR; targetFar -= totalAR; targetWarFaction.DefenseTargets.Add(systemStatus); } else { systemStatus.InfluenceTracker[warFaction.FactionName] += targetFar; targetFar = 0; targetWarFaction.DefenseTargets.Add(systemStatus); } } } }
//TODO go through this code. public static void AllocateAttackResources(WarFaction warFaction) { //contracts--code------- var factionRep = Globals.Sim.GetRawReputation(Globals.FactionValues.Find(x => x.Name == warFaction.faction)); var maxContracts = HotSpots.ProcessReputation(factionRep); //end------contracts---code----- if (warFaction.warFactionAttackResources.Count == 0) { return; } var warFactionAR = warFaction.warFactionAttackResources; //Go through the different resources allocated from attacking faction to spend against each targetFaction var deathListTracker = warFaction.DeathListTracker; foreach (var targetFaction in warFactionAR.Keys.Intersect(warFaction.attackTargets.Keys)) { var targetFar = warFactionAR[targetFaction]; //gets resources allocated to swing at other faction var startingTargetFar = targetFar; var attackTargets = warFaction.attackTargets[targetFaction]; //gets the list of systems names in combat with, of the currently selected faction // makes a list of systemStatus of the currents systems of the current faction this faction is at war with var map = new Dictionary <string, SystemStatus>(); foreach (var targetName in attackTargets) { map.Add(targetName, Globals.WarStatusTracker.systems.Find(x => x.name == targetName)); } var hatred = deathListTracker.deathList[targetFaction]; // I dont actualy know what the float is refering to for this, AR or DR ? // or something else entirely var targetWarFaction = Globals.WarStatusTracker.warFactionTracker.Find(x => x.faction == targetFaction); //gets opposong factions warfaction info // this loop keeps going untill the total amount of resources to use against the current enemy faction is exausted // targetFar is the total allocated resource while (targetFar > 0 && attackTargets.Count > 0) { // DE-CONSTRUCTOR! (string target, SystemStatus system) = map.GetRandomElement(); // gets a random system or a return value of null if (system == null) { Log("CRITICAL: No system found at AllocateAttackResources, aborting processing."); return; } //this looks like a filter check to catch anything that should not have gotten through, or is currently immune to war. if (system.owner == warFaction.faction || Globals.WarStatusTracker.FlashpointSystems.Contains(system.name)) { attackTargets.Remove(target); return; } //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); } } //Distribute attacking resources to systems. //TODO find out what triggers/flags the Contended status if (system.Contended || Globals.WarStatusTracker.HotBox.Contains(system.name)) { attackTargets.Remove(system.starSystem.Name); if (warFaction.attackTargets[targetFaction].Count == 0 || !warFaction.attackTargets.Keys.Contains(targetFaction)) { break; } continue; } var arFactor = Random.Range(Globals.Settings.MinimumResourceFactor, Globals.Settings.MaximumResourceFactor); // this calculates the total amount of resources the current system will get upto the the total amount that can potentially be // allocated to it. var spendAR = Mathf.Min(startingTargetFar * arFactor, targetFar); spendAR = spendAR < 1 ? 1 : Math.Max(1 * Globals.SpendFactor, spendAR * Globals.SpendFactor); //Spend factor could inflate value considerably //clamp that had been put in many places to try get rid of the crazy negative values. spendAR = Helpers.Clamp(spendAR, Globals.ResourceGenericMax); var maxValueList = system.influenceTracker.Values.OrderByDescending(x => x).ToList(); var pMaxValue = 200.0f; //What is P ? if (maxValueList.Count > 1) { pMaxValue = maxValueList[1]; //why 1 instead of 0 } var itValue = system.influenceTracker[warFaction.faction]; //should be a value between or equal to 0 and 100 var basicAR = (float)(11 - system.DifficultyRating) / 2; //I changed this from memory it was creating a much larger value and wasnt / 2 //just seemed like there was way to much inflation of values //almost like numbers were inflated so more weird dodgy math could be added to //try fix a problem. var bonusAR = 0f; if (itValue > pMaxValue) //either ive missed something or this code should never have to be called { bonusAR = (itValue - pMaxValue) * 0.15f; } var totalAR = basicAR + bonusAR + spendAR; // actuall amount of AR being swung at the current enemy system //looking back at things I modified this block of code originally not realising what it did. //from memory this one block, affects overaul influence way more then you would expect. if (targetFar > totalAR) { system.influenceTracker[warFaction.faction] += totalAR; //what i don't get is why boost the enemys influence by the amount of resources //they lose. It is possible that at the time i may have changed them to + //while trying to get rid of negative values. ahh yes because of the resource //system getting mangled and throwing massive negative values everywhere //influence was all over the place as well. targetFar -= totalAR; targetWarFaction.defenseTargets.Add(system.name); } else { system.influenceTracker[warFaction.faction] += targetFar; targetFar = 0; } } } }
public static void AllocateAttackResources(WarFaction warFaction) { var factionRep = Globals.Sim.GetRawReputation(Globals.FactionValues.Find(x => x.Name == warFaction.faction)); var maxContracts = HotSpots.ProcessReputation(factionRep); if (warFaction.warFactionAttackResources.Count == 0) { return; } var warFactionAR = warFaction.warFactionAttackResources; //Go through the different resources allocated from attacking faction to spend against each targetFaction var deathListTracker = warFaction.DeathListTracker; foreach (var targetFaction in warFactionAR.Keys.Intersect(warFaction.attackTargets.Keys)) { var targetFar = warFactionAR[targetFaction]; var startingTargetFar = targetFar; var attackTargets = warFaction.attackTargets[targetFaction]; var map = new Dictionary <string, SystemStatus>(); foreach (var targetName in attackTargets) { map.Add(targetName, Globals.WarStatusTracker.systems.Find(x => x.name == targetName)); } var hatred = deathListTracker.deathList[targetFaction]; var targetWarFaction = Globals.WarStatusTracker.warFactionTracker.Find(x => x.faction == targetFaction); while (targetFar > 0 && attackTargets.Count > 0) { // DE-CONSTRUCTOR! var(target, system) = map.GetRandomElement(); if (system == null) { Log("CRITICAL: No system found at AllocateAttackResources, aborting processing."); return; } if (system.owner == warFaction.faction || Globals.WarStatusTracker.FlashpointSystems.Contains(system.name)) { attackTargets.Remove(target); return; } //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; if (!system.CurrentlyAttackedBy.Contains(warFaction.faction)) { system.CurrentlyAttackedBy.Add(warFaction.faction); } if (!Globals.WarStatusTracker.PrioritySystems.Contains(system.starSystem.Name)) { Globals.WarStatusTracker.PrioritySystems.Add(system.starSystem.Name); } } //Distribute attacking resources to systems. if (system.Contended || Globals.WarStatusTracker.HotBox.Contains(system.name)) { attackTargets.Remove(system.starSystem.Name); if (warFaction.attackTargets[targetFaction].Count == 0 || !warFaction.attackTargets.Keys.Contains(targetFaction)) { break; } continue; } var arFactor = Random.Range(Globals.Settings.MinimumResourceFactor, Globals.Settings.MaximumResourceFactor); var spendAR = Mathf.Min(startingTargetFar * arFactor, targetFar); spendAR = spendAR < 1 ? 1 : Math.Max(1 * Globals.SpendFactor, spendAR * Globals.SpendFactor); var maxValueList = system.influenceTracker.Values.OrderByDescending(x => x).ToList(); var pMaxValue = 200.0f; if (maxValueList.Count > 1) { pMaxValue = maxValueList[1]; } var itValue = system.influenceTracker[warFaction.faction]; var basicAR = (float)(11 - system.DifficultyRating) / 2; var bonusAR = 0f; if (itValue > pMaxValue) { bonusAR = (itValue - pMaxValue) * 0.15f; } var totalAR = basicAR + bonusAR + spendAR; if (targetFar > totalAR) { system.influenceTracker[warFaction.faction] += totalAR; targetFar -= totalAR; targetWarFaction.defenseTargets.Add(system.name); } else { system.influenceTracker[warFaction.faction] += targetFar; targetFar = 0; } } } }