private static void Postfix(ToHit __instance, ref float __result, AbstractActor attacker, Weapon weapon, ICombatant target, Vector3 attackPosition, Vector3 targetPosition, LineOfFireLevel lofLevel, bool isCalledShot)
            {
                Pilot pilot = attacker.GetPilot();

                try {
                    Pilot TargetPilot = target.GetPilot();
                    if (TargetPilot.pilotDef.PilotTags.Contains("pilot_reckless"))
                    {
                        __result = __result + (float)settings.pilot_reckless_ToBeHitBonus;
                    }
                    if (TargetPilot.pilotDef.PilotTags.Contains("pilot_cautious"))
                    {
                        __result = __result + (float)settings.pilot_reckless_ToBeHitBonus;
                    }
                    if (TargetPilot.pilotDef.PilotTags.Contains("pilot_jinxed"))
                    {
                        __result = __result + (float)settings.pilot_jinxed_ToBeHitBonus;
                    }
                    if (TargetPilot.pilotDef.PilotTags.Contains("pilot_jinxed"))
                    {
                        __result = __result + (float)settings.pilot_reckless_ToBeHitBonus;
                    }
                }
                catch (Exception) {
                }
                if (pilot.pilotDef.PilotTags.Contains("pilot_reckless"))
                {
                    __result = __result + (float)settings.pilot_reckless_ToHitBonus;
                }
                if (pilot.pilotDef.PilotTags.Contains("pilot_cautious"))
                {
                    __result = __result + (float)settings.pilot_reckless_ToHitBonus;
                }
                if (pilot.pilotDef.PilotTags.Contains("pilot_drunk") && pilot.pilotDef.TimeoutRemaining > 0)
                {
                    __result = __result + (float)settings.pilot_drunk_ToHitBonus;
                }
                if (pilot.pilotDef.PilotTags.Contains("pilot_lostech") && weapon.componentDef.ComponentTags.Contains("component_type_lostech"))
                {
                    __result = __result + (float)settings.pilot_lostech_ToHitBonus;
                }
            }
Exemplo n.º 2
0
        private static string TeamAndCallsign(ICombatant who)
        {
            if (who == null)
            {
                return("null" + Separator + "null" + Separator + "null" + Separator);
            }
            Team   team = who.team;
            string teamName;

            if (team == null)
            {
                teamName = "null";
            }
            else if (team.IsLocalPlayer)
            {
                teamName = "Player";
            }
            else if (team.IsEnemy(Combat.LocalPlayerTeam))
            {
                teamName = "OpFor";
            }
            else if (team.IsFriendly(Combat.LocalPlayerTeam))
            {
                teamName = "Allies";
            }
            else
            {
                teamName = "NPC";
            }
            teamName += Separator;
            if (who is Building)
            {
                teamName += "Building";
            }
            else
            {
                teamName += who.GetPilot()?.Callsign ?? (who as AbstractActor)?.Nickname ?? who.DisplayName;
            }
            teamName += Separator;
            return(teamName + who.DisplayName + Separator);
        }
            public static void Postfix(EffectManager __instance, EffectData effectData, ICombatant creator, ICombatant target)
            {
                var p = creator.GetPilot();


                //              var effectsList = Traverse.Create(__instance).Field("effects").GetValue<List<Effect>>();
                //              var effectsList = __instance.GetAllEffectsCreatedBy(creator.GUID);


                ////////////////////no double dipping

                if (ModInit.modSettings.reUseRestrictedbonusEffects_XP.ContainsKey(effectData?.Description?.Id ?? "UNUSED") &&
                    !reUseRestricted)
                {
                    var effectXP = ModInit.modSettings.reUseRestrictedbonusEffects_XP[effectData?.Description?.Id];

                    var stat = p.StatCollection.GetStatistic("effectXP");
                    p.StatCollection.Int_Add(stat, effectXP);
                    ModInit.modLog.LogMessage($"No existing effect {effectData?.Description?.Id} from {creator.GetPilot()?.Description?.Callsign} targeting {target?.Description?.UIName}. Adding {effectXP} to {creator.GetPilot()?.Description?.Callsign}'s 'effectXP' pilot stat. No double-dipping until effect expires.");
                    return;
                }

                if (effectData?.effectType == EffectType.StatisticEffect && ModInit.modSettings.reUseRestrictedbonusEffects_XP.ContainsKey(effectData.statisticData?.statName ?? "UNUSED") &&
                    !reUseRestricted)

                {
                    var effectXP = ModInit.modSettings.reUseRestrictedbonusEffects_XP[effectData.statisticData?.statName];

                    var stat = p.StatCollection.GetStatistic("effectXP");
                    p.StatCollection.Int_Add(stat, effectXP);
                    ModInit.modLog.LogMessage($"No existing effect {effectData.statisticData?.statName} from {creator.GetPilot()?.Description?.Callsign} targeting {target?.Description?.UIName}. Adding {effectXP} to {creator.GetPilot()?.Description?.Callsign}'s 'effectXP' pilot stat. No double-dipping until effect expires.");
                    return;
                }

                ////////////////////////////degraded double dipping

                if (ModInit.modSettings.degradingbonusEffects_XP.ContainsKey(effectData?.Description?.Id ?? "UNUSED"))
                {
                    var effectXP = ModInit.modSettings.degradingbonusEffects_XP[effectData?.Description?.Id];

                    var degradationFactor = 1;
                    //use degFactor to apply sloppy seconds to XP bonus
                    if (reUseDegrades)
                    {
                        degradationFactor = new int[]
                        {
                            appliedEffect.Duration.numActivationsRemaining,
                            appliedEffect.Duration.numMovementsRemaining,
                            appliedEffect.Duration.numPhasesRemaining,
                            appliedEffect.Duration.numRoundsRemaining
                        }.Max() + 1;
                    }

                    ModInit.modLog.LogMessage($"Matching effect found: {effectData?.Description?.Id} from {creator.GetPilot().Description.Callsign} targeting {target?.Description?.UIName}. Adding {effectXP}/{degradationFactor} = {effectXP / degradationFactor} to {creator.GetPilot().Description.Callsign}'s 'effectXP' pilot stat. Degraded double-dip: more XP closer to effect expiration.");
                    effectXP /= degradationFactor;

                    var stat = p.StatCollection.GetStatistic("effectXP");
                    p.StatCollection.Int_Add(stat, effectXP);

                    return;
                }

                if (effectData?.effectType == EffectType.StatisticEffect && ModInit.modSettings.degradingbonusEffects_XP.ContainsKey(effectData.statisticData?.statName ?? "UNUSED"))

                {
                    var effectXP = ModInit.modSettings.degradingbonusEffects_XP[effectData.statisticData?.statName];

                    var degradationFactor = 1;
                    //use degFactor to apply sloppy seconds to XP bonus
                    if (reUseDegrades)
                    {
                        degradationFactor = new int[]
                        {
                            appliedEffect.Duration.numActivationsRemaining,
                            appliedEffect.Duration.numMovementsRemaining,
                            appliedEffect.Duration.numPhasesRemaining,
                            appliedEffect.Duration.numRoundsRemaining
                        }.Max() + 1;
                    }

                    ModInit.modLog.LogMessage($"Matching effect found: {effectData.statisticData?.statName} from {creator.GetPilot().Description.Callsign} targeting {target?.Description?.UIName}. Adding {effectXP}/{degradationFactor} = {effectXP / degradationFactor} to {creator.GetPilot().Description.Callsign}'s 'effectXP' pilot stat. Degraded double-dip: more XP closer to effect expiration.");
                    effectXP /= degradationFactor;

                    var stat = p.StatCollection.GetStatistic("effectXP");
                    p.StatCollection.Int_Add(stat, effectXP);

                    return;
                }

                ////////////////////////when i dip you dip we dip
                else
                {
                    if (ModInit.modSettings.bonusEffects_XP.ContainsKey(effectData?.Description?.Id ?? "UNUSED"))
                    {
                        var effectXP = ModInit.modSettings.bonusEffects_XP[effectData?.Description?.Id];
                        ModInit.modLog.LogMessage($"Adding {effectXP} to {creator.GetPilot().Description.Callsign}'s 'effectXP' pilot stat for applying {effectData?.Description?.Id} to {target?.Description?.UIName}. No restrictions on double-dipping.");

                        var stat = p.StatCollection.GetStatistic("effectXP");
                        p.StatCollection.Int_Add(stat, effectXP);
                        return;
                    }

                    if (effectData?.effectType != EffectType.StatisticEffect ||
                        !ModInit.modSettings.bonusEffects_XP.ContainsKey(effectData.statisticData?.statName))
                    {
                        return;
                    }
                    {
                        var effectXP = ModInit.modSettings.bonusEffects_XP[effectData.statisticData?.statName];
                        ModInit.modLog.LogMessage($"Adding {effectXP} to {creator.GetPilot().Description.Callsign}'s 'effectXP' pilot stat for applying {effectData.statisticData?.statName} to {target?.Description?.UIName}. No restrictions on double-dipping.");
                        var stat = p.StatCollection.GetStatistic("effectXP");
                        p.StatCollection.Int_Add(stat, effectXP);
                    }
                }
            }
            public static void Prefix(EffectManager __instance, EffectData effectData, ICombatant creator, ICombatant target)
            {
                {
                    effectsList = __instance.GetAllEffectsCreatedBy(creator.GUID);
                    if (effectsList.Count > 0)
                    {
                        appliedEffect =
                            effectsList.FirstOrDefault(x => x.EffectData == effectData && x.Target == target);

                        if (ModInit.modSettings.reUseRestrictedbonusEffects_XP.ContainsKey(effectData?.Description?.Id ?? "UNUSED") ||
                            ModInit.modSettings.reUseRestrictedbonusEffects_XP.ContainsKey(
                                effectData?.statisticData?.statName ?? "UNUSED"))
                        {
                            reUseRestricted = effectsList.Any(x => x.EffectData == effectData && x.Target == target);
                            ModInit.modLog.LogMessage(
                                $"Matching effect found: {effectData?.Description?.Id} from {creator.GetPilot()?.Description?.Callsign} targeting {target?.Description?.UIName}. No double-dipping!");
                        }

                        else if (ModInit.modSettings.degradingbonusEffects_XP.ContainsKey(effectData?.Description?.Id ?? "UNUSED") ||
                                 ModInit.modSettings.degradingbonusEffects_XP.ContainsKey(
                                     effectData?.statisticData?.statName ?? "UNUSED"))
                        {
                            reUseDegrades = effectsList.Any(x => x?.EffectData == effectData && x?.Target == target);
                            ModInit.modLog.LogMessage(
                                $"Matching effect found: {effectData?.Description?.Id} from {creator.GetPilot()?.Description?.Callsign} targeting {target?.Description?.UIName}. Applying degraded double-dipping!");
                        }
                    }
                }
            }
Exemplo n.º 5
0
            public static void Prefix(AttackDirector __instance, AbstractActor attacker, ICombatant target)
            {
                try
                {
                    if (attacker == null || target == null)
                    {
                        return;
                    }

                    if (attacker.team.IsLocalPlayer)
                    {
                        //    opforUnit = target.GetPilot().ParentActor;
                        if ((target.UnitType & UnitType.Building) != 0)
                        {
                            SpecManager.ManagerInstance.GatherAndApplyActiveBuildingSpecEffects(attacker, target);
                            return;
                        }

                        foreach (var encounterObjectGameLogic in attacker.Combat.EncounterLayerData.encounterObjectGameLogicList)
                        {
                            if (encounterObjectGameLogic as DefendLanceWithEscapeChunkGameLogic != null)
                            {
                                var encounterAsChunk = encounterObjectGameLogic as DefendLanceWithEscapeChunkGameLogic;
                                var encounterAsOGL   = encounterAsChunk.ensureUnitsSurviveObjective.encounterObject;
                                if (Traverse.Create(encounterAsOGL).Property("IsContractObjectivePrimary").GetValue <bool>())
                                {
                                    ModInit.modLog.LogMessage($"Checking for primary target unit.");
                                    if (encounterAsOGL.GetTargetUnits().Contains(target))
                                    {
                                        ModInit.modLog.LogMessage($"Primary target found.");
                                        SpecManager.ManagerInstance.GatherAndApplyActivePrimarySpecEffects(attacker,
                                                                                                           target);
                                        return;
                                    }
                                }
                            }
                            else if (encounterObjectGameLogic as DefendXUnitsChunkGameLogic != null)
                            {
                                var encounterAsChunk = encounterObjectGameLogic as DefendXUnitsChunkGameLogic;
                                var encounterAsOGL   = encounterAsChunk.defendXUnitsObjective.encounterObject;
                                if (Traverse.Create(encounterAsOGL).Property("IsContractObjectivePrimary").GetValue <bool>())
                                {
                                    ModInit.modLog.LogMessage($"Checking for primary target unit.");
                                    if (encounterAsOGL.GetTargetUnits().Contains(target))
                                    {
                                        ModInit.modLog.LogMessage($"Primary target found.");
                                        SpecManager.ManagerInstance.GatherAndApplyActivePrimarySpecEffects(attacker,
                                                                                                           target);
                                        return;
                                    }
                                }
                            }
                            else if (encounterObjectGameLogic as DestroyXUnitsChunkGameLogic != null)
                            {
                                var encounterAsChunk = encounterObjectGameLogic as DestroyXUnitsChunkGameLogic;
                                var encounterAsOGL   = encounterAsChunk.destroyXUnitsObjective.encounterObject;
                                if (Traverse.Create(encounterAsOGL).Property("IsContractObjectivePrimary").GetValue <bool>())
                                {
                                    ModInit.modLog.LogMessage($"Checking for primary target unit.");
                                    if (encounterAsOGL.GetTargetUnits().Contains(target))
                                    {
                                        ModInit.modLog.LogMessage($"Primary target found.");
                                        SpecManager.ManagerInstance.GatherAndApplyActivePrimarySpecEffects(attacker,
                                                                                                           target);
                                        return;
                                    }
                                }
                            }

                            var opforUnit = target.GetPilot().ParentActor;
                            SpecManager.ManagerInstance.GatherAndApplyActiveSpecEffects(attacker, opforUnit);
                        }
                    }
                    else if (target.team.IsLocalPlayer)
                    {
                        var playerUnit = target.GetPilot().ParentActor;
                        SpecManager.ManagerInstance.GatherAndApplyGlobalEffects(attacker, target);
                        //                        ModInit.modLog.LogMessage($"Attacker is opfor {attacker.DisplayName}, target is player unit {playerUnit.GetPilot().Callsign}.");
                        SpecManager.ManagerInstance.GatherAndApplyActiveSpecEffects(playerUnit, attacker);
                    }
                    else
                    {
                        ModInit.modLog.LogMessage($"Should be menage a trois.");
                        SpecManager.ManagerInstance.GatherAndApplyGlobalEffects(attacker, target);
                    }



                    //var HUD = Traverse.Create(__instance).Property("HUD").GetValue<CombatHUD>();
                    //Traverse.Create(HUD).Method("updateHUDElements", ___displayedActor);
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
            }