Ejemplo n.º 1
0
        public override Boolean CanDoAction(Command p_command)
        {
            InteractCommand interactCommand = (InteractCommand)p_command;
            Position        position        = Party.Position;
            GridSlot        slot            = Grid.GetSlot(position);
            Boolean         flag            = interactCommand.Target != null;

            flag |= (Party.SelectedInteractiveObject != null);
            flag |= (slot.GetPassiveInteractiveObjects(Party.Direction, Party.HasSpotSecrets(), Party.HasClairvoyance(), false).Count > 0);
            return(flag | slot.GetPassiveInteractiveObjects(EDirection.CENTER, Party.HasSpotSecrets(), Party.HasClairvoyance(), false).Count > 0);
        }
Ejemplo n.º 2
0
        public override void DoAction(Command p_command)
        {
            InteractCommand interactCommand = (InteractCommand)p_command;

            if (interactCommand.Target != null)
            {
                if (interactCommand.Target.Type == EObjectType.COMMAND_CONTAINER || (interactCommand.Target.Type == EObjectType.DOOR && interactCommand.Target.State == EInteractiveObjectState.DOOR_OPEN))
                {
                    return;
                }
                LegacyLogic.Instance.UpdateManager.InteractionsActor.AddObject(interactCommand.Target);
            }
            else if (Party.SelectedInteractiveObject != null)
            {
                if (Party.SelectedInteractiveObject.Type == EObjectType.COMMAND_CONTAINER || (Party.SelectedInteractiveObject.Type == EObjectType.DOOR && Party.SelectedInteractiveObject.State == EInteractiveObjectState.DOOR_OPEN))
                {
                    return;
                }
                LegacyLogic.Instance.UpdateManager.InteractionsActor.AddObject(Party.SelectedInteractiveObject);
            }
            else
            {
                Position position = Party.Position;
                GridSlot slot     = Grid.GetSlot(position);
                List <InteractiveObject> passiveInteractiveObjects = slot.GetPassiveInteractiveObjects(Party.Direction, Party.HasSpotSecrets(), Party.HasClairvoyance(), false);
                passiveInteractiveObjects.AddRange(slot.GetPassiveInteractiveObjects(EDirection.CENTER, Party.HasSpotSecrets(), Party.HasClairvoyance(), false));
                if (passiveInteractiveObjects.Count > 0)
                {
                    for (Int32 i = passiveInteractiveObjects.Count - 1; i >= 0; i--)
                    {
                        if (passiveInteractiveObjects[i].Type == EObjectType.COMMAND_CONTAINER)
                        {
                            passiveInteractiveObjects.RemoveAt(i);
                        }
                    }
                    for (Int32 j = passiveInteractiveObjects.Count - 1; j >= 0; j--)
                    {
                        if (passiveInteractiveObjects[j].Type == EObjectType.DOOR && passiveInteractiveObjects[j].State == EInteractiveObjectState.DOOR_OPEN)
                        {
                            passiveInteractiveObjects.RemoveAt(j);
                        }
                    }
                    LegacyLogic.Instance.EventManager.InvokeEvent(null, EEventType.PASSIVE_INTERACTIVE_OBJECT_FOUND, new InteractiveObjectListEventArgs(passiveInteractiveObjects));
                    LegacyLogic.Instance.UpdateManager.InteractionsActor.AddObject(passiveInteractiveObjects);
                }
            }
        }
Ejemplo n.º 3
0
        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));
                    }
                }
            }
        }