예제 #1
0
        public static void AttackResponse(int index, int Character_ID, NPC npc, int Damage)
        {
            try
            {
                ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer();
                BuildBasePacket((int)ClientSendPacketNumbers.AttackResponse, ref buffer);
                buffer.WriteString(DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss"));

                buffer.WriteInteger(Character_ID);
                buffer.WriteInteger(npc.Entity_ID);
                buffer.WriteInteger(Damage);
                buffer.WriteInteger(npc.Current_HP);
                Quest_Log ql = World.instance.GetQuestLogByNPCID(Character_ID, npc.NPC_ID);
                if (ql != null && npc.Current_HP <= 0)
                {
                    ql.Increment();
                    buffer.WriteByte(1);
                    buffer.WriteInteger(ql.Quest_ID);
                    buffer.WriteInteger(ql.ObjectiveProgress);
                    buffer.WriteInteger((int)ql.Status);
                }
                else
                {
                    buffer.WriteByte(0);
                }

                Log.log("Sending Attack Response packet to client..", Log.LogType.SENT);
                sendData(ConnectionType.CLIENT, ClientSendPacketNumbers.AttackResponse.ToString(), index, buffer.ToArray());
            }
            catch (Exception e)
            {
                Log.log("Building Attack Response packet failed. > " + e.Message, Log.LogType.ERROR);
                return;
            }
        }
예제 #2
0
        private static void CollectableInteract(ConnectionType type, int index, byte[] data)
        {
            ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer();
            buffer.WriteBytes(data);
            ReadHeader(ref buffer);
            int         Character_ID  = buffer.ReadInteger();
            int         Col_Entity_ID = buffer.ReadInteger();
            Collectable col           = World.instance.GetCollectableByEntityID(Col_Entity_ID);

            if (col != null && col.Active && MathF.Distance(World.instance.players[Character_ID], col) <= World.InteractionDistance)
            {
                col.Active = false;
                Quest_Log quest_Log = World.instance.GetQuest_Log(Character_ID, col.Collectable_ID);
                if (quest_Log != null)
                {
                    quest_Log.Increment();
                }
                SendData.CollectableInteractConfirm(index, col, quest_Log);
            }
        }