コード例 #1
0
ファイル: LootOverhaul.cs プロジェクト: nwg5817/LootOverhaul
        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);
                }
            }
        }
コード例 #2
0
ファイル: LootOverhaul.cs プロジェクト: nwg5817/LootOverhaul
        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);
            }
        }