feat(model): backport 4.3.4's PlayerModel and DressUpModel methods

SetDisplayInfo and SetCreature move from Model to PlayerModel, where
4.3.4 registers them, and now ride vanilla's own pane path: SetDisplay
(0x505CB0) stores the record and AttachDisplayModel (0x505A70) builds the
model with the engine's skins (ApplyCreatureDisplay), Stand, the pane
camera and light, and rebuilds it on every show. A co-hook on
AttachDisplayModel adds 4.3.4's SetUpModel step: a display with an Extra
record is dressed through the character compositor. SetCreature passes
the creature-cache record itself; SetDisplayInfo passes a per-pane record
holding the display ID, the only field the pane reads. The hand-built
ApplySkins is removed.

SetPortraitZoom, SetCamDistanceScale and RefreshCamera apply 4.3.4's
ConfigureCamera steps after vanilla's (0x505890); the defaults leave the
camera untouched. The portrait camera id is bounds-checked, since
GetCameraById indexes unchecked.

DressUpModel gains UndressSlot (one step of vanilla's Undress) and a
TryOn that takes item links, recipe links and carried item names in
front of vanilla's worker. PlayerModel:SetRotation takes 4.3.4's animate
flag, and Model:SetGlow exists as the no-op it is on a 4.3.4 Model.
This commit is contained in:
Brues
2026-10-19 12:11:21 -05:00
parent d5c6530b80
commit bbd78b437f
10 changed files with 959 additions and 218 deletions
+70
View File
@@ -0,0 +1,70 @@
// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
// `PlayerModel:SetRotation(rotation [, animate])` — 4.3.4's second argument.
//
// Vanilla's SetRotation (FUN_SCRIPT_PLAYERMODEL_SET_ROTATION) always turns the
// model with a shuffle animation (TurnTo 0x00505BB0). 4.3.4's RotateModel
// (CharacterModelBase.cpp) does the same when `animate` is true or absent, and
// with `animate` false only stores the facing: no shuffle, no turn latch. So a
// false `animate` stores the facing here and anything else runs vanilla's
// method unchanged.
#include "Game.h"
#include "Offsets.h"
namespace Model::Rotation {
namespace {
constexpr int kTypeNone = -1; // lua_type of an absent argument
using LuaMethod_t = int(__fastcall *)(void *L);
int __fastcall Script_SetRotation(void *L) {
if (Game::Lua::Type(L, 3) == kTypeNone || Game::Lua::ToBoolean(L, 3) != 0)
return reinterpret_cast<LuaMethod_t>(Offsets::FUN_SCRIPT_PLAYERMODEL_SET_ROTATION)(L);
void *pane = Game::Lua::ResolveTypedObject(L, 1, Offsets::VAR_PLAYERMODEL_LUA_TYPE_ID);
if (pane == nullptr)
return 0;
if (!Game::Lua::IsNumber(L, 2)) {
Game::Lua::Error(L, "Usage: SetRotation(rotation (in radians))");
return 0;
}
Game::Ref<float>(pane, Offsets::OFF_SIMPLEMODEL_FACING) =
static_cast<float>(Game::Lua::ToNumber(L, 2));
return 0;
}
const Game::Lua::FrameMethodEntry g_methods[] = {
{"SetRotation", &Script_SetRotation},
};
const Game::Doc::Field kArgs[] = {
Game::Doc::Req("rotation", "number", "The facing in radians."),
Game::Doc::Opt("animate", "bool", "true", "False turns the model without the shuffle animation."),
};
const Game::Doc::Function kSetRotation{"Turns the model to a facing.", kArgs, {}};
const Game::Doc::Method g_methodDocs[] = {
{"SetRotation", &kSetRotation},
};
void RegisterLuaFunctions() {
Game::Lua::RegisterFrameMethods(
reinterpret_cast<void *>(Offsets::VAR_PLAYERMODEL_METHOD_REGISTRY), g_methods, 1,
g_methodDocs, 1);
}
const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};
} // namespace
} // namespace Model::Rotation