DMorph 2.6.0: race morphs keep your own race rules, size shows and is shared

- DmorphHelper v3 hooks the game's model builder: during a race morph
  your model is built as the morph's race, but the game keeps your own
  race the rest of the time, so you understand your own languages (no
  garbled chat), and see your own flight paths and spells.
- Size now changes the model you see, not only the camera: the game
  draws the model at its own copy of the size, which DmorphHelper now
  sets too (found in WoW.exe at 0x614640).
- Sizes are shared with other DMorph users (a size token in the look
  and a small size message); older versions ignore it.
- The Setup check asks players with DmorphHelper v2 to run the installer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bdot89
2026-10-11 14:12:04 +01:00
co-authored by Claude Opus 5.5
parent f38c77f040
commit e4f369dddf
8 changed files with 320 additions and 32 deletions
+1
View File
@@ -109,3 +109,4 @@ The live copy is the game's `Interface\AddOns\DmorphOcto` folder, a git checkout
- 2.4.0, user report: Ashes of Al'ar mount "gone" (it was display 18179, Creature\Phoenix\Phoenix.mdx, named "Phoenix Hatchling" by Turtle, not mount-tagged). build_models.ps1 now has $MOUNT_MODEL (later-expansion rideable models by path: phoenix, winged/celestial horses, Northrend drakes, victorious steed, armoured raptor, lava/fel horses, Antonidas horse, nether rays, taxi wyverns/hippogryphs, ghost gryphon, riding turtle: 66 displays) and $MOUNT_NAMES (Phoenix -> "Ashes of Al'ar (Phoenix)"). Race morphs: VanillaHelpers rewrites BYTES_0 race, so TaxiNodeGetType hides the other faction's nodes and the spellbook re-sorts. M.HoldRace(reason) clears the display override (native race) while TaxiFrame (TAXIMAP_OPENED, redrawn via TaxiFrame_OnEvent) or SpellBookFrame (OnShow/OnHide wrapped at PLAYER_LOGIN) is open, pauses the DmorphHelper look watcher and shows the real look; ApplyBody waits while held. Untested in game: whether TaxiNodeGetType/spellbook re-read the race live. Scale slider asked: no installed DLL can set OBJECT_FIELD_SCALE_X; needs DmorphHelper_SetScale (C) and a rebuild (no compiler on this PC).
- 2.5.0 size: DmorphHelper v2 (HELPER_VERSION 2 in C and Lua) adds DmorphHelper_GetScale/SetScale(unit, 0.1-10) writing OBJECT_FIELD_SCALE_X (field 4, a float) + the display flip. Built on this PC with winlibs gcc 16.2 i686 msvcrt, unzipped to C:\Users\bdot1\tools\winlibs\mingw32 (downloaded with the user's OK): `PATH=/c/Users/bdot1/tools/winlibs/mingw32/bin:$PATH sh helper/build.sh` from Git Bash. Core: db.scale/scaleReal/scaleWritten, WatchScale inside WatchHelper, M.SetScale/GetScale, .scale, Reset everything clears it. UI: DmorphOctoSize slider (0.25-3, step 0.05, applied 0.3 s after it stops, right-click resets) on the name plate. Not shared with other DMorph users yet. Untested in game: whether the client draws a changed OBJECT_FIELD_SCALE_X on your own model after the flip, and how mounts and the camera react.
- 2.5.1, user report: "Gnome still can't speak that language, Goblin speaks Orcish". GetLanguageByIndex/GetDefaultLanguage follow the race VanillaHelpers writes (a Gnome morph lists Common, Gnomish), so 2.2.1's check passed Common. CaptureNative (run by EnsureSession right after clearing the display override, i.e. with the native race) now stores db.languages/db.defaultLanguage and SpeakableLanguage uses those. Goblin -> Orcish is correct for a Horde character. Also: flight-path birds got the mount skin (taxi = mount field > 0, no new buff -> the "any buff" fallback), and after landing the override held the bird ("can't cast spells"). WatchMount now skips UnitOnTaxi, uses the any-buff fallback only without an on-foot snapshot (login/reload mounted), and PLAYER_CONTROL_LOST/GAINED take the skin off (re-applied next tick if still riding).
- 2.6.0, user reports: (1) race morph still "speaks Orcish" = the client garbles chat (own and faction's) by the race in UNIT_FIELD_BYTES_0 (0x24, low byte), which VanillaHelpers sets to the morph race. DmorphHelper v3 hooks CGUnit_C::UpdateDisplayInfo (0x60ABE0, thiscall(unit), prologue push esi/push edi/mov esi,ecx/call rel32): for the active player, while DmorphHelper_SetRaces(build, own) is on, it writes the build race before the original and the own race after, so the model is built as the morph race but the byte holds your own race (languages, taxi nodes, spellbook). Lua KeepRace (core) switches it on for race morphs of another race, rechecks every 0.1 s (VanillaHelpers rewrites the override on server writes) and DmorphHelper_Rebuild on UNIT_INVENTORY_CHANGED(player); HoldRace is skipped while raceKept ~= 0. (2) Size moved only the camera: the camera reads OBJECT_FIELD_SCALE_X but the model is drawn at unit+0x90, which the per-frame code at 0x614a90 only eases towards the field (start time unit+0xA0, from +0xA4, 2 s) when the server changes it; 0x614640 is the game's instant path (+0x90 = field, +0xA0 = 0). SetScale now writes the field, +0x90 and clears +0xA0. Found by disassembling WoW.exe.original with winlibs objdump (8 places read field 4). Sizes are shared: "s<percent>" token after the guid in L and H messages (none = 100; old clients ignore it), "S <percent>" when only the size changes; receivers put it on with DmorphHelper_SetScale and restore the size they read first. All of this is untested in game.
+58 -3
View File
@@ -11,7 +11,7 @@
-- The client runs Lua 5.0: no #, no %, no string.match, no select(), and
-- table.getn() counts element by element, so long lists keep their own count.
local VERSION = "2.5.1"
local VERSION = "2.6.0"
local PREFIX = "|cff33ff99DMorph|r: "
-- VANILLAHELPERS_VERSION is major * 10000 + minor * 100 + patch; morphing
-- came in v1.1.0. Older versions load and set it, but can't morph.
@@ -1265,18 +1265,54 @@ local function DisplayRace(display)
end
end
-- With DmorphHelper v3 your own race stays in the game's race byte during a
-- race morph, and the morph's race is only used while the game builds your
-- model (DmorphHelper_SetRaces). Then languages, flight paths and spells all
-- follow your own race, and nothing needs holding. raceKept: the race your
-- model is built as (0: off); raceKeepWorks: whether DmorphHelper took it.
local raceKept, raceKeepWorks = 0, false
local function KeepRace()
if type(DmorphHelper_SetRaces) ~= "function" then
return
end
local morph = DisplayRace(BodyDisplayID() or 0)
local want = 0
if sessionReady and morph and nativeRace and morph ~= nativeRace and not next(raceHeld) then
want = morph
end
if want ~= raceKept then
local own = want ~= 0 and nativeRace or 0
raceKeepWorks = pcall(DmorphHelper_SetRaces, want, own) and true or false
raceKept = raceKeepWorks and want or 0
elseif want ~= 0 and type(DmorphHelper_GetRace) == "function" then
-- VanillaHelpers puts the morph's race back when the server resends
-- the field: your own race goes back in.
local ok, race = pcall(DmorphHelper_GetRace, "player")
if ok and race ~= nativeRace then
pcall(DmorphHelper_SetRaces, want, nativeRace)
end
end
end
local function ApplyBody()
helperHold, helperWait = 0.5, 0.5
if next(raceHeld) then
return true -- it goes on when the flight map or spellbook closes
end
return Morph(SetUnitDisplayID, "player", BodyDisplayID())
KeepRace() -- first, so the new model is built as the morph's race
local ok, err = Morph(SetUnitDisplayID, "player", BodyDisplayID())
KeepRace()
return ok, err
end
-- Holds (on) or releases your own race for a reason. Returns whether the
-- race was changed back just now, so the window can redraw.
function M.HoldRace(reason, on)
if on then
if raceKept ~= 0 then
return false -- DmorphHelper already keeps your own race (KeepRace)
end
local held = next(raceHeld) ~= nil
if held then
raceHeld[reason] = true
@@ -1504,7 +1540,7 @@ local MISSING_HELPER = "DmorphHelper.dll isn't loaded, so weapon glows, your siz
M.MISSING_HELPER = MISSING_HELPER
-- The DmorphHelper_Version() the DLL in helper\ reports. An older one in the
-- game folder (DMorph was updated, the DLL wasn't copied again) is flagged.
local HELPER_VERSION = 2
local HELPER_VERSION = 3
-- Rows 1-5 of the Races tab, in DmorphHelper_GetLook's order.
local OWN_LOOK_NPC = { "npcSkin", "npcFace", "npcHairStyle", "npcHairColour" }
@@ -2820,14 +2856,33 @@ mountFrame:SetScript("OnUpdate", function()
if this.wait <= 0 then
this.wait = 0.1
WatchMount()
KeepRace()
end
-- Gear the server changed is drawn by the game without a full rebuild,
-- so a helmet would follow your own race: rebuild as the morph's race.
if this.rebuild then
this.rebuild = this.rebuild - arg1
if this.rebuild <= 0 then
this.rebuild = nil
if raceKept ~= 0 then
pcall(DmorphHelper_Rebuild, "player")
end
end
end
end)
mountFrame:RegisterEvent("UNIT_INVENTORY_CHANGED")
-- Losing and getting back control (a flight path starts and lands, a fear,
-- a stun) takes the skin off: if you're still on your mount, the watcher
-- sees its buff and puts the skin on again a tenth of a second later.
mountFrame:RegisterEvent("PLAYER_CONTROL_LOST")
mountFrame:RegisterEvent("PLAYER_CONTROL_GAINED")
mountFrame:SetScript("OnEvent", function()
if event == "UNIT_INVENTORY_CHANGED" then
if arg1 == "player" and raceKept ~= 0 then
this.rebuild = 0.3
end
return
end
if watch.active then
StopSkin()
watch.real = nil
+1 -1
View File
@@ -2,7 +2,7 @@
## Title: DMorph |cff33ff99(OctoWoW)|r
## Notes: Morph window for OctoWoW: every creature model in the client (16,000+, with 3D previews, bosses and mounts), every race with NPC looks, 12,000+ items and 352 item sets. Skins for your mount, favourites, and DMorph users see each other's morphs. Weapon glows and real skin, face and hair with the bundled DmorphHelper.dll. Type /dmorph. Needs VanillaHelpers v1.1.0+ (OctoLauncher's vanillaHelpers mod); previews need ClassicAPI.
## Author: bdot89
## Version: 2.5.1
## Version: 2.6.0
## X-Website: https://github.com/bdot89/DmorphOcto
## SavedVariables: DmorphOctoAccount
## SavedVariablesPerCharacter: DmorphOctoDB
+3 -3
View File
@@ -6,7 +6,7 @@
**Become any creature, ride any mount, wear any item** · WoW 1.12 · OctoWoW
![Version](https://img.shields.io/badge/version-2.5.1-33ff99?style=flat-square)
![Version](https://img.shields.io/badge/version-2.6.0-33ff99?style=flat-square)
![WoW 1.12.1](https://img.shields.io/badge/WoW-1.12.1-c79c6e?style=flat-square)
![Models](https://img.shields.io/badge/models-16%2C000%2B-b46bff?style=flat-square)
![Items](https://img.shields.io/badge/items-12%2C000%2B-a335ee?style=flat-square)
@@ -175,10 +175,10 @@ Slots: `1` head, `3` shoulder, `4` shirt, `5` chest, `6` waist, `7` legs, `8` fe
## 💡 Good to know
- **Who sees what:** you and other DMorph users see your model, items and mount skin (friendly players only). Glows, looks and size are only on your own screen for now.
- **Who sees what:** you and other DMorph users see your model, items, mount skin and size (friendly players only; seeing someone's size needs DmorphHelper). Glows and picked faces are only on your own screen for now.
- **Seeing other DMorph users:** their morph shows when you target or mouse over them, when you're grouped, or straight away with SuperWoW. DMorph only talks to players near you, through hidden messages that no chat window shows.
- **Mount skins** go on when you mount and come off when you dismount. Flight master birds keep their own look.
- **Race morphs:** while the flight map or spellbook is open, your own race comes back for a moment, so you see all your flight paths and your spells stay in order. Your chat is always sent in a language your character knows.
- **Race morphs keep your own character's rules:** with DmorphHelper, the game still knows you as your own race, so you understand your own languages (no garbled chat), speak them, and see all your flight paths and spells as usual; only the model is the other race. Without DmorphHelper, your own race comes back for a moment while the flight map or spellbook is open, and chat is sent in a language you know, but other players' chat may look garbled.
- **Fast clicking is safe:** a click right after another waits its turn, so two looks never mix.
- **Shapeshifting** shows your morph instead of the form; reset your model first if you want the form.
- **Later expansions aren't in this game:** models, glows and races from The Burning Crusade onwards (Draenei, Mongoose glow, Outland mounts...) aren't in the 1.12 files, so no addon can show them. Everything OctoWoW and Turtle WoW added is included.
+84 -10
View File
@@ -68,7 +68,7 @@ local audience = {} -- name -> when they last showed they see us
local inGroup, inGuild = {}, {} -- names
local replies = {} -- way -> "L" (full look) or "H" (fingerprint)
local timers = {} -- clock times: join, ready, send, first, mount, reply, replied, query, scan, guild, next
local sent = { d = "0", m = "0", it = "-" } -- what the others were last told
local sent = { d = "0", m = "0", it = "-", s = "" } -- what the others were last told
local cache -- DmorphOctoAccount.peerCache for this realm
local guidWorks -- whether VanillaHelpers took a GUID as a unit token (nil: not tried)
local counts = { channel = 0, hidden = 0 }
@@ -481,8 +481,20 @@ local function ApplyTo(name, token)
done.mount = mount
end
end
-- Their size, through DmorphHelper (which every DMorph user may not have):
-- their own size is read first, to put back when they go back to it.
local scale = want.scale
if (scale ~= done.scale or (force and scale)) and type(DmorphHelper_SetScale) == "function" then
if scale and not done.scale then
local ok, real = pcall(DmorphHelper_GetScale, token)
done.scaleReal = ok and type(real) == "number" and real or 1
end
if Call(DmorphHelper_SetScale, token, scale or done.scaleReal or 1) then
done.scale = scale
end
end
done.version, done.scan, done.away = want.version, scanID, nil
if want == NONE and not done.display and not done.mount and not next(done.items) then
if want == NONE and not done.display and not done.mount and not next(done.items) and not done.scale then
applied[name] = nil
else
applied[name] = done
@@ -520,6 +532,7 @@ local function SetPeer(name, look, guid, confirmed)
peerCount = peerCount + 1
end
look.guid = guid or (peer and peer.guid)
look.scale = peer and peer.scale -- a full look message sets it again after
look.version = (peer and peer.version or 0) + 1
look.heard = confirmed and clock or -1000
look.confirmed = confirmed
@@ -654,12 +667,32 @@ end
-- Messages from other clients ---------------------------------------------------
-- A player's size from a message's "s<percent>" token (none: normal size).
-- Clients before 2.6 send no token and ignore it.
local function SizeOf(token)
local _, _, pct = strfind(token or "", "^s(%d+)$")
pct = tonumber(pct)
if pct and pct >= 10 and pct <= 1000 and pct ~= 100 then
return pct / 100
end
end
local function SetPeerSize(name, scale)
local peer = peers[name]
if peer and peer.scale ~= scale then
peer.scale = scale
peer.version = peer.version + 1
Scan()
end
end
local function ReadLook(sender, rest)
local _, _, d, m, it, guid = strfind(rest, "^(%S+) (%S+) (%S+) ?(%S*)")
local _, _, d, m, it, guid, size = strfind(rest, "^(%S+) (%S+) (%S+) ?(%S*) ?(%S*)")
local look = MakeLook(d, m, it)
if not look then
return
end
local scale = SizeOf(size)
if not strfind(guid or "", "^0x%x+$") then
guid = nil
end
@@ -673,9 +706,11 @@ local function ReadLook(sender, rest)
peer.confirmed = true
Cache()[sender] = { look = peer.look, guid = peer.guid, seen = time() }
end
SetPeerSize(sender, scale)
return
end
if SetPeer(sender, look, guid, true) then
look.scale = scale
Scan()
end
end
@@ -694,13 +729,14 @@ local function ReadMount(sender, m)
end
-- "Nothing changed": confirms what we remember, else we ask for it all.
local function ReadPrint(sender, print, guid)
local function ReadPrint(sender, print, guid, size)
Unask(sender)
Answered(sender)
asked[sender] = clock
local peer = peers[sender]
if peer and peer.print == print then
peer.heard = clock
SetPeerSize(sender, SizeOf(size))
if strfind(guid or "", "^0x%x+$") then
peer.guid = guid
end
@@ -753,9 +789,15 @@ local function Receive(sender, text, way)
elseif kind == "M" then
ReadMount(sender, rest)
elseif kind == "H" then
local _, _, print, guid = strfind(rest, "^(%S+) ?(%S*)")
local _, _, print, guid, size = strfind(rest, "^(%S+) ?(%S*) ?(%S*)")
if print then
ReadPrint(sender, print, guid)
ReadPrint(sender, print, guid, size)
end
elseif kind == "S" then
-- Only the size changed.
local peer = peers[sender]
if peer and peer.confirmed then
SetPeerSize(sender, SizeOf("s" .. rest))
end
elseif kind == "Q" then
ReadQuestion(sender, rest, way)
@@ -764,6 +806,16 @@ end
-- Your own changes ------------------------------------------------------------
-- Your size as a message token: "s150", or "" at normal size.
local function OwnSize()
local scale = Sharing() and M.GetScale and M.GetScale()
local pct = scale and math.floor(scale * 100 + 0.5) or 100
if pct == 100 then
return ""
end
return "s" .. pct
end
local function OnChange()
local d, m, it = OwnParts()
-- Mounting and dismounting go out at once; other changes wait until
@@ -771,6 +823,9 @@ local function OnChange()
if m ~= sent.m then
timers.mount = timers.mount or clock
end
if OwnSize() ~= sent.s then
timers.size = timers.size or clock + SETTLE
end
if d ~= sent.d or it ~= sent.it then
timers.first = timers.first or clock
timers.send = math.min(clock + SETTLE, timers.first + MAX_WAIT)
@@ -779,14 +834,23 @@ local function OnChange()
end
end
local function WithSize(text)
local size = OwnSize()
if size ~= "" then
return text .. " " .. size
end
return text
end
local function LookText()
return "L " .. OwnLook() .. " " .. (GUIDOf("player") or "-")
return WithSize("L " .. OwnLook() .. " " .. (GUIDOf("player") or "-"))
end
-- Tells everyone who needs it; that answers any waiting question too.
local function SendLook(ways)
sent.d, sent.m, sent.it = OwnParts()
timers.send, timers.first, timers.mount = nil, nil, nil
sent.s = OwnSize()
timers.send, timers.first, timers.mount, timers.size = nil, nil, nil, nil
local text = LookText()
for way in pairs(ways) do
Send(text, way)
@@ -813,6 +877,15 @@ local function SendNext()
end
elseif timers.send and clock >= timers.send then
SendLook(ChangeWays())
elseif timers.size and clock >= timers.size then
timers.size = nil
local size = OwnSize()
if size ~= sent.s then
sent.s = size
for way in pairs(ChangeWays()) do
Send("S " .. (size == "" and "100" or strsub(size, 2)), way)
end
end
elseif timers.reply and clock >= timers.reply then
timers.reply, timers.replied = nil, clock
local look = OwnLook()
@@ -821,7 +894,7 @@ local function SendNext()
if kind == "L" then
Send(LookText(), way)
else
Send("H " .. Fingerprint(look) .. " " .. (GUIDOf("player") or "-"), way)
Send(WithSize("H " .. Fingerprint(look) .. " " .. (GUIDOf("player") or "-")), way)
end
end
elseif table.getn(queue) > 0 and clock >= (timers.query or 0) then
@@ -873,7 +946,8 @@ local function Tick()
-- What we look like now is what everyone will learn by asking.
timers.introduced = true
sent.d, sent.m, sent.it = OwnParts()
timers.send, timers.first, timers.mount = nil, nil, nil
sent.s = OwnSize()
timers.send, timers.first, timers.mount, timers.size = nil, nil, nil, nil
timers.group = clock
end
if timers.group and clock >= timers.group and not (timers.next and clock < timers.next) then
+97 -6
View File
@@ -6,6 +6,11 @@
// - a player's skin colour, face, hair style, hair colour and facial hair
// (PLAYER_BYTES and PLAYER_BYTES_2)
// - a player's size (OBJECT_FIELD_SCALE_X, a float: what Enlarge spells change)
// - a player's race byte (UNIT_FIELD_BYTES_0): a race morph needs the morph's
// race while the model is built, but the game also reads it to know which
// languages you understand, which flight paths and spells you have; so
// the addon builds the model as the morph's race and keeps your own
// race there the rest of the time
//
// Lua functions (registered when the game loads its own):
// DmorphHelper_Version() -> version
@@ -15,6 +20,9 @@
// DmorphHelper_SetLook(unit, skin, face, hairStyle, hairColour, facialHair)
// DmorphHelper_GetScale(unit) -> scale (1 = normal size)
// DmorphHelper_SetScale(unit, scale) (0.1 to 10)
// DmorphHelper_GetRace(unit) -> race
// DmorphHelper_SetRaces(buildRace, ownRace) (0, 0 = off; see Race morphs)
// DmorphHelper_Rebuild(unit)
// unit is a unit token for a player you could help ("player", "target", ...);
// slot is an inventory slot, 1-19. The functions only write the values: the
// addon keeps what it wants and puts it back after the server resends them.
@@ -35,7 +43,7 @@
#define GAME_FASTCALL __attribute__((fastcall))
#define GAME_THISCALL __attribute__((thiscall))
#define HELPER_VERSION 2
#define HELPER_VERSION 3
// Game functions, build 5875 (from VanillaHelpers' Offsets.h).
#define FUN_INVALID_FUNCTION_PTR_CHECK 0x42A320
@@ -56,6 +64,13 @@
// Descriptor fields, as indexes into a unit's uint32 field array.
#define OBJECT_FIELD_SCALE_X 0x4 // a float
#define UNIT_FIELD_BYTES_0 0x24 // race, class, gender, power type (one byte each)
// In the unit object itself (build 5875, from 0x614640 and the per-frame
// size animation at 0x614a90): the size the model is drawn at, and when a
// size animation started (0 = none; it eases from +0xA4 to the field over 2 s).
#define UNIT_SHOWN_SCALE 0x90
#define UNIT_SCALE_ANIM_START 0xA0
#define UNIT_FIELD_DISPLAYID 0x83
#define PLAYER_BYTES 0xC1
#define PLAYER_BYTES_2 0xC2
@@ -230,13 +245,80 @@ static int GAME_FASTCALL Script_SetScale(void *L) {
LuaError(L, SET_SCALE_USAGE);
return 0;
}
float scale = (float)v, current;
float scale = (float)v;
uint32_t *f = Fields(unit);
memcpy(&current, f + OBJECT_FIELD_SCALE_X, sizeof current);
if (current != scale) {
memcpy(f + OBJECT_FIELD_SCALE_X, &scale, sizeof scale);
Reload(unit);
memcpy(f + OBJECT_FIELD_SCALE_X, &scale, sizeof scale);
// The field is what the camera reads; the model is drawn at the unit's
// own copy, which the game only animates towards the field when the
// server changes it. So set that copy too, and stop any such animation,
// as the game's own "size at once" code at 0x614640 does.
memcpy((char *)unit + UNIT_SHOWN_SCALE, &scale, sizeof scale);
*(uint32_t *)((char *)unit + UNIT_SCALE_ANIM_START) = 0;
return 0;
}
// Race morphs. VanillaHelpers writes the morph's race into your race byte,
// because the game builds a character model from it (skin, hair, helmets).
// But the game also reads that byte to know which languages you understand
// (it garbles your own and your faction's chat otherwise), which flight paths
// and spells you have. So, once the addon says so (DmorphHelper_SetRaces),
// your own race stays in the byte and the morph's race is only put in while
// the game builds your model (the UpdateDisplayInfo hook below).
static uint32_t g_buildRace = 0, g_ownRace = 0;
static UpdateDisplayInfo_t UpdateDisplayInfo_o = NULL;
static void *Me(void) {
uint64_t guid = GetActivePlayer();
return guid ? ObjectPtr(TYPEMASK_PLAYER, NULL, guid, 0) : NULL;
}
static void WriteRace(void *unit, uint32_t race) {
uint32_t *f = Fields(unit);
f[UNIT_FIELD_BYTES_0] = (f[UNIT_FIELD_BYTES_0] & 0xFFFFFF00u) | race;
}
static void GAME_FASTCALL UpdateDisplayInfo_h(void *unit, void *edx) {
(void)edx;
if (g_buildRace && g_ownRace && unit && unit == Me()) {
WriteRace(unit, g_buildRace);
UpdateDisplayInfo_o(unit);
WriteRace(unit, g_ownRace);
return;
}
UpdateDisplayInfo_o(unit);
}
static const char *RACE_USAGE = "Usage: DmorphHelper_GetRace(unit)";
static const char *SET_RACES_USAGE = "Usage: DmorphHelper_SetRaces(buildRace 0-20, ownRace 0-20)";
static const char *REBUILD_USAGE = "Usage: DmorphHelper_Rebuild(unit)";
static int GAME_FASTCALL Script_GetRace(void *L) {
void *unit = PlayerArg(L, 1, RACE_USAGE);
LuaPushNumber(L, Fields(unit)[UNIT_FIELD_BYTES_0] & 0xFF);
return 1;
}
// DmorphHelper_SetRaces(buildRace, ownRace): build your model as buildRace
// and keep ownRace in your race byte (written at once). 0, 0 turns it off.
static int GAME_FASTCALL Script_SetRaces(void *L) {
uint32_t build = NumberArg(L, 1, 0, 20, SET_RACES_USAGE);
uint32_t own = NumberArg(L, 2, 0, 20, SET_RACES_USAGE);
if (!UpdateDisplayInfo_o) {
LuaError(L, "DmorphHelper couldn't hook the model builder.");
return 0;
}
g_buildRace = build && own ? build : 0;
g_ownRace = build && own ? own : 0;
void *me = Me();
if (me && g_ownRace) {
WriteRace(me, g_ownRace);
}
return 0;
}
// Rebuilds a model (for a change the game made without rebuilding it).
static int GAME_FASTCALL Script_Rebuild(void *L) {
Reload(PlayerArg(L, 1, REBUILD_USAGE));
return 0;
}
@@ -249,6 +331,9 @@ static void GAME_FASTCALL LoadScriptFunctions_h(void) {
RegisterFunction("DmorphHelper_SetLook", (uintptr_t)&Script_SetLook);
RegisterFunction("DmorphHelper_GetScale", (uintptr_t)&Script_GetScale);
RegisterFunction("DmorphHelper_SetScale", (uintptr_t)&Script_SetScale);
RegisterFunction("DmorphHelper_GetRace", (uintptr_t)&Script_GetRace);
RegisterFunction("DmorphHelper_SetRaces", (uintptr_t)&Script_SetRaces);
RegisterFunction("DmorphHelper_Rebuild", (uintptr_t)&Script_Rebuild);
}
// The game's own image must reach every address used here (a 1.12.1 exe).
@@ -281,6 +366,12 @@ static void InstallHook(void) {
(LPVOID *)&LoadScriptFunctions_o) == MH_OK) {
MH_EnableHook((LPVOID)FUN_LOAD_SCRIPT_FUNCTIONS);
}
// Without it the race functions say so; everything else still works.
if (MH_CreateHook((LPVOID)FUN_CGUNIT_C_UPDATE_DISPLAY_INFO, (LPVOID)&UpdateDisplayInfo_h,
(LPVOID *)&UpdateDisplayInfo_o) != MH_OK ||
MH_EnableHook((LPVOID)FUN_CGUNIT_C_UPDATE_DISPLAY_INFO) != MH_OK) {
UpdateDisplayInfo_o = NULL;
}
}
static BOOL Ready(void) {
Binary file not shown.
+76 -9
View File
@@ -1483,6 +1483,41 @@ quiet()
say(".item head 0")
wait(3)
check(channelSays("DMO2 L 3HR 0 eA"), "once they come into range, your changes reach them")
-- Sizes are shared too (put on with DmorphHelper).
local sized = {}
function DmorphHelper_SetScale(unit, scale)
local u = Mock.Unit(unit)
if not u then
error("Unit not found.")
end
sized[u.guid] = scale
end
function DmorphHelper_GetScale(unit)
return 1
end
hear("Ally", "L 3HR 0 - " .. ally .. " s150")
check(sized[ally] == 1.5 and morphOf(ally).display == 4527, "a DMorph user's size shows on them")
hear("Ally", "S 50")
check(sized[ally] == 0.5, "a size message changes only the size")
hear("Ally", "S 100")
check(sized[ally] == 1, "and their own size goes back when they reset it")
hear("Ally", "L 3HR 0 - " .. ally)
check(sized[ally] == 1, "a look without a size (or from DMorph before 2.6) means normal size")
quiet()
DmorphOctoDB.scale = 2
say(".item head 0") -- any change tells the sharing code
wait(3)
check(channelSays("DMO2 S 200"), "your size goes out to DMorph users around you")
quiet()
hear("Someone", "Q Tester")
wait(4)
check(channelSays(" s200"), "and with your look when someone asks")
DmorphOctoDB.scale = nil
say(".item head 0")
wait(3)
hear("Ally", "L 3HR 3HR - " .. ally) -- Ally's look as the tests below remember it
DmorphHelper_SetScale, DmorphHelper_GetScale = nil, nil
Mock.units.target = nil
-- Looks are remembered: after a /reload a known player shows at once, and is
@@ -1749,12 +1784,30 @@ local OPTIONS = {
local game
local function installHelper(look)
game = { look = look, real = look, enchants = { [16] = { 803, 0 }, [17] = { 0, 0 }, [18] = { 0, 0 } }, lookWrites = 0,
scale = 1 }
scale = 1, race = 1, build = 0, own = 0, rebuilds = 0 }
local function whole(v, max)
return type(v) == "number" and v >= 0 and v <= max and v == math.floor(v)
end
function DmorphHelper_Version()
return 2
return 3
end
-- The race byte: VanillaHelpers writes the morph's race there (tests set
-- game.race), DmorphHelper_SetRaces keeps your own one in it.
function DmorphHelper_GetRace(unit)
return game.race
end
function DmorphHelper_SetRaces(build, own)
if not (whole(build, 20) and whole(own, 20)) then
error("Usage: DmorphHelper_SetRaces(buildRace 0-20, ownRace 0-20)")
end
local on = build ~= 0 and own ~= 0
game.build, game.own = on and build or 0, on and own or 0
if on then
game.race = own
end
end
function DmorphHelper_Rebuild(unit)
game.rebuilds = game.rebuilds + 1
end
function DmorphHelper_GetScale(unit)
return game.scale
@@ -1797,6 +1850,7 @@ local function removeHelper()
DmorphHelper_Version, DmorphHelper_GetItemEnchants, DmorphHelper_SetItemEnchants = nil, nil, nil
DmorphHelper_GetLook, DmorphHelper_SetLook = nil, nil
DmorphHelper_GetScale, DmorphHelper_SetScale = nil, nil
DmorphHelper_GetRace, DmorphHelper_SetRaces, DmorphHelper_Rebuild = nil, nil, nil
end
local function sameLook(a, b)
@@ -1859,13 +1913,13 @@ DmorphOctoDB, DmorphOctoAccount = nil, nil
loadWithHelper()
Mock.Tick(1.1)
slash("dmorph status")
check(contains(allChat(), "DmorphHelper v2 is loaded"), "status shows the helper's version")
check(contains(allChat(), "DmorphHelper v3 is loaded"), "status shows the helper's version")
slash("dmorph check")
check(contains(allChat(), "DmorphHelper: |cff33ff99OK"), "the check says the helper runs")
local currentVersion = DmorphHelper_Version
DmorphHelper_Version = function() return 1 end
DmorphHelper_Version = function() return 2 end
slash("dmorph check")
check(contains(allChat(), "An older DmorphHelper (v1)") and contains(allChat(), "Install DmorphHelper.bat"),
check(contains(allChat(), "An older DmorphHelper (v2)") and contains(allChat(), "Install DmorphHelper.bat"),
"an older DLL in the game folder is flagged, with how to update it")
DmorphHelper_Version = currentVersion
@@ -1993,14 +2047,27 @@ check(sameLook(game.look, orc), "and gets it back")
SpellBookFrame = CreateFrame("Frame", "SpellBookFrame")
SpellBookFrame:Hide()
Mock.Fire("PLAYER_LOGIN")
-- DmorphHelper v3 keeps your own race in the game's race byte during a race
-- morph (the model is built as the Orc): languages, flight paths and spells
-- follow your own race, so nothing has to be held.
check(game.build == 2 and game.own == 1 and game.race == 1,
"an Orc race morph is built as an Orc while your own race (Human) stays in the race byte")
game.race = 2 -- VanillaHelpers writes the morph's race again
Mock.Tick(0.2)
check(game.race == 1, "your own race goes straight back in")
SpellBookFrame:Show()
Mock.Tick(1.1)
check(vh.display == 49 and sameLook(game.look, REAL),
"while the spellbook holds your own race, your real look shows (not the Orc one)")
check(vh.display == 51 and sameLook(game.look, orc), "the spellbook no longer needs your own model shown")
SpellBookFrame:Hide()
Mock.Tick(1.1)
check(vh.display == 51 and sameLook(game.look, orc), "and the Orc morph and look come back when it closes")
SpellBookFrame = nil
local rebuilds = game.rebuilds
Mock.Fire("UNIT_INVENTORY_CHANGED", "player")
Mock.Tick(0.2)
Mock.Tick(0.2)
check(game.rebuilds == rebuilds + 1, "gear the server changes is rebuilt as the morph's race")
Mock.Fire("UNIT_INVENTORY_CHANGED", "target")
Mock.Tick(0.5)
check(game.rebuilds == rebuilds + 1, "but not someone else's")
press(DmorphOctoCreatorRandom)
check(wearable(game.look, "2:0") and vh.display == 51, "the dice picks a look the race can wear, on your model")
-- From an NPC look: the rows take you back to your own model with its face.