Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(LuaEngine/Packet): Add support ReadPackedGUID #271

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mostlynick3
Copy link

@mostlynick3 mostlynick3 commented Mar 23, 2025

Adds support for reading packed GUIDs in worldpackets (see e.g., packets SMSG_MOVE_GRAVITY_DISABLE, SMSG_MOVE_GRAVITY_ENABLE, SMSG_SPLINE_MOVE_START_SWIM, SMSG_SPLINE_MOVE_STOP_SWIM, SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, and others that use PackGUID instead of a full GUID), and closes #194

Tested with PackedGUID implementation of example script of issue 194.

local function OnPacketSend(event, packet, player)
	if packet:GetOpcode() == 592 then -- Direct damage combat log
		local packetSize = packet:GetSize()
		print("Packet size: " .. tostring(packetSize))

		local TargetPackedGUID = packet:ReadPackedGUID()
		print("Target GUID Byte " .. tostring(TargetPackedGUID))

		local AttackerPackedGUID = packet:ReadPackedGUID()
		print("Attacker GUID Byte " .. tostring(AttackerPackedGUID))

		-- The following values are generally accurate
		-- Read spell ID (4 bytes)
		local spellId = packet:ReadULong()
		print("Spell ID: " .. spellId)

		-- Read damage value (4 bytes)
		local damage = packet:ReadULong()
		print("Damage: " .. damage)

		-- Read overkill value (4 bytes)
		local overkill = packet:ReadULong()
		print("Overkill: " .. overkill)

		-- Read damage type (1 byte)
		local schoolMask = packet:ReadUByte()
		print("School Mask: " .. schoolMask)

		-- Read absorbed damage value (4 bytes)
		local absorb = packet:ReadULong()
		print("Absorb: " .. absorb)

		-- Read resisted damage value (4 bytes)
		local resist = packet:ReadULong()
		print("Resist: " .. resist)

		-- Read physical log flag (1 byte)
		local physicalLog = packet:ReadUByte()
		print("Physical Log: " .. physicalLog)

		-- Read unused field (1 byte)
		local unused = packet:ReadUByte()
		print("Unused: " .. unused)

		-- Read blocked damage value (4 bytes)
		local blocked = packet:ReadULong()
		print("Blocked: " .. blocked)

		-- Read hit info (4 bytes)
		local hitInfo = packet:ReadULong()
		print("Hit Info: " .. hitInfo)

		-- Read hit info (duplicate) (4 bytes)
		local hitInfo2 = packet:ReadULong()
		print("Hit Info 2: " .. hitInfo2)

		-- Read extended data flag (1 byte)
		local hitInfo3 = packet:ReadUByte()
		print("Hit Info 3: " .. hitInfo3)
	end
end

RegisterServerEvent(7, OnPacketSend)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReadGUID() Wrong value was read
1 participant