예제 #1
0
        public void sendCastAbilityOnEntityId(UInt16 viewId, UInt32 animationId, UInt16 value)
        {
            ClientView theView = Store.currentClient.viewMan.getViewById(viewId);

            Random randomObject = new Random();
            ushort randomHealth = (ushort)randomObject.Next(3, 1800);
            // RSI Health FX "send 02 03 02 00 02 80 80 80 90 ed 00 30 22 0a 00 28 06 00 00;"
            PacketContent pak = new PacketContent();

            if (viewId == 0)
            {
                viewId = 2;
            }
            pak.addUint16(viewId, 1);

            UInt32 theGoID = 12;

            if (theView != null)
            {
                theGoID = theView.GoID;
            }

            switch (theGoID)
            {
            case 12:
                pak.addByte(0x02);
                pak.addByte(0x80);
                pak.addByte(0x80);
                pak.addByte(0x80);
                if (viewId == 2)
                {
                    pak.addByte(0x80);
                    pak.addByte(0xb0);
                }
                else
                {
                    pak.addByte(0x0c);
                }
                pak.addUint32(animationId, 1);
                pak.addUintShort(Store.currentClient.playerData.assignSpawnIdCounter());
                break;

            case 599:

                // Its more a demo - we "one hit" the mob currently so we must update this
                lock (WorldSocket.npcs.SyncRoot)
                {
                    for (int i = 0; i < WorldSocket.npcs.Count; i++)
                    {
                        Mob thismob = (Mob)WorldSocket.npcs[i];
                        if (theView != null && thismob.getEntityId() == theView.entityId)
                        {
                            thismob.HitEnemyWithDamage(value, animationId);

                            if (thismob.getHealthC() <= 0)
                            {
                                thismob.setIsDead(true);
                                this.SendNpcDies(theView.ViewID, Store.currentClient, thismob);

                                // We got some Exp for it - currently we just make a simple trick to calculate some exp
                                // Just take currentLevel * modifier
                                Random rand = new Random();

                                UInt32 expModifier = (UInt32)rand.Next(100, 500);
                                UInt32 expGained   = thismob.getLevel() * expModifier;
                                // Update EXP
                                new PlayerHandler().IncrementPlayerExp(expGained);
                                thismob.setIsLootable(true);
                            }
                            WorldSocket.npcs[i] = thismob;
                        }
                    }
                }
                break;

            default:
                pak.addByte(0x02);
                pak.addByte(0x80);
                pak.addByte(0x80);
                pak.addByte(0x80);
                if (viewId == 2)
                {
                    pak.addByte(0x80);
                    pak.addByte(0xb0);
                }
                else
                {
                    pak.addByte(0x0c);
                }
                pak.addUint32(animationId, 1);
                pak.addUintShort(Store.currentClient.playerData.assignSpawnIdCounter());
                break;
            }

            string hex = StringUtils.bytesToString(pak.returnFinalPacket());

            Store.currentClient.messageQueue.addObjectMessage(pak.returnFinalPacket(), false);
            Store.currentClient.FlushQueue();
        }