internal void DistributeGold() { Party party = LegacyLogic.Instance.WorldManager.Party; if (party != null && Random.Value < m_dropGoldChance) { Int32 num = m_dropGoldAmount.Random(); if (LegacyLogic.Instance.WorldManager.Difficulty == EDifficulty.HARD) { num = (Int32)(num * 0.75f); } if (num > 0) { NpcEffect npcEffect; if (party.HirelingHandler.HasEffect(ETargetCondition.HIRE_BONUSGF, out npcEffect) && npcEffect.TargetEffect != ETargetCondition.NONE) { num = (Int32)Math.Round(num * (1f + npcEffect.EffectValue), MidpointRounding.AwayFromZero); } party.ChangeGold(num); if (m_monster != null) { MonsterLootEntryEventArgs monsterLootEntryEventArgs = new MonsterLootEntryEventArgs(m_monster); monsterLootEntryEventArgs.Gold = num; m_monsterLootEntries.Add(monsterLootEntryEventArgs); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.PARTY_GET_LOOT, monsterLootEntryEventArgs); } else if (m_quest != null) { QuestLootEntryEventArgs questLootEntryEventArgs = new QuestLootEntryEventArgs(m_quest); questLootEntryEventArgs.Gold = num; LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.PARTY_GET_LOOT, questLootEntryEventArgs); } } } }
private void OnGetLoot(Object sender, EventArgs p_args) { if (p_args is MonsterLootEntryEventArgs) { MonsterLootEntryEventArgs monsterLootEntryEventArgs = (MonsterLootEntryEventArgs)p_args; AddLoot(monsterLootEntryEventArgs.Gold, monsterLootEntryEventArgs.Item); } if (p_args is ChestLootEventArgs) { ChestLootEventArgs chestLootEventArgs = (ChestLootEventArgs)p_args; LegacyLogic.Instance.ActionLog.PushEntry(chestLootEventArgs); if (chestLootEventArgs.Gold > 0) { AddLoot(chestLootEventArgs.Gold, null); } if (chestLootEventArgs.Items != null) { foreach (BaseItem item in chestLootEventArgs.Items) { AddLoot(0, item); } } } if (p_args is QuestLootEntryEventArgs) { QuestLootEntryEventArgs questLootEntryEventArgs = (QuestLootEntryEventArgs)p_args; LegacyLogic.Instance.ActionLog.PushEntry(questLootEntryEventArgs); foreach (Character character in LegacyLogic.Instance.WorldManager.Party.Members) { if (character != null) { character.FlushRewardsActionLog(); } } if (questLootEntryEventArgs.Gold != 0) { AddLoot(questLootEntryEventArgs.Gold, null); } if (questLootEntryEventArgs.Item != null) { AddLoot(0, questLootEntryEventArgs.Item); } } }
internal void DropItem(BaseItem p_item) { Party party = LegacyLogic.Instance.WorldManager.Party; if (party != null && p_item != null) { PartyInventoryController partyInventoryController = party.Inventory; if (!partyInventoryController.CanAddItem(p_item)) { partyInventoryController = (PartyInventoryController)party.GetOtherInventory(partyInventoryController); } if (partyInventoryController.CanAddItem(p_item)) { if (p_item is Equipment) { LegacyLogic.Instance.WorldManager.HintManager.TriggerHint(EHintType.EQUIPMENT); } partyInventoryController.AddItem(p_item); if (p_item is Equipment && !((Equipment)p_item).Identified && !((Equipment)p_item).IsRelic()) { LegacyLogic.Instance.CharacterBarkHandler.RandomPartyMemberBark(EBarks.UNIDENTIFIED_ITEM); } if (p_item is Equipment && ((Equipment)p_item).IsRelic()) { LegacyLogic.Instance.CharacterBarkHandler.RandomPartyMemberBark(EBarks.RELIC); } if (m_monster != null) { MonsterLootEntryEventArgs monsterLootEntryEventArgs = new MonsterLootEntryEventArgs(m_monster); monsterLootEntryEventArgs.Item = p_item; m_monsterLootEntries.Add(monsterLootEntryEventArgs); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.PARTY_GET_LOOT, monsterLootEntryEventArgs); } else if (m_quest != null) { QuestLootEntryEventArgs questLootEntryEventArgs = new QuestLootEntryEventArgs(m_quest); questLootEntryEventArgs.Item = p_item; LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.PARTY_GET_LOOT, questLootEntryEventArgs); } } else if (m_monster != null || m_quest != null) { if (!m_inventoryFullBarkTriggered) { m_inventoryFullBarkTriggered = true; LegacyLogic.Instance.CharacterBarkHandler.RandomPartyMemberBark(EBarks.INVENTORY_FULL); } GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position); List <InteractiveObject> passiveInteractiveObjects = slot.GetPassiveInteractiveObjects(EDirection.CENTER, false, false, false); Container container = null; foreach (InteractiveObject interactiveObject in passiveInteractiveObjects) { Container container2 = interactiveObject as Container; if (container2 != null && container2.ContainerType == EContainerType.LOOT_BAG) { container = container2; break; } } if (container == null) { Int32 nextDynamicSpawnID = LegacyLogic.Instance.WorldManager.GetNextDynamicSpawnID(); SpawnCommand spawnCommand = new SpawnCommand(); spawnCommand.Type = EInteraction.OPEN_CONTAINER; spawnCommand.Precondition = "NONE"; spawnCommand.Timing = EInteractionTiming.ON_EXECUTE; spawnCommand.RequiredState = EInteractiveObjectState.NONE; spawnCommand.ActivateCount = -1; spawnCommand.TargetSpawnID = nextDynamicSpawnID; container = new Container(8, nextDynamicSpawnID); container.Location = EDirection.CENTER; container.Position = party.Position; container.Prefab = "Prefabs/InteractiveObjects/LootContainer/Lootbag/Lootbag"; container.Commands.Add(spawnCommand); container.ContainerType = EContainerType.LOOT_BAG; slot.AddInteractiveObject(container); LegacyLogic.Instance.WorldManager.SpawnObject(container, party.Position); } container.Content.AddItem(p_item); if (m_monster != null) { LegacyLogic.Instance.ActionLog.PushEntry(new MonsterLootEntryEventArgs(m_monster)); } else if (m_quest != null) { LegacyLogic.Instance.ActionLog.PushEntry(new QuestLootEntryEventArgs(m_quest)); } } } }