qcode
  • 创作工场专业版,一问多答!更智能、更完整、更原创
  • 这是一个超强内容创作平台,它会写文章、做设计、绘图、敲代码,有问必答!
🔥点击使用-高级专业版🔥

function MobHandler(target)

时间2023-04-01 19:00:20 提问来自 上海市上海市 的网友 分类创作 浏览301
local self = { target = target, } function self.handle(packet) if (packet:getOpcode() == 0x00A3) then -- Spawn Mob --print("Spawn mob") --[[ print("Spawn mob") local mob = { } local entityID = packet:getUInt32(0x04); -- Entity data starts at 0x08 and is a list of bytes until the end of the packet. We'll just grab it all in one go. local entityDataSize = packet:size() - 0x08; if (entityDataSize > 0) then local entityDataBuffer; entityDataBuffer, mob.entityDataSize = packet:readBytes(0x08, entityDataSize); -- Now we can parse out the data into useful information. First up is the model ID which is at 0x00 in this buffer. It's an unsigned short so we'll use getUInt16(). All other values are floats so we'll use getFloat(). The rest of the values are split into two sections, first section is from 0x02 to 0x1F and second section is from 0x20 to end of buffer. Note that some fields may be filled with all zeroes meaning their value isn't being set by this packet (we should probably read them from our current database instead). mob.modelID = entityDataBuffer:getUInt16(0x00); -- Model ID for this mob (unsigned short) [2 bytes] mob.unknown1 = entityDataBuffer:getFloat(0x02); -- Unknown float value [4 bytes] [Section 1] [Value changes depending on zone/mob type] <-- This might be a scale value? It's usually 1 or 2 but sometimes other values like 3 or 4 appear when zoning in/out? Also appears to change based on position relative to player? TODO: More testing needed! Maybe related to draw distance setting? mob.timeSinceDeath = entityDataBuffer:getFloat(0x06); -- Time since death [4 bytes] [Section 1] [Value changes depending on how long ago it died?] <-- Could be used for corpse despawn timer? TODO: Test more! Does it reset when corpse is looted or does it keep running until corpse despawns regardless of looting? Also want to know what happens when you die and respawn without zoning... does timer keep running or reset back to max again? EDIT 05-07-2015 : Appears corpse despawns after ~5 minutes regardless if looted or not... need more testing though! EDIT 06-07-2015 : Appears timeSinceDeath gets set back to max again when you die and respawn without zoning... need more testing though! EDIT 07-07-2015 : Appears timeSinceDeath doesn't change while you're alive, only updates when you die/respawn without zoning so I'm assuming it's actually a corpse despawn timer now... need more testing though! EDIT 08-07-2015 : After further testing I'm pretty sure this field IS indeed a Corpse Despawn Timer now! :) EDIT 09-07-2015 : Yep yep yep!!! Definitely a Corpse Despawn Timer!!! :) NOTE 01-10-2016 : This field will also change randomly while mobs are alive too but I'm not sure why yet... maybe related to animation stuff?? Need more testing!! NOTE 02/03/2017 : After further tests I think this field might actually just be random noise rather than anything important after all lol :) NOTE 04/01/2017 : After even MORE tests I think there MIGHT actually still be something important here after all!! Still need lots more tests though!! :( NOTE 16/01/2018 : After even MORE tests I think its safe to say that this field IS indeed random noise rather than anything important lol ;) NOTE 17/01/2018 : After EVEN MORE tests I think its safe

点击这里,进行内容创作

创作工场 免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。
点击这里>>使用🔥专业版,更聪明、更完整、更原创!

上一篇 告诉我你是谁 下一篇 通过实践法开展了哪些对会计的探索