Exemplo n.º 1
0
        public static void Postfix(PartyScreenLogic.PartyCommand command)
        {
            DropChance      dc         = new DropChance();
            double          dropChance = dc.CalculateChance();
            Random          random     = new Random();
            CharacterObject character  = command.Character;

            for (int index = 0; index < 12; ++index)
            {
                try
                {
                    if (random.NextDouble() < dropChance)
                    {
                        EquipmentElement equipmentElement = character.Equipment.GetEquipmentFromSlot((EquipmentIndex)index);
                        if (equipmentElement.Item != null)
                        {
                            ItemRoster itemRoster = PartyBase.MainParty.ItemRoster;
                            equipmentElement = character.Equipment.GetEquipmentFromSlot((EquipmentIndex)index);

                            itemRoster.AddToCounts(equipmentElement.Item, 1, true);

                            SubModule.WriteDebugMessage(equipmentElement.Item.Name.ToString() + " was looted");
                        }
                    }
                }
                catch (Exception ex)
                {
                    SubModule.WriteDebugMessage(ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        public static void WriteLootMessage(EquipmentElement _equipmentFromSlot, bool _isEnemy = true)
        {
            string message = _equipmentFromSlot.Item.Name.ToString();
            string side    = _isEnemy ? "enemy:" : "ally:";

            SubModule.WriteDebug(message, "Looted " + side, Color.FromUint(4282569842U));
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        public static void Loot(ItemObject _item, int number=1, bool removeDepleted=true, bool IsExecution=false)
        {
            if (_item == null)
            {
                SubModule.WriteException("Tried to loot a null item.");
                return;
            }

            if (IsExecution)
            {
                PartyBase.MainParty.ItemRoster.AddToCounts(_item, 1, true);
                return;
            }

            if (MapEvent.PlayerMapEvent!=null)
                MapEvent.PlayerMapEvent.ItemRosterForPlayerLootShare(PartyBase.MainParty).AddToCounts(_item, 1, true);
            
        }
Exemplo n.º 5
0
        public static void Postfix(PartyScreenLogic.PartyCommand command)
        {
            if (!LootOverhaulSettings.Instance.LootExecutedLords)
            {
                return;
            }

            CharacterObject  character = command.Character;
            EquipmentElement equipmentElement;

            int maxItemsToLoot = LootOverhaulSettings.Instance.ApplyItemPerUnitToLords? LootOverhaulSettings.Instance.MaxItemsPerUnit : 12;
            int itemsLooted    = 0;

            foreach (EquipmentIndex ei in LootOverhaul.allowedSlotsToLoot.Shuffle())
            {
                try
                {
                    if (itemsLooted >= maxItemsToLoot)
                    {
                        break;
                    }

                    equipmentElement = character.Equipment.GetEquipmentFromSlot(ei);
                    if (equipmentElement.Item == null)
                    {
                        continue;
                    }

                    LootExecuted(equipmentElement.Item);
                    SubModule.WriteLootMessage(equipmentElement);
                    itemsLooted++;
                }
                catch (Exception ex)
                {
                    SubModule.WriteException(ex.Message);
                }
            }
        }
Exemplo n.º 6
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);
            }
        }