示例#1
0
 private void OnDraggableClicked(RelicView relicView)
 {
     Unequip?.Invoke(this);
 }
示例#2
0
        public void UnequipActionCallsCorrectActorAction()
        {
            var action = new Unequip(_testPlayer, "");

            Assert.Equal("unequip", action.Do().ToString());
        }
示例#3
0
        public WorldModelDST(PreWorldState preWorldState)
        {
            this.Parent = null;

            this.Walter    = preWorldState.Walter;
            this.Cycle     = preWorldState.Cycle;
            this.CycleInfo = preWorldState.CycleInfo;

            //Getting Inventory from PreWorldState

            int size1 = preWorldState.Inventory.Count;

            this.PossessedItems = new List <Pair <string, int> >(size1);

            for (int i = 0; i < size1; i++)
            {
                Pair <string, int> tuple1 = new Pair <string, int>(preWorldState.Inventory[i].Item1, preWorldState.Inventory[i].Item3);
                this.PossessedItems.Add(tuple1);
            }

            //Getting Fuel items from PreWorldState

            this.Fuel = new List <Pair <string, int> >(preWorldState.Fuel.Count);

            foreach (var fuelItem in preWorldState.Fuel)
            {
                Pair <string, int> tuple1 = new Pair <string, int>(fuelItem.Item1, fuelItem.Item3);
                this.Fuel.Add(tuple1);
            }

            //Getting Fire Info

            this.Fire = preWorldState.Fire;

            //Getting Equipped items from PreWorldState

            int size2 = preWorldState.Equipped.Count;

            this.EquippedItems = new List <string>(size2);

            for (int i = 0; i < size2; i++)
            {
                this.EquippedItems.Add(preWorldState.Equipped[i].Item1);
            }

            //Getting WorldObjects from PreWorldState's Entities

            int size3 = preWorldState.Entities.Count;

            this.WorldObjects = new List <Pair <Pair <string, int>, Pair <int, int> > >(size3);

            for (int i = 0; i < size3; i++)
            {
                Pair <string, int> npair = new Pair <string, int>(preWorldState.Entities[i].Prefab, preWorldState.Entities[i].Quantity);
                Pair <Pair <string, int>, Pair <int, int> > tolist = new Pair <Pair <string, int>, Pair <int, int> >(npair, preWorldState.Entities[i].Position);
                this.WorldObjects.Add(tolist);
            }

            //Getting Available Actions

            this.AvailableActions = new List <ActionDST>();
            ActionDST action = new Wander();

            this.AvailableActions.Add(action);

            if (WorldHas("campfire") && preWorldState.Cycle >= Convert.ToSingle(13 - preWorldState.CycleInfo[2]))
            {
                action = new Stay("campfire");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("firepit") && preWorldState.Cycle >= Convert.ToSingle(13 - preWorldState.CycleInfo[2]))
            {
                action = new Stay("firepit");
                this.AvailableActions.Add(action);
            }
            if (HasFuel() && WorldHas("campfire"))
            {
                action = new AddFuel("campfire");
                this.AvailableActions.Add(action);
            }
            if (HasFuel() && WorldHas("firepit"))
            {
                action = new AddFuel("firepit");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("tree") && (Possesses("axe") || IsEquipped("axe")))
            {
                action = new Grab("tree");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("log"))
            {
                action = new Grab("log");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("sapling"))
            {
                action = new Grab("sapling");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("twigs"))
            {
                action = new Grab("twigs");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("flint"))
            {
                action = new Grab("flint");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("cutgrass"))
            {
                action = new Grab("cutgrass");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("grass"))
            {
                action = new Grab("grass");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("boulder") && (Possesses("pickaxe") || IsEquipped("pickaxe")))
            {
                action = new Grab("boulder");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("rocks"))
            {
                action = new Grab("rocks");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("berrybush"))
            {
                action = new Grab("berrybush");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("berries"))
            {
                action = new Grab("berries");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("carrot"))
            {
                action = new Grab("carrot");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("carrot_planted"))
            {
                action = new Grab("carrot_planted");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("axe"))
            {
                action = new Grab("axe");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("pickaxe"))
            {
                action = new Grab("pickaxe");
                this.AvailableActions.Add(action);
            }
            if (WorldHas("torch"))
            {
                action = new Grab("torch");
                this.AvailableActions.Add(action);
            }
            if (Possesses("log", 2) && Possesses("cutgrass", 3))
            {
                action = new Build("campfire");
                this.AvailableActions.Add(action);
            }
            if (Possesses("log", 2) && Possesses("rocks", 12))
            {
                action = new Build("firepit");
                this.AvailableActions.Add(action);
            }
            if (Possesses("cutgrass", 2) && Possesses("twigs", 2))
            {
                action = new Build("torch");
                this.AvailableActions.Add(action);
            }
            if (Possesses("twigs", 1) && Possesses("flint", 1))
            {
                action = new Build("axe");
                this.AvailableActions.Add(action);
            }
            if (Possesses("twigs", 2) && Possesses("flint", 2))
            {
                action = new Build("pickaxe");
                this.AvailableActions.Add(action);
            }
            if (Possesses("berries"))
            {
                action = new Eat("berries");
                this.AvailableActions.Add(action);
            }
            if (Possesses("carrot"))
            {
                action = new Eat("carrot");
                this.AvailableActions.Add(action);
            }
            if (Possesses("torch"))
            {
                action = new Equip("torch");
                this.AvailableActions.Add(action);
            }
            if (IsEquipped("torch"))
            {
                action = new Unequip("torch");
                this.AvailableActions.Add(action);
            }
        }
示例#4
0
        public static void AddItemToContainer(byte[] packet, Client cli)
        {
            PacketReader packetReader       = new PacketReader(packet);
            bool         noAppearanceUpdate = false;

            /* Container ID's:
             * 0065 Weaponpage
             * 0066 Armorpage
             *  0067 Implantpage
             *  0068 Inventory (places 64-93)
             *  0069 Bank
             *  006B Backpack
             *  006C KnuBot Trade Window
             *  006E Overflow window
             *  006F Trade Window
             *  0073 Socialpage
             *  0767 Shop Inventory
             *  0790 Playershop Inventory
             *  DEAD Trade Window (incoming)
             */

            packetReader.PopInt();
            packetReader.PopInt();
            int sender = packetReader.PopInt();

            packetReader.PopInt();
            packetReader.PopInt();
            Identity fromIdentity = packetReader.PopIdentity();
            byte     flag         = packetReader.PopByte();
            int      c350         = fromIdentity.Type;
            int      fromId       = fromIdentity.Instance;

            int      fromContainerID = packetReader.PopInt();
            int      fromPlacement   = packetReader.PopInt();
            Identity toIdentity      = packetReader.PopIdentity();
            int      toid            = toIdentity.Instance;

            c350 = toIdentity.Type;
            int toPlacement = packetReader.PopInt();

            int counterFrom = 0;

            if ((fromContainerID <= 0x68) || (fromContainerID == 0x73)) // Inventory or Equipmentpages?
            {
                for (counterFrom = 0;
                     (counterFrom < cli.Character.Inventory.Count) &&
                     (fromPlacement != cli.Character.Inventory[counterFrom].Placement);
                     counterFrom++)
                {
                    ;
                }
            }
            else
            {
                if (fromContainerID == 0x69)
                {
                    for (counterFrom = 0;
                         (counterFrom < cli.Character.Bank.Count) &&
                         (fromPlacement != cli.Character.Bank[counterFrom].Flags);
                         counterFrom++)
                    {
                        ;
                    }
                }
                else
                {
                    counterFrom = -1;
                }
            }

            // TODO: Add check for instanced items (fromcontainerid:fromplacement)
            if (counterFrom == -1)
            {
                return;
            }

            int counterTo;

            if (toIdentity.Type == 0xdead) // Transferring to a trade window??? (only bank trade window yet)
            {
                counterTo = cli.Character.Bank.Count;
            }
            else
            {
                for (counterTo = 0;
                     (counterTo < cli.Character.Inventory.Count) &&
                     (toPlacement != cli.Character.Inventory[counterTo].Placement);
                     counterTo++)
                {
                    ;
                }
            }

            AOItem itemFrom = null;

            if (counterFrom < cli.Character.Inventory.Count)
            {
                itemFrom = ItemHandler.interpolate(
                    cli.Character.Inventory[counterFrom].Item.LowID,
                    cli.Character.Inventory[counterFrom].Item.HighID,
                    cli.Character.Inventory[counterFrom].Item.Quality);
            }

            AOItem itemTo = null;

            if (counterTo < cli.Character.Inventory.Count)
            {
                itemTo = ItemHandler.interpolate(
                    cli.Character.Inventory[counterTo].Item.LowID,
                    cli.Character.Inventory[counterTo].Item.HighID,
                    cli.Character.Inventory[counterTo].Item.Quality);
            }

            // Calculating delay for equip/unequip/switch gear
            int delay = 0;

            if (itemFrom != null)
            {
                delay += itemFrom.getItemAttribute(211);
            }
            if (itemTo != null)
            {
                delay += itemTo.getItemAttribute(211);
            }
            if (delay == 0)
            {
                delay = 200;
            }
            int counter;

            if (toPlacement == 0x6f) // 0x6f = next free inventory place, we need to send back the actual spot where the item goes
            // something has to be free, client checks for full inventory
            {
                counter = 0;
                int counter2 = 0;
                int counter3 = 0;
                if (toIdentity.Type == 0xdead)
                {
                    while (counter3 == 0)
                    {
                        counter3 = 1;
                        for (counter2 = 0; counter2 < cli.Character.Bank.Count; counter2++)
                        {
                            if (cli.Character.Bank[counter2].Flags == counter) // using flags for placement
                            {
                                counter++;
                                counter3 = 0;
                                continue;
                            }
                        }
                    }
                }
                else
                {
                    counter = 64;
                    while (counter3 == 0)
                    {
                        counter3 = 1;
                        for (counter2 = 0; counter2 < cli.Character.Inventory.Count; counter2++)
                        {
                            if (cli.Character.Inventory[counter2].Placement == counter)
                            {
                                counter++;
                                counter3 = 0;
                                continue;
                            }
                        }
                    }
                }
                toPlacement = counter;
            }

            cli.Character.DoNotDoTimers = true;
            if (toIdentity.Type == 0xdead) // 0xdead only stays for bank at the moment
            {
                cli.Character.TransferItemtoBank(fromPlacement, toPlacement);
                noAppearanceUpdate = true;
            }
            else
            {
                switch (fromContainerID)
                {
                case 0x68:
                    // from Inventory
                    if (toPlacement <= 30)
                    {
                        // to Weaponspage or Armorpage
                        // TODO: Send some animation
                        if (itemTo != null)
                        {
                            cli.Character.UnequipItem(itemTo, cli.Character, false, fromPlacement);
                            // send interpolated item
                            Unequip.Send(cli, itemTo, InventoryPage(toPlacement), toPlacement);
                            // client takes care of hotswap

                            cli.Character.EquipItem(itemFrom, cli.Character, false, toPlacement);
                            Equip.Send(cli, itemFrom, InventoryPage(toPlacement), toPlacement);
                        }
                        else
                        {
                            cli.Character.EquipItem(itemFrom, cli.Character, false, toPlacement);
                            Equip.Send(cli, itemFrom, InventoryPage(toPlacement), toPlacement);
                        }
                    }
                    else
                    {
                        if (toPlacement < 46)
                        {
                            if (itemTo == null)
                            {
                                cli.Character.EquipItem(itemFrom, cli.Character, false, toPlacement);
                                Equip.Send(cli, itemFrom, InventoryPage(toPlacement), toPlacement);
                            }
                        }
                        // Equiping to social page
                        if ((toPlacement >= 49) && (toPlacement <= 63))
                        {
                            if (itemTo != null)
                            {
                                cli.Character.UnequipItem(itemTo, cli.Character, true, fromPlacement);
                                // send interpolated item
                                cli.Character.EquipItem(itemFrom, cli.Character, true, toPlacement);
                            }
                            else
                            {
                                cli.Character.EquipItem(itemFrom, cli.Character, true, toPlacement);
                            }

                            //cli.Character.switchItems(cli, fromplacement, toplacement);
                        }
                    }
                    cli.Character.SwitchItems(fromPlacement, toPlacement);
                    cli.Character.CalculateSkills();
                    noAppearanceUpdate = false;
                    break;

                case 0x66:
                    // from Armorpage
                    cli.Character.UnequipItem(itemFrom, cli.Character, false, fromPlacement);
                    // send interpolated item
                    Unequip.Send(cli, itemFrom, InventoryPage(fromPlacement), fromPlacement);
                    cli.Character.SwitchItems(fromPlacement, toPlacement);
                    cli.Character.CalculateSkills();
                    noAppearanceUpdate = false;
                    break;

                case 0x65:
                    // from Weaponspage
                    cli.Character.UnequipItem(itemFrom, cli.Character, false, fromPlacement);
                    // send interpolated item
                    Unequip.Send(cli, itemFrom, InventoryPage(fromPlacement), fromPlacement);
                    cli.Character.SwitchItems(fromPlacement, toPlacement);
                    cli.Character.CalculateSkills();
                    noAppearanceUpdate = false;
                    break;

                case 0x67:
                    // from Implantpage
                    cli.Character.UnequipItem(itemFrom, cli.Character, false, fromPlacement);
                    // send interpolated item
                    Unequip.Send(cli, itemFrom, InventoryPage(fromPlacement), fromPlacement);
                    cli.Character.SwitchItems(fromPlacement, toPlacement);
                    cli.Character.CalculateSkills();
                    noAppearanceUpdate = true;
                    break;

                case 0x73:
                    cli.Character.UnequipItem(itemFrom, cli.Character, true, fromPlacement);

                    cli.Character.SwitchItems(fromPlacement, toPlacement);
                    cli.Character.CalculateSkills();
                    break;

                case 0x69:
                    cli.Character.TransferItemfromBank(fromPlacement, toPlacement);
                    toPlacement        = 0x6f; // setting back to 0x6f for packet reply
                    noAppearanceUpdate = true;
                    break;

                case 0x6c:
                    // KnuBot Trade Window
                    cli.Character.TransferItemfromKnuBotTrade(fromPlacement, toPlacement);
                    break;

                default:
                    break;
                }
            }
            cli.Character.DoNotDoTimers = false;
            if ((fromPlacement < 0x30) || (toPlacement < 0x30)) // Equipmentpages need delays
            {
                // Delay when equipping/unequipping
                // has to be redone, jumping breaks the equiping/unequiping
                // and other messages have to be done too
                // like heartbeat timer, damage from environment and such
                Thread.Sleep(delay);
            }
            else
            {
                Thread.Sleep(200); //social has to wait for 0.2 secs too (for helmet update)
            }
            SwitchItem.Send(cli, fromContainerID, fromPlacement, toIdentity, toPlacement);
            cli.Character.Stats.ClearChangedFlags();
            if (!noAppearanceUpdate)
            {
                cli.Character.AppearanceUpdate();
            }
            itemFrom = null;
            itemTo   = null;
        }
示例#5
0
 private void OnSlotUnequip(RelicSlotView relicSlotView)
 {
     Unequip?.Invoke(relicSlotView.Slot.Relic);
 }