Skip to content

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)

@iThorgrim iThorgrim self-requested a review August 10, 2025 15:27
@iThorgrim iThorgrim merged commit 1555895 into azerothcore:master Aug 19, 2025
@mostlynick3 mostlynick3 deleted the read-packed-guids branch August 19, 2025 20:40
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
2 participants