mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
e5dec4dbb73ddcc92501babdb18df92a4aa55c60
1511
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e5dec4dbb7 |
fix(auctionhouse): don't post from a quiver or soul bag's free slot
The multisell's free-slot search treated a bag as general-purpose when its item record's BagFamily field read 0. A vanilla quiver, ammo pouch or soul bag leaves that field empty (the family comes from its class/subclass), so those bags counted as general and a stack could be split into them. It now asks Item::BagFamily::BitmaskForRecord, the reader Container::Bag and C_Item.GetItemFamily already use. A bag whose record is not cached is still not trusted as general. |
||
|
|
075525a3bb |
refactor(event): add SignalHook::AutoObserve for one-event observers
Five SignalHook subscribers never suppress anything: each checks for one
event id and returns false (the totem tracker on SPELLS_CHANGED,
MirrorTimer on PLAYER_LEAVING_WORLD, SelectionColor on FRIENDLIST_UPDATE,
ActivationOverlay on SPELL_UPDATE_USABLE, loot/Scan on QUEST_LOG_UPDATE).
SignalHook::AutoObserve{eventID, fn} takes the id and a plain callback;
the hook on FUN_FIRE_EVENT_NO_ARGS runs the matching observers before the
interceptors, so an observer also sees an event an interceptor
suppresses. The five use it; interceptors (loot suppression, the
PLAYER_ENTERING_WORLD payload, the script profiler) stay AutoSubscribe.
|
||
|
|
544cb603ff |
refactor(event): name the engine event ids in Offsets.h
Engine event ids are fixed for the binary: each is its slot in the static name array at 0xBE1198, written by the boot initializer FUN_0051AB30 as `mov [0xBE1198 + id*4], "NAME"`. Offsets.h already carried a few as constants (SPELL_UPDATE_USABLE, UPDATE_MOUSEOVER_UNIT, ...), but seven modules resolved others by name at runtime with LookupByName and cached the result in a global of their own, and loot/Scan kept three as local constants. The ids were read from those stores in WoW.exe (the same read reproduces every constant already in Offsets.h): UNIT_FACTION 0x1D, UI_ERROR_MESSAGE 0xE0, SPELLS_CHANGED 0x104, LOOT_OPENED 0x10B, LOOT_CLOSED 0x10D, PLAYER_ENTERING_WORLD 0x110, PLAYER_LEAVING_WORLD 0x111, QUEST_LOG_UPDATE 0x134, FRIENDLIST_UPDATE 0x15F. The totem tracker, MirrorTimer, SelectionColor, the UNIT_FACTION polyfill, the equipment-set errors, friend notes, the PLAYER_ENTERING_WORLD payload and loot/Scan now use them. cvar/Update keeps its lookup by name: cvars also change on glue, whose event table has no CVAR_UPDATE. The SignalHook comparisons stay correct on glue because no glue event id (0..25) equals any of these. |
||
|
|
19bfd118d3 |
fix(totem): fire PLAYER_TOTEM_UPDATE on the reservation's live slot
The tracker looked up its own reserved event with LookupByName once and kept the id in a global for the process lifetime. A /reload re-claims custom event slots (Event::Custom::PrepareForReload / RetryClaims), so after a reload the cached id could name another event, or none, and PLAYER_TOTEM_UPDATE went to the wrong slot. It now reads _totemUpdate.Slot() at fire time, as Custom.h prescribes. |
||
|
|
58cffbf33f |
refactor(spell): CancelSpellByName finds the aura with FindSlotBySpellName
CancelSpellByName walked the player's buff slots 0..31 itself and matched names with the C runtime's _stricmp. Aura::Data::FindSlotBySpellName is that lookup already, comparing with the engine's SStrCmpI as 4.3.4's GetSortedAuraSlot does for UnitAura's name form. It now calls it with the Helpful filter, which selects by the aura's real polarity rather than the slot range: on Turtle a debuff that spills into a buff slot is no longer a match, and it could not be cancelled anyway. |
||
|
|
749b7007d0 |
refactor(unit): share CreatedBySpell through Unit::Identity
UNIT_CREATED_BY_SPELL (+0x230) was read by a file-private helper in Unit::Pet (behind UnitCreatedBySpell) and again inline by Totem::Owner's totem test. It is now Unit::Identity::CreatedBySpell, beside OwnerGuid, the other summoner field reader; both callers use it. |
||
|
|
dbbff4d9e6 |
refactor(lua): one Game::Lua::GlobalText over FrameScript_GetText
Five files declared their own typedef for FrameScript_GetText (FUN_FRAMESCRIPT_GET_TEXT, 0x703BF0) and called it with (-1, 0): the chat tokens' %f fallback, the combat log's UNKNOWNOBJECT, Item::TypeInfo's equip-slot names, the equip-slot name match and /fstack's header. With no count or gender the engine takes FrameScript::GetVariable (0x704350): a _G read that also takes a number, "" when unset, never null. They now call Game::Lua::GlobalText(name). The equip-slot match calls Item::TypeInfo::InvTypeName rather than re-deriving it. EquipmentSet::Text::Global stays separate on purpose: it reads raw (it runs on the world tick, where no __index may run) and returns a copy. |
||
|
|
f13e9acd1e |
refactor(spell): one Spell::Lookup::DurationMs over the engine's helper
Six call sites declared their own typedef for FUN_GET_SPELL_DURATION (0x6EA000) and called it with pet = 0: aura/Source, model/SceneSpell, spell/Cast (twice), the totem tracker and turtle/DurationMods. Their third-argument types even disagreed (char / int). They now call Spell::Lookup::DurationMs(rec, applyMods), which returns the engine's value unchanged (negative for an infinite duration), so each caller keeps its own clamp and SceneSpell still sees "forever" for an endless channel. |
||
|
|
78c69741f4 |
refactor(object): read descriptors through Object::Fields
The descriptor pointer (m_objectFields, the broadcast UpdateField block) of a unit, player, game object or corpse sits at +0x110, and Offsets.h named that one slot three times: OFF_UNIT_DESCRIPTOR, OFF_CGUNIT_OBJECT_FIELDS and OFF_GAMEOBJECT_DESCRIPTOR. About 45 sites read it inline and eight files kept a one-line Descriptor() / Fields() wrapper of their own (aura/Data, aura/Instance, unit/Health, unit/Power, spell/AutoPrepare, spell/Range, combatlog/Entry, object/Corpse). There is now one constant, OFF_OBJECT_FIELDS, carrying the Script_UnitClass verification (0x5183FE), and one null-safe reader, Object::Fields(obj), beside Object::ByGuid. Every read and every wrapper goes through it. An item's descriptor sits at +0x114 and keeps Item::ObjectFields. The two raw uses of the offset that remain need the address, not the value: the game-object usable-mounted call takes &object->descriptor, and cursor/Npc's thunk asserts the replayed offset. |
||
|
|
117781d5fc |
refactor(unit): reach the local player through Unit::Identity
Seventeen files resolved the local player with the token resolver,
ResolveUnitToken("player"). Unit::Identity::PlayerObject() returns the
same CGPlayer (both go through FUN_OBJECT_RESOLVE_BY_GUID with a mask the
player passes), but by GUID with no token parse and gated on the object
registry, so it is null out of world instead of reaching a resolver that
dereferences a null registry root.
Four local wrappers go with it: aura/Data's LocalPlayer, debug/Probe's
ResolvePlayer / ResolvePlayerDescriptor, player/InputEvents' Player, and
spell/Level's PlayerDescriptor. Sites that resolved the player only to
read its descriptor (IsCurrent, Mod, SkillLine, ShapeshiftForm) call
Unit::Identity::PlayerDescriptor. The RegistryReady gates in loot/Scan,
loot/Unit, loot/Nearby and target/Nearest only guarded calls that are now
gated themselves, so they go too.
|
||
|
|
4dc7e5130a |
refactor(object): gate on Object::RegistryReady instead of the raw pointer
Six sites tested [VAR_LOCAL_PLAYER_PTR] for null inline to mean "the world is up": loot/Scan, loot/Unit, loot/UnitItem, target/Nearest, the totem tracker, and the inline-texture glue check (whose comment already defines glue as "no local player"). Object::RegistryReady is that exact test, named; they now call it. The remaining reads of the global use its value (SoftTarget's manager identity, Identity's player GUID), not a null test. |
||
|
|
d92203aa6e |
refactor(event): fire engine events through Event::Custom::Fire
Event::Custom::Fire is the one typed wrapper over the engine's printf-style dispatcher FUN_FIRE_EVENT (0x703F50), and it works for any event id, not only reserved ones. Five sites declared their own cdecl typedef and cast the address instead: the chat-event site redirect (chat/EventArgs), the UNIT_FACTION polyfill, Unit::Focus, and the two token re-fires in Unit::TokenEvents. They now call the wrapper; the arguments and their order are unchanged. |
||
|
|
3cc66e6cff |
refactor(spell): read spell icons through Spell::Lookup::IconPath
Six modules resolved a spell's SpellIcon.dbc path themselves: aura/Data, lossofcontrol, spell/Cast, spell/Info (twice), spell/Tracking and the totem tracker, each with its own records/count walk. They now call Spell::Lookup::IconPath(rec, active). Tracking keeps its fallback to the base icon when the spell has no active icon. IconPath treats an empty path as missing; the extracted SpellIcon.dbc has no empty path in any of its 1502 rows, so no return changes. spell/Info's LookupSubRecord and ReadGlobal go with it; its one remaining use, the SpellRange row, reads through DBC::Record with the same id > 0 guard. |
||
|
|
8de1d08d4b |
refactor: read every localized DBC string through DBC::LocalizedString
The remaining inline `record + offset + [VAR_LOCALE_INDEX] * 4` reads (Map, Faction, FactionGroup, ItemSet, SpellItemEnchantment, QuestInfo, ItemSubClass) now go through DBC::LocalizedString / LocalizedField. The ItemSubClass.dbc walk and the ItemClass / INVTYPE lookups were written three times: item/Info.cpp and item/GetData.cpp each carried a copy of what Item::TypeInfo already exports. Both now call Item::TypeInfo::ClassName / SubClassName(FindSubClass(...)) / InvTypeKey; SubClassName accepts a missing row and returns "". The locale clamps in item/Set, item/EnchantInfo and quest/Details go: start-up stores VAR_LOCALE_INDEX as a position in the 8-entry locale name table (0x402562), so it is always 0..7 and in range of every 8-slot name array, and the engine's own enchant-name readers (FUN_00496170, FUN_00495D60) index without one. EnchantInfo keeps its enUS fallback for an empty name. ITEMSET_LOCALE_COUNT is dropped and QuestInfo's name column gets OFF_QUESTINFO_NAME in Offsets.h. Sites that pushed an empty string as "" keep "". |
||
|
|
8917bf0a2a |
refactor: share the spell-name, rank and distance readers
Spell.dbc's localized name and rank were read inline in about 20 files, each re-deriving `record + offset + [VAR_LOCALE_INDEX] * 4`. They now go through Spell::Lookup::Name / Rank, which sit on a new DBC::LocalizedString(record, offset): the record-pointer form of the existing by-id DBC::LocalizedField, which now calls it. Both return null for an empty string. A DBC string slot is never null, only "", so every site that passed an empty name or rank through as "" (GetSpellInfo's rank, the cast-info returns, the UNIT_SPELLCAST_* formats, where a null %s corrupts the arguments after it) keeps "" explicitly. Private copies go: combat log SpellName, aura/Data LocalizedSpellName, CastEvents LocalizedField and two unused LocaleIndex helpers. Game::DistanceSq replaces about a dozen inline x/y/z squared-distance sums over float[3] points. It sums in the same order, so results are bit-identical, including the model-scene sites that mirror engine float math. Vec3-struct, 2D and differently ordered sums stay as they are. Totem::Owner now uses Unit::Identity::OwnerGuid for the owner and Aura::Data::FindSlotBySpellName to find the aura on a totem, in place of its own copies. |
||
|
|
ac45d56a43 |
feat(aura): attribute totem auras to the totem's owner
Every aura a totem applies now names the shaman who owns the totem as its caster, so sourceUnit is "player" for your own totems' auras, on you and on every group member in view. The server's caster is the totem, so this is a ClassicAPI extension. A unit is a totem when its UNIT_CREATED_BY_SPELL (+0x230) is a spell with a SUMMON_TOTEM_SLOT1..4 effect (87-90); its owner is UNIT_FIELD_CREATEDBY. The server stamps both on every totem and both are broadcast, so other shamans' totems resolve too. Totem::Owner holds the two lookups. A party area aura (Strength of Earth, the resistance totems) reaches the group with no packet that names the caster: the server copies it onto each member itself. The totem keeps its own copy in a visible aura slot, though, so the application hook (FUN_ON_AURA_ADDED, 0x6123F0) looks for a visible totem that carries the same spell line (same ID, or same localized name, since a low-level target gets a lower rank). The target's own totem wins, then the nearest one. A stranger's group is not visible to the client, so two groups' identical totems side by side are told apart by distance only. An aura a totem casts (Earthbind) arrives through SMSG_SPELL_GO with the totem as caster. The aura store and its duration now use the owner (the server applies the owner's duration mods to a totem's spells); the cast events keep the totem. The six modules that walked the object list each declared their own typedefs for ClntObjMgrEnumObjects (0x468380). They now share Object::ForEachVisible, which also gates on the object registry, since the walker reads the object manager with no null check. The totem effect IDs move to Offsets.h, and spell/Level.cpp drops its local copy of SPELL_EFFECT_APPLY_AREA_AURA_PARTY. |
||
|
|
1e91b5e033 |
feat(totem): add the totem1-totem4 unit tokens
"totem1" .. "totem4" now name the player's totem creature in each
totem slot (1 Fire, 2 Earth, 3 Water, 4 Air), so UnitGUID("totem1")
gives the slot's GUID and every other Unit* function works on it too.
GetTotemInfo keeps the 7 returns that retail has.
The token is a new branch in the existing hook on the token-to-GUID
resolver FUN_TOKEN_TO_GUID (0x515970), next to markN. All the Script_Unit*
globals, TargetUnit, IsUnitToken and the [@unit] macro conditions read
tokens through that one function, so they all accept it. The GUID comes
from Totem::Tracker, which finds the creature by its entry and
CreatedBy == player. The token is empty until the tracker finds that
creature.
Unit events reach the token the same way they reach markN: totemN is
appended to Unit::TokenEvents' token list, and the tracker calls
TokenEvents::Refresh when a slot gets its creature, when the creature
goes away, and when a recast replaces it. Refresh reruns the engine's
recompute FUN_UNIT_SCRIPT_RECOMPUTE, which sets or clears the
registration bit that makes the engine watch the unit's fields.
|
||
|
|
ad9c8213ea |
feat(autocomplete): suggest the account's other characters
C_AutoComplete now knows the characters on this realm's character list. Each one has the AccountCharacter flag and the priority AccountCharacterSameRealm, which ranks above Friend. None has the Online flag, because the account plays the current character, so lists that need Online (whisper, invite) leave them out and lists like mail include them. The source is the session's own copy of the list. In 1.12.1 the ClientConnection at 0xC28128 lives from startup to exit, and RealmConnection::HandleCharEnum (0x5B42A0) stores the SMSG_CHAR_ENUM records at +0x1AE8 (count +0x1AE4, 0x110 bytes each, guid +0x00, name +0x08). Only that handler rebuilds the array and only ~RealmConnection frees it, so it is still there in the world. The glue roster at 0xB42144 cannot be used: CGlueMgr::Suspend (0x46AC90) frees it on the way into the world. The connection is read through ClientServices::GetCurrent (0x5AB490) with a null check. |
||
|
|
5f924b7714 |
feat(install): log which hook failed to install
A failed install used to leave ClassicAPI absent with no trace of why: InstallHooks returned false on the first MinHook error and nothing was written anywhere. Every failing step now writes one line to Logs\classicapi_debug.log with the step, the target address and MinHook's status string. Feature hooks also name their registration site (file:line). HookAutoRegister records it through __builtin_FILE / __builtin_LINE default arguments, so none of the registrations had to change. The five core hooks in DllMain name their Offsets constant, and MH_Initialize / MH_ApplyQueued failures are logged too. No hook is live until the final MH_ApplyQueued, so any failure leaves the client fully stock; the log line says so. |
||
|
|
bb6df3556c |
feat(settings): retail Settings window, with Interface Options on top
Ports retail's Blizzard_Settings_Shared (Settings, categories, canvas and vertical layouts, the setting controls, key binding rows, SettingsPanel, SettingsInbound) as the one options window. Addons of both eras land in it: newer addons register through the Settings API, and the 3.3.5 InterfaceOptions_AddCategory API (Ace3's AddToBlizOptions) now registers a canvas category. Its panel protocol maps onto the window's: okay on commit (Close, Apply, Escape), default and refresh where the window calls OnDefault / OnRefresh, cancel only when the window closes without a commit. A panel's name is its category ID, as Ace3 and newer addons set it. The old InterfaceOptionsFrame* names alias the window's frames so addons that restyle or overlay them keep working. ClassicAPI's own pages are vertical layouts of Settings controls (cvar and proxy settings, key binding rows, a ClassicAPI number box for settings that take any number), so the window's search finds them. They are the window's game categories, at the root of its first tab, which reads ClassicAPI; addons go on the AddOns tab. C_SettingsUtil.OpenSettingsPanel and NotifySettingsLoaded fire SETTINGS_PANEL_OPEN and SETTINGS_LOADED through the engine's event dispatcher (Event::Custom::FireValues), passing the category ID as given. Also: slider:SetEnabled, Enum.BindingSet, C_CVar.GetCVar / GetCVarDefault / RegisterCVar, C_KeyBindings.GetBindingIndex and its two context answers, and retail's CvarUtil, BindingUtil, MinimalSlider, DropdownWithSteppers and ColorPickerFrame:SetupColorPickerAndShow. Engine changes the window needs: - CVAR_UPDATE(cvarName, value) for every change of a cvar Lua can see, from a hook on CVar::Set (0x0063DF50). 1.12 fires CVAR_UPDATE only from Script_SetCVar with a caller's token. The change is queued and fired at the head of the next UI frame, never inside the setter: the engine sets cvars mid-way through its own work while a script runs further up the stack. - Script SetParent (0x007A1550) shows a frame that is shown under a visible parent, as 3.3.5's CSimpleFrame::SetParent does; 1.12's (0x0076AB10) re-shows only a frame that was visible before. The key binding rows move their buttons onto an input blocker and back after the blocker is hidden. - The child walks of the frame show (0x0076AE10) and hide (0x0076AD50) run on a copy of the child list and skip a child that has left. Each child runs its OnShow / OnHide inside the walk, and 1.12 (and 3.3.5, and 4.3.4) read the next node only afterwards, from a node a reparenting script may have freed. Auctionator's options page opens another page from its OnShow, and the window takes the first out of its canvas with SetParent(nil) while the canvas is being shown. 1.12 specifics in the port: - ToggleGameMenu() without an argument is the Escape handler and can SpellStopCasting or ClearTarget, so closing returns to the game menu through ShowUIPanel(GameMenuFrame). - StaticPopup_EscapePressed runs OnCancel(data, "clicked"), so button2 is always the dialogs' no-op choice. Only Turtle's StaticPopup has button3 / OnAlt; stock 1.12 shows two buttons. - The layout-cache reader (0x4905e0) replaces a movable or resizable frame's anchors and size from a saved record, so the window is neither: it has no drag or size handle. - A $parent name under an unnamed frame takes the nearest named ancestor's name, so pooled rows avoid templates that anchor slices by name (UIPanelButtonTemplate2, InputBoxTemplate). - GetChecked returns 1 or nil, GetBinding has no category, and GetBindingText is FrameXML Lua that needs the "KEY_" prefix. - The slider rounds every value to its step in single-precision floats, and the rounding does not settle, so a value set from a setting does not report back as a change. - Retail's Options and control atlases do not exist; the controls use 1.12's checkbox, slider, dropdown and spellbook page arrows, the frames the tooltip backdrop. Retail's strings are added in all eight locales. Not ported yet: the Keybindings category.v1.21.0 |
||
|
|
d3f0674b1a |
feat(item): fire WEAPON_ENCHANT_CHANGED
WEAPON_ENCHANT_CHANGED (no payload) fires when the temporary enchant on an equipped main hand, off hand or ranged weapon is applied, renewed or removed, or loses a charge. 1.12 signals nothing for SMSG_ITEM_ENCHANT_TIME_UPDATE (0x1eb): HandleItemTimers (0x5e4f30) only calls CGItem_C::SetEnchantmentExpiry (0x5d9cc0). A renewal of the same enchant changes only that clock, so no descriptor field and no UNIT_INVENTORY_CHANGED report it. A Net::PacketDispatch subscriber reads the body (u64 item GUID, u32 slot) and marks the event for the temporary slot of an equipped weapon. Field changes come from the engine's type-wide ITEM_FIELD_ENCHANTMENT watcher OnItemEnchantmentChanged (0x5d95a0, registered by 0x5d9360 on the whole 7-slot block). A post-original co-hook marks the event when the item is an equipped weapon, found with Item::Location::FindByGUID. Both paths only mark; the event fires once on the next WorldTick. That is the UniqueEvent shape Blizzard's docs give it, and it orders the fire after the engine's handler, which runs after the funnel subscriber and sets the expiry GetWeaponEnchantInfo reads. WeaponEnchant.cpp's local INVSLOT_* copies now use Offsets.h. |
||
|
|
4ab88523ba |
fix(swing): pick the ranged range probe by the equipped weapon
C_SwingTimer's Ranged range check chose its probe spell by the ranged item's ammo type: ammo -> Auto Shot (75), none -> Shoot (5019). Thrown weapons use no ammo, so they got the wand's 0-30 yd range with no minimum, and warriors and rogues with a bow, gun or crossbow got Auto Shot's 35 yd instead of their own 30 yd. The probe now walks the ranged attack spells (Auto Shot, Shoot, Throw, Shoot Bow, Shoot Gun, Shoot Crossbow) and asks the engine's own equipped-item check, 0x006E40E0 (the leg of the IsUsableSpell verdict 0x006E3D60 that matches EquippedItemClass / EquippedItemSubClassMask against unbroken equipped items), which ones the weapon satisfies. It takes the first the player knows, else the first that fits, so Auto Shot wins for a hunter and Throw or the matching Shoot for everyone else. It is called with checkAmmo and report off, so it never posts an error. A broken ranged weapon fits none and reports no check. Auto Shot's ID moves to Offsets.h; CastEvents had its own copy. |
||
|
|
73266d64a2 |
feat(tooltip): pass the item GUID to OnTooltipSetItem
OnTooltipSetItem now gets the shown item's GUID as arg1, and as (self, itemGUID) under modern script args. It is nil when no item object is behind the tooltip. This is a ClassicAPI extension. The value is p3 of CGTooltip::BuildItem (0x52b650), the item object's GUID. It is read from the builder call, not from tooltip+0x380, because an incremental build (p7 = 1, a recipe's created item) skips that copy. SetBagItem, SetBuybackItem, SetSendMailItem, SetInventoryItem, SetTradePlayerItem and SetAction pass a real GUID. SetLootItem passes a zero GUID, as do the other setters whose item is a loot, merchant, auction, mail or link row. The fire goes through Frame::ScriptArgs::RunWithValues, which, like FUN_00704d50, does not touch the exec context. The stack save/restore, recursion guard and compare Suppressor stay as before. Every GUID-to-item lookup now goes through one search, Item::Location::FindByGUID. It reads the player's inventory list as a GUID array, the way FUN_INVMGR_WALK (0x6223f0) does: equipment and bag slots, backpack, bank 39..68, buyback 69..80 and keyring 81+. It also reads each equipped bag's and bank bag's own list. A GUID string passed to C_Item.GetStackCount and the other item accessors now finds bank, keyring and buyback items. C_Item.GetItemLocation and the location form of the action APIs now return keyring, bank and equipped-bag locations. Buyback has no location. The bank counts only while the banker GUID at 0xbdd038 is set, the same gate GetItemBySlot applies. The search does not resolve through the object manager alone, because a deleted, mailed or traded item stays there. Equipment sets had their own copy of this walk. They now use the shared search and keep their scope: gear, bags and bank, never equipped bags, the keyring or buyback. BankerOpen moves to Item::Location. The buyback range is the server's BUYBACK_SLOT_START/END. |
||
|
|
0959f9ebf6 |
feat(broodwatch): Onyxia descends at ten minutes
The run no longer ends at 10:00. The brood, the elites and the egg clutches stop, and Onyxia flies in and lands near you. Killing her wins the run, and the banner shows how long the fight took. She fights in the three phases of the server script (vmangos boss_onyxia): - To 65%: she follows you and uses Flame Breath (a cone ahead), Tail Sweep (behind her, a knockback) and Wing Buffet (all around her, a knockback), on the script's timers. - To 40%: she flies between eight points above the lair and throws Fireball at your spot. Sometimes she crosses the lair with Deep Breath over a marked lane that bursts into burning ground. Whelps come in waves from the lair's two caves. - After that: she lands, and Bellowing Roar fears you and makes the lava cracks erupt. In the air her movement is off and Onyxia.lua moves her each step, with her model's LiftOff, Fly, Hover and Land animations. She cannot die in the air. Her model has no Dead animation, so she holds the last frame of Death. Foes.lua now gives a kind a list of acts, each with its own timer. An act can be limited to the front or back of the striker, and can deal a share of your maximum health. Two new act types: a cone that can point behind the striker, and a nova around it. Onyxia does not take taunts, holds, knockbacks or the Sapper and Soulstone instant kills. `/broodwatch onyxia [2|3]` brings her at once, at the health that starts that phase. |
||
|
|
944236d6e6 |
fix(api): match retail in fourteen functions and events
These are the bugs found while the API descriptors were written. Each was checked against Blizzard's generated documentation, and the ones marked "probed" against a live retail client. Return values - C_Item.GetItemData: allowableClass and allowableRace are signed in the ItemStats record, where -1 means all. They were read as unsigned and came out as 4294967295. - C_DateAndTime.CompareCalendarTime: the sign was reversed. It now returns 1 when the first time is earlier (probed). - CopyToClipboard: returns 0 when the clipboard could not be written. It returned the length even then. - C_TaxiMap: position is a vector, so position:GetXY() works. Arguments - UnitIsAFK / UnitIsDND: a non-string argument raises the usage error, as the sibling unit functions do. It returned false. - UnitInRange: the "player" check ignores case, as token resolution does. "Player" ran a real range check. - C_Timer.NewTimer / NewTicker: the callback receives its handle. The handle is pinned in the registry beside the callback and released with it. C_Timer.After still passes nothing. C_EncodingUtil - CompressString and DecompressString default to Deflate. Decompress no longer detects Zlib or Gzip when the method is omitted. - CompressString takes Enum.CompressionLevel (new enum), mapped to zlib levels -1, 1 and 9. A raw zlib level made Enum.CompressionLevel.Default (0) store the data uncompressed. - Enum.Base64Variant.UrlSafe is renamed StandardUrlSafe, and its encoded output is padded (probed: "a" gives "YQ=="). - SerializeJSON / SerializeCBOR raise "attempted to serialize a <type> value" for a function or userdata (probed). They returned nothing. The new options.ignoreSerializationErrors writes such a value as null / undefined (probed). The error is raised after the encode buffers are released, because a Lua error does not unwind C++ frames. - SerializeCBOR writes Lua strings as byte strings (probed: the key "a" is 41 61). The decoder already reads both kinds. Events - AUCTION_MULTISELL_START passes the number of auctions. - LOSS_OF_CONTROL_ADDED passes "player" before the effect index. Offsets - Script_UnitPowerType (0x00517940, slot 31 of the unit registration table) and the QuestInfo.dbc records/count globals (0x00C0D9CC / 0x00C0D9D0) move from local constants in unit/Power.cpp and quest/Details.cpp to Offsets.h. |
||
|
|
35be7600b6 |
perf(ui): share one copy of the color table across the DLL
kColors in ColorData.h was a namespace-scope constexpr array, which has internal linkage: each of the six files that include the header got its own 2.6 KB copy in .rdata. Marking it inline gives the table external linkage, so the linker keeps one. The DLL shrinks by 16.5 KB (2,254,336 -> 2,237,440 bytes). |
||
|
|
b7a78565f7 |
docs: an API descriptor for every registration (#144)
* docs(container): describe the C_Container functions
Descriptors for the 17 undocumented C_Container functions and the
ItemQuestInfo structure. SwapItems, MoveItem, AutoStoreItem,
GetContainerItemCharges, GetContainerItemRepairCost and
IsContainerItemOpenable are not in retail's API and are marked as
ClassicAPI extensions.
* docs(aura): describe the C_UnitAuras functions
Descriptors for the 16 undocumented C_UnitAuras functions, plus the
AuraData structure that GetAuraDataByAuraInstanceID already named but
nothing defined. The four positional getters share the Classic Era
UnitAura return list.
* docs(equipmentset): describe the C_EquipmentSet functions
Descriptors for the 18 undocumented C_EquipmentSet functions,
GameTooltip:SetEquipmentSet, and the EQUIPMENT_SETS_CHANGED,
EQUIPMENT_SWAP_PENDING and EQUIPMENT_SWAP_FINISHED events. They
describe what the functions return here, which differs from retail in
places: an icon path, not a file ID; numMissing, not numLost;
GetIgnoredSlots lists slot numbers.
* docs(faction): describe the reputation functions
Descriptors for GetFactionIDByIndex, GetFactionInfoByID,
GetFactionParentID, the 17 undocumented C_Reputation functions, the
FactionData structure, and the FACTION_STANDING_CHANGED event.
C_Reputation.IsFactionInactive and SetFactionInactive mirror stock
globals, but no Blizzard client has them under C_Reputation, so they
are marked as ClassicAPI extensions.
* docs(player): describe the player functions and events
Descriptors for C_PlayerInfo.CanUseItem, GetName, GetClass, GetRace,
GetSex and IsConnected; GetPlayerFacing, GetPlayerInfoByGUID,
UnitNameFromGUID and IsLoggedIn; the four C_PlayerCache functions; and
the PLAYER_EQUIPMENT_CHANGED, UPDATE_INVENTORY_DURABILITY,
HEARTHSTONE_BOUND and six PLAYER_STARTED/STOPPED_MOVING, LOOKING and
TURNING events. They describe what the functions return here: sex is 2
or 3, not the UnitSex enum, and GetPlayerInfoByGUID has no level.
C_PlayerCache is ours, so its functions are marked as extensions.
GetCritChance and GetRangedCritChance move from system "PaperDollInfo"
to "PlayerGlobals": PaperDollInfo is the C_PaperDollInfo namespace's
system, and a global must not share it.
* docs(map): describe the C_Map functions
Descriptors for the 30 undocumented C_Map and C_MapExplorationInfo
functions, the UiMapDetails, UiMapLayerInfo, UiMapPoint,
AreaTriggerInfo, MapOverlayInfo and MapOverlayTile structures, and the
USER_WAYPOINT_UPDATED event. mapType is a plain number because no
Enum.UIMapType is registered, and flags is always 0. GetAreaTriggerInfo,
GetAreaTriggers, GetAreas, GetMapAreaIDs, GetMapOverlays and
GetUnexploredMapTextures are marked as ClassicAPI extensions.
* docs(loot): describe the C_Loot and C_LootHistory functions
Descriptors for the six C_Loot functions and the four C_LootHistory
functions, the LootableUnit, ScannedCorpse and ScannedLootItem
structures, and the LOOT_SCAN_COMPLETED and three LOOT_HISTORY_* events.
Every C_Loot function here and C_LootHistory.Clear are marked as
ClassicAPI extensions; Blizzard's C_Loot has none of them.
* docs(sound): describe the sound functions
Descriptors for the six undocumented C_Sound functions, the PlaySound,
PlaySoundFile, StopSound, MuteSoundFile and UnmuteSoundFile globals, the
PlaySoundParams and RecentSoundFile structures, the ItemSoundType and
Vocalerrorsounds enums, and the SOUNDKIT_FINISHED event.
C_Sound.PlaySound's second argument is documented as the channel name it
takes here, not retail's UISoundSubType. GetRecentSoundFiles is marked as
a ClassicAPI extension.
* docs(console): describe the console functions
Descriptors for ConsoleExec, ConsoleEcho, ConsoleIsActive,
ConsoleGetColorFromType, ConsoleGetFontHeight, SetConsoleKey,
CalculateStringEditDistance, ConsoleGetAllCommands and
ConsolePrintAllMatchingCommands, the ConsoleCommandInfo structure, and
the ConsoleCommandType and ConsoleCategory enums. The game and glue
registrations of each function share one descriptor. ConsoleExec and
ConsoleEcho return nothing here, and SetConsoleKey takes a key code.
* docs(voicechat): describe the text-to-speech functions
Descriptors for the four C_VoiceChat text-to-speech functions, the ten
C_TTSSettings functions, the VoiceTtsVoiceType structure, and the five
VOICE_CHAT_TTS_* events. The event payloads follow the shapes the
client sends here. GetSpeechVoiceID, SetVoiceOptionByName and
RefreshVoices are marked as ClassicAPI extensions.
* docs(api): correct entries that drifted from the code
Fixes entries that the descriptor pass found to differ from what the
functions do: C_PlayerInfo.GetSex never returns 1, the name and race
getters need a visible unit for unit locations too, RememberPlayer
raises on missing arguments, mutes outlive a reload, scan results fill
in during a scan, LootHistory names can be nil and ROLL_CHANGED can
carry playerIndex 0, GetMapRectOnMap's fallback and Kalimdor ID, dungeon
maps have no parent, and GetBestMapForUnit gives zones, not subzones.
HEARTHSTONE_BOUND and the player input-state events now describe only
their behavior; the packet handlers, engine addresses and hook notes
are gone.
* docs(loot): say when LOOT_HISTORY_FULL_UPDATE fires
The comment above the loot-history event names said FULL_UPDATE was
never fired from C++, but FireFullUpdate sends it when a roll opens a
new item, when the 128-item ring evicts the oldest entry, and from
C_LootHistory.Clear.
* docs(api): describe behavior, not implementation
API.md is the contract for addon authors, so it no longer names engine
addresses, struct offsets, internal type and field names, packet
opcodes, hook mechanics, source files or our C++ modules, and drops
provenance notes and remarks about which client version lacks what.
Where that text carried a real behavior, the behavior stays in plain
words: "when the server answers" in place of an opcode, "ignores the
merchant and repair cursor modes" in place of the function it skips.
Also: C_Spell.GetSpellPowerCost no longer calls GetSpellInfo's cost the
base cost (both are the effective cost), the C_Spell cast-info note no
longer calls the functions player-only, the name-cache intro says the
game empties its cache on each world entry, and examples use a generic
realm name.
* docs(item): describe the item functions
Descriptors for the 95 undocumented item registrations: the C_Item
readers, lock, use and equip calls, the GetItemInfo family, the
Get*ItemID companions, the GameTooltip item methods, the ItemData,
ItemSetInfo and ItemEnchantInfo structures, the InventoryType,
ItemClass and ItemQuality enums, and the ITEM_DATA_LOAD_RESULT and
GET_ITEM_INFO_RECEIVED events. They describe what the functions return
here where it differs from retail: GetItemSetInfo returns a table,
GetWeaponEnchantInfo returns twelve values, and RequestLoadItemData
returns whether the request went out. GetItemIDForItemInfo's return is
now optional, since input that names no item returns nothing.
* docs(unit): describe the unit functions
Descriptors for the 49 undocumented unit functions, the PowerType enum,
and the PLAYER_FOCUS_CHANGED and UPDATE_SHAPESHIFT_FORM events. They
describe what the functions do here: UnitHealthMissing has no
usePredicted argument, IsFalling and IsSwimming take no unit,
UnitPowerType returns no color, and UnitPosition keeps its Y-first
return order.
* docs(baselib): describe the Lua library additions
Descriptors for the Lua 5.1 functions added to the game's Lua: select,
unpack with a range, xpcall with arguments, collectgarbage options,
debugstack, the math hyperbolics, fmod and modf, string.match, gmatch,
reverse, byte, split, join and trim with their global aliases, and
strreplace, plus Mixin and CreateFromMixins. strreplace is the one
ClassicAPI extension; retail binds the other aliases itself.
* docs(api): correct entries the item and unit descriptors contradicted
UnitIsMinion, UnitIsPet and UnitIsOtherPlayersPet raise on a string that
is not a unit token; only a token that names no unit, or a non-string,
returns false. GetItemCooldown does not take item names. A full request
queue makes RequestLoadItemData return false. GetInventoryItemID needs a
player, so pets and totems return nil. GetItemNameByID keeps a link's
random suffix. GetInventoryItemRepairCost raises on a non-number slot.
The Get*ItemID intro no longer calls the companions stock functions.
Also settles two entries that contradicted themselves: the summoning
ritual's channel events do fire, and GetSecondsUntilDailyReset counts to
UTC midnight. C_PlayerInfo.UnitPosition gets a line under UnitPosition.
* fix(docs): map the remaining widget method registries to systems
Methods registered on the Button, Slider, StatusBar, MessageFrame,
SimpleHTML, ScrollingMessageFrame, PlayerModel and DressUpModel
registries had descriptors, but the browser listed them as an unmapped
registry. The five Blizzard has use its names (SimpleButtonAPI and so
on); the other three are named the same way.
* docs(ui): describe the frame, texture and input functions
Descriptors for the texture, region, frame, button, editbox and tooltip
methods ClassicAPI adds, the C_Texture atlas, C_XMLUtil, C_ColorUtil,
C_UIColor and C_NamePlate functions, the binding, modifier-key, cursor
and screen globals, the AtlasInfo, XML template and DBColorExport
structures, Enum.UICursorType, and the nameplate, cursor and
MODIFIER_STATE_CHANGED events. IsMouseButtonDown, GetMouseButtonName and
GetCursorDelta move to the InputGlobals system.
* docs(spell): describe the spell, action and creature functions
Descriptors for the remaining spell, spellbook, tracking, action bar,
talent, totem, loss-of-control, macro, combat, tradeskill, targeting,
GUID, class, C_CreatureInfo and C_GameObjectInfo registrations, their
structures, and the LEARNED_SPELL_IN_SKILL_LINE, PLAYER_TOTEM_UPDATE,
LOSS_OF_CONTROL_*, CREATURE_DATA_LOAD_RESULT and
GAMEOBJECT_DATA_LOAD_RESULT events. The IsItemAction,
HasBonusActionBar and IsStackableAction globals move from the
C_ActionBar system to ActionBarGlobals.
* docs(world): describe the gossip, quest, social and vendor functions
Descriptors for C_GossipInfo, the friends and /who functions, C_QuestLog
and the quest globals, C_TaxiMap, C_MerchantFrame, C_AuctionHouse.PostItem,
the mail, group, instance, coin-text, chat, character-order and
expansion globals, their structures, the FlightPath enums, and the
QUEST_DATA_LOAD_RESULT and AUCTION_MULTISELL_* events. Globals that
named a namespaced system (QuestLog, PartyInfo, CurrencyInfo) move to
the matching *Globals system, and GetCoinText gets separate global and
C_CurrencyInfo descriptors.
* docs(lua): describe the cvar, encoding, time, addon and Lua functions
Descriptors for the cvar, C_EncodingUtil, C_DateAndTime, C_Timer,
C_AddOns, coroutine, table, security-account, event, script, clipboard
and hooksecurefunc registrations, the CalendarTime and SavedAccountInfo
structures, and the Base64Variant, CompressionMethod and
AddOnSecurityStatus enums.
* docs(api): correct entries the last descriptor pass contradicted
SelectOption takes an optional password for boxCoded options.
IsWhoQueryPending clears when the answer arrives, not after a timer, and
SendWhoQueryByName raises on a nil or non-string name. SetTalentByID
raises on a nil or non-number talentID. The gossip getters also read the
quest greeting window. GetPoint returns three values for an anchor with
no relative frame. RegisterAtlas's rectangle is optional.
GetSecondsUntilDailyReset returns nothing before login.
CopyToClipboard is a Blizzard function, not an extension, and always
returns the length. ConvertHSLToRGB, DoesTemplateExist,
GetNamePlateForGUID, GetNamePlateGUIDs and SetModernScriptArgs are
labelled as ClassicAPI extensions, and C_AuctionHouse.PostItem is
described as retail's function plus a numStacks argument.
IsAddOnLoadable's descriptor notes the nil reason for an unknown name.
* docs: start every function and event summary with a verb
Function summaries now read "Returns …", "Returns whether …" and so on,
not a bare "Whether …", "The …" or "How many …", and event summaries
read "Fires when …" instead of describing the past ("A cast ended").
A few two-sentence summaries become one sentence, and the two range
check toggles say what they do rather than "Used with …".
* refactor(lua): require a descriptor on every registration
The registrars and Event::Custom::AutoReserve no longer default their
doc argument, so a function, method table, enum, alias or custom event
registered without a descriptor does not compile. The _classicapi_
debug functions, which the documentation export skips, pass nullptr
explicitly.
* docs: stop calling namespaced Blizzard globals extensions
A function is a ClassicAPI extension only when no Blizzard client ships
it under any name. C_XMLUtil.DoesTemplateExist (the global
DoesTemplateExist), C_PlayerInfo.UnitPosition, C_Reputation.
IsFactionInactive and SetFactionInactive, and C_Macro.CreateMacro and
EditMacro are Blizzard globals under a namespace Blizzard never gave
them, so their descriptors and API.md no longer label them extensions.
* refactor(baselib): register newproxy through the registrars
newproxy set its global by hand so its C closure could carry the weak
table of valid metatables as an upvalue, which left it the one global
with no descriptor. The weak table now lives in the registry (made on
first use in each Lua state), so newproxy is a plain C function that
RegisterGlobalFunction and RegisterGlueFunction bind with a descriptor.
Behavior is unchanged.
* docs(api): drop the C++ module name from the aura timing heading
* docs(api): fix descriptor errors found in review
- UnitSpellTargetName is a Blizzard function (Unit system): drop the
extension flag and file it under UnitGlobals.
- Flag the ClassicAPI-only spell functions as extensions: GetSpellRadius
(global and C_Spell), GetSpellReagents, GetSpellDispelType,
IsNextMeleeSpell, ResetsMeleeSwing, GetSpellMechanicByID,
GetSpellEffectMechanics, GetSpellEffectInfo, GetSpellRequiredTargetLevel,
GetSpellLevelInfo and C_SpellBook.GetPlayerSpellsByAura. No Blizzard
client ships any of them.
- Name the Region registry SimpleScriptRegionAPI, as retail does, and
make the no-counterpart comment cover all three rows it applies to.
- Start the VOICE_CHAT_TTS_SPEAK_TEXT_UPDATE summary with a verb.
- Type GetCurrentChatEvent's guid return as WOWGUID, matching
GetCurrentChatGUID.
- Say that the itemInfo argument also accepts an item string.
* docs(api): document the methods the source count missed
_classicapi_UndocumentedAPI() still listed 23 names. Each sat in a method
array that already had a partial doc array, so the source count read it
as documented.
- GameTooltip: SetUnitAura, SetUnit, GetUnit, GetUnitGUID, HasUnit.
GetUnitGUID and HasUnit are extensions; no Blizzard client ships them.
- FontString: GetStringHeight, GetUnboundedStringWidth, GetWrappedWidth,
GetNumLines, GetLineHeight, IsTruncated, SetMaxLines, GetMaxLines,
GetFieldSize.
- ModelScene actor: GetObjectType, IsObjectType, GetName, GetParent,
HasScript, GetScript, SetScript, HookScript, as our object methods
return them (1/nil, no HookScript result).
- GetAverageItemLevel moves to PaperDollInfoGlobals: PaperDollInfo is the
C_PaperDollInfo namespace.
The in-game check now reports 0.
|
||
|
|
3bf4574132 |
fix(docs): use Blizzard's "bool" type name in API descriptors
Thirty descriptors across 20 files typed their fields as "boolean", Lua's spelling. Blizzard's APIDocumentation always writes "bool" (3917 uses in the retail generated docs, no "boolean"), and Game.h already asked for it. The /classicapi browser showed these fields with a type no Blizzard entry uses, and a future annotation generator would have had to map both spellings. Game.h now names "boolean" as the wrong spelling. The TODO #107 note drops a wrong claim about Vararg calls (every one already passes a type first) and lists the Blizzard type aliases the annotation mapping must cover. |
||
|
|
a28efb73e5 |
docs(todo): add dev tools, engine showpieces and advanced combat logging
#107 plans LuaLS annotations generated from the recorded doc descriptors, and notes descriptors that put a sentence in the type slot. #108 and #109 park the dev-tool and showpiece ideas. #110 records the Classic Era advanced combat log format, read from real Era logs, as the reference for an advanced combat log and an encounter replay. |
||
|
|
8e721237f6 |
feat(addons): zhCN localization for ClassicAPI_DebugTools and 6 missing globals fix (#141)
* feat(debugtools): add zhCN localization for ClassicAPI_DebugTools
* fix(locales): add 6 missing global strings to zhCN
* feat(debugtools): clean up slash command dispatch and add help subcommand
* fix(debugtools): use %s instead of %d in PROFILER_CALLS_FORMAT
ns.Count() always returns a string (either a formatted number or '-'),
never a number. Feeding it to %d causes format() to throw. Change the
locale template to %s so both '-', '1,234', etc. render correctly.
* fix(debugtools): repair regressions from the localization pass
- XML labels: 1.12's Button/FontString loader passes the text attribute
verbatim to FrameScript_GetText (0x703BF0), which reads the global of
exactly that name and falls back to the raw value. Nothing strips
"$...$", so text="$TI_SHOW$" rendered as literal "$TI_SHOW$". Use the
bare global name, as stock FrameXML does.
- Tabs: ns.AddTab(name, label) keeps a fixed English key for ns.ShowIn
and a separate localized button label. Keying tabs by the translated
name made ShowIn("Globals") return nil and error on a zhCN client.
- Frames tab state: restore visible / "shown, parent hidden" / hidden.
The inverted branch reported a shown frame under a hidden parent as
hidden and made the third state unreachable.
- /profiler: unknown or incomplete subcommands print the usage again
instead of doing nothing.
- Deep Tracking / CPU Profiling buttons: split the label from ON/OFF so
the state keeps its accent / grey colour.
- Restore the gap between owner and CPU time in the frame-stack and
Frames-tab tooltips, and the leading space of " (replaced)".
- zhCN: ADDON_OPTIONS titles the shared Interface Options panel and the
game-menu button, not ClassicAPI's own settings; revert to 插件设置.
---------
Co-authored-by: jilinge <jilinge@users.noreply.github.com>
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
d689aab94c | docs(readme): reorder the highlights and add cooldown frames, timer bars and menus | ||
|
|
71206cad13 | docs(readme): shorten the highlight rows to one or two sentences each | ||
|
|
b208faec31 |
feat(frame): frame:SetPassThroughButtons, clicks that go through a frame
frame:SetPassThroughButtons(...) names the mouse buttons a frame lets through: a press of one of them skips the frame, which gets no OnMouseDown, OnMouseUp or OnClick for it, and goes to the next click-enabled frame under the cursor. The frame keeps its other buttons and its hover. Each call replaces the list, no names clears it, and an unknown name adds nothing without an error. XML takes passThroughButtons="LeftButton, RightButton". The press handler 0x007662C0 copies the input payload behind a 0x10-byte header at [ebp-0x40], so the pressed button bit sits at +0x14 (OFF_UI_MOUSE_EVENT_BUTTON; 0x0076BF70 ANDs the same field with the drag mask). Frame::MouseInput already replaces the target read at 0x00766389 with its click walk; the thunk now also passes that event copy, and the walk skips a frame whose mask holds the button. The world frame sits in the same mouse lists at stratum 0, so a passed press with no frame below still reaches the world. A press while another button is held goes to the pressed frame (+0x80) before the target read, so it is routed as the engine routes it. The walk still runs only when some frame uses one of these features. Button names resolve through Frame::ClickEvents::MaskForButtonName, next to ButtonNameForMask; Bindings::Command's private copy of the table is gone. Also lists the mouse click/motion methods in the README. |
||
|
|
b0f4f68a0f |
fix(broodwatch): stop offering spells spent on a fusion or evolution
Taking a fusion or evolution removes its source spells from the run's spell list, so the level-up cards saw them as unowned and offered them again as new spells (Explosive Trap after Frost Trap, Frostbolt after Frost Volley). BuildOffers now skips any spell whose fusion or evolution you already own. |
||
|
|
960c510d51 |
build: compile every source file as its own parallel job
The Visual Studio generator compiles a project's files serially, and Offsets.h / Game.h reach nearly every one of the 672 sources, so an edit to either was a full serial rebuild. /MP alone does not fix it: it parallelizes only within a batch of files with identical settings, and CMake gives each .cpp whose name repeats in another directory (21 Info.cpp, 6 Tooltip.cpp, ...) its own object path, which left ~130 files in one-file batches run one after another. MSBuild's MultiToolTask schedules each file as its own job instead. Full rebuild on a 24-core machine: 81 s serial, 38 s with /MP, 12 s with MultiToolTask. Compiler flags are unchanged, and the DLL is the same size. |
||
|
|
6b907f09d4 |
feat(model): scene:SetWorldTerrain, a map's ground, water and sky in a ModelScene (#139)
* fix(dbc): accept id 0 in DBC::Record, as the client's own lookup does
The client indexes a table's id map (store +0x08) by id and refuses only an
id above the largest id (+0x0C, signed, so negatives too) and an empty slot
(0x005F4010: test/jl, cmp/jg, null test). DBC::Record also refused id 0,
which is a real row in Map.dbc (Eastern Kingdoms), TerrainType and
ItemClass (Consumable); every other table leaves slot 0 empty, so it still
returns null there.
Effects: map 0 now has its directory, so scene:SetWorldTerrain(0, ...)
finds Eastern Kingdoms' tiles; the scene's death thud plays on TerrainType
0; ItemClass 0 resolves to "Consumable" in the item name lookups.
Instance::Info and the C_Map MapInfo reader had each copied the lookup
without the id 0 check to work around it; both now call DBC::Record.
* feat(model): scene:SetWorldTerrain, a map's ADT terrain in a ModelScene
scene:SetWorldTerrain(mapID, x, y [, radius]) shows the map's ground around
a point, in map coordinates (radius default one tile, 533.33331 at
0x0080654C); scene:ClearWorldTerrain() removes it. The Gurubashi Arena's
pit is terrain under its WMO, so SetWorldModel at the arena's MODF plus
SetWorldTerrain shows it as the world does.
The chunks are the world's CMapChunk objects, owned by the scene and built
and drawn by the world's own functions (model/SceneTerrain.cpp):
- Load: the ADT is read whole and its MHDR read as ParseAreaFile
(0x006C2010) reads it. LoadAreaTextures (0x006C20E0) fills an area
stand-in's texture slots. Each chunk is constructed (0x006AF1D0), gets
CreateAreaChunk's fields (0x006C2880) and the self-contained steps of
CMapChunk::Load (0x006AF5F0) in order: FixupRecordPointers, header
fields, BuildVertices, LoadNormals, the impassable flag, AddLayer,
CreateShadowTexture, CreateCombinedTexture. LinkNeighbours (global area
table), LoadReferences (the world's doodad hashes), LinkLights and the
area's filing are world state and left out; the scene links its own
chunks by LinkNeighbours' rule. Each record is bounds-checked first.
- Buffers: the world's chunk pool is freed and rebuilt on a far clip change
or map unload (CreateChunkBufferPool 0x006AE640), and only the world's
listed chunks give theirs back; its empty-pool fallback is the device's
shared dynamic buffer. The scene makes its own static pools the same way
(CreatePool 0x0058A160, PoolBuffer 0x00589F80; freed by 0x0058A040 and
GxBufferRelease), which SelectMesh never trades away (it re-acquires only
for a usage 2 pool).
- Draw, before the WMO: DrawChunkPass (0x00684510) per chunk the scene's
volume shows (IsBoxCulled 0x00682F40): the chunk level and view depth
(0x006AFAD0), the world transform at the chunk less the eye, a lighting
record at the chunk's centre with the scene's lights there, the scene's
fog and, when the depth less twice the radius is inside the fog end, its
light as the sun (DrawMapEntity's slots 0x006C0CC0), then SelectMesh
(0x006BEB50). DrawLayers reads the camera (0x00C7CF20) and fog end
(0x00C62964) globals, which hold the scene's values while it draws. The
anisotropic mip bias is the pass's own immediate (0x00684528).
- Teardown: UnloadChunk (0x006A6B10) and ~CMapChunk, the scene's buffers,
then each tile's texture handles (HandleClose, as UnloadArea does).
- The chunks are built again when the terrain shader flags, shadowLevel or
map shadows change (glue screen to world).
Not yet: collision, the tile's doodads and grass, terrain liquid.
* feat(model): actors walk on the scene's terrain; traces and sweeps find it
The scene's ground is now its WMO and its terrain, taken in the order the
world's queries take map objects and chunks:
- Box query (the mover's sweeps, SweepCollider): QueryGroundFacets gathers
the WMO's facets, then the terrain's, as 0x006AA8B0 does; a WMO still
loading fails it. The terrain leg is the gather's cell math (0x006AA92D:
fistp(float(0.24 x float(17066.666 - c)) - 0.5), bounds against 0 and
34133.332) and GatherChunkFacets' wall and triangle legs (0x006AAE2A..
0x006AB3F1): AddImpassableWalls' quads (0x006AB530, the 32000 immediate
at 0x006AB59C), the hole bits (0x008103F8), the five-vertex outcodes
against the box grown by 0.019444443 (0x00810468, 0x008101B8) and the
four cell triangles (0x00810438). Their planes are Contact::MakeFacet,
whose arithmetic is the chunk gather's inline SSE path operand for
operand. GatherChunkFacets itself finds its chunk through the global
area table (0x00C96318), so it cannot see the scene's chunks.
- Segment trace (TraceSegment, area-kit shards): TraceGround traces the WMO,
then lets the terrain lower the fraction, as 0x0069BFF0 does. The terrain
leg converts the ends to cells as 0x0069C320 does and calls the client's
four cell walks (0x0069C4E0, 0x0069C570, 0x0069C600, 0x0069C780), which
only fill its scratch list (0x00C962C8, count 0x00C89F40); then
TraceListedCells (0x0069C920) over the scene's chunks: the ray relative
to each chunk, its four cell triangles (0x0081047C) through
IntersectRayTriangle (0x007C2C40, slack immediate at 0x0069CB96), the
nearest t*k at or above 0. The normal is PlaneFromTriangle's (as the
terrain first hit 0x006AA600 takes it), turned toward the start.
The mover's facet context is the scene frame. World::Sweep moved to the
scene (SweepGround) so it sweeps against both. A cell outside the scene's
chunks has no ground; the world fails or ends there, but the scene's
terrain ends at its radius and a WMO may reach past it.
* feat(model): shadows, selection circles, markers and reticles on terrain
The world lays a decal through its box test TestWorldBox (0x006AD2C0): map
objects into the shared triangle batches (mask 0xF00F0), then the terrain
(0xF0F00, TestTerrainBox 0x006AD4E0). The terrain leg's cells are
fistp(float(0.24 x d) - 0.5) of the distances from the map origin (0.24 at
0x00810B44, 0.5 at 0x0086AAC4), the first from the unrounded origin - min.y;
rows run from the max-x cell >> 3 to the min-x cell >> 3, columns likewise.
TestChunkBox (0x006AD610) finds each chunk through the global area table,
takes the box less the chunk position, clips the cell rectangle to
{0, 0, 7, 7} (IntersectCellRects 0x006ADBF0) and, under 0x100, calls
TestChunkTriangles (0x006AD7E0, fastcall(chunk, rect, box, unused), ret 8),
which reads only the chunk and writes one batch: its kept cell triangles,
the chunk's translation as the matrix, its vertices at +0x83C.
Terrain::CollectDecalBatches is that leg over the scene's own chunks,
calling TestChunkTriangles on each. World::DrawDecal now takes the WMO and
the terrain (either null), collects them in the world's order and draws
the batches with the existing DrawDecalBatches states. The scene's decal
helpers take the paint's ground (WMO, terrain); the flat quad is left for
a scene with neither.
* feat(model): footsteps and the actor's ground on the scene's terrain
AttachEntityToGround (0x006A8A20) traces the terrain (TraceTerrainSegment,
mask 0x100) and the map objects down 1000 yards from the probe point; with
neither hit it probes up past the bounds; the terrain wins when it is
nearer. A terrain win links the unit outdoors (the sun, no map object
lights), and its ground id is GetGroundEffect (0x0069B1C0) at the entity's
position: the cell from the map origin (0.24 at 0x0081073C, 0.5 at
0x0086A750; distances 0 to 34133.332), no hole, then the cell's dominant
layer from the chunk's MCNK +0x40 map (the row's word masked by
0x008104B4[column] and shifted by 0x008104C4[column]), that layer's effect
id (+0x0A, 0xFFFF none) into GroundEffectTexture (0x00C0DC60 / 0x00C0DC64),
whose +0x18 is the TerrainType id. GetGroundEffect finds the chunk through
the global area table, so Terrain::GroundEffect transcribes it over the
scene's chunks.
World::Place now runs both legs (the terrain through Terrain::Trace), and
World::Settle / Ground take the backdrop (nullable) and the terrain, so a
scene with terrain and no WMO places its actors too; the cached placement
keys on the terrain's serial as well. The Gurubashi pit's layer (ground
effect 587) is TerrainType 0, Dirt.
* feat(model): the terrain's own doodads (trees, plants, rocks) in a scene
A chunk's MCRF doodad references index the tile's MDDF placements, and the
world makes one CMapDoodadDef per unique id (+0x04, the hash 0x00CA7DDC).
PlaceDoodadDef (0x00694BC0) places it: position (origin - +0x10,
origin - +0x08, +0x0C), each a float sum; scale the word +0x20 x 1/1024
(0x008090D8); angles float(degrees x pi/180) with z + pi in one store;
the matrix TranslateMatrix, RotateMatrix about z, y and x (0x007BDD60),
ScaleMatrix (0x007BDD00); then CreateDoodadModel (0x00695100), the same
model setup as a WMO's doodads. LoadReferences (0x006B00F0) marks a chunk's
doodads outdoors (flag 4, intensity 1.0), and map lights only reach doodads
owned by WMO groups, so they take the sun and the zone fog: in the scene,
the frame's light and fog.
The WMO doodad code is now shared: a Doodad's WMO is optional and its sound
flag points to its owner's. World::Props holds a map's own doodads with the
same model setup, bounds, distance fade (0x00683F80), animate list, sounds
and collision facets (GatherDoodadFacets 0x006ABC40 rules, one stamp per
query). Terrain::QueryFacets adds each chunk's props after its triangles,
as GatherChunkFacets does (0x006AB496); a prop still loading fails the
query. SetPlayWorldModelSounds covers them.
* feat(model): the terrain's grass (detail doodads) in a scene
The world's chunk pass (0x006847C9) scatters a drawn chunk's detail
doodads once, with world flag 0x100000, when its view depth +0x78 is below
the horizon 0x00867958 (read live; 300.0 in this image):
CMapChunk::CreateDetailDoodads (0x006BFC10) from the layers' ground
effects, seeded by the chunk's grid position. The detail pass (0x006813D0)
then sets stage 0's mip bias (the immediate at 0x006813EA) and, for each
such chunk with a batch +0xC0, the chunk's transform and lighting record,
then DrawDetailDoodads (0x006C02D0) with the fade ramp. The scene runs both
over its own chunks.
The batches' slot buffers come from the world's detail pools, which
PrepareDetailDoodadBuffers (0x006B1D30) frees and rebuilds while 0x00CB0034
is set (a frillDensity change), after freeing only the world's listed
chunks' batches (0x006924F0); a slot's release (0x006B21D0) reads its
buffer's pool. So a scene batch gives its slot buffers back after each draw
(the world's idle release 0x006B28E0); the scene runs Prepare itself while
the flag is set (the world's frame never does at the glue screen), and
frees its batches (0x006B2030) to scatter them again when the rebuild
stamp 0x00CB003C, written only by Prepare, moves. CreateDetailDoodads reads
512 bytes at the MCSH pointer with or without a shadow map, so a chunk
whose range lies outside its file gets none.
The chunk pass and the detail pass each get their own render state push,
as DrawChunkPass and the detail pass do: the shader path's layer draw
(DrawLayersShader 0x006BF690) leaves its pixel program bound, and with one
push around both the grass drew through it as opaque quads.
* feat(model): the terrain's water and lava in a scene
A scene's terrain now shows the rivers, lakes, ocean and lava of its
chunks, drawn by the world's own liquid code.
Load: after LoadNormals, each chunk runs CMapChunk::LoadLiquids
(0x006AF760), which reads one MCLQ block (0x324 bytes) per liquid flag
of the MCNK header into the four slots at chunk +0x118 and builds each
slot's vertices. The record check now bounds the MCLQ blocks too.
Buffers: the slots take a vertex and an index buffer from two static
pools the scene makes, as CreateLiquidBufferPool (0x0068CA50) makes the
world's (81 vertices of 40 bytes, 192 indices). The world rebuilds its
own pool, which would leave the scene's slots on freed buffers;
CChunkLiquid::Draw (0x0068DE40) re-acquires only for a usage-2 pool.
Each pair is marked unfilled with 0x0058A130, the call
AcquireLiquidBuffers (0x0068CC60) makes, so the first draw fills the
vertices and the strip.
Draw: the three passes are copied in the world's order. Magma
(DrawMagmaPass 0x006855A0: no culling, lighting or blending) after the
WMO, as DrawWorldScene has it; the ocean (0x00685010) then the river
(0x006851B0) before the WMO's liquids, as RenderLiquid (0x006816D0)
has it. Each pass binds its swatch, then the water program
(0xC81B7C) with the white specular and the shininess (0x8102E8) and
alpha blend when fancy water (0xC9A324) is on, else the add combine
on stage 1. A slot is culled by its box (0x0068DF40: the chunk's box
with the slot's heights as z), placed at its chunk less the eye, lit
as GatherSlotLights (0x0068DF70) lights it, and drawn with the pass.
The camera, fog end, frustum and world stack are staged as for the
chunks (one Staged helper now serves all three).
Colours: the river and ocean swatches refill from the light state
while their fresh flags (0xC8117C, 0xC81B70) are clear. World::MapWater
swaps the eight water fields of the live light record (+0x34..+0x40,
+0x68..+0x74) for the scene map's at the eye; the flags are cleared
before and after the draw, so the swatches take the scene's colours
and the world's next frame refills its own. The WMO's water uses the
same swap.
Actors do not swim in this water yet, and GetLiquidAtPoint does not
find it.
* feat(model): swimming, liquid queries and the camera under terrain water
The scene's terrain liquid now answers the queries the world asks of
its own, so actors swim in it, GetLiquidAtPoint finds it, the camera
goes under it, and the splashes play.
Point query: GetLiquidStatus (0x0069B6D0) finds its chunk through the
global area table, so its terrain leg is transcribed over the scene's
chunks: u and v at 0.24 cells a yard (0x0081073C), stored and rounded
less 0.5; each slot's tile byte (+0x10) gives type & 3; the ocean is
height 0 under 0.01, else the MCLQ heights (+0x0C) bilinear at 53
bits, stored, the point under it plus 0.01. The scene asks the WMO
first and the terrain after, as GetLiquidStatus asks the map objects
first; GetLiquidAtPoint and the actor's swim step use it.
Swimmer's facets: GatherChunkFacets (0x006AADC0) under class 0x30000
adds an impassable chunk's walls (they ignore the class) and, for
each slot the class names, GatherLiquidFacets (0x006AB4E0): the facet
batches reset, GatherLiquidCellFacets (0x0068CEC0, called on the
scene's own slots) with the chunk-relative box and clipped cell
rectangle, and the batches emitted. The doodad leg takes no def for
this class. The box-to-cells step and the chunk window are shared
with the solid query; ResetFacetBatches and EmitFacetBatches leave
SceneWorld's anonymous namespace for it.
Camera: CameraEnvironment (0x006809C0) asks the claimed group's
liquid, else the liquid query (0x006723D0) at the probe point: the
eye lowered to the lowest near corner of the view. The probe drop
now comes from the scene's paint, so a scene without a WMO has one.
Under a liquid the world builds its light table with that liquid's
params and takes its fog from it (BuildSceneFog 0x006CEE30: end
+0x44 capped at the far clip, start +0x48 times it, colour band 7
+0x1C); LiquidFog swaps the frame's fog for that during the paint,
and a WMO's lava or slime without its own fog targets the same. A
terrain-only scene clears to the fog colour under a liquid, as
DrawWorldScene does (0x0068124D); the paint order and the water
colours follow the camera's liquid.
Sounds: CGUnit_C::UpdateSwimState (0x006030C0) plays the race splash
(ChrRaces +0x34, kept at +0xB18 by PostInit 0x005FB880) when the depth
past 0.4 of the height (0x0080C5C0) differs from the last test's
(+0x9A4), while not swimming; the mover's port now does, and the
actor keeps its unit's splash. The $FSD footstep is wet
(IsPointAtLiquidSurface 0x0060A740) when the unit, placed outdoors,
stands in a liquid (UpdateMapEntityEnvironment 0x0069E280) whose
LiquidType for the area (0x007CCF40; area from 0x0069B120) has flag
0x2, and the event point is from 0.01 above to 2/3 below the surface.
Constants already named under other roles are reused: 0x0081073C and
0x0086A750 become VAR_POINT_CELLS_PER_YARD and VAR_POINT_HALF_CELL,
and the nameplate lift 0x0080ABFC becomes VAR_TWO_THIRDS.
* feat(model): the map's sky over a scene's terrain without a WMO
A scene with terrain and no WMO now clears and draws its frame as the
world's does in the open, in place of a depth-only clear.
DrawWorldScene (0x0068123F) clears to black while the camera is dry and
to the fog colour (+0x70) under a liquid, and draws the sky only when
dry and the weather byte is set; outside every map object that byte
always stands set. The sky pass the WMO scenes already run (the dome
colours from the camera's heading, the map's light from BuildMapLight
with its sun disc and skybox slots, DrawSky, the world's objects put
back after) now takes the map, the camera's liquid and the portal
walk's skybox weight instead of the backdrop, so ClearAndDrawOpenSky
runs it for the terrain's map with no skybox from a walk. Under a
liquid the frame's fog is already the map's for it (LiquidFog), so the
clear takes that colour.
* feat(model): the drift motes around a scene camera in a liquid
A scene's camera in water, ocean or magma now sees the world's drift
cloud: the motes that float around the camera under a liquid.
The world builds one cloud at start-up (0x0066F971: 0xFA40 bytes,
CreateDriftCloud 0x0068E5A0 with the size base 1/36, the edge 30.0 and
Textures\WaterPoop02.blp at 0x00867A34) and drives it from its own
camera. A scene now owns a cloud made the same way the first time its
camera enters a liquid, and runs the world's steps from its camera:
- CameraEnvironment's change leg (0x00680AEE): on a change to water or
ocean the scatter (0x0068E720) in the new liquid's mode and the size
base 1/36 (0x0068E670), 1/9 for magma, and the enable byte +0xFA14;
slime clears it.
- The world frame's advect (0x0066FEE0 to 0x0068E930), with the scene's
eye staged in the camera position (0x00C7CF20) and its frame time in
the frame seconds (0x00C62510) the advect reads.
- The world stage's draw (0x006701E0 to 0x0068EFE0) after the models,
in the device's view with the world transform identity.
Both run while the camera is in a liquid and world flag 0x2000000 (the
waterParticulates setting) is set. The cloud's texture is closed with
0x0068E640 when the scene goes. The module is model/SceneWater.cpp.
The world transform stack id 8 moves from two local constants to
Offsets.h (GX_XFORM_WORLD).
* feat(model): foam rings and wakes of actors in shallow water
An actor whose movement is on now leaves the world's ripples in shallow
liquid: foam rings while it stands, turns or splashes, wakes along its
motion while it moves.
The world keeps its ripples in one pool of 128 records (0x50 bytes) that
its liquid query fills and its liquid pass draws. A scene keeps a pool
of its own with the same records (model/SceneWater.cpp), and the steps
are transcribed:
- CGUnit_C::EmitWaterRipple (0x005FA760), each actor update (as
0x0060802E) and after the swim decision's splash (kind 0xC9, as
0x0060319F): with the unit's liquid and bit 0x40 (flag 0x1 of the
area's LiquidType, kept now by the placement's liquid leg), the depth
under twice the collision height (at least 1.0) and the next time
(+0xC78) reached. The kind (moving 0xF, turning 0x30, still, splash)
and the table 0x00860A4C {0, 0, 1, 0} make a wake or a ring; the size,
lifetime and growth come from three draws of the client random stream
and the function's own constants, scaled down past half the depth and
for a still unit (0x0080C474); a ring takes a fourth draw for its
heading, a wake the motion's; the next time follows the speed, or
400 ms and a draw's share of 50.
- AddSplash's immediate leg (0x0068BDA0, gated by waterRipples
0x0086A03C and mode 0x00C89DB8), AddRipple (0x0068F9F0: the active
mover's range 0 to 31) and EmitRipple (0x0068F5C0): the record, its
rise and decay at 0.4 of the life (0x00810348), and the liquid
triangles TestWorldBox finds in its box with class 0xF0000, here
World::LiquidTriangles over the WMO and the scene's terrain.
- UpdateRipples (0x0068FAE0), its ageing in the scene's update and its
draw in the scene's liquid phase: blend 3, fog, depth write, culling
and lighting off, the depth bias footstepBias x 1/1024, the world
stack at Translate(-eye), per category its texture (0x00C800E4) over
format 4 vertices with the alpha's byte over white and the uv through
BuildDecalTransforms (0x006D6FA0) of the box turned by the heading.
The scene's terrain box test (TestTerrainBox) now has TestChunkBox's
liquid leg (0x006AD75E): GatherLiquidCellFacets on each slot the class
names, into the same batches. The shadow decal's class asks for liquid
too, so actor shadows lie on terrain water as in the world.
The scene's clock times the ripples, so a paused scene holds them.
* fix(model): scene terrain review fixes and shared view volume
SweepCollider in a scene with no WMO and no terrain returned the feet
again instead of feet + move: SweepGround copied the feet into the end
before its ground check. With no ground the body now moves the full
distance, as the doc says; while a WMO loads the feet still stay put.
Water::Update made the scene's ripple pool with a zero clock, so a
ripple added in the frame the camera first entered water died on the
next age. It now goes through Ensure, which sets the scene's clock.
Trace read 0x008029D4 under a second name, VAR_TRACE_RUN_EPSILON; it
now reads VAR_TWO_POW_MINUS_22 and the duplicate is gone.
The paint builds its view volume once and hands it to every pass that
built its own: the camera probe (0x006809E2), the portal walk for the
sky, the WMO draw and the terrain's chunk, magma and water passes. The
sky's draw (0x006D4940) only saves and restores the viewport, and
FrustumStore (0x00682D90) only copies from the volume, so one volume
serves the whole paint.
The SFile wrapper is one class (model/SceneFile.h) for the WMO and the
terrain readers. The terrain's decal and liquid box tests take their
chunk rectangle and shifted box from ChunkWindow, and AreaAt its row
and chunk from Cell and ChunkAt, in the same rounding as before.
|
||
|
|
8c4a9be0dd |
feat(model): the ModelScene frame type, WMO backdrops, and the Broodwatch game (#138)
* feat(model): add the ModelScene frame type and C_ModelInfo
ModelScene is a 3D stage of model actors with its own camera. 1.12.1's
Model frame is already one: every Model frame owns an M2 scene and a
clock, and its paint (SimpleModelDraw 0x0076D240) animates and draws the
whole scene, each unattached model with its own placement matrix. The
stock frame only ever places one model.
So a ModelScene is a CSimpleModel: the Model factory's allocation plus
our fields, CSimpleModel's constructor (0x0076C8E0), then copies of its
two vtables with the Model half hidden from Lua. Lookup goes to our
method hash and then CSimpleFrame's, the type answers ModelScene, Frame
and Region but not Model, and Model's script names and XML loader give
way to the Frame ones. The layer emit queues our paint on ARTWORK. The
paint repeats SimpleModelDraw call for call: save the device transforms,
project through the frame's camera over its rect, clamp the viewport,
clear depth, place each actor where slot 0x98 would place the one
model, animate the scene from the camera eye, draw passes 0 and 1, and
restore.
The camera is a CCamera made and installed the way the PlayerModel
pane makes its fallback camera (CameraCreate 0x007AC930,
SimpleModelInstallCamera 0x0076CE80). Eye and target come from the
position and forward axis. The yaw and roll properties are solved so
that the view's up vector equals the requested one. The default light is
set the way PlayerModel's constructor sets its own.
An actor is a script object holding one model in the frame's scene. It
is lit through the frame's light callback, placed with
CM2Model::SetBaseTransformTRS (0x00710650), and polled for load and
dressing from the frame's update, never from the paint. A display with
an Extra record is dressed through the engine compositor. The bounding
boxes come from GetSequenceInfo (0x00711A20) and GetBoundingBox
(0x00713640).
C_ModelInfo's getters read the rows of scenes 4, 44 and 596, embedded
from the retail 12.1.7 exports. The four active-scene functions do
nothing, as retail's own documentation says, and live in Compat.lua.
The same calls on Turtle and on retail draw the same picture (scene
4's camera on the Brown Horse, centred on Z, scaled by retail's
normalization).
Frame::Subclass now holds the vtable copy and the per-class method
hash, which Cooldown uses too. Model::DisplayInfo::CreateDisplayModel
builds a display's model for both portraits and actors.
* refactor(coord): push script coordinates through one engine chain
Every script coordinate the engine pushes (GetLeft, GetStringWidth,
GetFont's height, GetCursorPosition, OnCursorChanged) is
DivideByScreenScaleX(GetScaledScreenAspect() * [0x007FFD68] * value):
0x0041AD70, then the 1024.0f read from .rdata, then 0x0041AE40, with
the quotient stored from ST0 as a double.
Game::InternalToPixel did the same arithmetic from the globals in double
precision, while the edit-box caret, the font height getters and texture
tiling each kept a private copy of the engine chain. InternalToPixel now
makes the engine's calls in the engine's order, rounding the float
product once as the engine's fstp dword does, and the three modules use
it. PixelToInternal reads the 1024 from the same .rdata float, so the
UI_COORD_SCALE_UNIT constant is gone.
* feat(model): run retail's ModelScene Lua on the scene frame
Retail's camera registry, camera base, orbit camera, scene mixin and
actor mixin come over verbatim, with their XML templates, so a scene
built with SetFromModelSceneID frames, scales and orbits its actors the
way retail's does. What they need from the client:
Actor templates. 1.12's XML loader registers every virtual top-level
node whatever its tag, so <Actor name="ModelSceneActorTemplate"> is a
template that Xml::Template finds. CreateActor(name, template) loads it
the way an animation group loads its own: the whole inherits chain's
mixins first, then each node from the base up, then OnLoad. The
parentKey, parentArray, <Scripts> and <KeyValues> readers move out of
the animation loader so both use them.
Scene state. Light setters write the frame's M2Light through the
engine's own setters (M2LightSetType 0x0071B620, SetDirection
0x0071B6A0, SetPosition 0x0071B650, SetEnabled 0x0071B780). Fog uses
the Model frame's fields (+0x3A4..+0x3B0), stored as Model's own
SetFogColor, SetFogNear, SetFogFar and ClearFog store them, and starts
at retail's values. The draw layer goes through the engine's layer-name
functions (0x006F18B0, 0x006F1900) and marks both layers changed.
SetPaused keeps the frame update but skips Model's M2SceneAdvance. The
XML loader adds drawLayer, fogNear, fogFar and <FogColor> after the
frame's own loader.
Actor state. A blend operation for PlayAnimation. Spell visual kits use
the routine behind PlayerModel:ApplySpellVisualKit, which now takes a
model instead of a pane; the actor applies a kit once its model loads
and takes the effects off when the kit changes. 1.12 has no animation
kits, so PlayAnimationKit and StopAnimationKit change nothing.
GetCursorDelta, which the orbit camera drags with, samples the top's
cursor (+0x1118) once a frame at the head of the UI render callback and
converts it the way GetCursorPosition (0x0048B820) does, so the delta is
the difference of two GetCursorPosition values. C_PlayerInfo.
GetAlternateFormInfo answers false, false: 1.12 has no alternate forms.
* feat(model): show a unit on a ModelScene actor
ModelSceneActor:SetModelByUnit copies the unit's model the way 1.12.1's
character panes do in AttachUnitModel (0x005059A0): the unit's own
character component is pumped forced (UpdateCharacterComponent 0x00477860),
its model (+0xD8) is copied into the scene's M2 scene with
CreateModelFromModel (0x00707400, which carries the helm, shoulders and
held items), the effect and spell attachments come off
(DetachAllItemModels 0x0047A230), and the hand grips close (CloseHand
0x00479660). What DressUpModel's SetModelInstance (0x00504350) adds comes
next: a clone of the unit's component (CloneCharacterComponent 0x00476CB0,
on a pool component with the model AddRef'd) and the two held-item lanes
from unit vtable +0x98. The actor pumps the clone on every update, as the
DressUpModel paint (0x00504470) pumps its own, so outfit changes show at
once; OnModelLoaded waits for its first composite.
On top: retail's Dress, Undress(includeWeapons), UndressSlot, SetSheathed /
GetSheathed, SetAutoDress / GetAutoDress, IsGeoReady and GetModelUnitGUID.
Undress mirrors ClearModel (0x00504490); sheathing is the unit's
AttachHandItem step (AttachItemModel 0x0047A0C0 with the sheathed flag).
The lane, weapon and undress steps move out of Model::DressUp into
Model::Outfit, which the DressUpModel pane and the actor share. One change
on the pane: UndressSlot on a held slot no longer needs the component.
PumpDresser takes the engine's force argument, which the old typedef
called an unused pointer.
* feat(model): seat the player on a mount in the dressing room
A ModelScene mount actor now seats a rider the way 1.12's world mount
(0x00607A00) does: CM2Model::Attach (0x00712F70) puts the rider's model on
the mount's attachment 0, and the rider plays the seat animation (91).
Attach takes the rider off the scene's animate list and the mount holds a
reference on it, so the actor update no longer re-links a seated rider, a
rider that drops its model detaches first, and a mount that drops its
model unseats the rider through the CM2Model destructor (HandleClose2
0x007103A0 destroys at zero). The seated rider keeps its placement, now
relative to the seat, as the world mount sets the attached rider's base
transform.
CalculateMountScale is the mount display's CreatureModelScale
(CreatureDisplayInfo col 4, OFF_CREATUREDISPLAYINFO_SCALE): the world
seats the rider at +0x98 over that scale, and +0x98 is always 1.0.
DetachFromMount only detaches, leaving the seat animation, unlike the
world's Dismount (0x00607CE0). M2::Attach / M2::Detach wrap the two calls
for the actor and the visual kits; Detach tests the parent first, since
the engine call drops a reference unconditionally.
C_MountJournal.GetMountFromItem returns the mount of an item whose use
spell applies SPELL_AURA_MOUNTED; an uncached item starts its load.
Enum.ModelBlendOperation is registered.
The dressing room gains retail's mount mode: DressUpLink,
DressUpMountLink and DressUpMount show a ModelScene over DressUpFrame's
backdrop, above the button row, in place of DressUpModel (whose scale 2
rect reaches over the buttons). DressUpItem returns to the player model.
A mount whose creature is not cached opens when CREATURE_DATA_LOAD_RESULT
arrives. Control-click previews a mount from a spell link (Turtle-shaped
links too), from a cached item that is not wearable, and from the
spellbook, where a mount spell then never casts.
Retail's ModelSceneControlFrame is ported with its strings in every
locale and GameTooltip_AddBodyLine. Its seven atlases are built in: the
sprites cut from retail's CommonIcons / CommonButtons into one 128x128
palettized BLP2 near their drawn size, since a built-in texture has one
mip. Held rotation counts retail's per-frame 0.05 per 1/60 s, the speed
of 1.12's own rotate buttons, instead of per frame at 1.12's uncapped
frame rates.
* feat(model): project scene points to the frame, store overlapped models
The ModelScene mixin calls two scene methods the frame did not have: OnLoad
calls SetAllowOverlappedModels(true) for StoreModelSceneMixinTemplate, and
Transform3DPointTo2D calls Project3DPointTo2D.
Project3DPointTo2D runs the point through the matrices the paint draws with.
It saves the device projection and view (0x0058B090 / 0x0058B0B0), runs
CameraSetDeviceTransforms (0x007ADA40) over the frame's rect, reads both back
and restores them. The view looks from the origin, so the point goes in
relative to the camera eye. The matrices are row-vector, and the perspective
matrix (0x005C3CC0) puts 1 at m11, so w' is the view depth. A |w'| under
0.001 projects nothing, the rule of the engine's own projector (0x005C4F30).
The result is in the frame's units times its effective scale, from the
bottom-left of the frame, as InternalToPixel gives the rect's extent. A point
behind the camera still projects. Depth is 1 at the near clip and 0 at the
far clip, by distance along the camera's forward axis.
SetAllowOverlappedModels stores its flag (default false). 1.12 draws a model
frame whatever overlaps it, so the flag has nothing to gate.
* feat(model): frame a scene's picture with view insets and translation
SetViewInsets(left, right, top, bottom) and SetViewTranslation(x, y), with
their getters and the XML <ViewInsets left right top bottom> child, frame
the camera's picture inside the ModelScene. Both are in the frame's own
units, with y up.
The paint gives the camera's CameraSetDeviceTransforms (0x007ADA40) the
frame's rect less the insets and moved by the translation, converted to
layout units with PixelToInternal(length * effective scale). The camera
takes its aspect from that rect, as it does from the frame's. The device
projection is then read back (0x0058B090), scaled and shifted in clip space
so that the view rect lands where it lies in the frame, and set again
(0x0058B040). The viewport stays the frame's rect, so drawing still stops
at the frame's edges, and negative insets let the view reach past them.
Project3DPointTo2D keeps projecting over the frame's rect and ignores both
settings, which is what retail does.
* feat(model): pause a ModelScene actor, show a unit's creature display
SetPaused(paused[, affectsGlobalPause]) holds one actor's animation while
the rest of the scene plays on. It uses the engine's own resume: the key
bone's place in its sequence is read once the model has loaded with
CM2Model::GetKeyBoneAnimState (0x00711FE0) and set back each update with
SetKeyBoneAnimTime (0x007127F0). The model stays on the scene's animate
list, so a paused actor still moves, turns and takes the light, and its
sequence never reaches its end. Unpaused, it plays on from that frame.
GetPaused returns the actor's own flag and the global one, set as the
retail probe read them back: the default sets both, and
affectsGlobalPause false sets only the actor's own.
SetModelByUnitCreatureDisplayID(unit) shows the display the unit shows
now (UNIT_FIELD_DISPLAYID) the way SetModelByCreatureDisplayID shows one.
Retail's pet tab calls it with "pet".
* fix(model): end one-shot actor animations, drop a replaced one's end
M2SceneAdvance (0x007074D8) updates only the models on the scene's animate
list, and that update (CM2Model::Update, 0x00719370) is what queues a
sequence's end callback; the paint's animate pass then empties the list.
Actors put their models on the list after the scene frame's clock had
advanced, so no actor model was ever updated: a looping animation still
played (its pose comes from the scene clock), but a one-shot one such as
AttackUnarmed stopped on its last frame and OnAnimFinished never ran. The
scene's update now links every ready actor model (Link) before the clock
runs, the order the Model frame's own clock (0x0076D7F0) uses.
A new animation also drops an end still pending for the one it replaces.
The engine reports a replaced play to the done callback as reason 1, which
the actor ignores; an end queued in the same advance reached the actor as
if the new animation had ended. Two actors whose animations ended in one
advance then saw OnAnimFinished for the animation the other's script had
just given them.
* docs: document the ModelScene frame, its actors and C_ModelInfo
API.md gains a ModelScene section: CreateFrame("ModelScene") and its XML
attributes with the scene's starting camera, light and fog; the camera,
view inset and translation, Project3DPointTo2D, light, fog, draw layer,
pause and overlapped-model methods; every actor method (model sources,
unit dressing, placement, bounding boxes, animation and pause, spell
visual kits, mount seating), the actor scripts and <Actor> templates;
and the four C_ModelInfo getters. C_MountJournal.GetMountFromItem joins
the Mount section and GetCursorDelta the Input section.
README.md adds a Model scenes highlight, the ModelScene, ModelSceneActor,
ModelInfo and Mount rows, GetCursorDelta in the in-game and glue tables,
and Enum.ModelBlendOperation.
* fix(model): UndressSlot does nothing without a character component
Model::Outfit::UndressSlot cleared and detached a held lane even when the
pane or actor had no character component. It called DetachHeldItemSlot
and zeroed the lane on a creature model, or on a pane whose component at
OFF_DRESSUPMODEL_COMPONENT was not built yet. Before the Outfit split,
DressUpModel:UndressSlot returned early in that case.
The check is back in the shared helper, so DressUpModel and the
ModelScene actor both return before they touch a lane or a component
slot. Undress (ClearModel, 0x00504490) still clears both lanes without a
component, as vanilla's own does.
* fix(dressup): keep a pending mount preview until its own creature loads
When a mount's creature is not cached, DressUpMount records the mount and
waits for CREATURE_DATA_LOAD_RESULT. The handler cleared that record on
any creature's result. A failed or successful load of an unrelated
creature (another addon's query, a world creature) consumed it, and the
preview never opened when the mount's creature arrived.
The pending record now holds the creature GetMountInfoExtraByID loads:
the misc value of the mount spell's SPELL_AURA_MOUNTED effect, read with
C_Spell.GetSpellEffectInfo. Only that creature's result clears the
record, and only a successful one opens the preview.
* fix(dressup): look a link's mount up once
DressUpItemLink went on to DressUpMountLink for an item the model cannot
wear, and DressUpLink called DressUpMountLink again when that returned
false. A link that was neither wearable nor a mount ran the mount lookup
twice, and an uncached item started its cache load and wrote the pending
mount twice.
The wearable-item step is now one local function. DressUpItemLink, which
1.12.1's FrameXML (ItemRef, bags, loot, the auction house) calls alone,
tries the item and then the mount. DressUpLink keeps retail's shape: the
item step for item links, then one DressUpMountLink call that gets its
forcedFrame.
* refactor(frame): share the frame-class plumbing in Frame::Subclass
Cooldown and ModelScene each carried their own copy of the parts every
frame class this DLL adds needs: a type id, IsA, IsObjectType,
GetObjectType, GetScriptMethod, the deleting destructor and its layout
thunk, the vtable build, and a factory body that allocates the block with
SMemAlloc (FUN_STORM_SMEM_ALLOC, zero-filled), runs the engine class's
constructor and installs the vtables. The copies had already drifted:
Cooldown compared type names with _stricmp, ModelScene with Storm's
SStrCmpI.
Frame::Subclass::Class now holds a class's name, the engine class it
extends (vtable, layout vtable, constructor), its size and a function that
releases its own fields, plus its type id, method hash and vtable copies.
Templates on that object give the shared overrides, BuildVTables, New and
RegisterFactory (FUN_FRAMEXML_REGISTER_FACTORY). Both classes now answer
IsObjectType through Game::StrCmpI and take CSimpleFrame's script resolver
(+0x0C), which Cooldown's copied vtable already held.
* refactor(frame): one wrapper for each draw-layer invalidate
CSimpleFrame::NotifyLayerChanged (FUN_FRAME_NOTIFY_LAYER_CHANGED,
0x0076A990, __thiscall (frame, layer)) was wrapped by hand in Cooldown,
ModelScene and ClipChildren, and CScriptRegion::NotifyLayerChanged
(FUN_REGION_NOTIFY_LAYER_CHANGED, 0x0077FDF0, __thiscall (region)) in the
inline-texture pool and the texture wrap. Each file carried its own
typedef for the same engine call.
frame/LayerChange.h now holds the two: NotifyFrame and NotifyRegion. All
five files call them.
* refactor(model): share the ModelScene argument checks
Scene.cpp and SceneActor.cpp each had NumberArgs and FloatArg, the same
loop that raises the engine's "Usage: <owner>:<usage>" error when an
argument is not a number, with the frame and actor arguments in a
different order.
One NumberArgs, which takes the owner's display name, and one FloatArg
are now declared in model/Scene.h and used by both files.
* refactor(model): call the M2 tint, alpha and child lookup through M2.h
CM2Model's SetDiffuseColor (FUN_M2MODEL_SET_DIFFUSE_COLOR, 0x00710CF0)
was wrapped by hand in VisualKit and SceneActor, FindChild
(FUN_M2MODEL_FIND_CHILD, 0x00712F00) in Outfit and SceneActor, and
VisualKit called SetAlpha (FUN_M2MODEL_SET_ALPHA, 0x00710CB0) directly
next to the M2::SetAlpha wrapper.
M2.h gains SetDiffuse and FindChild, and the three files call M2::
for all three.
* refactor(model): one copy of a unit's model without its items
The portrait bake and the ModelScene actor's SetModelByUnit both copied a
unit's model with CreateModelFromModel (FUN_M2SCENE_COPY_MODEL,
0x00707400, flags 0) and stripped the copy's helm, shoulders and held
items with DetachAllItemModels (FUN_DETACH_ALL_ITEM_MODELS, 0x0047A230),
each with its own typedefs.
M2::CopyWithoutItems does the two steps; both callers use it.
* refactor(gx): one save and restore of the device transforms
The draws that leave the UI pass's transforms saved and restored the
device projection, view and viewport by hand, each with its own
typedefs: the ModelScene paint (as SimpleModelDraw 0x0076D240 does), the
portrait bake, ClipChildren's ScrollFrame-shaped draw (0x00787220), and
the ModelScene projection, which reads the camera's matrices back.
AlphaGradient read the projection and viewport the same way, and the
scene and the bake each wrapped CameraSetDeviceTransforms
(FUN_CAMERA_SET_DEVICE_TRANSFORMS, 0x007ADA40).
gx/Device.h now wraps FUN_GX_GET/SET_PROJECTION, FUN_GX_GET/SET_VIEW and
FUN_GX_GET/SET_VIEWPORT, and Gx::SavedTransforms saves all three for a
scope and restores them at its end. Model::Camera::SetDeviceTransforms
wraps the camera call. Only AlphaGradient's hooks on the two setters
still name the addresses.
The projection now also puts back the viewport, unchanged. The bake
reads and disables fog just before it saves the transforms; the restore
order is the same as before.
* refactor(frame): one wrapper for the layout sub-object's calls
Every region and frame carries a layout sub-object at +0x24 (4.3.4's
CLayoutFrame; OFF_REGION_ANCHOR, OFF_FRAME_LAYOUT_SUBOBJECT for a frame),
and three engine calls on it were wrapped by hand in sixteen files, each
with its own typedef and often its own AnchorOf / LayoutOf / FrameOf
helper:
- CLayoutFrame::GetRect (FUN_REGION_GET_RECT, 0x00768320), the
{bottom, left, top, right} rect, false before layout;
- IsResizePending (FUN_REGION_LAYOUT_DIRTY, 0x00768310);
- CLayoutFrame::Resize (FUN_LAYOUT_RESIZE, 0x007680E0), 1 to lay out now,
0 to mark for the layout pass.
frame/Layout.h now holds them, taking the region or frame itself, with
Of and OwnerOf for the sub-object and back, and GetResolvedRect for the
read the edge getters make (Script GetLeft 0x007A1A19: a pending resize
run now, then the rect). Frame::Subclass::FrameOfLayout is replaced by
OwnerOf.
* refactor(storm): one wrapper for SMemAlloc and SMemFree
Storm's SMemAlloc (FUN_STORM_SMEM_ALLOC, 0x006462E0) and SMemFree
(FUN_STORM_SMEM_FREE, 0x00646430), both __stdcall with four arguments,
were called by hand in thirteen files, through AddOns::EngineIO's
typedefs, local typedefs, Event::Custom's own pair and
Frame::Subclass::Allocate.
storm/Memory.h now holds Storm::Alloc, with a zero-fill option for the
flag bit 3 (Offsets::STORM_SMEM_FLAG_ZERO_FILL), and Storm::Free. Every
caller uses them, with the same file and line labels as before; the
EngineIO typedefs, Custom's pair and Subclass::Allocate are gone.
* docs(model): Project3DPointTo2D ignores the view insets and translation
The ModelScene paint frames the camera over the view rect (the frame's
rect less its insets, moved by its translation), and Project3DPointTo2D
frames it over the whole rect. That looked like a gap, so retail was
probed: a 400x200 scene with its camera at (-10, 0, 0) projected the
origin to (142.22, 71.11) plainly, with SetViewInsets(100, 0, 0, 0) and
with SetViewTranslation(50, 0). The comment above Project now records
this, so the whole-rect framing stays.
* fix(model): register Enum.ModelSceneSetting
OrbitCameraMixin tests the camera row's flags against
Enum.ModelSceneSetting.AlignLightToOrbitDelta on every update
(ShouldAlignLightToOrbitDelta), so a scene with an orbit camera threw
"attempt to index field 'ModelSceneSetting'" each frame. C_ModelInfo's
module now registers the enum with its one value, 1, under the
UIModelInfo system.
* feat(model): ModelSceneActor:TryOn
A scene actor can now put an item on its model, as DressUpModel:TryOn
does on the dressing-room pane. Creature displays carry no weapons (a
creature's are server-side equipment), so this is how an actor holds a
sword, shield or staff.
The pane's worker, TryOnItem (FUN_DRESSUPMODEL_TRY_ON_ITEM, 0x00504540),
has two arms, and Outfit::TryOn now holds both for the pane and the
actor:
- armor: UnequipCharacterSlot (0x00478960), then EquipBodySlotById
(FUN_CHARCOMP_SET_ITEM, 0x00478AA0) on the inventory type's component
slot;
- held items: pick the hand, keep the other lane only when CanHoldBoth
(FUN_DRESSUPMODEL_CAN_HOLD_BOTH, 0x00504BC0) allows the pair, with
dual wield from FUN_PLAYER_CAN_DUAL_WIELD (0x005EAB70) when the model
shows the active player, detach the target lane, fill it and attach
the item model (0x0047A0C0).
The pane takes armor only while its ready byte is set, which is
DISPLAYID == NATIVEDISPLAYID (0x00504450); the actor reads the same two
fields (OFF_UNIT_FIELD_NATIVEDISPLAYID = 0x1F8 added), so a shapeshifted
unit's copy takes held items only. A creature display takes held items
only, as it has no character component.
Model::TryOn holds the shared argument read (item ID, link, recipe link,
carried item name, hand slot name, enchant), the worn-item lookup and
ERR_NOT_EQUIPPABLE. DressUpModel:TryOn now uses it and Outfit::TryOn;
its own copies are gone.
The pane's worker waits for an uncached item record through the item
cache callback. The actor waits for the record and for its model to
load, and puts the waiting items on in Update, before OnModelLoaded
runs. It returns Enum.ItemTryOnReason: DataPending while the record
loads, NotEquippable for a type with no arm or armor on a model that
cannot take it, else Success.
* docs(model): ModelSceneActor:TryOn
API.md gets an entry for the actor's TryOn: which models take armor and
which take held items, the dual-wield rule, the wait for the model and
for the item data (with the hand and enchant kept), and what removes the
items. SetSheathed now says it applies to any actor and to items that
TryOn adds later. The README's ModelSceneActor row lists :TryOn.
* feat(model): ModelSceneActor DressPlayerSlot, IsSlotAllowed, IsSlotVisible
DressPlayerSlot puts one inventory slot of a SetModelByUnit actor back
to what its unit wears. An armor slot copies the unit's own character
component record for the body slot (the dword array at component+0x4A8
that UnequipCharacterSlot 0x00478960 reads and clears) onto the actor's
clone with UnequipCharacterSlot + EquipBodySlotById (0x00478AA0), so a
helm or cloak the unit hides stays off: the unit's component has no
record there. A hand slot re-reads the unit's held-item lane, display
row and enchant glow and hangs only that lane, the other hand untouched.
IsSlotAllowed answers with TryOn's arms: the hands on any model, armor
slots when the actor has a component or a dressed display and is not
shapeshifted. IsSlotVisible gives the same answer; no 1.12 model hides
a slot it allows.
Outfit's slot map is now public (ComponentSlotOf) and HangWeapons hangs
each lane through one HangLane step that DressSlot shares.
* feat(model): ModelSceneActor ItemTransmogInfo methods
GetItemTransmogInfo(slot), GetItemTransmogInfoList() and
SetItemTransmogInfo(info [, slot, ignoreChildItems]) on the actor. On
1.12.1 the appearance is the item ID and the illusion is the
SpellItemEnchantment whose glow a weapon shows.
The actor keeps what each inventory slot 1..19 wears (Outfit::Worn).
SetModelByUnit reads it from the player's visible items
(FUN_UNIT_GET_VISIBLE_ITEM 0x005F0D60, item ID at +0x08), only for slots
the model shows: an armor slot while the unit's character component
holds a record for it (+0x4A8 + slot*4, so a hidden helm or cloak is 0),
a hand while its lane holds an item. A weapon's enchant is the first of
the visible item's 7 enchants (+0x0C) with an ItemVisual, the walk
GetItemDescVisual (0x0062EC70) makes, and only when a glow shows.
Non-player units have no visible items (the table is uninitialized), so
NPCs and creature displays read 0.
Outfit::TryOn now returns the inventory slot it filled; TrimWorn zeroes
every slot the clone component or lanes no longer show after TryOn,
Undress, UndressSlot and DressPlayerSlot, so evictions follow the model.
SetItemTransmogInfo is TryOn on the info's IDs without ERR_NOT_EQUIPPABLE,
which the callers show themselves. An appearanceID of 0 changes nothing.
The list entries are built with ItemUtil.CreateItemTransmogInfo, now
ported with ItemTransmogInfoMixin, and Constants.Transmog is registered.
* feat(model): DressUpModel ItemTransmogInfo methods
DressUpModel:GetItemTransmogInfo(slot), GetItemTransmogInfoList() and
SetItemTransmogInfo(info [, slot, ignoreChildItems]), the same contract as
the ModelSceneActor's: appearanceID is the item ID, illusionID the enchant
whose glow a weapon shows, 19 slots in the list.
The pane keeps its own Outfit::Worn. SetModelInstance reads the unit's
visible items into it after the original clones the unit. Then the engine's
TryOnItem worker (0x00504540) fills it from its own arms: the armor slot of
the component slot it set, the hand that TryOnAttach hangs (with the enchant
only when a glow shows), and nothing for the lane that TryOnEvict detaches,
because the worker leaves that lane's bytes in place. A read trims every slot
the pane no longer shows, which also covers the engine's Undress
(ClearModel 0x00504490).
SetItemTransmogInfo is TryOn without ERR_NOT_EQUIPPABLE. The worker shows
it only in its default arm (DisplayError 0x13), after the record is cached,
so a quiet try-on skips the worker for that arm. An uncached item is
remembered per pane and skipped the same way when the worker's cache
callback runs it again.
The ItemTransmogInfo argument reader and the ItemUtil.CreateItemTransmogInfo
pushers move from SceneActor.cpp to Model::TryOn, so both frame types share
them. Outfit gains InvSlotOfComponent for the armor arm's slot.
* feat(model): DressUpModel IsSlotAllowed and IsSlotVisible
IsSlotAllowed answers from the gates of 1.12.1's DressUpModel::TryOnItem
worker (0x00504540): a hand takes any held item, and an armor slot needs
the pane's character component (+0x3F8) with its ready byte (+0x40C) set.
A shapeshifted unit has neither, so its armor slots are not allowed. The
neck, rings, trinkets and ranged slot have no arm in the worker. A pane
without a model allows nothing. No 1.12 model hides an item in a slot it
takes, so IsSlotVisible gives the same answer.
The slot rule moves into Outfit::SlotAllowed, which the ModelScene actor
now shares, and TryOnResult reads the armor gate through the same
ArmorReady helper.
* feat(model): ModelSceneActor SetSheathedCategory and UseUnitSheatheCategory
SetSheathedCategory(slot, category) picks where a sheathed hand item
hangs: Default (its own place), Back, Side, or Hide. It also adds
Enum.TransmogOutfitSlotOptionSheatheCategory.
1.12.1 finds the sheath attachment from the item's ItemStats sheath
type through GetSheathAttachment (0x0047A070): 1 is the back pair
(26/27), 2 is a large weapon on the back (30/31), 3 is the hip (32/33),
4 is the shield (28), and 0 has no sheath point. AttachItemModel
(0x0047A0C0) and DetachHeldItemSlot (0x0047A310) both use the type they
are given. So a category comes down to a different type for the lane:
Back turns 3 into 1, Side turns 1 or 2 into 3, and Hide gives 0.
Shields and held off-hand items keep their own type.
The lane holds the type it hangs with, so every engine detach (Undress,
UndressSlot, a TryOn that replaces the hand) removes the model from the
place it hangs at. The actor keeps each lane's own type and category,
and re-hangs a lane after each write (SetModelByUnit, TryOn,
DressPlayerSlot). UseUnitSheatheCategory(true) uses every item's own
type, because 1.12.1 units have no category.
* feat(model): ModelSceneActor attachment points and AttachToActor
Three ClassicAPI extensions on the actor:
- GetAttachmentPosition(attachmentID) calls the engine's
CM2Model::GetAttachmentPosition (0x00712D50). It takes the
attachment's offset through its bone matrix and then through the
scene matrix (+0xDC, the inverse of the view the bones were built
under). The result is in the space of the root's base matrix, which
is the space of SetPosition. The engine does not check the id, and a
missing id (lookup 0xFFFF) reads past the attachment table. So the
method checks HasAttachment (0x00712CB0) first. It also needs every
model in the parent chain to be loaded, because the call waits for
the file and animates the parents first (EnsureAnimated, 0x00714000).
- AttachToActor(parent, attachmentID) hangs the actor on any
attachment through CM2Model::Attach (0x00712F70). It works like
AttachToMount without the seat animation. An id that the parent does
not have hangs the child at the parent's origin, which is the
unresolved-index path of EnsureAnimated.
- DetachFromActor() takes the actor off its parent (CM2Model::Detach,
0x00713020).
EnsureAnimated recurses through the parent chain, so an attach cycle
never ends. M2::CanAttach now refuses a cycle for both AttachToActor and
AttachToMount. HasAttachment moves into M2.h, and VisualKit uses it.
* feat(model): ModelSceneActor PlaySpellVisual
A ClassicAPI extension. actor:PlaySpellVisual(spellID [, target
[, castTimeMs]]) plays the visual of a spell cast between two actors. It
follows the steps of the world chain between two units. That chain
depends on units, missile objects and world objects, and an actor has
none of them, so model/SceneSpell.cpp repeats each step on actor models:
- The visual comes from GetSpellVisualRecord (0x006EC1E0), which also
makes the violenceLevel swap. The cast time comes from
FUN_GET_CAST_TIME, unless the caller gives one. The speed is
Spell +0x94.
- Precast (0x006EC220): the visual's +0x04 kit loops on the caster for
the cast time.
- Cast: the +0x08 kit plays once. A visual with a missile (+0x18 set,
speed above 0, a target other than the caster) makes the +0x1C model,
or Spells\ErrorCube.mdx, as the launcher 0x0060A3D0 does. Without a
missile, the impact plays at once (0x006E8BF0).
- Release: at the caster model's $CSL, $CSR or $CST event. The actor
model gets the engine's event callback (CM2Model::SetEventCallback,
0x007133A0), as a unit's model does (0x00607800). Without the event,
the release follows ReleaseMissilesFromHand (0x0060C9B0): it uses the
first of those events that the model has, else the caster's position.
The release then happens when the cast kit has no animation, when the
cast animation ends, or 2000 ms after the queue.
- Flight (0x0061CEB0, 0x0061E2A0): the speed is fitted to the time the
missile was queued (t = d/speed - queued, capped at 100). The missile
plays 144 InFlight and turns to its direction of travel. It aims each
frame at the target's attachment: +0x24 through
s_spellVisualAttachments (0x00860A18), else 15, else 19, else 0.75 of
the target's height. The +0x28 sound loops through the 2D loop player
0x00458900 until arrival, then fades over 0.15 s.
- Arrival (0x0061DC50): the target plays its wound animation, then the
+0x0C impact kit. A +0x30 impact model stays at the point until it
has no live particles (the impact list, 0x0061E930).
A kit's animation plays in place of the actor's animation. It does not
fire OnAnimFinished, and SetAnimation cancels it. Kit sounds play
through the by-ID player. Sound::Play gets a small header (PlayKitID,
PlayKitLooped, Stop) so that other modules can start a sound and stop
it safely. M2.h gets the event, particle and attachment helpers, and
VisualKit exposes its loop callback.
* feat(model): ModelSceneActor animation event sounds
ClassicAPI extensions: actor:SetPlayAnimationSounds(enabled) and
scene:SetGroundTerrain([terrainTypeID]), each with its getter.
Each actor model now gets the engine's event callback
(CM2Model::SetEventCallback, 0x007133A0), as a unit's model does
(0x00607800). model/SceneEvents.cpp sorts the events by their
four-character tag, as the unit dispatcher CGUnit_C::OnModelEvent
(0x005FFBD0) does. It receives the $CSL, $CSR and $CST missile
releases, which moved there from SceneSpell.cpp. When the actor opts
in, it also plays the sounds that a unit plays. They come from the
CreatureSoundData of the display: its own row, else its model data's,
as GetSoundData (0x0060AFB0) picks it.
- $FD1 to $FD4: the fidgets at +0x38 (0x006232C0).
- $FDX: the stand vocal at +0x20, with the world's 41-in-101 chance
and a 10 s limit shared by all actors. It never plays for the
active player's copy (0x006236B0, 0x00623490).
- $WNG and $WGG: the wing flap at +0x2C and the glide at +0x30. The
dispatcher plays them as vocal kinds 7 and 10, through slot 34
(push 7 / push 0xA, call [eax+0x88]).
- $FSD: the engine's GetFootstepSound (0x00458450), by the scene's
ground terrain, with FootstepSounds on.
- $DTH: the dry thud from the engine's death-thud table (0x00C4E0F4),
by size class (GetUnitSoundSize 0x00625500) and the ground.
- $CSD: the event's own SoundEntries id, with EmoteSounds on.
- $TRD: the precast sound (SpellVisual +0x38) of a PlaySpellVisual
that is still preparing (0x0062FAA0).
The sounds are off by default, so stock scenes such as the dressing
room stay silent. They play in 2D through the by-ID player. A scene
without a ground terrain has no footsteps and no death thud. $CSS,
$CAH and $AH0 to $AH3 play nothing: they present a pending swing
(0x006247D0), and an actor never swings at anything. The unit's
display ID is kept on the actor so that its sound data can be found.
* feat(model): ModelSceneActor ApplySpellVisualKit
A ClassicAPI extension with the contract of retail's PlayerModel
(CharacterModelBase) method of the same name. The kit is added next to
the kits that the actor already shows. The actor's SetSpellVisualKit
keeps retail's behaviour: it replaces the actor's one kit.
The kit goes through Model::VisualKit::Apply, the same routine
PlayerModel:ApplySpellVisualKit uses. This is the char-select ghost's
kit step (0x004727F0) for any kit: the effect models hang at their
attachments, and the tint and alpha procedures apply. The model owns
the effects, so a looping kit stays until the model changes, and a
oneShot kit stops when its sequence ends. HasAttachment waits for an
unloaded model file, so a call made before the model has loaded is
held in Actor::pendingKits and applied with SetSpellVisualKit's kit
once the model loads.
* feat(model): ModelScene GetActorAtCursor and OnActorEnter/OnActorLeave
A ClassicAPI extension: scene:GetActorAtCursor() returns the shown actor
under the cursor, and the scene scripts OnActorEnter / OnActorLeave
(self, actor) run when that actor changes while the scene is the mouse
focus.
The pick is the world's own object pick (0x00480A50) on the scene's M2
scene, not a bounding-box test: EnableRayHits (0x007089B0), then
CM2Model::SetHitTestMode(model, 1, 0, actor) (0x00713CB0, ret 0xC) on
each shown actor's model and its children (held items, kit effects), as
0x00480D90 does for a unit; a child that is another actor's model (a
seated rider) is left to that actor. M2SceneRayHit (0x007089C0, ret 0x10,
retry 1 as the world passes) skins each instance animated in the latest
collect on the CPU and returns the value of the nearest triangle. The
ray empties the hit list on every call.
The ray is in view space, where the collect leaves the instance
matrices: the cursor (UI context +0x1118, NDC) in the paint's viewport
(the frame's rect clamped to the screen), unprojected through the
paint's own projection at view depth near and far. The paint's camera
leg is now CameraTransforms, shared with the pick, so view insets and
translation move the pick with the picture. CCamera::SetDeviceTransforms
(0x007AC640) reads only the rect's aspect, so the clamped viewport is
the space the cursor maps into.
The hover runs from the scene's update walk, only while one of the two
scripts is set (Frame::ExtraScripts cells) and the scene is the mouse
focus (UI context +0x7C).
* feat(model): ModelSceneActor SetShadowShown blob shadows
A ClassicAPI extension, off by default: actor:SetShadowShown(shown) /
IsShadowShown() put the world's blob shadow under the actor.
The shadow is 1.12's own (DrawBlobShadow 0x006D7920, reached from the
entity draw through 0x006D78F0): drawn only while shadowLOD
(0x0086F5B4) is 1 and the model is ready; the bounds of sequence (0, 0),
skipped when the x or y extent is under the range epsilon, clamped to
+-5 and multiplied by the length of the base transform's row 0
(GetBaseTransform 0x00710600); the four corners turned by the base
rotation and moved by the base translation. The texture is the one the
unit setup loads (Textures\ShadowBlob.blp, handle 0x00CE9DFC, device
object through 0x0044ACF0), with the decal's states: blend 4
(DST_COLOR / ZERO), lighting, fog and depth write off, combiner preset 5,
and the colour white with the model's alpha (GetAlpha 0x00710CA0;
0x004A2C10 packs that byte on top).
The world lays the shadow onto the ground's batches with a decal
(0x006D7330). A scene has no ground, so the paint draws the turned box
itself as a flat triangle strip on the plane of the base translation,
after the animate pass and before the draw passes, so every model draws
over the shadows. Culling is off, as for the engine's lightning quad
(0x007AFCB0). The decal's height fade and its shadowBias depth test
EQUAL are not drawn: both exist to match real ground. A model hung on
another casts none.
* feat(model): ModelScene WMO backdrops (SetWorldModel)
A ClassicAPI extension: scene:SetWorldModel(path [, x, y, z [, yaw
[, doodadSet]]]), scene:SetWorldModelByMapID(mapID) and
scene:ClearWorldModel() show a WMO around the scene's actors. Both
setters return whether a WMO is shown; a set that fails clears it.
ModelSceneActor:SetModelByPath refuses .wmo paths, which only the scene
shows.
The map object is the world's own. CMapObj::Get (0x006A3230) loads it
into the engine's cache with one reference ours, released by CountDown
(0x006A33F0). Each paint keeps every group alive for 30 s (group
+0x15C) and queues LoadGroup (0x006A4A30) for a group that is neither
parsed (+0x164) nor being read (+0x160), so a group the world frame has
freed comes back. The pools, shaders and cache come from
CMap::Initialize at client start, so a WMO also shows at the glue
screen.
The engine's reader ends the program when a file does not open
(CMap::SafeOpen) and parses the root's chunks in a fixed order without
reading their tags. A root is refused unless MVER and the 16 chunks from
MOHD to MFOG are in that order inside the file, it has at most 384
groups, and each group file opens.
The paint draws the WMO after the animate pass, the way
DrawMapObjectPass (0x00684840) draws one instance:
- render states pushed; world stack 8 = placement x Translate(-eye);
- the frustum stack pushed (0x00682380), a volume of the scene's view
stored on it (BuildFrustumCorners 0x005C43B0 over the device view
moved by -eye and the device projection, planes by 0x00686640), then
moved into the object's space with the inverse placement
(0x00682ED0), which the drawers cull each batch against;
- a lighting record at the object's bounding sphere
(M2LightingInitialize 0x0071BC30, the scene's M2 lights for that point
by 0x0070A0F0, the scene light as the sun by 0x0071BF90, then the fog),
committed at the eye with fog by 0x0071C730;
- each parsed group: the portal vertex fade once (0x006C43D0), then the
interior (0x006B5190) or exterior (0x006B4F10) drawer, called directly,
because the world sets its drawer pointers only in its own frame.
Fog: the world fogs a WMO's insides with its MFOG records only for a WMO
with more than one record (0x0069DE20). With no candidate the fog is
record 0, its end capped at the far clip and its start that record's
fraction of the end. Other WMOs take the scene's own fog, staged with
the scene light by the frame's light callback (0x0076D680).
The drawers read two world globals. The group fog flag (0x00CA7F00)
would replace the fog with the light state's interior fog, so it is 0
while the scene draws. Window materials write the sun's colours through
the sun pointer (0x00C89EF0), which is NULL at the glue screen, so while
the scene draws it points at a copy of the scene light.
SetWorldModelByMapID reads the map's directory from Map.dbc, then the
WDT's MPHD, MAIN, MWMO and MODF. Only a map whose WDT holds one WMO and
no terrain has an answer. The placement is the world's own for a WDT
object: translate (-pos[2], -pos[0], pos[1]), then rotate z by
rot[1] + pi, y by rot[0] and x by rot[2] (degrees by 0x007FFAAC), with
the record's doodad set. Scene positions then are the map's positions,
so a creature's spawn point places its actor in the room.
Not drawn yet: the doodads, the room's light on the actors, liquids and
the camera's fog inside the WMO.
* feat(model): ModelScene WMO doodads and positional scene sounds
A WMO backdrop now shows its doodads the way the world builds them, and
every sound a scene plays is heard from the scene's camera at its distance.
Doodads (model/SceneWorld.cpp). Each parsed group makes its doodads as
CreateGroupDoodads (0x00695AA0) does: the group's MODR indices, kept when
FindDoodadSet (0x006A4FB0) gives set 0 or the instance's set; a doodad two
groups list is one def, sun-lit when any of them is exterior. Each def
mirrors CreateGroupDoodadDef (0x00694E90) and CreateDoodadModel
(0x00695100): the MODD record's translate / quaternion / scale matrix
times the placement, SplitLightColor (0x006A77E0) into the ambient and
directional bytes, the model from the MODN name, SetBaseTransform, the
engine's own done callback (0x006951B0) and PlayAnimation(-1, 0, -1, ...).
Lighting mirrors AddLights (0x006A8050): an exterior doodad takes the
frame's sun (the frame light callback 0x0076D680); an interior one its
ambient bytes and its directional bytes along the fixed direction at
0x00CA816C, then the group's MOLT point lights built as CreateGroupLights
(0x00695C00) and AddMapLight (0x006A7AC0) build them. An interior doodad
in a WMO with more than one MFOG takes MFOG[0], else the scene's fog.
Each frame mirrors DrawDoodadModels (0x00683F80): the world shows every
doodad it draws again (SetAnimated + SetVisible), faded by its sphere
(SetDoodadDefBounds 0x006952A0, CM2Model::GetBoundingSphere 0x00713680)
and the camera's ground distance, with the radius classes, fade ends and
ranges read live from 0x00810188..0x008101A8 and the large end capped by
the far clip.
Doodad sounds are opt-in, scene:SetPlayWorldModelSounds(enabled) /
GetPlayWorldModelSounds (a ClassicAPI extension, off by default): the
$DSO / $DSL / $DSE events of DoodadModelEvent (0x006951E0) through
PlaySoundAt (0x00458870) and the world's loop emitters (0x00461D80 add,
0x00462000 move, 0x00461F80 remove). The emitter pump runs only in the
world, so they play only there. A hidden scene (CSimpleFrame::Hide,
0x0076AD50) drops its loops.
Positional scene sounds (model/SceneSound.cpp). The engine has one
listener, placed by the world camera. A scene point is played where it
lies from the scene camera, its offsets along the camera's forward, up
and side laid along the listener's, read back through
FSOUND_3D_Listener_GetAttributes (0x007FDB50) in the engine's axes. The
engine then applies the row's cutoff, minimum distance and panning as for
a unit that far away. Sound::Play gains the world's 3D players:
PlayKitIDAt (0x0045CF00, RET 0x18, NULL past the cutoff), PlayKitLoopedAt
(0x004589A0) and Move (Sound::SetPosition 0x007A5B10), all owned so
StopSound stops them.
The actors use it: spell kit sounds at the actor, the missile's loop
following the missile (re-mapped each paint) and stopped when the scene
hides, and the animation sounds of SetPlayAnimationSounds at the actor.
actor:PlaySound(soundKitID) is a ClassicAPI extension: a SoundKitID once at
the actor, returning willPlay, soundHandle as PlaySound does.
* feat(model): ModelScene actors take the WMO's light
An actor standing in the scene's WMO is lit the way the world lights a
unit standing in it, instead of by the scene light alone.
Placement (World::Settle, from the scene's update) mirrors PlaceEntity
(0x006A8C10). LinkEntityToMapObject (0x006A8ED0): the model's bounds
through its base matrix give the world box and its centre (SyncLightNode
0x006717D0); the box goes into WMO space (TransformBox 0x006DC540) and is
tested against the WMO (BoxOverlaps 0x006A4670) and each group
(BoxOverlapsGroup 0x006A4830, GetLoadedGroup, GroupBoxAnyHit 0x006A3EE0 or
GroupSegmentAnyHit 0x006A3F10). In each non-exterior group,
TraceGroupMasked (0x006A3A40, mask 0x20) probes 1000 yards down from the
centre (0x008022CC), else 1000 up; t is shared, so the nearest face of all
groups wins, and its point is taken along the down probe as the engine
takes it. SetEntityLightFlags (0x006A87F0): no face, or a group with flag
0x40, means the sun. Else BakeGroupLight's face path (0x006A8410):
SampleGroupColor (0x006A4DC0) reads the face's MOCV colour and
SplitLightColor splits it (directional floor 0xA8, ambient cap 0x60); a
day face blends both toward the sun by the colour's alpha. Every linked
group adds its MOLT lights through AddMapLight (GatherMapObjectLights
0x006A79C0), so torches light the actors near them. The actor is placed
again when its translation moved a squared 0.001 or more (0x00801360),
when its model changed, or when a new group of the WMO was made.
The light (World::ActorLight, the actor model's new lighting callback)
mirrors ApplyMapLighting (0x006A7300): an interior actor gets the WMO fog,
the ambient bytes and the directional bytes along the fixed indoor
direction (0x00CA816C, blended toward the sun's by a day face); a sun-lit
one the frame's light and fog; both then their map lights. The scene light
is the sun throughout. Without a WMO the callback is the frame's own, as
before.
The doodads' map lights move to a per-group list on the backdrop, shared
with the actors, and the interior light slots to one helper.
Not mirrored: AnimateMapEntityLight's ramp (0x0069E770), so the light
changes at once. A model with an M2 parent is not placed.
* docs: ModelScene WMO backdrops, scene sounds and actor:PlaySound
docs/API.md gains the WMO backdrop methods (SetWorldModel,
SetWorldModelByMapID, ClearWorldModel), SetPlayWorldModelSounds /
GetPlayWorldModelSounds, a Scene sounds section on hearing a scene from
its camera, and actor:PlaySound. SetWorldModel covers the props, their
fade, and the light the WMO gives the actors. SetPlayAnimationSounds and
PlaySpellVisual now say where their sounds play. README lists the new
methods.
* feat(model): ModelScene shadows and footsteps on the WMO floor
Actors in a WMO scene now stand on the WMO the way 1.12.1 places a unit.
A unit's world entity is made with factory flags 0 (CGObject_C::CreateNode
0x00613E10 -> 0x00670DB0), so it lacks +0x90 bit 0x2000 (flag bit 3,
0x00670E9C) and ReattachEntity 0x006A86D0 sends it to AttachEntityToGround
0x006A8A20, not PlaceEntity 0x006A8C10 (game objects), which the actor
light mirrored before. Place now follows the unit's path: the probe starts
at the model's collision box centre through its matrix (UpdateNode
0x00613F80, GetCollisionBox 0x00713700) and finds the nearest group face
1000 yards down, else up past the sphere (TraceMapObjectsNearest 0x006A8840:
SegmentHitsGroupBox 0x006A47E0, IntersectSegment 0x006B92B0 mask 4). Only
that group links the actor and adds its MOLT lights. SetEntityLightFlags
picks the sun or interior, TraceGroupFace 0x006A2600 finds the face and
GetFaceTerrainType 0x006A26C0 its material's terrain type.
Footsteps and the death thud use that terrain type when the scene has no
SetGroundTerrain (the unit's +0xC60).
SetShadowShown on a WMO scene lays the blob as the world's decal.
DrawBlobShadow 0x006D7920 is mirrored up to DrawDecal: the box from 5/3 of
the height below the feet to 1 above it (0xCEA610 / 0xCEA60C, ThirdOf
0x006D6E50), the texture matrix, white with the model's alpha, depth
function 1 when shadowBias is 0. DrawDecal's world reads are replaced:
BuildDecalTransforms 0x006D6FA0 runs in its absolute mode, because the
other mode reads the world camera (null at the glue screen), and is moved
to the eye. DrawDecalBatches 0x006D7480 is mirrored with the WMO's own
facets (TestMapObjectBox 0x006AD330 -> CollectBoxFacets 0x006A3B10, mask
0x2F0122) and the engine's vertex, index and draw calls
(0x006D7810, 0x006D78A0, 0x0058A830). A scene without a WMO keeps the flat
quad.
The engine's queries take a map object def but read only its placement
(+0x94), inverse (+0xD4) and object (+0x118); the backdrop keeps a block
with those three.
actor:StopSpellVisual() (an extension) interrupts the casts still being
prepared, the drop a new cast already did (0x0060D1C0 stops the old
spell's kits). Without it a precast that ended after a death played its
cast animation over the death.
* feat(model): ModelScene ranged shots (Auto Shot) and actor ammo
1.12.1 builds a ranged shot from the shooter, not from the spell. Auto
Shot (75) has no SpellVisual; UnitGetSpellVisual (0x0060D450) fills a
ranged spell's (Attributes 0x2) empty visual fields (the precast, cast and
impact kits, the missile flag and model, path, attachment, flight sound
and precast sound) from the SpellVisual of the ranged item's
ItemDisplayInfo (+0x28). A bow's (visual 5) gives LoadBow, AttackBow and
the arrow whoosh 4222. PlaySpellVisual now builds that 64-byte visual per
cast from the actor's ranged lane (INVTYPE_RANGED, THROWN or RANGEDRIGHT),
so it no longer needs the spell to have a visual of its own.
The arrow is the ammo. SMSG_SPELL_START / GO carry an ammo display for a
ranged spell; the launcher (CGUnit_C::LaunchSpellMissile 0x0060A3D0) makes
the missile from the visual's +0x1C when it is at least 1, else from the
ammo through CreateLooseItemModel (0x00479F40, the record's second model
and texture in the body model's scene), else the error cube, and draws a
missile launched during a rifle animation at alpha 0. The launch needs the
visual's missile flag or an ammo display (0x006E8A50). The ammo follows
the server's rule: a thrown weapon is its own ammo; a bow, crossbow or gun
shoots the actor's ammo, else what the server gives an NPC (5996 Rough
Arrow, 5998 Light Shot).
actor:TryOn(ammoItemID) (an extension) sets that ammo. The dress-up
worker refuses INVTYPE_AMMO, so the actor takes it before the worker's
dispatch; Outfit::ArmOf stays the worker's mirror. The held lane's byte 1
is now named subclass (UNIT_VIRTUAL_ITEM_INFO's layout).
$BWR releases a queued missile as the unit's model event does
(0x00600159): from the body's attachment 35 during a bow animation
(IsBowAnimation 0x005FCFB0), 36 during a rifle animation (IsRifleAnimation
0x005FCFD0), else from the event's point.
Not mirrored yet: BowPull and the nocked ammo on $BWP, the bowstring,
arrows stuck in the target, and drawing the ranged weapon at the shot.
* docs: ModelScene floor shadows and footsteps, ranged shots, StopSpellVisual
API.md documents what the last three commits added to ModelScene actors:
- actor:StopSpellVisual(), which interrupts the spells an actor still
prepares (a cast already made, and its missile, go on).
- actor:PlaySpellVisual for ranged spells: the ranged weapon gives what
the spell's visual lacks (all of Auto Shot's), the actor's ammo is the
missile (a plain arrow or bullet without one, a thrown weapon throws
itself), bullets do not show in flight.
- actor:TryOn of arrows and bullets as the actor's ammo.
- actor:SetShadowShown on a WMO floor: it follows slopes and steps and
fades with height; no floor, no shadow.
- scene:SetGroundTerrain and actor:SetPlayAnimationSounds: without a set
ground, the WMO floor under an actor picks its footstep and death thud
sounds.
- scene:SetWorldModel: only the lights of the part an actor stands on
light it, and the floor picks its sounds and takes its shadow.
README lists :StopSpellVisual with the other actor methods.
* feat(model): ModelScene WMO group liquid and camera fog
A scene's WMO now draws the liquids of its groups and fogs as the world
fogs a WMO around its camera.
Liquid: the world's group liquid pass (DrawGroupLiquidPass 0x00684CD0)
sets matrix 8 to the placement moved by the camera, commits a lighting
record with fog and calls DrawMapObjectGroupLiquid (0x006B4060). The
scene does the same for each parsed group with flag 0x1000, after its
opaque list and before its translucent one, as the world draws the pass
between its model lists. The engine's drawer gives the animated frames
(0x0068AAC0), the magma scroll and, with BuildGroupDepthRamp (0x006B6B60)
first, the water's depth ramp. A group whose first liquid type is past 8
is not drawn: type 0xF asks GetLiquidFrame for a frame past its table.
The parity flag is 1, the value every group gets from outside the portal
walk (RunGroupCallback 0x006B4160), so all tiles draw.
Camera fog: each scene update traces 1760 down from the scene's camera
as ClaimCameraMapObject (0x006821F0) traces from the world's: the nearest
floor of the groups, then CrossPortals (0x006A3F80) with the fraction
1.05, and no claim for a group whose MOGI flags have 0x8.
GetCameraInteriorFog (0x0069DE20) is mirrored for the claim (it reads the
world camera's globals): record 0 blended with the first group's
candidate fogs, farthest first, by the engine's LightFalloff (0x0069E1C0)
and LerpFogRecord (0x0069EFD0). BuildSceneFog (0x006CEE30) gives the
rest: the target's end is capped at the far clip, the weight moves 0.25
a second (0x008115B0) toward 1 while the camera is over an interior
group and toward 0 otherwise, and the drawn fog is the scene's fog
moved toward the target by it. The WMO, its interior doodads and the
interior actors take the drawn fog (ApplyMapObjectFog 0x006C31E0). This
replaces the fixed record 0 fog. The first update takes the weight as
it stands; the camera's own liquid is not asked.
* docs: ModelScene WMO liquid and camera fog
SetWorldModel: the WMO's own fog holds while the camera is above an
indoor part, fades in and out over 4 seconds, blends nearby fog zones,
comes in from the far clip in a scene without fog, and does not change
for a camera in liquid. The WMO's water, lava and slime show and
animate; outdoor water takes the colors of the player's zone.
* feat(model): ModelScene actors draw the bow and nock the ammo
An actor that casts a ranged spell now poses with its ranged weapon as a
unit does.
At the spell's start (HandleSpellStart 0x006E78A1, for Attributes 0x2 or
the auto-repeat flag), SetAmmoDisplay (0x0060BA30) is mirrored: the ammo
in hand is made with CreateLooseItemModel (kind 0x19 for a thrown
ranged item) and nocked at attachment 35 when the bow is already drawn.
$BWP (OnCombatModelEvent 0x006247D0) with a ranged spell under way runs
PlayBowPull (0x00624CC0): the weapon model, the item AttachItemModel
hung in its lane's hand (attachment 1 or 2), plays 160 BowPull at its
sequence length over the time left in the body's animation, from the
key bone state (hi - ftol(position / speed) - lo; nothing with the latch
set). The ammo then goes on the string unless a gun or crossbow shoots,
and the bow is drawn. $BWR with a missile waiting plays 0 on the weapon
for a bow animation and 161 BowRelease for a rifle one, then takes the
ammo off. EndRangedPose (0x0060F530) runs where the engine runs it, at
the missile release and when an interrupt drops a precast: the bow is no
longer drawn, the ammo leaves the hand and the weapon stands unless it
plays 161.
The models carry $BWP only in 105 LoadBow, so the precast's load must
not repeat. The sequence-end handler's ranged cases (0x005FC3F0) are
mirrored for kit animations: 105 goes on to 109 HoldBow and 106 to 110,
always, and a hold replays while the weapon is held and the spell still
prepares, so a long precast draws once and holds.
* fix(model): ModelScene spell animations do not play over a death
A unit without health plays only death animations: CGUnit_C::
PlayAnimation (0x005FE2F0) returns unless IsDeathAnimation (0x005FDA90,
__stdcall) holds for the animation. An actor had no such gate, so a
missile already in flight when the target died still played its wound
(and its impact kit's animation) on arrival and replaced the death
animation; StopSpellVisual only drops the casts still preparing.
An actor whose own animation is a death animation now takes no kit
animation over it, and setting a death drops the kit animation that
plays. The missiles still land and show their impact effects.
* feat(model): ModelScene arrows stick in their target
A missile shot from a bow, crossbow or thrown weapon now stays in the
actor it hits for 5 seconds, as a unit's does.
The launcher (0x0060A509) flags a ranged spell's missile when the ranged
item is a bow, crossbow or thrown weapon (0x0060A710: class 2, subclass
2, 18 or 16). Launch (0x0061CEB0) settles the target attachment: the
visual's, else 15, else 19, else none; Aim and the stick share that
choice. ArriveHit (0x0061DC50) with the flag, an attachment and a target
model runs StickInUnit (0x0061E7C0): the missile, snapped to the
destination with the turn of its flight (Arrive 0x0061E1D0), plays 191
Impact and is attached at the attachment, its base set to its world pose
times the inverse of GetAttachmentMatrix (0x00712DE0, scene space) at
the target's scale (InvertAffineMatrix). The target's stuck list frees
each one once its 5000 ms pass (object slot 14); a paused actor holds
them, and they go with its model. The wound and the impact kit play
first, as before.
The missile flies at one point, the attachment, as in the world: on a
large model such as Onyxia's (chest 34 at (2.77, 0, 4.20)) the arrows
all stick at that point inside the body.
* feat(model): ModelScene WMO fog follows the camera into liquid
The camera fog now asks the liquid around the camera as the world does.
CameraEnvironment (0x006809C0) probes at the camera's x and y and the
lowest z of the camera and the four near corners of its frustum (a
corner at or below the lowest, or NaN, replaces it); with the claim it
asks LiquidHeight (0x006B9F10) of the claim's first group in model
space, the type starting as 0xF. The scene keeps the drop below the eye
from the frustum volume its WMO draw builds.
BuildSceneFog (0x006CEE30) picks the target from it: water or ocean
take the underwater sub-record (+0x24); magma with fog flag 0x100 and
slime with 0x10 take it too and make the zone fog the target; magma or
slime without the flag take the zone fog as the target. GetCameraInteriorFog
now blends both sub-records and keeps the flags of record 0 or of the
nearest candidate. With the camera in liquid the paint draws the WMO's
liquids after the translucent models, as the frame does (0x004836D6).
Not mirrored: the zone fog the camera's liquid makes the target changes
only the WMO, its doodads and the indoor actors, not every model; a
scene has no terrain, so outside the WMO the camera is always dry.
* feat(model): ModelScene actors draw the ranged weapon and dual wield
A ranged or auto-repeat spell's start now sets the caster's sheathe
state 2 at once, as HandleSpellStart (0x006E78F3) does through
SetSheatheState (0x00611CF0, (2, 1, 1)): the ranged lane hangs in its
hand and the other held item at its sheath point. A unit that is not
the active player keeps state 2 through its later animations
(0x005FDF80 asks for 2 again), so the actor keeps it until SetSheathed,
SetModelByUnit or a new model. Every re-hang (SetSheathed, the sheathe
categories, a try-on) honours it per lane, so a sheathed bow now comes
to hand for the shot and BowPull finds it there.
An actor that shows a creature display or a model file now holds two
one-hand weapons. DressUpModel's TryOnItem asks the active player's
dual-wield skill (0x005EAB70) only when it shows that player and
refuses a second one-hander on any other model; the world draws a
creature's two weapons regardless. An actor that shows a unit keeps the
dressing room's rule.
* docs: ModelScene ranged pose, stuck arrows, camera liquid fog
PlaySpellVisual: the ranged weapon comes to hand at the spell's start;
the arrow in hand, the draw and the release; instant shots do not draw;
arrows and thrown weapons stay in the target for 5 seconds; no spell
animation plays over a death animation. StopSpellVisual lowers a drawn
bow. TryOn: an actor without a unit holds two one-hand weapons.
SetWorldModel: the camera in the WMO's water takes its underwater fog,
in lava or slime the scene's fog unless the WMO has one for it.
* feat(model): ModelScene WMO light eases and lights spell models
An actor's light in the scene's WMO now changes the way a 1.12.1 unit's
entity light does. AnimateMapEntityLight (0x0069E770) moves each byte of
the ambient toward its target by max(1, trunc(2.0 x dt x 255)) per tick.
It moves the intensity, which scales the directional light in
ApplyMapLighting (0x006A7300), by 3.3333 x dt. The bake
(BakeMapEntityGroupLight 0x0069E4C0) writes the ambient target, not the
ambient. The target intensity is 1.0 indoors and 2.5 (0x00810A68) on an
exterior group. A new node starts at 1.0 with the day ambient
(0x00670DB0). Outside, with no channel moving, the ambient follows the
day's. World::Settle now takes the frame's elapsed time and eases each
tick, and places the node again only when the model moved.
A missile in flight gets its own entity light node, as the world gives
one (CreateLightObjectB 0x00671010 from 0x0061E655, placed by
AttachEntityToGround). Impact models left behind get one too. Each model
releases its callback back to the frame's before the light goes.
LightChildren now copies the parent model's own lighting callback pair
(+0x3BC / +0x3C0), so a nocked arrow and a stuck missile are lit like
the actor that holds them, not with the frame's flat light.
* fix(model): ModelScene casts keep their pose through a wound
A wound or an impact animation on a casting actor replaced the precast's
looping animation, and when it ended the actor went back to its script
animation: the hands dropped while the precast glow went on, or a
cowering pose showed through a later cast. A 1.12.1 unit replays its
spell's looping kit animation after a one-shot ends. The actor now keeps
the precast's loop under a one-shot and plays it again when the one-shot
ends. The loop ends with the precast, a death, a new model or a script
animation.
The anim-done callback also took the end of any key bone's track as the
end of the actor's animation, so a finger track ending mid-cast restarted
a loop or cut a cast short. It now makes the character pane's test
(0x005062A0, the same as the unit's 0x005FCA28): only the body track
(key bone -1 or the root, 26) ends the animation. Another bone's track
is stopped when it ends, except HandsClosed (15), which keeps a weapon's
grip.
* fix(model): ModelScene missile landing does not end the next precast
A mage's Fireball is still in flight when the next cast's precast
begins. When the missile landed, its finished cast was dropped through
EndPrecast, which also ends the caster's looping precast animation. That
loop now belonged to the newer cast, so the caster's hands fell to its
sides while the precast glow went on, and the cast threw normally at its
end. A cast ends its own precast once, when its cast phase starts, so
dropping a cast now ends the precast only while the cast still prepares.
* feat(model): ModelScene bows draw their string
A 1.12.1 bow's string is not part of its model. RefreshRangedWeaponModel
(0x00611E10) gives the ranged model of a bow (class 2, subclass 2) the
draw callback DrawBowstring (0x00611FF0) through SetDrawCallback
(0x00710DB0), with the unit as its user data, and sets a null callback
before it closes that model. The M2 draw runs the callback as one of the
model's elements. It draws two lines in the lighting record's colour
from the bow's $WTT event to its $WTB event: through the body's
attachment 35 while the bow is drawn (+0xD58 bit 0x4000, set by $BWP),
else through their midpoint.
The callback reads only the unit's model (+0xD8) and that bit, so an
actor keeps a block shaped like those two unit fields and hands it to
the engine's own DrawBowstring. Each update the actor finds the bow in
its ranged lane where the lane hangs it, in the hand or at the sheath
point the weapon trail's lookup gives (GetSheathAttachment 0x0047A070,
then FindChild), holds a reference on it, and strings it. A bow no
longer hung, or a released model, is unstrung first. The drawn bit
follows the actor's bow pull and release.
* feat(model): ModelScene actors hold a ranged weapon in its own slot
A 1.12.1 unit holds its ranged weapon apart from its two hands: hand 2 of
the held-lane and display virtuals, inventory slot 18, its model at
+0xD24. The model is hung only in the ranged sheathe state.
ApplySheatheChange (0x00611770) entering state 2 moves the melee items to
their sheath points, then RefreshRangedWeaponModel (0x00611E10, arg 0)
empties attachments 1, 2 and 0 and hangs the weapon in hand through
AttachItemModel with body slot 0x11: attachment 1 for INVTYPE_RANGEDRIGHT
and THROWN, else 2. Leaving state 2 for 0 detaches attachment 35 and the
weapon's hand, then opens that hand (OpenHand 0x004796B0); for 1,
RefreshRangedWeaponModel(1) hangs it at its sheath point, which a bow or
gun does not have. Outside state 2 the weapon shows nowhere.
Actors now do the same, as a ClassicAPI extension (retail has no ranged
slot). TryOn puts every bow, gun, crossbow, wand and thrown weapon in the
ranged slot, whatever hand is named, so a hunter can hold two melee
weapons and a bow. A ranged spell draws the weapon (DrawRanged);
SetSheathed puts it away (SheatheRanged). SetModelByUnit reads the unit's
hand 2 (Outfit::ReadRanged), and UndressSlot, DressPlayerSlot,
IsSlotAllowed and the transmog lists know slot 18. Shots, ammo, the bow
pull, stuck missiles and the bowstring use the ranged slot. A bow in it
is strung when hung, and the callback is cleared before its reference
goes, as RefreshRangedWeaponModel does. DressUpModel is unchanged.
* docs: ModelScene ranged slot, bowstring, eased WMO light
TryOn puts ranged weapons in slot 18; the ranged weapon shows only while
the actor shoots, in the hand the world uses. The slot methods, the
transmog lists, SetSheathed, SetSheathedCategory and PlaySpellVisual say
so. A bow has a string. An actor's light in a WMO changes over a short
time, and missiles and impact effects take the light of their place.
* feat(model): ModelScene outdoor WMO water takes its map's light
A 1.12.1 WMO's exterior water colours its vertices from the world's light
table: the deep river colour (colour band 17, table +0x40) in
DrawGroupLiquid's exterior arm, and the river alphas (LightParams columns
5 and 6, +0x68 / +0x6C) that BuildGroupDepthRamp (0x006B6B60) ramps
between. BuildLightTable (0x006D2260) makes that table each frame at the
camera from the current map's light list (0x006D6170: the map's Light
rows, slot 0 the one at the origin, else Light id 1): slot 0 gathered at
the half-minute of the day (GatherLightRecord 0x006D64D0 on the
LightParams of reference 0, or 1 under water), then each area light the
eye is inside of blended in farthest first by its falloff
(BlendAreaLights 0x006D2D00, OverblendLightRecord 0x006D30E0); in magma
LightParams 7, in slime 6. A scene's WMO showed the player's zone.
The backdrop now knows its map: SetWorldModelByMapID's, or a new
optional mapID argument to SetWorldModel. With one, the scene builds
that map's table at its own camera through the engine's gather and blend
(the storm blend, which follows the player's weather, is left out) and
puts its three water fields into the world's table only while its
liquids draw, then puts the world's back.
* fix(model): ModelScene WMOs no longer draw pink outside their own fog
A WMO's exterior group drawer (0x006B4F10), and the interior one too,
turns the device fog on for every material without flag 0x2 and keeps
the fog range the device holds: the world always commits a fog
(M2LightingSetDeviceLights 0x0071C730) just before. A scene without fog,
outside a WMO's own fog, committed a record with none, which turns the
fog off and leaves the range alone, so the drawers fogged with the
device's starting state (0x00593BF0): 0 to 1.0, in 0xFFFF0080. Every
exterior surface past a yard drew solid pink: Onyxia's Lair from
outside, all of Stormwind.
After the commit, a scene without fog now sets the device fog range from
the far clip to 1e10, the fog end of a world without light (the
immediate at 0x006D2301), under a render-state scope around the WMO's
draw and its liquids' draw: the drawers' fog then covers nothing the
scene draws, as its models show none.
* docs: ModelScene SetWorldModel mapID and outdoor water light
SetWorldModel takes an optional mapID: with it, the WMO's outdoor water
takes that map's light at the camera and the world's time of day, with
the nearby zone lights blended in; without it, the light where the
player is. SetWorldModelByMapID's water takes its map's light.
* feat(model): ModelScene TraceSegment and a sound listener actor
scene:TraceSegment(start, end) returns the first face of the scene's WMO
on a segment: the hit point, the face's unit normal turned toward the
start, and the fraction. It is the scene's per-group trace (Nearest,
TraceMapObjectsNearest 0x006A8840 over the one WMO) with face mask 4,
which CMapObjGroup::IntersectSegment (0x006B92B0) widens to 0x84: every
face but the detail faces, the set the world's line of sight and the mover
test (class 0x100111 builds the same mask). The normal is crossed from the
hit triangle as CMapObj::IntersectSegment (0x006A37B0) reads it: facet
batch 0's first three indices into its vertices, read right after the
group's call, then turned into scene space by the placement. Only loaded
groups answer. The class word moves to Offsets.h as WORLD_TRACE_CLASS_LOS,
which LineOfSight.cpp used as a local constant.
scene:SetSoundListenerActor(actor) hears the scene's sounds at an actor.
The world's listener (0x00482EA0) stands at the unit the player drives
while SoundListenerAtCharacter is on: its position raised by scale times
box height (+0x90 * +0xBC), facing the unit's facing with z 0, up
(0, 0, 1); otherwise at the camera. The scene mirrors both branches, with
the listener actor in place of the unit and the scene camera in place of
the world's.
* feat(model): ModelScene TraceSegment camera face set
TraceSegment takes an optional camera flag that traces the faces the
world's camera collides with. The camera solver (0x0050E570) traces with
class 0x100171, whose mask builder (0x006A3839) gives face mask 0x82:
detail faces block it and the no-camera-collision faces (MOPY 0x02) do
not, where the line-of-sight set (0x84) is the other way round. The flag
passes mask 2 to CMapObjGroup::IntersectSegment (0x006B92B0) in place of
4; the call ORs in the visited bit.
With it an orbit camera can do the solver's boom sweep: trace from the
target toward the eye and stop 1/9 yard (0x00808A04) short of the hit.
* feat(model): ModelScene GetLiquidAtPoint
scene:GetLiquidAtPoint(x, y, z) returns the liquid of the scene's WMO at
a point, its type (0 water, 1 ocean, 2 magma, 3 slime) and the height of
its surface, found the way the world finds a unit's. The group is the one
whose face lies nearest below the point, the probe AttachEntityToGround
(0x006A8A20) runs from a unit; CMapObjGroup::LiquidHeight (0x006B9F10)
then answers at the point in WMO space. It reads the MLIQ tile under the
point and answers only below the surface (water 0.01 above it); a group
whose MOGP liquid word is set answers that type everywhere with FLT_MAX,
returned as a nil surface. The type is masked with 3, as the camera's fog
reads the same answer, and the surface goes back to scene space through
the placement.
With it a scene can run the client's swim decision (0x006030C0): swim
once the surface stands more than 0.75 of the collision height over the
feet, stop below that less 1/36 yard.
* feat(model): ModelScene SweepCollider on the client's contact sweep
scene:SweepCollider(feetX, feetY, feetZ, radius, height, moveX, moveY,
moveZ) sweeps a body to its first contact with the scene's WMO and
returns where its feet stop and the normal of the facet it met. It is a
ClassicAPI extension.
The sweep is the client mover's own, transcribed in SceneContact.cpp
one function at a time: CMovement::SweepVolume 0x00632BA0, with the
volume's planes and vertices (0x00631440, 0x00631BE0), the polygon clip
and its 1/720 band (0x006318C0, 0x00631870, 0x00632980), the swept face
prisms (0x00632460, 0x00632F80, PlaneFromTriangle 0x00637480), the
contact distance (0x006329E0, 0x00632830), the nearest facet per face
(0x00632700), the bevel faces and the band rule (0x00632280), and the
facet gather with its cached box (0x00631E70). The arithmetic keeps the
client's 53-bit sums, float stores and operand order, so a body meets a
face where the client's mover would. The body is the client's volume:
a square box over a downward point at the feet, sides at 61.6 degrees.
The facets come from the same WMO box query as the decals (CollectBox,
TestMapObjectBox 0x006AD330, class 0x100111), read out of the facet
batches up to each batch's triangle count (+0x16, the loop bound of the
facet emitter 0x00671CC0). Each facet is built as that emitter builds
it on its SSE path: the vertices through the batch matrix, the normal
(v1 - v0) x (v2 - v0) scaled by rsqrtss, d = -n.v0. So a face blocks
only from its front, as in the world.
Safety: nothing here calls or patches the client's mover. Its facet
lists (0x00C4E52C, 0x00C4E564) and cached box (0x00C4E5A0) are never
read or written; the sweep keeps its own list and box per call. The
swimmer and hover branches of 0x00632BA0 are not taken, since a scene
body has neither flag.
* feat(model): ModelScene actors move with the client's mover
actor:SetMovementEnabled(true) gives a scene actor the client's own
mover: it walks and runs over the scene's WMO, slides along walls, steps
up and down ledges, falls and jumps as a character does. The commands
StartMovingForward/Backward, StopMoving, StartStrafingLeft/Right,
StopStrafing, StartTurningLeft/Right, StopTurning and Jump, and
IsFalling, are ClassicAPI extensions.
SceneMover.cpp transcribes CMovement for a scene body, one client
function per function, with the client's 53-bit sums and float stores:
- the tick (0x00616800, 0x00616620; a 250 ms window), the integrator
(0x00616DE0, 0x00616CB0), the displacement from the anchors
(0x007C5360, straight line 0x007C4ED0, turn arc 0x007C52C0), the
facing (0x007C4F30), the heading basis and direction (0x007C5880,
0x007C5A20), the anchors (0x007C5CD0) and the speed (0x007C4C90);
- the substep loop 0x00634040 and its swept query 0x00633840;
- the walk resolver 0x006367B0 with the face rise 0x00635C00, the wall
push-out 0x00635D80, the bevel direction 0x00636610, the triangle
class tests (0x006333D0, 0x006334A0, 0x006336A0, 0x00633720), the step
probe 0x00636100 and the fall-away lookahead 0x00635F80;
- the fall step 0x00635B00 and the airborne resolver 0x00635600 with its
step sweep 0x006351A0, step time 0x00635450, wall push 0x00635090 and
wall normal 0x00634AE0 (three-plane solve 0x00634FC0 over the 3x3
determinant and inverse 0x007BE0E0, 0x007BE2A0);
- the fall arc (0x007C5D20 to 0x007C6290: distance, time for a drop,
apex, start, jump at -7.955547, landing, the far-fall latch 0x00633240,
the deferred direction latches 0x0061AB20) and the movement commands
(0x007C6AE0 to 0x007C6DD0, position reset 0x007C69A0, facing
0x007C6F30, fall gate 0x007C61C0).
Two places follow the binary over benilla-re's transcription: the
fall-away lookahead starts a real fall and sweeps (+0x68, +0x6C, -D)
(0x00635FF7, 0x00636014), and stopping runs the fall gate only on a
step edge, flag 0x4000000 (0x007C6BBD).
The body's box is the one the client gives a unit of the actor's
display (CGUnit_C::UpdateCollisionSize 0x0060B270): CreatureModelData
collision width +0x38 and height +0x3C, now in Offsets.h, at the larger
of the actor's scale and the display's CreatureModelScale. The facets
come from the scene's WMO through World::QueryFacets, which fails before
the WMO has loaded, so the body waits. PointOverFacet (0x006335D0) joins
the contact sweep.
Safety: the client's movers, their manager, its lists (0x00C4E52C) and
its cached box are never read or written; transports, splines, the
event queue, packets, hover and pitch are left out. The substep loops
carry a pass cap the client lacks, so a fault in the port cannot hang
the game. Swimming (the free-move resolver 0x00634640) is not ported.
* feat(model): ModelScene actors swim with the client's mover
A moving actor now swims in the scene WMO's liquids, through the
client's own swim path, transcribed in its order and precision.
The decision is CGUnit_C::UpdateSwimState (0x006030C0), run after each
tick as OnMoverStepped (0x005FAC70) runs it: the depth is the liquid
surface (World::LiquidAt) less the feet's z. The body starts swimming
deeper than 0.75 of its height unless IsRising (0x007C5DE0) holds, and
stops out of liquid or below 0.75 h - 1/36. Swimming on is EnterSwim
(0x007C6E50 with the latches 0x0061AB20), as the active mover's request
applies it; off is 0x007C6E80, which levels the pitch and starts a fall.
A swimmer resolves through the free-move resolver (0x00634640) and its
slide (0x00634300): no gravity, no steps, the solid list swept first and,
until a solid facet stops it, the liquid list for the rest; it re-anchors
at each end but a failed sweep, as the client does. The swept query
(0x00633840) takes its swim box about the move's midpoint (0x00633B5E)
and, for a swimmer, the liquid list in the same box. The contact gather
(0x00631E70) refills that list too, and a sweep of it uses 0.75 of the
height (0x00632C64), so the swimmer meets the surface as a ceiling with
its head above it. The liquid planes are reversed as 0x00633E90 and
0x006320E0 reverse them.
The liquid facets come from the client's own per-group liquid gather:
World::QueryLiquidFacets walks the groups whose MOGI bounds touch the box,
as CollectBoxLiquid (0x006A3C20) does, and for each loaded one resets the
batches and calls CollectLiquidBox (0x006BB170) with the swimmer's class
0x30000 (water and ocean, not magma or slime), then the facet emitter.
Nothing is patched; the client's lists and cached box are not touched.
The pitch: the rate (0x007C5C90), its integration and +-pi/2 clamp
(0x007C4F80), the pitch arc (0x007C5180) and the turn and pitch arc
(0x007C4FD0) with their clamp climb, and every displacement mode of
0x007C5360. Commands StartPitch (0x007C6DF0, only while swimming) and
StopPitch (0x007C6E30). A swimmer moving forward or back is posed by
2pi less its pitch about its y axis, as the unit pose (0x00608560,
0x0060A110) feeds the euler builder 0x007BF4B0; the actor's rotate about
y (0x007BDD60) has the same sense.
New actor methods: StartPitchingUp, StartPitchingDown, StopPitching and
IsSwimming. SetMovementEnabled's description covers swimming and the
pitch.
* feat(model): ModelScene doodads are solid to moving actors
A scene's WMO doodads now block the mover and SweepCollider as the
world's doodads block a character.
The facet query follows the world gather for a map object
(GatherMapObjectFacets 0x006AAAB0) over the scene's one WMO: the
placement's box (CMapObj::GetBoundingBox 0x006A4420 through the
placement) must touch the query box; then the group faces as before;
then each group, in index order as CreateGroupDefs (0x00695960) links
them, whose MOGI bounds through the placement touch the box gives its
doodads by GatherDoodadFacets' rules (0x006ABC40): each doodad once per
query (the s_mapQueryId stamp, advanced by GatherWorldFacets 0x006AA8B0),
its collision box (+0x14C) tested closed. A group not yet parsed or a
doodad whose model file has not loaded fails the query, as in the
client, and the facets gathered so far stay in the list.
The doodad's facets transcribe CM2Model::GatherCollisionFacets
(0x007137C0) into our own code, so the client's facet list and the
model's vertex caches are not touched: the M2 collision mesh (shared
data +0xF0 to +0x100) through the doodad's matrix (0x007BCA80, the same
arithmetic as our 0x007BCC60 transform), a triangle kept unless all
three vertices lie past one face of the box, its plane from the mesh
normal turned by the matrix rows normalized above 2^-22, d = -n.v0.
A doodad's bounds now follow SetDoodadDefBounds (0x006952A0) and are set
when its model file loads (0x007103D0 with 0, 0, as the pending-def
finish 0x00698C50 sets the def's loaded bit): the sphere and the
collision box (0x00713700) through TransformBox (0x006DC540). A shared
doodad sits in each of its groups' lists, as CreateGroupDoodadDef
(0x00694E90) returns the existing def.
* feat(model): ModelScene moving actors turn their body as a unit does
A moving actor's model is now drawn at a body facing that follows the
mover's, through the body pass of CGUnit_C::Update (0x00607ED0), while
the actor's yaw stays the mover's facing.
The actor is the active mover, so its display facing (+0xC98) is the
mover's own (UpdateDisplayFacing 0x00600CD0), with the turning bit 0x1
and the time it last stood still (+0xCB0). The world's camera sets these
at the render (MakeViewAngles 0x0050F7A1), after the units' update, so
the body pass reads the ones the last frame set, and the actor keeps
that order: body pass, then display.
The body facing (+0xC94): a swimmer's is the display's; strafing aims a
quarter turn aside, an eighth when also moving forward or back, the side
by strafe direction and backing up, and closes a quarter of the gap each
frame; moving straight or falling snaps it. Past a quarter turn the body
follows at once, and standing, not turning, it catches up at eight times
the turn rate over the time since the display stood still. Each wrap is
WrapAngleToPi (0x006084F0). The rest turns key bones 4 and 6 about z,
half then what remains, an eighth of a turn each at most, through
SetKeyBoneFlags (0x00711F10), BuildAxisRotation4x4 (0x007BDB00) and
SetKeyBoneOverride (0x00712B00); the bones are marked when the model
loads, as OnModelLoaded (0x0060CE70) marks them with HasKeyBone
(0x00711D20), and touched only on a loaded model. A rider leaves bone 4
to its mount. Turning the mover off clears the overrides.
The shuffle animations the pass would pick standing (11, 12) are the
script's, as the actor's animation is.
* feat(model): ModelScene draws the world's sky behind its WMO
A scene with a WMO backdrop now clears its frame and draws its sky as
DrawWorldScene (0x00681070) does before its terrain and map objects:
- No interior group holds the camera and the camera is dry: clear to
black (mask 3), then DrawSky (0x006D4940). The pass draws the stars,
the sun disc, the white moon, moon02, the gradient dome, the clouds
and the skybox slots, in the depth range [0.975, 0.98] of the device
viewport, around the eye. The scene's view has no translation, as the
world's has none, so the same pass fits.
- An interior group holds the camera: clear to the drawn fog's colour
(light state +0x80) and draw no sky. Under liquid outside: the zone
fog's colour.
The pass draws the world's sky objects, which BuildLightTable
(0x006D2260, from 0x006D4530 each world frame) makes from the world's
camera and light. The scene makes the light-derived parts again, as the
build makes them, then puts the world's back:
- the light state's heading (+0x30) from the scene camera's forward:
atan2(y, x), or atan2(z, x) when x*x + y*y is not above the double
0.0001 (0x00811658), plus the float 2pi (0x0080295C) below 0;
- for a backdrop in a map, that map's light at the scene camera
(BuildMapLight, as the outdoor water already takes it) in the live
table (0x00CE9C0C), with no screen tint (+0x44, the player's) and the
override and slots (+0x54..+0x6B) cleared;
- the dome's colours (ColourSkyDome 0x006D0F50, 5 x columns + 2 at
[0x00CE99A0+0x14]);
- colour band 9 (record +0x20) into the sun disc and white moon
(0x00CE9858, +0x0C, 0x20 apart);
- the skybox slots (0x006D2C79): each {LightSkybox id, weight} pair at
record +0x78 with an id, a weight above 0 and an id below the
LightSkybox count (0x00CE9DB4) interns its row's path (InternSkybox
0x006D4640) into slot +0x5C, weight +0x64. A null row, which the
engine would read through, is skipped.
The pass runs only while the sky flag (+0x198) is set and the dome has
its colours, so a scene at the glue screen keeps a plain clear. World
stack 8 is identity around the pass and the render states are pushed.
The camera claim (ClaimCameraMapObject 0x006821F0) now runs for every
WMO, not only for those with their own fog. The world claims the camera
whatever the fog, and its liquid probe reads the claim.
Not done: the cloud texture stays the world's, because the world builds
it a band at a time from its own light. From inside, the world also
draws the sky when its portal walk (WalkPortals 0x006B41C0) reaches an
exterior group; the scene does not. The sun and moon glares (0x006D48C0)
are not drawn.
* feat(model): ModelScene draws the sky through a WMO's portals
From inside a WMO, the 1.12.1 world draws the sky only when its portal
walk (WalkPortals 0x006B41C0) from the camera's groups reaches an
exterior group: the walk sets the weather byte 0x00CA80C4 for a group
flagged 0x148, and DrawWorldScene (0x00681070) then clears to black and
runs DrawSky. With the byte clear it clears to the drawn fog colour. A
group flagged 0x40000 also puts the WMO's MOSB name into the skybox
state 0x00CA8080, which DrawWorldScene loads into skybox slot 0 at the
camera's WMO fog weight (SetSkyboxSlot 0x006D4810).
The scene now runs the same walks for its WMO from its own camera:
- Inside, the interior seed's (0x006B3B20) walk: a new pass
(0x00CA8014), the group fog flag set, the liquid-group state cleared,
object-to-clip = the world stack's slot (0x0058B280) times the
device's view-projection (0x0058B0C0), and the camera point in model
space; each claimed group walks over (-1,-1,1,1) at depth 0, passing
itself as its interior group unless it is flagged 0x48. The backdrop
now keeps the claimed group indices, not only a flag.
- Outside, the exterior seed's (0x006B3DD0) walk from each MOGI group
flagged 0x8 and not 0x10000 whose box the view volume does not cull
(0x00682F60), which can still name a skybox.
Safety: WalkPortals runs with a null group callback (0x00CDE5B0) and
the inside leg (0x00CDE5AC) clear, so it links nothing into the world's
frame and records no windows into the world's 16-entry window array.
Every global it reads or writes (callback, inside leg, camera point,
object-to-clip, fog flag, liquid seen/parity, weather byte, skybox
state) is saved before the walk and restored after it.
The world's second pass, which walks the WMO again through each
recorded window, is not run: it can only name a skybox that the first
walk did not reach, since the weather byte is already set by then.
* feat(model): ModelScene walks a WMO again through its windows
The 1.12.1 interior seed (0x006B3B20) walks in two phases. The first
walk from the camera's groups runs with the inside leg (0x00CDE5AC)
set, so WalkPortals (0x006B41C0) records a window for each portal into
an exterior group it crosses: five floats at 0x00CBE324 + 0x14 * i, the
overlap rectangle mapped to [0, 1] and the portal's reach, counted at
0x00CBE320. The second phase clears the inside leg and, for each
window, builds the window's volume (BuildPortalVolume 0x00682930,
__fastcall(corners, rect), plain ret) and walks from every MOGI group
flagged 0x8 and not 0x10000 whose box that volume shows (0x00682F60),
over the window as (2r - 1). That walk can reach an exterior group that
no portal joins to the camera's groups, and so a group flagged 0x40000
that puts the WMO's MOSB skybox into the skybox state.
The scene now runs both phases from its own camera. The exterior seed
(0x006B3DD0) builds its volume the same way from the rectangle
(0, 0, 1, 1), so the outside walk shares the same code.
BuildPortalVolume lerps the camera corner rays at 0x00C7BCD8, which the
world fills from its own camera (FUN_FRUSTUM_CORNERS at 0x00680E3C);
the call at 0x006B3CA4 passes them in ecx and the record in edx. The
scene writes its own camera's corners there for the walk, from the
same corner builder.
Safety: the corner rays, the window count and the 16 window records
(0x006B37B0 constructs 16) are saved before the walk and restored
after it, with the globals the first walk already kept. The seed's
last loop (RunGroupCallback 0x006B4160 for 0x10000 groups) changes
only the liquid state and calls the callback, which is null here, so
it is not run.
* feat(model): ModelScene actors play a unit's movement animations
An actor with the mover on now picks and plays its animations as the
1.12.1 client does for a unit from its own mover. The chain lives on
CGUnit_C, which an actor is not, so model/SceneLocomotion.cpp is that
chain on the actor:
- The pick, SelectBaseAnimation (0x005FD8B0, mask -1), for what a scene
body can claim: the airborne hold (falling far, or a fall with a
start speed that is not 0 or NaN), ResolveMoveAnimation (0x005FD100:
swim 41 to 45, back 13, sprint 143 from 11 yd/s at 0x0080C484, run 5
above twice the walk speed, else walk 4), ResolveShuffleAnimation
(0x005FD3F0) behind CanShuffle (0x005FCE30), and the idle
(0x005FD830: 41 swimming, else 0, nothing while JumpEnd's +0xD58 0x4
lock holds).
- The play, CGUnit_C::PlayAnimation (0x005FE2F0): a move animation
(IsMoveAnimation 0x005FEE80) at GetCurrentSpeed (0x007C4C90) over the
sequence's speed (GetSequenceInfo 0x00711A20 +0x08), starting at the
phase of the move animation it replaces, in the client's 32-bit
arithmetic (the imul and two divs at 0x005FE606); and nothing when
the track already plays it (PlayTrack 0x005FDBA0).
- The triggers. Each movement command the mover takes animates its
message, as UpdatePlayerMovement (0x00615C30) sends it through
ProcessLocalMoveEvent (0x0060E0A0) to AnimateMoveOpcode (0x0060E480):
starts end the ranged pose and pick, a jump plays 37, stops and turns
pick. The swim decision's start and stop, and a position reset
(MSG_MOVE_TELEPORT_ACK), pick too. A new Body::stepped hook runs where
the substep loop (0x00634040) calls BroadcastStateChange (0x0061A820),
with the flags before the substep and its jump test: a landing runs
UpdateLandingAnimation (0x00602C60: 39 standing, 187 ahead or aside
after a jump or far fall), a fall start or far fall runs
PlayFallAnimation (0x00602C40), a swim's end picks. The body pass's
tail (CGUnit_C::Update after 0x006083E6) sets the 0x800 / 0x1000
shuffle bits from the turn it made and picks when the shuffle should
start or end. A finished sequence plays PlayFollowOnAnimation's
(0x005FC3F0) follow-on: 37 and 38 go to 38, 40 to 40, the rest pick.
The gate's animation sets are the engine's own (IsEmoteAnimation
0x005FCED0, IsSpellCastAnimation 0x005FCBB0, IsThrownAnimation
0x005FCF90, IsBowAnimation, IsRifleAnimation), all `int __fastcall(int)`
with a plain ret, read from the bytes. EndRangedPose (0x0060F530) moves
out of the cast module's private namespace for the move starts.
Left out, as an actor has no unit state: the death, special stand,
loot, cast, ready, ranged, stand state and emote resolvers, stealth,
splines and the walk mode. A spell kit's animation stays on top of the
pick, and an actor whose own animation is a death animation is left to
its script.
* feat(model): ModelScene casts report when they reach their target
actor:PlaySpellVisual now returns a cast ID (nil when the spell has no
visual, the actor shows no model or the target is in another scene),
and the caster's new OnSpellVisualImpact script runs with (spellID,
target, castID) when the cast reaches its target. A game can apply a
spell's result at the moment its impact shows, without timing the
flight itself.
The moment is the one the scene's cast chain already plays the impact
at, which follows the 1.12.1 client: a missile's arrival (the frame
whose step passes the remaining distance, as CMissile's update at
0x0061E3E8 tests it, then ArriveHit 0x0061DC50), or the cast itself for
a spell with no missile, a speed of 0, or the caster as target (the
immediate impact 0x006E8BF0). A spell interrupted while it prepares
(StopSpellVisual, or a new cast ending the precast) never arrives, so
its script does not run.
Safety: Impact only queues the event in Actor::spellImpacts. The actor's
update runs the scripts after Casts::Update has stepped every cast, from
a moved-out copy of the queue. A handler that casts or stops a spell
then changes spellCasts outside the step that iterates it (and holds a
reference into it), and an impact it causes waits for the next update.
The script slot is the seventh of the eight an animation object has
(a static_assert holds the list to Animation::kMaxScripts).
docs/API.md describes the cast ID and the script, with an example.
* feat(model): ModelScene actors walk to a point along the client's spline
actor:MoveTo(x, y, z [, facing]) moves an actor with the mover on as a
server's SMSG_MONSTER_MOVE moves a unit, through our own copy of the
1.12.1 client's spline path. The live movers are not touched.
The mover side (SceneMover.cpp), one client function each:
- CGUnit_C::OnMonsterMove 0x006018F0: the ground path from where the body
stands (a lone point within 1/36 yd is dropped; AnchorSplinePath
0x006021C0 leaves a path that starts at the body as it is), the guard
points (0x00601E66 to 0x00601ECA), the length (0x00601EF4), the speed
capped at 4x the run speed (0x00601F3D) and the fistp duration of at
least 1 ms (0x00601F9F). A path of 1/6 yd or less stops the body where
it stands (FlushAndStopSpline 0x00618750). The duration the scene sends
is the path at the body's own swim, walk or run speed.
- StartSplinePath 0x006187A0: StopAllMotion 0x0061AA70, InitSpline
0x007C62C0, StartSpline 0x007C6A50 (run mode from spline flag 0x100,
then StartMove), the final angle (SetSplineFacingAngle 0x006188A0).
- The curve in mode 0 (straight chords by arc length): the segment
locator 0x00453840, the chord point 0x004541B0 and length 0x00454320,
the totals 0x004543D0 / 0x00453920, the frame 0x00453480 / 0x00454580.
- FollowSpline 0x007C5490 (progress by fild/fidiv, facing by fpatan, the
swimmer's pitch by asin), the warp gate GetSplineStep 0x00616AF0 (past
3 yd or 60 yd/s the point is taken without collision), and SnapIfFar
0x00616D60 after the substeps (0x00616DE0).
- The arrival in BroadcastStateChange 0x0061A820: stop, snap, final
facing, CompleteSpline 0x00619DE0. The substep loop 0x00634040 skips
its speed test while a spline is live, and GetCurrentSpeed 0x007C4C90
gives the spline's length over its duration.
The actor is the client's active mover, so a finished spline is reported
(CMSG 0x2C9) and freed. That report is the actor's new OnMoveFinished
script. The script plays the server's part, so every other movement
command, SetYaw, SetPosition and the new SetWalking end the move first
(ClearSpline 0x007C6310, as UpdatePlayerMovement 0x00615C30 does for a
move event that is not the player's own). SetWalking / IsWalking set the
run mode (SetRunMode 0x007C71C0); a moving actor re-picks its animation
on the change (MSG_MOVE_SET_RUN_MODE / WALK_MODE in AnimateMoveOpcode
0x0060E480). The arrival plays MSG_MOVE_STOP's pick, and the swim end is
not sent along a spline.
Left out: flying splines (flag 0x200), facing a point or a target at the
end, and the precast clear (UnitClearPrecastSpell 0x0060D040), which an
actor's casts have no part for.
* docs(model): document ModelScene movement, traces, liquids and listener
API.md gets the scene functions that had no entry: TraceSegment (with
its camera faces), GetLiquidAtPoint, SweepCollider and
SetSoundListenerActor / GetSoundListenerActor. Scene sounds now names the
listener actor.
It also gets the actor's movement: SetMovementEnabled /
IsMovementEnabled (the WMO it moves on, a character's speeds, the body
size from the creature display, the drop to the floor, and the
position, yaw, tilt and animations that follow the movement), a table of
the movement commands and their applied result, IsFalling, IsSwimming,
MoveTo with a two-point patrol on OnMoveFinished, and SetWalking /
IsWalking. The actor scripts table gains OnSpellVisualImpact and
OnMoveFinished.
The README's model scene summary and its ModelScene and ModelSceneActor
rows list the same names.
* refactor(model): call the engine's math and read its constants live
The ModelScene mover and contact sweep carried their own copies of engine
code and data. They now use the client's.
Constants: every float the transcribed mover reads from 1.12.1's .rdata
(and the two fall-speed caps in .data, the 2pi the static initializer
fills at 0x00CF5D00) is an Offsets.h entry read where it is used, through
Game::Live<T>. Each value was checked against WoW.exe's bytes. The pooled
floats other modules already named for one use (0x00801360, 0x008026BC,
0x008029D4, 0x00803568, 0x008022CC, 0x00801620, 0x0080306C, 0x00801628)
are renamed by value, since the mover reads them too.
Leaf math: the pure geometry helpers the mover calls are now called, not
copied: DotVector3 0x00602630, PlaneFromTriangle 0x00637480,
PlaneDistanceAlongRay 0x006329E0, ClipPolygonByPlane(s/Except) 0x006318C0
/ 0x00631870 / 0x00632980, IntersectThreePlanes 0x00634FC0 and
PointToLineDistanceSquared 0x00634F40. Each is __fastcall with callee
cleanup and reads only its arguments and .rdata (Ghidra). Two stay
transcribed: FindNearestTriangleEdge 0x00634DA0 reads the client's facet
list at 0x00C4E534, and SelectBevelContactNormal 0x00636610 reads an
unwritten stack slot as an index when three bevels have no odd one out.
Wrappers: engine calls that several files cast themselves get one typed
home: M2.h (key-bone animation state, sequence info, base transform,
scene draw, model lights, the IsXAnimation tests, whose death test is
__stdcall and the rest __fastcall), gx/Matrix.h (the 0x007BxXXX matrix
helpers), gx/Device.h (render-state journal, state setters, transform
stacks, clear), Frame::Layout (DDC/NDC conversion), Texture::DeviceTexture,
Xml::ReadColor and Frame::Subclass's slot types.
* refactor(model): share the compositor calls and call WrapAngleToPi
Outfit declared its own casts of the character compositor's create,
clone, unequip-slot and set-item calls (FUN_CHARCOMP_*), which
DisplayInfo also casts. They are now DisplayInfo's NewDresser,
CloneDresser, UnequipDresserSlot and SetDresserItem, beside the pump and
destroy it already exported.
The actor's body-turn pass copied WrapAngleToPi (0x006084F0). That
function is `double __stdcall(float)`, ret 4, and reads only .rdata and
the CRT's fmod (Ghidra), so the pass calls it; the pi and 2pi constants
it was copied with leave Offsets.h.
Also drops VAR_MOVER_MINUS_SKIN, unused since ClipPolygonByPlane is
called, and two unused locals in Cooldown's AnimateVerts.
* feat(model): FollowCamera, an orbit camera that follows an actor
A camera type in the camera registry, built on OrbitCameraMixin. Its
target is an actor's position plus a height, set each frame before the
orbit camera's own update.
The eye is placed as the world's follow camera places it: the boom
sweep of the solver at 0x0050E570. The sweep is skipped when the
distance is not past the near clip by more than 2^-20 (0x008026BC).
Otherwise a trace of the camera's faces from the target to the eye
(scene:TraceSegment with camera set, the ray query of 0x0050E816)
shortens the distance. A distance shortened by more than 2^-22
(0x008029D4) backs off by 1/9 yard (0x00808A00, 0x0050E871 to
0x0050E8A4), never below 0. The vertical probe and the near box clip
of the solver are left out. The game gives the pivot height.
With no actor to follow, it is a plain orbit camera.
* feat(model): FollowCamera takes the world camera's pivot height
actor:GetCameraPivotHeight(distance) gives the height the world's
follow camera eases to for a unit, read from the actor's model as
CCamera::BuildPivotHeights (0x0050CA90) reads a unit's. The camera's
target setter (0x0050D0F0) rebuilds the presets every frame once the
model has loaded, so the actor's are read at each call:
- base: the unposed offset of attachment 17 (GetAttachmentOffset
0x00712CF0) plus 7/72 yard (0x00808AB0), or 0.9 (0x00804588) of the
collision box (0x00713700), times the scale;
- near: lowered by the stand-state animation's sequence bounds top
under Stand's (0x0050CDDF on);
- swimming: lowered the same way by Swim (42) when the model has both
(0x0050CCE3 on);
- each kept from 5/6 (0x008089CC) to 15 (0x008089C8).
ArmPivotHeight (0x0050F880) picks swimming for a swimmer, else near
under 1.8315 yards of target distance (0x008089B0), else far. The
constants are read live. An actor has no stand state: the animation it
plays stands in when it is one the jump table at 0x0050D0CC gives, and
cameraHeightIgnoreStandState (its CVar* at 0x00BE0CF4, stored at
0x0050BD9E) ignores it. A mount is left out. Until the model has
loaded the method returns nothing and the camera waits, as the world's
update does (0x0050E900).
FollowCamera drops its height argument and eases to that height as the
camera's height channel does: the first one is taken at once
(BeginHeightTransition 0x00512790), each new one is armed
(ArmHeight 0x005126B0) for |change| / cameraHeightSmoothSpeed seconds
and eased with the cosine curve of 0x0050F160.
M2 gains HasAnimation, GetCollisionBox and GetAttachmentOffset
wrappers; SceneSpell and SceneWorld use them in place of their local
function pointers.
* docs(model): document FollowCamera and GetCameraPivotHeight
API.md gets a Follow camera section (SetFollowActor / GetFollowActor,
the pivot, the smooth height change at cameraHeightSmoothSpeed, the stop
in front of walls, the wait for the model, and how to add the camera to
a ModelSceneMixinTemplate scene) and an actor:GetCameraPivotHeight
entry (the mouth or collision-box base, the stance animations near the
actor, the swim drop, the 5/6 to 15 yard range). README lists both.
* feat(model): scene:GetCursorRay, the world frame's pick ray
The world frame builds its pick ray in ScreenPointToRay (0x004813B0,
called by PickAtCursor 0x00481190): the cursor's fractions across and
up its rect, then UnprojectScreenPoint (0x007AD2C0), which reads the
device view and projection, builds the frustum corners and interpolates
the near and far planes, then the camera's eye added to both points
because the view leaves it out.
The scene does the same with the transforms it paints with: the cursor's
fractions across the paint's viewport (the frame's rect clamped to the
screen), CameraTransforms (the camera's CameraSetDeviceTransforms
0x007ADA40, fitted to the view insets) under SavedTransforms,
UnprojectScreenPoint, then the scene camera's eye. It returns the two
points in scene coordinates, or nothing when the cursor is off the
picture or the frame is hidden.
The world traces that ray with class 0x1000114, whose WMO face mask
(0x006A3839) is 0x84, the mask TraceSegment uses by default, and which
skips doodads as TraceSegment does. So GetCursorRay into TraceSegment is
the world's point pick on a scene.
CursorClip becomes CursorFraction (0 to 1) so both pick paths share it;
GetActorAtCursor maps the fractions into clip space itself, the same
arithmetic as before. Offsets.h gains FUN_UNPROJECT_SCREEN_POINT and
gx/Device.h a wrapper for it.
* docs(model): document scene:GetCursorRay
API.md gets a GetCursorRay entry (the two points, when it returns
nothing, and how TraceSegment finds the WMO point under the cursor, with
a right-click move example). README lists it.
* feat(model): scene:GetActorsInRadius, the nearest-unit collector's test
scene:GetActorsInRadius(x, y, z, radius) returns a table of the scene's
actors near a point, nearest first. It applies the test of the 1.12.1
client's nearest-unit collector (0x00494200, the enumeration callback
behind TargetNearestEnemy and its kin) to the scene's own actor list:
- A unit counts only when its scene node is drawn (0x006704C0: node not
null and +0x94 clear). The scene's counterpart is a shown actor with
a model; scene info actors without one (scene 4's "unwrapped",
"wrapped", "player-rider") do not count.
- The distance is the squared difference of the two positions in all
three axes, kept when it is not more than the squared radius
(0x0049435B..0x0049436B: fcompp, test ah,0x41).
- The list is sorted by squared distance ascending, as the collector's
compare (0x00494450) orders entries of one kind; ties keep creation
order (stable sort).
Pure reads of the actor vector and positions; no engine call, no state
change.
* docs(model): document scene:GetActorsInRadius
* feat(model): the scene clock, GetSceneTime and scene timers
A ModelScene's M2 scene already keeps a clock: uint32 milliseconds at
scene +0x0C, which SetTime (0x00707490) stores and M2SceneAdvance
(0x007074B0) moves forward. The Model frame's update (slot 14,
0x0076D7F0) advances it by the truncated milliseconds of each frame.
SetPaused already skips that advance, and a hidden frame does not
update, so this is the clock every actor animates by, and it stands
still exactly when they do.
- scene:GetSceneTime() returns the seconds that clock has run since the
frame was made. OnFrameUpdate reads +0x0C before and after the base
update and adds the uint32 difference, so the sum starts at 0 and
never wraps. OFF_M2SCENE_TIME added to Offsets.h.
- scene:After / NewTimer / NewTicker are C_Timer's contract on that
clock. They share C_Timer's queue, cancel handles and registry
callbacks: each entry now has an owner (null for C_Timer). The scene
fires its own entries from OnFrameUpdate right after the clock moves,
before the actors update. Its destructor drops them (CancelOwned).
C_Timer's WorldTick fires only owner-null entries, and its next-
deadline early-out now covers only those. The argument checks of the
three C_Timer functions moved into the shared Time::Timer::Script.
- SetPaused's descriptor is unchanged; GetSceneTime and the three timer
methods have descriptors marked as ClassicAPI extensions.
* docs(model): document the scene clock and scene timers
* feat(model): actor highlight, selection circle and the move marker
Three things the 1.12.1 world draws for units, now on scene actors.
actor:SetHighlight(kind, highlighted) / IsHighlighted([kind]) keep the
two light bits of a unit: "target" is bit 0 and "mouseover" bit 1, as
SetLight (0x614550) and ClearLight (0x6144F0) use them. Setting a bit
gives the model the emissive colour through 0x710D40 (__thiscall(model,
float rgb[3])). The world takes it from the ambient band of the light
state; the scene takes it from the scene light's ambient, the light that
stands in for the sun. Clearing makes the model black only when no bit
is left, as ClearLight does. A new model gets the glow again.
actor:SetSelectionCircle(r, g, b [, a]) / ClearSelectionCircle /
GetSelectionCircle replay CGUnit_C::DrawSelectionCircle (0x608E00).
The radius is the one 0x60AEE0 computes at model load (sqrt of half the
xy diagonal of animation 0's bounds, the model bounds without it, 1.2
when flat) times the scale. The box is the feet +-(r, r, 2r). The yaw
matrix (0x615070) turns about z by minus HeadingBetweenPoints (0x47F220)
from the scene eye. The state is SetSelectionCircleState (0x614E00).
The decal is fade 0.5 with flags 0x200122. It is drawn for each actor
before its shadow, as DrawEntityModels draws the circle before the blob.
It is gated by the ObjectSelectionCircle cvar.
scene:SetMoveMarker(x, y, z) / ClearMoveMarker / GetMoveMarker replay
the auto-move marker (0x611400): the box is the point +-s, s = min +
(max - min) * (sin(2pi t / period) + 1) / 2 on the OS clock, from the
static .data values at 0x860AE0..0x860AE8 (500 ms, 0.5, 0.75), colour
0xFFFFFF7F. It uses the same yaw matrix, state and decal.
With a WMO the decals land on its faces through DrawDecal (0x6D7330)'s
transforms and DrawDecalBatches (0x6D7480)'s states. Without one they
land on one flat quad at the feet. The shared decal code in
SceneWorld.cpp is split into WithDecalStates / WithDecalTransforms for
the two paths.
Fog: 0x614E00 turns off lighting (state 0xE), not fog. The world draws
these decals in the fog CWorld::SetFogState sets for the whole pass.
The scene paint has no fog of its own at that point, so the device's
default (0 to 1 in 0xFFFF0080) made every circle pink.
World::CommitDecalFog commits the scene's fog first: the WMO's lighting
record, as the WMO liquids get theirs, or the frame's light and fog
without a WMO.
The decal fade and flags move to Offsets.h, because the soft-target
circle uses them too.
* docs(model): document the actor highlight, selection circle and move marker
* feat(model): a paused scene stops movement and spell visuals too
scene:SetPaused stopped only what runs on the M2 scene clock (scene
+0x0C): the animations, GetSceneTime and the scene timers. The mover
ticked on the OS clock, as the client's does, and the casts stepped by
the frame's elapsed time. A paused scene therefore still moved its
actors in a frozen pose and flew its missiles.
The scene clock is the scene's world time, so the actors now run on
it:
- The mover (Mover::Init, Mover::Tick) and the body-facing stamps
(the catch-up turn of 0x600CD0) read the scene clock through the new
Model::Scene::ClockMs. The spline start (b.clock) stays in the same
base. Mover::Tick does nothing for a zero window, so a paused scene
holds every body. On unpause the body sees only the time the scene
ran, so nothing jumps ahead.
- Actor::Update takes the ms the scene clock moved this frame, as
seconds, for Casts::Update (precasts, missiles, impacts, stuck
arrows). That is 0 while paused. OnUpdate keeps the frame's elapsed
time.
- The move marker's pulse (0x611400's sine over 0x860AE0 ms) reads the
scene clock where the world's reads the OS clock, so it holds too.
FUN_SIMPLEMODEL_GET_SCENE (0x76CFC0) makes the scene on first use, so
a scene frame always has a clock to read. A hidden scene runs no
update, so its clock and its actors stop as before.
* feat(model): names over scene actors, as the world draws a unit's
actor:SetNameText(text [, r, g, b]) / ClearNameText / GetNameText show
a name over the head. It is drawn the way the 1.12.1 world draws a
unit's name (PLAYERNAMEDESC::UpdatePlate, 0x6C6E90):
- It runs from the body model's draw callback, installed with
SetDrawCallback (0x710DB0, list0 0) as the unit's is at 0x6C7756.
It draws only when CM2Model::IsReady (0x710450), as
PlayerNameDrawCallback (0x6C7780) checks.
- The plate scale is 0.2, or d / 4 * 1.5 * 0.2 above 4 yards, where d
is the name height over the feet (0x6C6F10..0x6C6F3C, reading the
constants at 0x8112A8, 0x8112AC and 0x80679C).
- The text is made with GxuFontCreateString (0x5C1C30) on the world's
name font (0xCE8738), with the grammar pass (0x7716F0), a 100000 box,
justification 2/1, flags 0xC8 and the colour. The block height is
the extra lines times the scale.
- Each draw adds the string to the world's name batch (0xCE8734,
0x5C1E60), places it at the name position raised by the block height
(0x5C2770) and draws the batch (0x5C1EF0). A colour change alone goes
to GxuStringSetColor (0x5C2750), as the colour refetch does.
A custom draw runs under the scene's rebased view with a zero offset
(0x70D96D). The paint gives the scene its eye as the origin, so the
callback places the name at its absolute scene position, as the world
does.
actor:GetNamePosition() mirrors CGUnit_C::GetNamePosition (0x608640).
It uses attachment 18 on the model. A seated rider counts as mounted,
so it uses attachment 29 on its mount's model. Without the attachment,
the point is 1.25 times the scaled box height above the feet.
The name font and batch exist only in the world: world entry makes them
(0x6C7470), and PlayerNameShutdown (0x6C7630) frees them in
ClientDestroyGame (0x40202F), before CGGameUI::ShutdownGame. Each actor
therefore keeps the font its string was made with, and frees the
string only while that font still exists. At the glue screens no name
draws.
* feat(model): actor movement speeds and spell ground areas
actor:SetMovementSpeed(speedType, speed) / GetMovementSpeed(speedType)
set the walk, run, run back, swim, swim back and turn speeds of an
actor's mover, as a server changes a creature's speed. The client's
spline speed opcodes (0x2FE to 0x303, switch 0x00601360) call the
CMovement setter at once: SetWalkSpeed 0x007C70D0, SetRunSpeed
0x007C7030, SetRunBackSpeed 0x007C7080, SetSwimSpeed 0x007C7120,
SetSwimBackSpeed 0x007C7170, SetTurnRate 0x007C6FF0. Each stores the
value unless it is within 2^-22 of the field ([0x008029D4]; a NaN
stores), re-anchors, and refreshes the current speed except for the
turn rate. Mover::SetSpeed mirrors that. The switch then calls
AnimateMoveOpcode (0x0060E480, nothing for these opcodes) and
UpdateBaseAnimation(-1) (0x005FD9E0), so the actor re-picks its
animation and rate (Locomotion::Repick). The setter leaves a spline
alone, so a MoveTo keeps the speed it started with. Speeds live on the
mover and go back to the defaults when the movement turns off, as the
walk mode does; a speed of 0 or less is a usage error.
actor:SetModelBySpellArea(spellID, radius) shows a spell's ground area
as the world shows a dynamic object (CGDynamicObject_C). The model is
the one slot 10 names (0x005D5890 -> 0x005D57C0): the spell's visual
(GetSpellVisual 0x006EC1E0) must have the area flag (+0x2C), and its
+0x30 SpellVisualEffectName row gives the file. Once loaded, the actor
runs the loaded hook (slot 13, 0x005D52F0): the scale is the radius
over the bounding-sphere radius when that is above 0.001 (the double at
0x00801608), else over the effect row's +0x10 size when that is above
0; a model with animation 158 and none for 0 loops 158, as the done
callback (0x005D5580) replays it. The area's model events follow the
dynamic object's (0x005D58C0): $SND plays its payload at the area,
always; $SHK shakes the world camera, which a scene does not have.
The area kit (+0x34: the kind-9 shard emitter and the looping sound)
is not part of this yet.
* feat(model): the area kit of a spell ground area: shards and loop
An actor that shows a spell's ground area (SetModelBySpellArea) now
runs the area kit, as the world's dynamic object starts it when it is
created (CGDynamicObject_C, 0x005D55C0) and stops it when it is
deactivated or destroyed. Nothing new is exposed to Lua.
The kit is the visual's +0x34 SpellVisualKit, read only with the area
flag +0x2C set. Its first kind-9 procedure (cmp at 0x005D5640) starts
the shard emitter (0x006ECE30 -> 0x006EB930): the shard file is the
type's entry in the char *[7] at 0x00870E24 (the low byte of the bits
of the procedure's first value + 512.0, shifted right 14; read there
with no bound, here bounded), and the rate is the procedure's second
value (+0x5C), scaled by the spell detail record [0x00CEE9A8] +0x28:
x0.33 at 0 ([0x00808300]), x0.66 at 1 ([0x0081199C]).
Each update the emitter adds the scene seconds times the rate and
spawns a shard per whole 1.0 (0x006EBAD0). A shard mirrors 0x006EBB64
to 0x006EBDA9: a draw u in [0, 1) and a unit vector from the client's
own random state (0x004531E0 and 0x0044FD00 on 0x00882664), a point
u * radius out and 16.666666 up ([0x00810E20]), a trace to it from
1/6 over the centre that keeps 0.95 of a hit's fraction ([0x008119A0]),
then a trace 33.333332 down ([0x0080FEE4]) whose hit is the shard's
place, else the area's centre. The traces are the scene WMO's
(World::Trace); without a WMO the shard lands at the area's height.
The shard's model plays its animation once after 2 * b ms, b the byte
of a draw * 255.0 + 512.0, and the done callback's natural end (reason
0, 0x006EBE70) frees it; every fourth event of the shards plays when
it is a $SND (0x006EBE30). The scene clock times them, so they hold
while the scene is paused, and they play out after the area goes.
The kit's sound (+0x34) loops at the area and stops with the 3.0 fade
of 0x005D56D0; a hidden scene silences it and the next update loops it
again.
The entity-light helpers (LightAsEntity, ReleaseLit, SettleLight) move
from SceneSpell.cpp to Scene.h so the shards light as missiles do.
* feat(model): ground-target reticles on actors; quiet areas when paused
actor:SetGroundReticle(radius [, valid]) / ClearGroundReticle() /
GetGroundReticle() show the world's ground-target reticle at the
actor's position. The world draws one at the pointer while a spell
waits for a ground position (WorldFrame, 0x004837B0, the path without
a placement model); any actor can show one here, so a scene can mark
several spots, and an actor with no model serves as a marker.
The recipe is the world's: the box is the point +- the radius in x and
y and +- 2.0 ([0x00801628]) in z, a radius of 0 taking 1.3888889
(0x3FB1C71C, 0x00483858); inside a state push, lighting (0xE) and depth
write (0x12) off and blend 2; the in-range or out-of-range texture at
stage 0x17 (0x00B4B344 / 0x00B4B348, Spell-Shadow-Acceptable and
-Unacceptable, loaded when the world frame is built at 0x00481C00,
bound through 0x0044ACF0); then DrawDecal (0x006D7330) in white, with
no texture matrix and fade 0.5, onto the receiver class 0x200122. The
world draws it after the opaque models and before the water and the
translucent models (0x004836B0), in its fog; the scene draws it after
M2 pass 0, in the scene's fog (World::CommitDecalFog), or flat at the
actor's height without a WMO. The liquid pass (class 0xF0000) is not
mirrored. Before the world frame exists the textures are null and no
reticle draws.
A spell area's loop sound went on while the scene was paused: the
paused scene still runs each actor's update with no time, which the
area kit took for running. The world has no pause; here a paused scene
(SetPaused) or actor silences the loop, which starts again when the
pause ends. The shards already held, on the scene clock.
* feat(model): chain-lightning bolts on scene casts; quiet missiles when paused; docs
The 1.12.1 client draws Chain Lightning's arcs from a spell visual kit
procedure of kind 0 or 12 (0x0060D7FC, through the byte table at
0x0060DC20 to 0x006ECB90). The procedure's values decode, as the area kit
does (bits of value + 512.0, shifted right 14), to a SpellChainEffects id,
a strand count capped at 3 (0x006ECC65) and a persistent flag. Chain
Lightning's cast kit 321 has kind 12, chain 1, one strand; row 1 of
SpellChainEffects.dbc is segment 2.78, width 0.5, jitter 0.04, texture
period 1.0, life 1000 ms, Textures\SpellChainEffects\Lightning.blp.
Each hop of the world's LightningObject gets a bolt from the client's
lightning renderer (Lightning.cpp, a 32-byte __thiscall object): Init
0x007B0760, Destroy 0x007B0780, CreateBolt 0x007B07F0 (ret 0x2C),
MoveBolt 0x007B0950, ShowBolt 0x007B0BD0, DestroyBolt 0x007B0AC0, Update
0x007B0A40 and Render 0x007B0A80. The hop update (0x006EC460) creates the
bolt with the row's shape, then moves it between its ends each frame; the
caster's end is its $CSL event point, else its position raised by 0.75 of
its height (0x006EC6F0), and the target's is the attachment the spell
visual's +0x24 names, else its position (0x006EC780).
A scene now owns one renderer and drives it through those functions
(model/SceneChain.cpp). A scene cast has one target, so a chain is one hop
from the caster to the target, timed on the scene clock for the row's
life, hidden while either actor is hidden. The bolts update after the
actors and draw after the translucent models. The per-bolt draw
(0x007AFCB0) pushes and pops its render states and restores the device
view and the transforms it changes, so the frames drawn after the scene
are not affected. The kit-byte decode is shared with the area emitter as
Model::Scene::DecodeKitByte.
The world has no pause, so a missile's flight loop ran on through a paused
scene. A paused scene or caster now stops the loop at once, and the loop
starts again from the spell visual's missile sound when the pause ends; a
hidden scene's missiles get their sound back the same way.
docs/API.md gains the scene actor methods of this branch that had no
entry: actor:SetModelBySpellArea, actor:SetGroundReticle /
ClearGroundReticle / GetGroundReticle and actor:SetMovementSpeed /
GetMovementSpeed, with the chain bolts and the paused sounds in the
PlaySpellVisual, scene:SetPaused and actor:SetPaused entries.
* feat(model): actor:KnockBack, the client's knockback launch on scene actors
A 1.12.1 server knocks a unit back with SMSG_MOVE_KNOCK_BACK (0xEF, to
its controller) or MSG_MOVE_KNOCK_BACK (0xF1, relayed): a direction
pair, a horizontal speed and a vertical speed that the server negates
into the client's down-positive fall speed. Both paths end in the same
launch on the unit's CMovement, 0x006179C0: swimming ends (0x007C6E80),
a fall starts at the vertical speed (0x007C61F0, which re-anchors with
the old flags), the direction pair overwrites the heading +0x68 and the
direction +0x5C with 0 in z, flag 0x2 clears and 0x8001 sets whatever
the speeds, and the horizontal speed goes to +0x84. Nothing about the
unit refuses it. The direction is world-absolute.
Mover::KnockBack transcribes that launch on a scene body. While the body
falls, the direction is not recomputed (0x007C5A20 returns early), so the
flight keeps its line; the 0x8000 latch, now named FLAG_STOP_ON_LAND,
makes the landing stop the move (ApplyLatches 0x0061AB20), as it does a
knocked-back character's.
actor:KnockBack(fromX, fromY, horizontalSpeed, verticalSpeed) stands in
for the server's KnockBackFrom: the direction from the point to the
actor, or the facing turned half a circle (the client's pi, 0x0081052C)
on the point itself, and the actor's preparing spells stop, as the
server interrupts non-melee spells. As every move event that is not the
player's own, it ends a MoveTo first (ClearSpline). The acknowledgement's
animation follows: AnimateMoveOpcode (0x0060E480) plays 40, Fall, for
0xF0 (0x0060E4FC, PlayAnimation 0x005FE2F0 with 0x28). A dead actor keeps
its death animation, so a corpse flies in its death pose.
docs/API.md documents the method next to MoveTo.
* feat(model): actor:FadeOut, the world's model fade; dead actors lie Dead
When the 1.12.1 client removes an object (deactivate 0x006145E0), it
hands the model to FadeOutModel (0x00672DF0) at its current alpha. A
ready model (0x00710450 with 0, 0) at an alpha of 0.01 or more, or NaN
(fcomp [0x008029D0] at 0x00672E21, test ah,5 / jnp), is kept with the
time and that alpha; any other is released at once. Each frame the pass
0x00672EF0 shows (3 - 2x)x^2 with x = (1 - age x 0.0005) x the alpha,
held to 0..1 (0x00672FD3 to 0x00673025, 3.0 at 0x0080297C), and releases
the model when the age passes 2000 ms (cmp eax,0x7D0; jle at 0x00672F36).
actor:FadeOut applies that curve on top of the actor's alpha in
ApplyAlpha and hides the actor where the world releases the model; an
actor below 0.01 or with no ready model hides at once. The world times
the fade with the OS tick; here it runs on the scene clock, so a paused
scene holds it. Show, Hide and SetShown end it. actor:IsFadingOut
reports it. The 0.0005 is the mover's VAR_MOVER_STALL, named again as
VAR_MODEL_FADE_RATE where FadeOutModel reads it.
A unit's death in the world ends in a hold: PlayFollowOnAnimation
(0x005FC3F0) sends Death (1) and Dead (6) through its byte table
0x005FC848 to 0x005FC52D, and Drown (131) and Drowned (132) to
0x005FC573. While the unit is dead (0x00605F90), each plays Dead or
Drowned through 0x007121A0 in the variation the ended sequence played
(GetKeyBoneAnimState 0x00711FE0); otherwise it picks again. Locomotion's
FollowOn now has that arm for an actor with the mover, which is dead
while it plays a death animation, so it lies where it fell instead of
playing Death again. An actor without the mover repeats its animation,
as before.
docs/API.md documents FadeOut and IsFadingOut, and the death hold under
SetMovementEnabled.
* feat(addons): Broodwatch, a survivors game on the ModelScene backport
Broodwatch holds Onyxia's Lair against an endless brood: the lair is a
scene's WMO (scene:SetWorldModelByMapID(249)), the hero and every whelp
are actors with the client's mover, and spells, items and hits are the
client's own spell visuals. It doubles as a load test and a showcase for
the scene features it uses: MoveTo and SetMovementSpeed for the chase,
PlaySpellVisual with OnSpellVisualImpact for the spells, Chain
Lightning's bolts, SetModelBySpellArea and SetGroundReticle for the
ground areas, KnockBack for the explosions, FadeOut and the Dead hold for
the corpses, Project3DPointTo2D for the hit numbers and item icons, and
Cooldown frames and eased StatusBars for the HUD.
The addon lives at the repository's root AddOns/, outside src/embed, so
it is not embedded in the DLL; the client links to it with a junction
from Interface\AddOns\Broodwatch. /broodwatch starts a run.
The files share the addon table (local _, BW = ...): Data holds the
tuning, Core the shared state and helpers, then Brood, Spells, Hud and
Items, and Broodwatch.lua the run, the keys and the setup.
* feat(model): a kit's world effect on scene actors; lasting effects hold
A 1.12.1 SpellVisualKit has nine effect columns that hang on attachments
(+0x0C to +0x2C) and a tenth, +0x30, that the world plants on the
ground. PlayUnitSpellVisualKit (0x0060EDF0) makes a CEffect for it and
PlantEffect (0x0061FCF0) puts it at the unit's position (the unit's
vtable +0x14) or at the point it is given; with a spell that has a root
aura (26) in one of its three effects the effect gets flag 0x4000 and
follows the unit. Frost Nova's state kit 285 keeps its ice there
(Frost_Nova_state.mdx), so a frozen actor showed only the head glow.
A scene actor's kit now plants that effect: a model of its own in the
scene at the actor's position, lit as an entity like the area shards
(LightAsEntity), shown and animated in the actor's link, placed in its
place pass, its light settled in its update, and released with the
kit. SetSpellVisualKit carries no spell, so the effect stays where it
was planted, as the world's does without flag 0x4000.
A lasting effect also ended up re-forming. The world gives a state
kit's effects (kind 2) KitEffectHoldCallback (0x005FF170): when the
first sequence ends cleanly, a model with animation 158, Hold, plays it
under KitEffectDecayCallback (0x005FF1D0), which plays Hold again until
the effect's end time; a state kit leaves that time at 0, so the effect
holds until its aura goes. Our kits used only the channel kits' loop
(KitEffectLoopCallback 0x0060ED00), which replays the first sequence.
A non-one-shot kit effect now holds Hold when its model has it and
replays its sequence otherwise, so Frost Nova's ice forms once and
stays, while a precast glow without Hold loops as before.
Animation 158 was named ANIM_DYNAMIC_OBJECT_LOOP for the ground areas'
use; it is ANIM_HOLD now, its AnimationData name, with both readers in
its comment. docs/API.md describes the ground effect and the hold under
SetSpellVisualKit.
* feat(broodwatch): eight new spells, rank V masteries, client names
New spells, tanky and fun, each on the scene features it shows off:
Power Word: Shield soaks the bites into a share of your health with its
bubble kit on; Thorns burns the biters each second; Frost Nova freezes
the brood around you in Frost Nova's ice (state kit 285); Psychic Scream
sends it fleeing under its terror kit; Demoralizing Shout softens its
bites; Stoneclaw Totem pulls it onto an earth totem with the Battle
Chicken's taunt; Blast Wave hurls it away with KnockBack; and Summon Imp
brings an imp that follows you and casts the real Firebolt. Brood.lua
gains the holds, fears and weaknesses (Hold, Fear, Weaken, UpdateStates)
with their kits, and elites shrug off half of a hold or a fear.
At rank V every spell masters and does something new: Frostbite,
Shadowburn, Overload, leaps that grow, Corruption that amplifies, Echo,
dazes, an Aftershock, a totem's eruption, Deep Freeze, a second Rain of
Fire, Consecration that follows you, a shield that bursts, Thorns that
heals, Shatter, Terror, a battle cry, a Stoneclaw stun and two imp
bolts. A new spell's card teases its mastery; the rank V card names it.
The level-up cards grow to their text (GetStringHeight) and hang below
the hint, all three at the tallest one's height, so nothing is cut off.
Spell names and the passives named after a spell come from
C_Spell.GetSpellName, and the items from the Item mixin by their real
item IDs, so the client's language shows.
* feat(model): channels, ground-point casts, and a lasting kit's loop sound
Channels. A 1.12.1 spell channels when AttributesEx (+0x1C) has a bit of
0x44. After its cast the server sets UNIT_CHANNEL_SPELL and the client
plays the visual's +0x14 channel kit as a lasting (kind 2) kit
(0x00612A30): its effects hold, its animation is the unit's while it
channels (0x00612990), and its chain procedures (kinds 0 and 12) draw the
beam to the channel object, which a persistent chain (value3) keeps until
0x0060D1C0 ends the channel. PlaySpellVisual now takes a channelTimeMs
after the cast time and adds a Channel phase: the kit lasts the given time,
else the spell's duration from GetSpellDuration (0x006EA000, unmodified),
forever for an endless one. The lightning renderer never expires a bolt
on its own, so a channel's hops are held by its cast ID and Chains::End
drops them. StopSpellVisual takes an optional castID to end one cast.
A lasting kit's loop. The kit player (0x0060EDF0) asks GetSoundDefFlag200
(0x00458830) about the kit's sound; a lasting kit (kinds 2 to 4) whose
sound has the bit plays it as an effect sound, a 3D loop that follows the
unit (AddEffectSound 0x0061FEC0) and stops with the effect (CEffect::Stop
0x006203E0, Sound::Stop2 over 0.15 s). Every channel kit's sound has it,
so Drain Life's drone now lasts the beam rather than its file. A lasting
kit records the loop animation it set and gives the caster's loop back
only while it still owns it, so a newer kit's loop is not cut short.
Ground points. actor:PlaySpellVisualAtPoint(spellID, x, y, z [, castTimeMs
[, channelTimeMs]]) casts at a point of the scene. At the go a visual with
no missile (+0x18 is 0) and a +0x30 model plants that model at the target
block's destination (0x006E8088 to 0x006E8143: a 0x90-byte CEffect built
by 0x0061F490 and placed by PlantEffect 0x0061FCF0), turned by the
caster's facing and scaled by its scale (0x00620A90). It plays its
sequence once; EffectDoneCallback (0x005FBF50) then stops it, hidden while
its particles finish, and the dying list (0x0061F680) frees it once none
lives. Its $SND events play at the event's point and $HIT wounds the
caster, the effect's target (0x0061F6F0). No impact kit plays: the instant
impact returns on an empty hit list (0x006E8BF0). A visual with a missile
flies one missile to the point (0x006E8A50, masks 0x20 and 0x40) and
leaves its +0x30 impact model there. Inferno (1122) is the first user: its
infernal_impact_base meteor. OnSpellVisualImpact runs with a nil target.
* feat(broodwatch): Drain Life, Mind Flay, Inferno, and a steeper late game
Two channels on PlaySpellVisual's channel phase: Drain Life holds its
green beam on the toughest enemy and heals you each second, and its
mastery leaps the beam to the next enemy when the target dies; Mind Flay
flays and slows the toughest enemy in range, and at rank V each tick also
flays the enemies around it. A beam ends with StopSpellVisual(castID) when
its target dies or slips out of reach.
Inferno, on PlaySpellVisualAtPoint: the meteor falls on the thickest pack,
burns it and stuns it for 2 s (Inferno Effect 22703) with the stun swirl
(state kit 349), and an Infernal (display 169) stands in the crater,
rooted for 1.7 s as the server roots it (22707). Then it hunts the
nearest whelp, and its Immolation burns the whelps around it each second
and turns them on it. At rank V a second meteor falls on another enemy.
A strong run reached level 85 and cleared the lair at full health, so
the late game grows steeper: the experience per level gains a cubic term
(5 + 3L + L^3/50), whelp health grows with the cube of 1 + t/300 (x8 at
5:00, x27 at 10:00) while bites keep the square, and the item damage
follows the health.
* feat(model): actor:AddAuraVisual / RemoveAuraVisual, a unit's auras on actors
A 1.12.1 unit shows every aura it carries at once. When an aura slot
fills, 0x005FF350 plays the state kit of the spell's visual (SpellVisual
+0x10, now OFF_SPELLVISUAL_STATE_KIT) as a lasting kind 2 kit through the
kit player (0x0060EDF0): each effect column's model holds at its
attachment (158 Hold at each end, KitEffectHoldCallback 0x005FF170), and
the +0x30 world effect is planted where the unit stands (PlantEffect
0x0061FCF0), turned by its facing and scaled by its scale (0x00620A90),
following it for a spell with a root aura (26: flag 0x4000, re-placed at
the owner each update, 0x006205A5). When the slot clears, 0x005FF290
stops the spell's kits with force (0x00614150): an effect whose model is
loaded and has 159 Decay (ANIM_DECAY) plays it and stops at its end
(0x006141F0, the same test as EffectDoneCallback); any other stops at
once (CEffect::Stop 0x006203E0: hidden, its particles finish).
SetSpellVisualKit holds one kit, so two auras on one actor replaced each
other. model/SceneAura.cpp keeps a list of auras per actor, one per spell
as one slot holds a spell: AddAuraVisual(spellID) shows the state kit
beside the actor's kit, RemoveAuraVisual([spellID]) ends one aura or all.
VisualKit gains Stop (the removal step for an attached effect, through its
dying list), SetsColor (now shared with the cast's precast and channel
tints) and ApplyProcedures, so a removed tint gives the model back the
colors of the kits still on it. Casts::Retire hands a stopped world effect
to the actor's impact list, which frees it once its particles are gone.
The auras survive a model change and show once the new model loads;
ClearModel ends them, as the actor pool releases through it. Not played:
a state kit's animation and sound.
* feat(broodwatch): Lightning Shield, Polymorph, Arcane Missiles, Death Coil
Lightning Shield (324) circles you with its real orbs through
AddAuraVisual, beside Power Word: Shield's bubble; every half second an
orb strikes a whelp biting you with the spell's impact kit (62), and the
shield ends with its last orb. At rank V each strike also hits a second
whelp. Polymorph (118) turns the toughest enemies into the Polymorphed
Sheep (creature 16372, display 856): a sheep wanders and does not bite,
then turns back; at rank V the whelps around each target turn too. One
ApplySpeed now sets an enemy's run speed for sheep and slows alike.
Arcane Missiles (5143) channels its kit (729) and fires the real Arcane
Missile (7268) each second, as the server's periodic trigger does; at
rank V each missile splits into three. Death Coil (6789) harms, heals you
and fears its target for 3 s, at rank V everything around it.
Channels count their ticks now: one each second, the last at the
channel's end as a periodic aura's last tick comes at its expiry. The end
check used to run first and drop the last tick of every channel.
Hovering a spell or passive on the build bar shows its tooltip: the rank,
the blurb, the stats at that rank and the mastery.
* feat(broodwatch): /broodwatch <spell> [rank] starts a run with one spell
A spell key of SPELLS after the command starts the run with that spell
alone, at the rank given (I by default, at most V), so a new spell or its
mastery can be tried at once. An unknown key says so; the bare command
still starts a normal run with Frostbolt.
* feat(model): auras pin their animation; the client's missile release; kit ground effect turns
The stationary pin. CGUnit_C::PlayAnimation (0x005FE2F0) passes every
request but a death through ApplyEffectAnimation (0x005FDE80): while the
unit's movement flags have none of 0x20000F (the four directions and
swimming), the newest effect on its list whose kit animation is positive
and whose flags carry 0x1000 (the kind 2 state kit, 0x0060EECD) plays
that animation with variation -1 instead. Actor::PlayAnimation now does
the same with the newest aura from AddAuraVisual, so a stunned actor
stands stunned and a moving one runs; the mover's path moves set the
forward flag as StartSplinePath (0x006187A0) does. A new aura with an
animation picks again unless the model already plays it (0x0060F383 to
0x0060F399); its end does not, and the pinned animation plays on until its
sequence ends, as on a unit.
The missile release. The unit's sequence-end handler (0x005FC920) asks
0x005FCCB0 about the ended id before it tests the reason (0x005FC9FC), so
a cast animation that ends or that another play replaces releases the
queued missiles (0x0060C9B0 at 0x005FC9A2): the spell casts of 0x005FCBB0
(2, 32, 33, 53, 54, decoded from its jump table at 0x005FCBD8) and 46, 49
and 107. The scene released on the natural end of any kit animation; it
now calls the client's test (FUN_IS_MISSILE_RELEASE_ANIMATION) in the
actor's done callback, for either reason. Arcane Missiles' ChannelCastDirected
(124) is not a cast, so its missile waits for $CSL/$CSR/$CST or the
2000 ms of 0x0060A814, as in the world.
The kit's ground effect. A planted effect is placed by 0x00620A90 as
Translate(point) * Rotate(owner's facing) * Scale(owner's scale), a scale
at or below 0 taken as 1. SetSpellVisualKit's +0x30 effect stood unturned
at scale 1; it now takes the actor's facing and scale when planted, as
the aura visuals' do.
* feat(broodwatch): holds and fears show their spells' auras, stacked
A whelp showed one SpellVisualKit at a time, so a frozen whelp that was
feared lost its ice. Each hold or fear now names the spell whose aura it
is, and the whelp shows it with AddAuraVisual for its own time: Frost
Nova's freezes (122), Psychic Scream's fear (8122), Inferno Effect's stun
(22703), the Thorium Grenade's stun (its use spell 19769, state kit 780),
Stoneclaw's rank V stun as War Stomp (20549), and Death Coil (6789, which
has no state kit, as in the world). The auras stack; a stun or Polymorph
that breaks a fear ends its aura, a death ends them all, and the stun
kits' Stun animation pins while the whelp stands. Power Word: Shield on
the hero is its aura (17) too, so it shows beside Lightning Shield's orbs
and decays when it ends. The kit IDs in Data.lua and every
SetSpellVisualKit call are gone.
* feat(model): aura visuals play their state kit's sound
A 1.12.1 kit plays its sound (+0x34) once per play: the first effect it
makes carries the play's flag word, and PlayUnitSpellVisualKit (0x0060EDF0)
ORs 0x400, "no kit sound", into its own word after that, so only that
effect's one-time arm pass sounds (0x00620C10 to 0x006210B9); a kit that
made no effect plays it at the end of 0x0060EDF0 (0x0060F434 to
0x0060F4BC). For a lasting kit (kinds 2 to 4) whose definition has bit
0x200 (GetSoundDefFlag200 0x00458830) the sound loops on the unit
(AddEffectSound 0x0061FEC0 -> PlaySoundLoop3D) until CEffect::Stop stops
it with a 0.15 s fade (push 0x3E19999A before Sound::Stop2 at
0x006204B6). A definition with bit 0x20 asks every play path for the
duplicate check (0x00458F40, called from InternalPlaySoundAt at
0x0045CF5B and from PlaySoundLoop3D), so it plays once however many units
show it at once.
AddAuraVisual now plays its state kit's sound at the actor when the aura
shows, or loops it there for a 0x200 sound, following the actor, quiet
while the scene or actor is paused and while the scene is hidden, and
fading out with the aura. The loop test and the fade move to the scene's
Sounds module (Sounds::KitLoops, Sounds::kStopFadeSec), which the casts'
channel and missile sounds share.
* feat(broodwatch): Hellfire, a channel on yourself that burns you too
Hellfire (1949) channels on the hero: the scene's channel on the caster
takes it as it is (no beam to itself, no impact kit). Each second its
periodic trigger, Hellfire Effect (5857), bursts around the hero through
PlaySpellVisualAtPoint at the hero's feet (its cast kit 844, no impact on a
target), burns every whelp within reach, and lights the first eight hit
with its impact kit (845). The fire burns the hero for 3 a tick, as the
spell's own damage aura (3) does; at rank V it heals instead. It only
starts with the brood in reach. The burn reaches the hero through a new
pendingHurt, which Power Word: Shield soaks and the red glow shows as a
bite's. A channel without a target (def.self) lasts its time and centres
its tick on the hero.
* feat(model): the scene camera shakes; PlaySpellVisual at a table of targets
Camera shakes. A 1.12.1 kit names a SpellEffectCameraShakes row at +0x38;
the kit player plays it once per play (0x0060EE2E) through
PlaySpellEffectCameraShakes (0x006ECB40), which adds each of the row's
three CameraShakes ids with CameraAddShake (0x00511D40): the row's type,
axis, amplitude times 1/36, frequency, duration, pre-roll and decay, kept
with the position and the clock (0x00511C60). A dynamic object's $SHK
event adds the row its payload names at the event's point (0x005D5920 to
0x005D592B). Each frame the camera's walk (0x00511760) ages them (ms * 0.001
plus the pre-roll, gone at the duration), cuts each by its distance from
the eye (0x005116E0: whole within 9 yards, nothing past 80, times
0.7^((d - 9) / 9) between, the double 0.7 at 0x00808AD0), keeps the
strongest per axis, and evaluates it (0x00511610: A sin(2 pi t f), times
exp(-t k) for type 1; axis 0 along the heading, 1 across, 2 up). The
driver adds the sum to the eye (0x0050EDCC); the view never turns.
model/SceneShake.cpp does this per scene on the scene clock, so a paused
scene holds its shakes. Paint adds the offset to the eye it draws the sky,
world, models, decals and beams from; the projection stays unshaken. The
kits a scene plays (casts, SetSpellVisualKit, ApplySpellVisualKit, aura
visuals) and a spell area's $SHK shake it. The heading is the scene
camera's, the world's being the followed unit's facing. A kit's shake
plays at the actor: the client plays it from the first effect node's
position, which a bone-attached node has not filled yet (read at
0x00620E0E, filled at 0x0062101D), so a kit like Thunder Clap's 356 shakes
at the world origin there and the camera drops it. The footstep (0x005FBF70)
and swing (0x00625C30) shakes stay off; stock scenes would shake.
A table of targets. A spell go carries a hit list: the cast kit plays once,
the launcher makes one missile per hit (0x006E8A50), and without missiles
the instant impact walks the list (0x006E8BF0). PlaySpellVisual now takes a
table of actors as that one cast: the first is the cast's target, each
other gets a sibling cast with the same ID and its own missile, or its
impact at once, and OnSpellVisualImpact runs for each target. The siblings
join the cast list after the step that made them, as a step holds a
reference into it. Each missile still starts its own flight loop through
PlaySoundLoop3D (0x004589A0), as in the world.
* feat(broodwatch): evolutions, one-cast volleys, a quieter grenade stun
A spell at rank V with the passive it needs (any rank) can evolve: every
level-up then offers the evolution first, and it takes the spell's slot
and recharge. Six, each a real spell: Frostbolt and Multishot become
Frostbolt Volley (8398), Shadow Bolt and Might Shadow Bolt Volley (9081),
Corruption and Vampiric Embrace Siphon Life (18265), Power Word: Shield and
Vigor Divine Shield (642), Thunder Clap and Devotion War Stomp (45), and
Rain of Fire and Amplify Flamestrike (2120). An evolution has one rank,
never comes on its own, and shows a purple E on the bar; a rank V card and
a spell's tooltip name its evolution, an evolved spell's tooltip what it
came from.
A volley is one PlaySpellVisual at a table of its targets, so its cast
plays once; each impact comes back with the actor it hit. Frostbolt
Volley fires four bolts every 0.9 s: each missile starts its own flight
loop as in the world, and eight at once roared. Dots carry their spell and
heal (Siphon Life's), a shield the aura it shows (Divine Shield's immunity),
and a missile's slow lands with it.
The Thorium Grenade's stun showed its own aura, whose kit plays Gouge
(3313) on every whelp with no duplicate guard; it shows War Stomp's
silent StunSwirl (20549) now.
* fix(model): PlaySpellVisual at one actor again
|
||
|
|
a16b99073a |
fix(spell): stop gating notInterruptible on the cast's InterruptFlags
notInterruptible required InterruptFlags 0x02 (channels: ChannelInterruptFlags 0x04) before counting the player's interrupt spells, because the server's interrupt effect tests that bit. But the server tests its own spell_template, not the client's Spell.dbc, and a server can patch the one without the other. Stock 1.12.1 ships every Healing Ward rank (5605, 6274, 11899) with InterruptFlags 0x0D; Turtle's DBC patches them to 0x0F. On a stock client the gate read 0x0D and reported Healing Ward as uninterruptible for warriors and rogues, while Pummel stopped it on the reporter's realm. 171 timed SILENCE casts in the stock DBC lack the bit. The verdict is now PreventionType SILENCE plus the caster's immunity auras, against the player's spellbook interrupt / silence masks. The isChannel parameter existed only to pick the flag column, so it is gone from NotInterruptible and from CurrentCastOf, along with the now-unused SPELL_INTERRUPT_FLAG_DAMAGE, CHANNEL_FLAG_INTERRUPT and OFF_SPELL_RECORD_CHANNEL_INTERRUPT_FLAGS. Fixes #137 |
||
|
|
d7103de564 |
feat(spell): count set bonuses in GetSpellBonusHealing
Set-bonus spells are applied server-side as auras the client never sees as buffs or known spells, so the derived healing sum missed them — Lawbringer (3) is "Increase Healing 31" (9317), Judgement (3) is 57 (18037). Add a pass that counts the equipped members of each set from the item record's set id (OFF_ITEMSTATS_ITEM_SET), reads ItemSet.dbc's bonus spells and member thresholds, and runs every met bonus through the same aura decoder — the rule the item tooltip's set-bonus lines use at 0x52DFB9. The Ironclad (aura 199) armor conversion stays on UNIT_FIELD_RESISTANCES[0]: the server's SpellBaseHealingBonusDone uses GetArmor(), the full total, even though the talent text says "Armor from items". Refs #135v1.20.6 |
||
|
|
c00eb24a8d |
fix(event): refuse glue's event table and re-validate cached claim slots
CGGameUI::Initialize (0x0048FE00) calls RegisterScriptFunctions — where our LoadScriptFunctions hook enables claim writes — and only then SetScriptEventTable(0xBE1198, 0x225), which builds the in-game table. Between the two the live table at [0xCEEF68] is still glue's 26-entry one. A third-party DLL that registers a frame from its own LoadScriptFunctions hook fires our Frame::RegisterEvent (0x00702140) hook in that window: Grow enlarged the glue table (26 -> 142), the reservations claimed slots 26..125 in it, the engine freed that buffer and built the real table, and every cached slot stayed non-negative — never retried, invisible to IsEventValid, and a Fire would have signalled whatever engine event sat at that id. Two guards, both read off the engine's own build: - GameTableInstalled: the in-game build always passes 0x225 names and the other DLLs' SetEventCount clamps only enlarge, so a table smaller than EVENT_NAME_TABLE_STATIC_COUNT is glue's. Claim and Grow refuse it. - Stale: each reservation keeps the SStrDup'd pointer it wrote; when the live entry at its slot no longer holds that pointer (or name), the table was rebuilt behind us and every slot is forgotten and re-claimed before the original RegisterEvent populates any chain. Fixes #134 |
||
|
|
b65c9e0319 |
fix(spell): never auto-unshift out of Spirit of Redemption
3.3.5's and 4.4.2's SpellShapeshiftForm.dbc give Spirit of Redemption (form 32) flags 0x4100, which include SHAPESHIFT_FORM_FLAG_NO_AUTO_UNSHIFT (0x100). So the later clients' CGUnit_C::CanAutoUnshift refuses it, and no cast, interaction or item use cancels it. 1.12's row has flags 0, so with autoUnshift on, our CanAutoUnshift allowed it. A priest in Spirit of Redemption who cast a NOT_SHAPESHIFT spell, right-clicked an NPC or object, used an item or opened the flight map sent CMSG_CANCEL_AURA for it. The later-client flags that 1.12's rows lack now sit in one table: CAN_INTERACT on the druid forms and Ghost Wolf (read only while autoUnshift is on, as before), and NO_AUTO_UNSHIFT on form 32, which CanAutoUnshift reads unconditionally, as 4.3.4 does. With it, every autoUnshift site leaves Spirit of Redemption on and keeps 1.12's own refusal. The comment on FormCanInteract also records why a locked object still unshifts. It opens by a spell (Opening 6478 for chests and barrels), and the server's CheckCast form test refuses that spell on 1.12's spell data, which keeps SPELL_ATTR_NOT_SHAPESHIFT (3.3.5 dropped it).v1.20.5 |
||
|
|
de033896b1 |
feat(spell): let autoUnshift talk and use objects in the druid forms
1.12's SpellShapeshiftForm.dbc gives SHAPESHIFT_FORM_FLAG_CAN_INTERACT (0x8) only to Shadowform. 3.3.5 and 4.4.2 also give it to Cat, Travel, Aquatic, Bear, Dire Bear and Ghost Wolf, and Turtle's id 11 (Swift Travel Form) has it there too. So in the later clients, these forms pass the NPC right-click gate (CGPlayer_C::HandleOnRightClick, 0x005F0130) and the game-object use check (0x005F3130) as they are. The form cancel that comes before the range check almost never runs. In 1.12, autoUnshift cancelled every druid form at that gate, even when the NPC was out of interact range. With autoUnshift on, the redirected IsShapeShifted calls at both gates and at CanInteractNow (0x00606880) now read a form in that set as able to interact. They report "not shifted", so the engine's own 0x8 test that follows does not refuse it, and the cursor shows the NPC's service icon. The cancel stays for a form that cannot interact in either client. Neither vmangos nor tortoise-wow tests the form on an NPC or object interaction. CanInteractWithNPC and the use handlers have no form check; the only one is item use. So the client gates are the only refusal. |
||
|
|
dc8d4caf12 |
fix(loot): skip corpses that stay lootable after LootAllCorpses (#133)
* fix(loot): skip corpses that stay lootable after LootAllCorpses A corpse whose remaining loot this player can never take keeps UNIT_DYNFLAG_LOOTABLE set: quest items for quests they don't have, condition-gated loot, and the like. The per-corpse re-check still passes, so a caller that runs C_Loot.LootAllCorpses from a timer re-opens the same corpse on every walk and re-sends the refused CMSG_LOOT_ITEM, which never clears. Loot mode now remembers every corpse it opened and released. Later walks skip a remembered corpse while it is still visible and lootable; the entry is dropped once the corpse stops being lootable or leaves the object manager. A corpse that merely left render range is dropped too, so it gets one retry when the player comes back. ScanNearbyLoot stays read-only and keeps reporting the corpse. 1.12 has no per-slot "cannot loot" flag (GetLootSlotInfo has no `locked` return), so one refused request per corpse is unavoidable; this only stops it from repeating on every walk. * docs(loot): describe the LootAllCorpses corpse skip Explain why a corpse that stays lootable after the walk is skipped by later walks, and when the skip entry is dropped. * fix(loot): skip only corpses that open empty in LootAllCorpses The previous change remembered every corpse the loot walk opened. The most common reason a corpse stays UNIT_DYNFLAG_LOOTABLE is full bags, so those corpses were never looted again by the walk, even after the player freed bag space. Rolls and master-loot assignments in progress had the same problem. The server never sends a player a loot slot that player cannot take: another member's quest item and condition-gated loot are left out of SMSG_LOOT_RESPONSE, while the corpse stays lootable for as long as any loot remains. So the stuck corpse opens to an EMPTY window, with no coin and no populated VAR_LOOT_SLOTS entry. Loot mode now remembers a corpse only when the scraped window is empty. A window with anything in it (full bags, a roll, a master-loot slot) is retried. An entry is forgotten: - on the first world tick where its unit is gone or no longer lootable. This replaces the prune at walk start, which missed a corpse that left view and came back, and a creature that respawned with the same GUID and died again, between two walks; - all at once on QUEST_LOG_UPDATE (event 0x134, observed through the shared FUN_FIRE_EVENT_NO_ARGS interceptor and never swallowed), because quest items are per-player loot and a quest change can put an item into a window that was empty. The memory moves out of the per-walk ScanCtx into its own vector. The API reference now describes the skip as a contract only. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
20069f3815 |
docs(api): sort the reference's sections alphabetically
Seven sections were out of place in the body: ChatBubbles (after Mount), Bindings (after Focus), APIDocumentation, CVar, MerchantFrame, NamePlate and PvP. The contents list shared the last four. Both are now in the same case-insensitive order, with one blank line between contents groups (DeathInfo and Sound had none). The ClassicAPI namespace section had no contents entry; it has one now. The PVP_TIMER_UPDATE entry moves from the PvP section to Events, between PLAYER_SWING_RANGE_UPDATE and QUEST_ACCEPTED. It now names the PvP timer and links the two timer functions, and the PvP section links to it. |
||
|
|
f2fa112f0a |
feat(mount): add C_MountJournal.GetMountFromSpell and GetMountInfoExtraByID
1.12.1 has no mount table, so a mount's ID is the ID of the spell that summons it: GetMountFromSpell(458) returns 458. A spell is a mount when one of its effects applies SPELL_AURA_MOUNTED (78); Spell.dbc is read directly, so mounts the player has not learned resolve too. On Turtle every mount item carries spell 46499 "Add Mount to Collection" instead of its mount spell (the server maps item to spell from its own table), so only the mount spell gives a mount ID. GetMountInfoExtraByID returns the nine retail values. The display ID is the one the server mounts the player on: the mount aura's misc value is a creature entry, and the client's creature cache holds that creature's display (SMSG_CREATURE_QUERY_RESPONSE carries the template's first display, and every mount creature has exactly one). An uncached creature returns nil and starts the cache load through the new Creature::Info::RequestLoad, which C_CreatureInfo.RequestLoadCreatureByID now uses too; CREATURE_DATA_LOAD_RESULT fires when the data lands. Verified in game: 23219 (Swift Mistsaber) returns 14332. Mount type and model scene default to 230 and 4. Seven mounts take retail's values instead (the six Qiraji battle tanks use scene 44, the Riding Turtle type 231), each checked by name against Turtle's Spell.dbc. The seat animation is 91 (Mount), the animation 1.12.1's world mount plays on the rider. |
||
|
|
fca967c827 |
refactor(spell): test a spell's auras through one HasAuraEffect
Six places asked the same question of a Spell.dbc record: does one of its three effects apply aura N (EffectApplyAuraName, +0x16C, int32[3])? Each had its own loop: the combat log's damage-shield lookup, crowd-control classification and its snare test, tracking-spell detection, C_SpellBook.GetPlayerSpellsByAura, and the aura-source periodic-damage gate (which also hard-coded 3 for the effect count). Spell::Lookup now has FindAuraEffect (the index of the first effect that applies the aura, or -1, for callers that read that effect's other columns) and HasAuraEffect on top of it, next to the existing HasEffect. All six call it. Code that pairs an aura with the same effect's misc value, amount or effect code (Cancel, Interruptible, BonusDamage, StatAccum, EffectInfo) keeps its own per-effect reads. |
||
|
|
24404b5a23 |
fix(swing): report only a held main-hand reset at attack start
SMSG_ATTACKSTART re-fired PLAYER_SWING(MainHand) whenever the main-hand swing was still running. That was meant for a cast reset recorded before the attack (held back because no swing was coming yet), but the server also sends SMSG_ATTACKSTART on a target switch mid-attack. Unit::Attack then resets only the off-hand timer; the main-hand swing keeps going. The event carried just the time left in that swing, so listeners read a nearly finished swing as a fresh, short one. Each swing type now carries a held flag, set only by a reset recorded without notify and cleared when that type's PLAYER_SWING fires. The attack-start path reports the main hand only while it is held. Fixes brues-code/SuperCleveRoidMacros#11v1.20.4 |
||
|
|
a106d86969 |
fix(unit): consult the name cache only when no unit object is held
UnitClassBase and UnitRaceBase now follow stock Script_UnitClass (0x00518350) and Script_UnitRace (0x00518200) branch for branch. "player" reads the selected-character record; any other token goes through GetGUIDFromName + ClntObjMgrObjectPtr(TYPEMASK_UNIT) and reads the held object's descriptor byte (+0x79 class, +0x78 race). The NameCache record (+0x140 / +0x138, null callback) is peeked only when no object is held. Before, the NameCache was also peeked when a held object's byte was 0. That never changed a result (creatures are not in the NameCache) but resolved the token twice and did not match the engine's branch. The comments and API.md also claimed creatures return nil, that class IDs run 1-9, and that UnitClass has a third return. None of that is true: creatures go through the same ChrClasses/ChrRaces lookup as in UnitClass/UnitRace, Druid is 11, and stock returns exactly two values.v1.20.3 |
||
|
|
fac3be3a0b |
refactor(lua): take integer enum and constants entries as arrays
RegisterIntegerEnum and RegisterConstants took their entries with a count beside them, written as sizeof(t) / sizeof(t[0]), std::size, or a literal. They now take Game::ArrayRef<EnumIntegerEntry>, as RegisterFrameMethods does, so the count comes from the array's type. The documentation recorders RecordEnum and RecordConstants take the same view. All 34 call sites pass only the array. The six literal counts were checked against their arrays first: each was the full length, so every Enum.* and Constants.* table gets the same entries as before. Five files that included <iterator> only for std::size drop it. |
||
|
|
b49c107778 |
refactor(lua): take frame-method tables as arrays, not pointer and count
Every RegisterFrameMethods call passed its method table and doc table with a count beside each: sizeof(t) / sizeof(t[0]), std::size, or a literal. The literals had to be kept in step with the tables by hand. Game::ArrayRef<T> is a view over a file-scope array that takes the count from the array's type, the way Doc::FieldList already did for a function's arguments and returns. FieldList is now ArrayRef<Field>, Doc::MethodList is ArrayRef<Method>, and RegisterFrameMethods takes (context, methods, docs). The table and count still go to the engine's frame-method iterator (FUN_REGISTER_FRAME_METHODS) unchanged, and to the documentation recorder. All 84 call sites pass only the arrays. The 16 literal counts were checked against their tables first: each was the full length, so every registry gets the same methods as before. |