public override void OnAgentRemoved(
     Agent affectedAgent,
     Agent affectorAgent,
     AgentState agentState,
     KillingBlow killingBlow)
 {
 }
Esempio n. 2
0
 public override void OnAgentRemoved(
     Agent affectedAgent,
     Agent affectorAgent,
     AgentState agentState,
     KillingBlow blow)
 {
     if (affectedAgent.Team != null && affectedAgent.Character != null)
     {
         --this._agentCounts[(int)affectedAgent.Team.Side];
     }
     base.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow);
 }
 public override void OnAgentRemoved(
     Agent affectedAgent,
     Agent affectorAgent,
     AgentState agentState,
     KillingBlow killingBlow)
 {
     if (affectedAgent.Character == null || (affectorAgent?.Character == null || agentState != AgentState.Killed && agentState != AgentState.Unconscious || affectedAgent.Team == null))
     {
         return;
     }
     (float num1, float num2) = MissionGameModels.Current.BattleMoraleModel.CalculateMoraleChangeAfterAgentKilled(affectedAgent, affectorAgent, WeaponComponentData.GetRelevantSkillFromWeaponClass((WeaponClass)killingBlow.WeaponClass));
     if ((double)num1 == 0.0 && (double)num2 == 0.0)
     {
         return;
     }
     this.ApplyAoeMoraleEffect(affectedAgent, affectedAgent.GetWorldPosition(), affectorAgent.GetWorldPosition(), affectedAgent.Team, num1, num2, 10f);
 }
Esempio n. 4
0
 public static void Postfix(BattleAgentLogic __instance, Agent affectedAgent,
                            Agent affectorAgent,
                            AgentState agentState,
                            KillingBlow killingBlow)
 {
     if (affectedAgent != MissionSpawnAgentPatch.heroAgent)
     {
         AgentInitializeMissionEquipmentPatch.AgentOriginalWeaponSpeed.Remove(affectedAgent);
         MissionOnTickPatch.AgentRecoveryTimers.Remove(affectedAgent);
         MissionSpawnAgentPatch.CurrentStaminaPerAgent.Remove(affectedAgent);
         MissionSpawnAgentPatch.MaxStaminaPerAgent.Remove(affectedAgent);
     }
     else
     {
         // need to reset weapons' speeds on agent death
         MissionOnTickPatch.ChangeWeaponSpeedsHandler(affectedAgent, 1.0, false);
     }
 }
Esempio n. 5
0
 public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
 {
     if (blow.DamageType != DamageTypes.Invalid && (agentState == AgentState.Unconscious || agentState == AgentState.Killed) && affectedAgent.IsHuman)
     {
         if (affectorAgent != null && affectorAgent.IsEnemyOf(affectedAgent))
         {
             this._missionScoreboardComponent.ChangeTeamScore(affectorAgent.Team, this.GetScoreForKill(affectedAgent));
         }
         else
         {
             this._missionScoreboardComponent.ChangeTeamScore(affectedAgent.Team, -this.GetScoreForKill(affectedAgent));
         }
     }
 }
Esempio n. 6
0
        public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
        {
            if (!_config.AI.PersonalEffects.Enabled)
            {
                return;
            }
            if (Campaign.Current == null)
            {
                return;
            }
            if (affectedAgent.Character == null)
            {
                return;
            }
            if (!affectedAgent.IsHero)
            {
                return;
            }

            if (_personalDeathEffectAgentList.Contains(affectedAgent) && affectorAgent == Agent.Main)
            {
                try {
                    var killedHero = Hero.FindFirst(x => x.StringId == affectedAgent.Character.StringId);
                    var playerHero = Hero.FindFirst(x => x.StringId == affectorAgent.Character.StringId);

                    ChangeRelationAction.ApplyPlayerRelation(killedHero, _config.AI.PersonalEffects.RelationshipChange, false, true);
                    playerHero.Clan.AddRenown(_config.AI.PersonalEffects.RenownGain);

                    Helpers.Say("{=death_personal_effect}" + _strings.Lord.DeathPersonalEffect
                                .Replace("$NAME$", affectedAgent?.Name ?? "")
                                .Replace("$RENOWN$", _config.AI.PersonalEffects.RenownGain.ToString())
                                .Replace("$RELATIONSHIPHIT$", _config.AI.PersonalEffects.RelationshipChange.ToString()),
                                new Dictionary <string, TextObject> {
                        { "NAME", new TextObject(affectedAgent?.Name ?? "") },
                        { "RENOWN", new TextObject(_config.AI.PersonalEffects.RenownGain.ToString()) },
                        { "RELATIONSHIPHIT", new TextObject(_config.AI.PersonalEffects.RelationshipChange.ToString()) }
                    });
                } catch (Exception ex) {
                    if (_config.Cheering.DebugMode)
                    {
                        Helpers.Log($"{ex.Message}");
                        Helpers.Log($"{ex.StackTrace}");
                    }
                }
            }
        }
Esempio n. 7
0
        public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
        {
            if (Mission.Current.CombatType != Mission.MissionCombatType.Combat)
            {
                return;
            }
            if (affectedAgent == null)
            {
                return;
            }
            try
            {
                if ((affectedAgent.IsMainAgent == false && !affectedAgent.IsMount))
                {
                    //Don't get your companion equipment
                    if (affectedAgent.IsHero && affectedAgent.Team == Agent.Main.Team)
                    {
                        return;
                    }

                    for (int i = 0; i < 12; i++)
                    {
                        EquipmentIndex   equipmentIndex = (EquipmentIndex)i;
                        var              rdm            = MBRandom.RandomFloatRanged(BMRandomTweaksConfiguration.Instance.LootRandomMaxRoll);
                        EquipmentElement equipmentFromSlot;
                        if (rdm < PlayerDropRate) //Might as well use the player loot rate.  If player looses they get no loot anyway.
                        {
                            if (affectedAgent.Character.Equipment.GetEquipmentFromSlot(equipmentIndex).Item != null)
                            {
                                equipmentFromSlot = affectedAgent.Character.Equipment.GetEquipmentFromSlot(equipmentIndex);
                                if (!BMRandomTweaksConfiguration.Instance.HorseDropEnabled)
                                {
                                    if (equipmentFromSlot.Item.ItemType == ItemObject.ItemTypeEnum.HorseHarness ||
                                        equipmentFromSlot.Item.ItemType == ItemObject.ItemTypeEnum.Horse)
                                    {
                                        continue;
                                    }
                                }

                                float itemValue = equipmentFromSlot.Item.Value + 0.1f;
                                if (itemValue > 1.3f * PlayerMaxValue || itemValue < 0.8f * PlayerMaxValue)
                                {
                                    equipmentFromSlot = this.GetEquipmentWithModifier(equipmentFromSlot.Item, PlayerMaxValue / itemValue);
                                    itemValue         = equipmentFromSlot.ItemValue;
                                }
                                if (itemValue > PlayerMaxValue * 1.3f)
                                {
                                    float single = PlayerMaxValue / (Math.Max(PlayerMaxValue, itemValue));
                                    if (MBRandom.RandomFloatRanged(itemValue) < single)
                                    {
                                        LootedItems.Add(equipmentFromSlot);
                                    }
                                }
                                else
                                {
                                    LootedItems.Add(equipmentFromSlot);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Log("Error OnAgentRemoval");
                ErrorLog.Log(ex.ToStringFull());
            }
        }
Esempio n. 8
0
        public static void Postfix(Mission __instance, Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow killingBlow)
        {
            try
            {
                DropChance dc = new DropChance();

                if ((affectedAgent.IsMainAgent || affectedAgent.IsMount))
                {
                    return;
                }

                if (!affectedAgent.IsEnemyOf(Agent.Main))
                {
                    if (SubModule.debugEnabled)
                    {
                        SubModule.WriteDebugMessage("Killed an ally.");
                    }
                    if (!SubModule.LootAlliesEnabled)
                    {
                        return;
                    }
                }

                for (int index = 0; (long)index < (long)12; ++index)
                {
                    EquipmentIndex equipmentIndex = (EquipmentIndex)index;
                    if (new Random().NextDouble() < dc.CalculateChance())
                    {
                        EquipmentElement equipmentFromSlot = affectedAgent.Character.Equipment.GetEquipmentFromSlot(equipmentIndex);
                        if (equipmentFromSlot.Item != null)
                        {
                            equipmentFromSlot = affectedAgent.Character.Equipment.GetEquipmentFromSlot(equipmentIndex);
                            if (SubModule.debugEnabled)
                            {
                                //SubModule.WriteDebugMessage("debugMessage");
                            }
                            MapEvent.PlayerMapEvent.ItemRosterForPlayerLootShare(PartyBase.MainParty).AddToCounts(equipmentFromSlot.Item, 1, true);
                            SubModule.WriteDebugMessage(equipmentFromSlot.Item.Name.ToString() + " was looted!");
                        }
                    }
                    else
                    {
                        if (SubModule.debugEnabled)
                        {
                            SubModule.WriteDebugMessage("No Luck! " + (new Random().NextDouble() * 100).ToString("0.##") + "% vs. " + (dc.CalculateChance() * 100).ToString("0.##") + "%");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SubModule.WriteDebugMessage(ex.Message);
            }
        }
 public void GotKilled(Hero victimHero, Agent victimAgent, Hero attackerHero, Agent attackerAgent, AgentState agentState, KillingBlow blow)
 => OnGotKilled?.Invoke(victimHero, victimAgent, attackerHero, attackerAgent, agentState, blow);
Esempio n. 10
0
 public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow killingBlow)
 {
     if (affectedAgent.Character != null && ((affectorAgent != null) ? affectorAgent.Character : null) != null && (agentState == AgentState.Killed || agentState == AgentState.Unconscious) && affectedAgent.Team != null)
     {
         ValueTuple <float, float> valueTuple = MissionGameModels.Current.BattleMoraleModel.CalculateMoraleChangeAfterAgentKilled(affectedAgent, affectorAgent, WeaponComponentData.GetRelevantSkillFromWeaponClass((WeaponClass)killingBlow.WeaponClass));
         float item  = valueTuple.Item1;
         float item2 = valueTuple.Item2;
         if (item == 0f && item2 == 0f)
         {
             return;
         }
         this.ApplyAoeMoraleEffect(affectedAgent, affectedAgent.GetWorldPosition(), affectorAgent.GetWorldPosition(), affectedAgent.Team, item, item2, 10f, null, null);
     }
 }
Esempio n. 11
0
        public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
        {
            base.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow);

            if (!IsActivated)
            {
                return;
            }

            if (PlayerAgent != null && Utils.IsPlayerAlly(affectedAgent, PlayerAgent))
            {
                AllyAgentRemovedEvent?.Invoke(affectedAgent);
            }
        }
Esempio n. 12
0
        public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
        {
            base.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow);

            SwitchFreeCameraLogic.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow);
        }
Esempio n. 13
0
 public void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
 {
     affectedAgent.RemoveComponent(affectedAgent.GetComponent <CommandSystemAgentComponent>());
 }
Esempio n. 14
0
 public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
 {
     OnAgentDeleted(affectedAgent);
 }
Esempio n. 15
0
 public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow killingBlow)
 {
     if (!GameNetwork.IsClientOrReplay && !this.IsMatchEnded() && affectorAgent != null && affectedAgent != null && affectedAgent != affectorAgent && affectedAgent.IsHuman && affectorAgent.IsHuman && _match != null)
     {
         try
         {
             var p = _match.GetParticipant(affectorAgent.Origin.UniqueSeed);
             if (firstKiller == null)
             {
                 firstKiller = p;
             }
             achievements[p].NumberOfKills++;
         }
         catch { }
     }
 }
Esempio n. 16
0
 public override void OnEarlyAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
 {
     if (affectedAgent == Agent.Main)
     {
         _orderController.OnOrderIssued -= ReactToIssuedOrder;
         _orderController.OnSelectedFormationsChanged -= ReactToChangedFormations;
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Runs when any agent in mission is removed in some way. Includes mounts. Includes kills, but method also handles removal by other means.
        /// </summary>
        public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
        {
            try {
                if (!config.KillBased)
                {
                    return;
                }
                if (!blow.IsValid)
                {
                    return;
                }
                if (affectorAgent.Character == null || affectedAgent.Character == null)
                {
                    Say($"{affectorAgent.Name} isn't a character/is a mount.");
                    return;
                }
                if (config.OnlyNamedCharacters && !affectorAgent.IsHero)
                {
                    Say($"{affectorAgent.Name} isn't a hero.");
                    return;
                }
                if (config.PlayerOnly && !affectorAgent.IsPlayerControlled)
                {
                    Say($"{affectorAgent.Name} isn't a player.");
                    return;
                }
                if (config.ExcludeCavalry && affectorAgent.HasMount)
                {
                    Say($"{affectorAgent.Name} is mounted - no healing.");
                    return;
                }

                DoHealing(affectorAgent);
            } catch (Exception ex) { Say($"{ex.Message}"); return; };
        }
Esempio n. 18
0
        public static void Postfix(Mission __instance, Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow killingBlow)
        {
            try
            {
                if (MapEvent.PlayerMapEvent == null)
                {
                    return;
                }

                if ((affectedAgent.Character == PartyBase.MainParty.Leader || affectedAgent.IsMount))
                {
                    return;
                }

                if (affectorAgent == null && !LootOverhaulSettings.Instance.LootPanickedEnabled)
                {
                    SubModule.WriteDebug("Some coward has fleed...");
                    return;
                }

                if (affectedAgent.Team.IsPlayerAlly)
                {
                    if (affectorAgent.Character == PartyBase.MainParty.Leader)
                    {
                        SubModule.WriteDebug("You've killed an ally!", "Oops:");
                    }
                    if (!LootOverhaulSettings.Instance.LootAlliesEnabled)
                    {
                        return;
                    }
                }

                if (rng.NextDouble() < dc.CalculateChanceForUnit())
                {
                    int itemsLooted = 0;
                    foreach (EquipmentIndex ei in LootOverhaul.allowedSlotsToLoot.Shuffle())
                    {
                        EquipmentElement equipmentElement = affectedAgent.Character.Equipment.GetEquipmentFromSlot(ei);

                        if (equipmentElement.Item == null)
                        {
                            continue;
                        }

                        if (rng.NextDouble() > dc.CalculateChanceForItem())
                        {
                            continue;
                        }

                        LootOverhaul.Loot(equipmentElement.Item);
                        SubModule.WriteLootMessage(equipmentElement, !affectedAgent.Team.IsPlayerAlly);
                        itemsLooted++;

                        if (itemsLooted >= LootOverhaulSettings.Instance.MaxItemsPerUnit)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    string messageTitle = affectedAgent.Team.IsPlayerAlly ? "Allied unit:" : "Enemy unit:";
                    string message      = "No Luck! Will not be looted :(";

                    if (affectedAgent.Team.IsPlayerAlly && LootOverhaulSettings.Instance.LootAlliesEnabled)
                    {
                        SubModule.WriteDebug(message, messageTitle);
                    }

                    if (!affectedAgent.Team.IsPlayerAlly)
                    {
                        SubModule.WriteDebug(message, messageTitle);
                    }
                }
            }
            catch (Exception ex)
            {
                SubModule.WriteException(ex.Message);
            }
        }
Esempio n. 19
0
        public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
        {
            if (!enable)
            {
                return;
            }
            if (affectedAgent == null || affectorAgent == null || !affectorAgent.IsMainAgent || !affectorAgent.IsEnemyOf(affectedAgent) || affectedAgent.IsMount)
            {
                return;
            }
            float health = ((affectorAgent.Health + GameLoadConfiguration.healAmount < affectorAgent.HealthLimit) ? (affectorAgent.Health + GameLoadConfiguration.healAmount) : affectorAgent.HealthLimit);

            affectorAgent.Health = health;
            affectorAgent.UpdateAgentProperties();
            if (agentState == AgentState.Killed)
            {
                textHandler.kill();
            }
            else if (agentState == AgentState.Unconscious)
            {
                textHandler.stun();
            }
            textHandler.SetShowText(true);
        }
Esempio n. 20
0
 public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
 {
     _querySystemSubLogic.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow);
 }
Esempio n. 21
0
 public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
 {
     base.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow);
     _agentsToStopProcessing.Add(affectedAgent);
 }