예제 #1
0
파일: Map.cs 프로젝트: x3sphiorx/SagaRO2
        public void RemoveItemFromActorPC(ActorPC pc, int itemID, byte amount, ITEM_UPDATE_REASON reason)
        {
            ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e;
            DeleteItemResult res;
            byte             namount, index;
            Item             item = pc.inv.GetItem(CONTAINER_TYPE.INVENTORY, itemID);

            res = pc.inv.DeleteItem(CONTAINER_TYPE.INVENTORY, itemID, amount, out index, out namount);
            if (res == DeleteItemResult.ERROR || res == DeleteItemResult.WRONG_ITEMID)
            {
                return;
            }
            switch (res)
            {
            case DeleteItemResult.NOT_ALL_DELETED:
                Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
                p2.SetContainer(CONTAINER_TYPE.INVENTORY);
                p2.SetItemIndex(index);
                p2.SetAmount(namount);
                p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT);
                p2.SetUpdateReason(reason);
                eh.C.netIO.SendPacket(p2, eh.C.SessionID);
                MapServer.charDB.UpdateItem(pc, item);
                break;

            case DeleteItemResult.ALL_DELETED:
                Packets.Server.DeleteItem delI = new SagaMap.Packets.Server.DeleteItem();
                delI.SetContainer(CONTAINER_TYPE.INVENTORY);
                delI.SetAmount(1);
                delI.SetIndex(index);
                eh.C.netIO.SendPacket(delI, eh.C.SessionID);
                MapServer.charDB.DeleteItem(pc, item);
                break;
            }
        }
예제 #2
0
        public void OnAddItem(Item nItem, SagaDB.Items.ITEM_UPDATE_REASON reason)
        {
            byte          index, amount;
            AddItemResult res = I.inv.AddItem(nItem, out index, out amount);

            if (res == AddItemResult.ERROR)
            {
                Logger.ShowWarning("pc event handler: cannot add item with ID " + nItem.id, null);
                return;
            }

            nItem.index = index;
            nItem.stack = amount;

            if (res == AddItemResult.NEW_INDEX)
            {
                Packets.Server.AddItem p1 = new SagaMap.Packets.Server.AddItem();
                p1.SetContainer(CONTAINER_TYPE.INVENTORY);
                p1.SetItem(nItem);
                C.netIO.SendPacket(p1, C.SessionID);
                MapServer.charDB.NewItem(this.C.Char, nItem);
            }

            Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
            p2.SetContainer(CONTAINER_TYPE.INVENTORY);
            p2.SetItemIndex(nItem.index);
            p2.SetAmount(nItem.stack);
            p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT);
            p2.SetUpdateReason(reason);
            C.netIO.SendPacket(p2, C.SessionID);
            MapServer.charDB.UpdateItem(this.C.Char, nItem);
        }
예제 #3
0
        //09 0C
        public void OnSkillAddSpecial(SagaMap.Packets.Client.SkillAddSpecial p)
        {
            if (this.state != SESSION_STATE.MAP_LOADED)
            {
                return;
            }

            Actor            sActor = (Actor)this.Char;
            Item             item;
            byte             amount;
            int              id;
            byte             index = p.GetIndex();
            DeleteItemResult res;

            SkillHandler.SkillAddResault res2;
            item = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, index);
            id   = item.id;
            res2 = SkillHandler.SkillAddSpecial(ref this.Char, item.skillID);
            Packets.Server.SkillLearned p3 = new SagaMap.Packets.Server.SkillLearned();
            if (res2 != SkillHandler.SkillAddResault.OK)
            {
                p3.SetResult(res2);
                this.netIO.SendPacket(p3, this.SessionID);
                return;
            }
            else
            {
                p3.SetResult(res2);
            }
            SkillHandler.SendAddSkill(this.Char, item.skillID, 0);
            this.netIO.SendPacket(p3, this.SessionID);
            res = this.Char.inv.DeleteItem(CONTAINER_TYPE.INVENTORY, index, id, 1, out amount);
            switch (res)
            {
            case DeleteItemResult.NOT_ALL_DELETED:
                Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
                p2.SetContainer(CONTAINER_TYPE.INVENTORY);
                p2.SetItemIndex(index);
                p2.SetAmount(amount);
                p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT);
                p2.SetUpdateReason(ITEM_UPDATE_REASON.PURCHASED);
                this.netIO.SendPacket(p2, this.SessionID);
                MapServer.charDB.UpdateItem(this.Char, item);
                break;

            case DeleteItemResult.ALL_DELETED:
                Packets.Server.DeleteItem delI = new SagaMap.Packets.Server.DeleteItem();
                delI.SetContainer(CONTAINER_TYPE.INVENTORY);
                delI.SetAmount(1);
                delI.SetIndex(index);
                this.netIO.SendPacket(delI, this.SessionID);
                MapServer.charDB.DeleteItem(this.Char, item);
                break;
            }
        }
예제 #4
0
        public void OnWeaponAuge(SagaMap.Packets.Client.WeaponAuge p)
        {
            if (this.state != SESSION_STATE.MAP_LOADED)
            {
                return;
            }

            Actor            sActor = (Actor)this.Char;
            int              id;
            byte             index = p.GetSlot();
            byte             slot  = p.GetWeaponSlot();
            byte             amount;
            Item             item = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, index);
            DeleteItemResult res;
            Weapon           weapon = WeaponFactory.GetActiveWeapon(this.Char);

            if (slot == 0)
            {
                weapon.augeSkillID = item.skillID;
            }
            weapon.stones[slot] = item.skillID;
            Packets.Server.WeaponStone p3 = new SagaMap.Packets.Server.WeaponStone();
            p3.SetUnknown(1);
            p3.SetWeaponSlot(slot);
            p3.SetValue(item.skillID);
            this.netIO.SendPacket(p3, this.SessionID);
            id  = item.id;
            res = this.Char.inv.DeleteItem(CONTAINER_TYPE.INVENTORY, index, id, 1, out amount);
            switch (res)
            {
            case DeleteItemResult.NOT_ALL_DELETED:
                Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
                p2.SetContainer(CONTAINER_TYPE.INVENTORY);
                p2.SetItemIndex(index);
                p2.SetAmount(amount);
                p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT);
                p2.SetUpdateReason(ITEM_UPDATE_REASON.PURCHASED);
                this.netIO.SendPacket(p2, this.SessionID);
                MapServer.charDB.UpdateItem(this.Char, item);
                break;

            case DeleteItemResult.ALL_DELETED:
                Packets.Server.DeleteItem delI = new SagaMap.Packets.Server.DeleteItem();
                delI.SetContainer(CONTAINER_TYPE.INVENTORY);
                delI.SetAmount(1);
                delI.SetIndex(index);
                this.netIO.SendPacket(delI, this.SessionID);
                MapServer.charDB.DeleteItem(this.Char, item);
                break;
            }
        }
예제 #5
0
        public void ProcessItem( MapClient client, string args )
        {
            int itemID;
            Item nItem;
            try { itemID = int.Parse( args ); }
            catch( Exception ) { itemID = 1; }

            try
            {
                nItem = new Item(itemID);
            }
            catch(Exception)
            {
                client.SendMessage( _MasterName, "cannot create item with ID " + itemID );
                return;
            }
            byte index, amount;
            AddItemResult res = client.Char.inv.AddItem( nItem, out index, out amount );
            if( res == AddItemResult.ERROR )
            {
                client.SendMessage( _MasterName, "cannot add item with ID " + itemID );
                return;
            }

            nItem.index = index;
            nItem.stack = amount;

            if( res == AddItemResult.NEW_INDEX )
            {
                Packets.Server.AddItem p1 = new SagaMap.Packets.Server.AddItem();
                p1.SetContainer( CONTAINER_TYPE.INVENTORY );
                p1.SetItem( nItem );
                client.netIO.SendPacket(p1, client.SessionID);
                MapServer.charDB.NewItem(client.Char, nItem);
            }

            Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
            p2.SetContainer( CONTAINER_TYPE.INVENTORY );
            p2.SetItemIndex( nItem.index );
            p2.SetAmount( nItem.stack );
            p2.SetUpdateType( SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT );
            p2.SetUpdateReason(ITEM_UPDATE_REASON.FOUND);
            client.netIO.SendPacket(p2, client.SessionID);
            MapServer.charDB.UpdateItem(client.Char, nItem);
            client.SendMessage( _MasterName, "Created item with ID " + itemID );
        }
예제 #6
0
        public void OnWeaponAuge(SagaMap.Packets.Client.WeaponAuge p)
        {
            if (this.state != SESSION_STATE.MAP_LOADED) return;

            Actor sActor = (Actor)this.Char;
            int id;
            byte index = p.GetSlot();
            byte slot = p.GetWeaponSlot();
            byte amount;
            Item item = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, index);
            DeleteItemResult res;
            Weapon weapon = WeaponFactory.GetActiveWeapon(this.Char);
            if (slot == 0)
            {
                weapon.augeSkillID = item.skillID;
            }
            weapon.stones[slot] = item.skillID;
            Packets.Server.WeaponStone p3 = new SagaMap.Packets.Server.WeaponStone();
            p3.SetUnknown(1);
            p3.SetWeaponSlot(slot);
            p3.SetValue(item.skillID);
            this.netIO.SendPacket(p3, this.SessionID);
            id = item.id;
            res = this.Char.inv.DeleteItem(CONTAINER_TYPE.INVENTORY, index, id, 1, out amount);
            switch (res)
            {
                case DeleteItemResult.NOT_ALL_DELETED:
                    Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
                    p2.SetContainer(CONTAINER_TYPE.INVENTORY);
                    p2.SetItemIndex(index);
                    p2.SetAmount(amount);
                    p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT);
                    p2.SetUpdateReason(ITEM_UPDATE_REASON.PURCHASED);
                    this.netIO.SendPacket(p2, this.SessionID);
                    MapServer.charDB.UpdateItem(this.Char, item);
                    break;
                case DeleteItemResult.ALL_DELETED:
                    Packets.Server.DeleteItem delI = new SagaMap.Packets.Server.DeleteItem();
                    delI.SetContainer(CONTAINER_TYPE.INVENTORY);
                    delI.SetAmount(1);
                    delI.SetIndex(index);
                    this.netIO.SendPacket(delI, this.SessionID);
                    MapServer.charDB.DeleteItem(this.Char, item);
                    break;
            }
        }
예제 #7
0
        //09 0C
        public void OnSkillAddSpecial(SagaMap.Packets.Client.SkillAddSpecial p)
        {
            if (this.state != SESSION_STATE.MAP_LOADED) return;

            Actor sActor = (Actor)this.Char;
            Item item;
            byte amount;
            int id;
            byte index = p.GetIndex();
            DeleteItemResult res;
            SkillHandler.SkillAddResault res2;
            item = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, index);
            id = item.id;
            res2 = SkillHandler.SkillAddSpecial(ref this.Char, item.skillID);
            Packets.Server.SkillLearned p3 = new SagaMap.Packets.Server.SkillLearned();
            if (res2 != SkillHandler.SkillAddResault.OK)
            {
                p3.SetResult(res2);
                this.netIO.SendPacket(p3, this.SessionID);
                return;
            }
            else
            {
                p3.SetResult(res2);
            }
            SkillHandler.SendAddSkill(this.Char, item.skillID, 0);
            this.netIO.SendPacket(p3, this.SessionID);
            res = this.Char.inv.DeleteItem(CONTAINER_TYPE.INVENTORY, index, id, 1, out amount);
            switch (res)
            {
                case DeleteItemResult.NOT_ALL_DELETED:
                    Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
                    p2.SetContainer(CONTAINER_TYPE.INVENTORY);
                    p2.SetItemIndex(index);
                    p2.SetAmount(amount);
                    p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT);
                    p2.SetUpdateReason(ITEM_UPDATE_REASON.PURCHASED);
                    this.netIO.SendPacket(p2, this.SessionID);
                    MapServer.charDB.UpdateItem(this.Char, item);
                    break;
                case DeleteItemResult.ALL_DELETED:
                    Packets.Server.DeleteItem delI = new SagaMap.Packets.Server.DeleteItem();
                    delI.SetContainer(CONTAINER_TYPE.INVENTORY);
                    delI.SetAmount(1);
                    delI.SetIndex(index);
                    this.netIO.SendPacket(delI, this.SessionID);
                    MapServer.charDB.DeleteItem(this.Char, item);
                    break;
            }
        }
예제 #8
0
        public void OnAddItem( Item nItem, SagaDB.Items.ITEM_UPDATE_REASON reason )
        {
            byte index, amount;
            AddItemResult res = I.inv.AddItem(nItem, out index, out amount);
            if (res == AddItemResult.ERROR)
            {
                Logger.ShowWarning("pc event handler: cannot add item with ID " + nItem.id,null);
                return;
            }

            nItem.index = index;
            nItem.stack = amount;

            if (res == AddItemResult.NEW_INDEX)
            {
                Packets.Server.AddItem p1 = new SagaMap.Packets.Server.AddItem();
                p1.SetContainer(CONTAINER_TYPE.INVENTORY);
                p1.SetItem(nItem);
                C.netIO.SendPacket(p1, C.SessionID);
                MapServer.charDB.NewItem(this.C.Char, nItem);
            }

            Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
            p2.SetContainer(CONTAINER_TYPE.INVENTORY);
            p2.SetItemIndex(nItem.index);
            p2.SetAmount(nItem.stack);
            p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT);
            p2.SetUpdateReason(reason);
            C.netIO.SendPacket(p2, C.SessionID);
            MapServer.charDB.UpdateItem(this.C.Char, nItem);
        }
예제 #9
0
파일: Map.cs 프로젝트: Willyham/SagaRO2
 public void RemoveItemFromActorPC(ActorPC pc, int itemID, byte amount,ITEM_UPDATE_REASON reason)
 {
     ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e;
     DeleteItemResult res;
     byte namount, index;
     Item item = pc.inv.GetItem(CONTAINER_TYPE.INVENTORY, itemID);
     res = pc.inv.DeleteItem(CONTAINER_TYPE.INVENTORY, itemID, amount, out index, out namount);
     if (res == DeleteItemResult.ERROR || res == DeleteItemResult.WRONG_ITEMID) return;
     switch (res)
     {
         case DeleteItemResult.NOT_ALL_DELETED:
             Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem();
             p2.SetContainer(CONTAINER_TYPE.INVENTORY);
             p2.SetItemIndex(index);
             p2.SetAmount(namount);
             p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT);
             p2.SetUpdateReason(reason);
             eh.C.netIO.SendPacket(p2, eh.C.SessionID);
             MapServer.charDB.UpdateItem(pc, item);
             break;
         case DeleteItemResult.ALL_DELETED:
             Packets.Server.DeleteItem delI = new SagaMap.Packets.Server.DeleteItem();
             delI.SetContainer(CONTAINER_TYPE.INVENTORY);
             delI.SetAmount(1);
             delI.SetIndex(index);
             eh.C.netIO.SendPacket(delI, eh.C.SessionID);
             MapServer.charDB.DeleteItem(pc, item);
             break;
     }
 }