mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
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.
This commit is contained in:
@@ -90,7 +90,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th
|
||||
| [Frame: Slider](docs/API.md#sliderenable--sliderdisable--sliderisenabled) | `:Enable` / `:Disable` / `:IsEnabled` |
|
||||
| [Frame: Cooldown](docs/API.md#createframecooldown--name-parent-template) | `CreateFrame("Cooldown")`, `:SetCooldown`, `:SetCooldownDuration`, `:SetCooldownFromExpirationTime`, `:Clear`, `:GetCooldownTimes`, `:GetCooldownDuration`, `:GetCooldownDisplayDuration`, `:Pause` / `:Resume`, `:SetPaused` / `:IsPaused`, `:SetReverse` / `:GetReverse`, `:SetDrawEdge` / `:GetDrawEdge`, `:SetDrawSwipe` / `:GetDrawSwipe`, `:SetDrawBling` / `:GetDrawBling`, `:SetSwipeColor`, `:SetEdgeColor`, `:SetSwipeTexture`, `:SetEdgeTexture`, `:SetBlingTexture`, `:SetRotation` / `:GetRotation`, `:SetHideCountdownNumbers` / `:GetHideCountdownNumbers`, `:GetCountdownFontString`, `:SetCountdownAbbrevThreshold` / `:GetCountdownAbbrevThreshold`, `:SetCountdownMillisecondsThreshold` / `:GetCountdownMillisecondsThreshold`, `:SetMinimumCountdownDuration` / `:GetMinimumCountdownDuration`, `OnCooldownDone`, `CooldownFrame_Set`, `CooldownFrame_Clear`, `CooldownFrame_SetDisplayAsPercentage` |
|
||||
| [Frame: ModelScene](docs/API.md#modelscene) | `CreateFrame("ModelScene")`, `<ModelScene>` (`drawLayer`, `fogNear`, `fogFar`, `<FogColor>`, `<ViewInsets>`), `:CreateActor`, `:GetNumActors`, `:GetActorAtIndex`, `:SetCameraPosition` / `:GetCameraPosition`, `:SetCameraOrientationByYawPitchRoll`, `:SetCameraOrientationByAxisVectors`, `:GetCameraForward`, `:GetCameraRight`, `:GetCameraUp`, `:SetCameraFieldOfView` / `:GetCameraFieldOfView`, `:SetCameraNearClip` / `:GetCameraNearClip`, `:SetCameraFarClip` / `:GetCameraFarClip`, `:SetViewInsets` / `:GetViewInsets`, `:SetViewTranslation` / `:GetViewTranslation`, `:Project3DPointTo2D`, `:SetLightType` / `:GetLightType`, `:SetLightVisible` / `:IsLightVisible`, `:SetLightDirection` / `:GetLightDirection`, `:SetLightPosition` / `:GetLightPosition`, `:SetLightAmbientColor` / `:GetLightAmbientColor`, `:SetLightDiffuseColor` / `:GetLightDiffuseColor`, `:SetFogColor` / `:GetFogColor`, `:SetFogNear` / `:GetFogNear`, `:SetFogFar` / `:GetFogFar`, `:ClearFog`, `:SetDrawLayer` / `:GetDrawLayer`, `:SetPaused`, `:SetAllowOverlappedModels` / `:GetAllowOverlappedModels` |
|
||||
| [Frame: ModelSceneActor](docs/API.md#actorsetmodelbycreaturedisplayiddisplayid--useactiveplayercustomizations) | `:SetModelByCreatureDisplayID`, `:SetModelByPath`, `:SetModelByUnit`, `:SetModelByUnitCreatureDisplayID`, `:GetModelUnitGUID`, `:Dress`, `:Undress`, `:UndressSlot`, `:TryOn`, `:DressPlayerSlot`, `:IsSlotAllowed` / `:IsSlotVisible`, `:GetItemTransmogInfo`, `:GetItemTransmogInfoList`, `:SetItemTransmogInfo`, `:SetSheathed` / `:GetSheathed`, `:SetAutoDress` / `:GetAutoDress`, `:IsGeoReady`, `:ClearModel`, `:IsLoaded`, `:GetModelPath`, `:SetPosition` / `:GetPosition`, `:SetYaw` / `:GetYaw`, `:SetPitch` / `:GetPitch`, `:SetRoll` / `:GetRoll`, `:SetScale` / `:GetScale`, `:SetUseCenterForOrigin` / `:IsUsingCenterForOrigin`, `:GetActiveBoundingBox`, `:GetMaxBoundingBox`, `:Show` / `:Hide` / `:SetShown` / `:IsShown` / `:IsVisible`, `:SetAlpha` / `:GetAlpha`, `:SetAnimation` / `:GetAnimation`, `:GetAnimationVariation`, `:SetAnimationBlendOperation` / `:GetAnimationBlendOperation`, `:SetPaused` / `:GetPaused`, `:SetSpellVisualKit` / `:GetSpellVisualKit`, `:PlayAnimationKit` / `:StopAnimationKit`, `:AttachToMount`, `:DetachFromMount`, `:CalculateMountScale`, `OnLoad`, `OnUpdate`, `OnModelLoading`, `OnModelLoaded`, `OnModelCleared`, `OnAnimFinished`, `<Actor>` templates |
|
||||
| [Frame: ModelSceneActor](docs/API.md#actorsetmodelbycreaturedisplayiddisplayid--useactiveplayercustomizations) | `:SetModelByCreatureDisplayID`, `:SetModelByPath`, `:SetModelByUnit`, `:SetModelByUnitCreatureDisplayID`, `:GetModelUnitGUID`, `:Dress`, `:Undress`, `:UndressSlot`, `:TryOn`, `:DressPlayerSlot`, `:IsSlotAllowed` / `:IsSlotVisible`, `:GetItemTransmogInfo`, `:GetItemTransmogInfoList`, `:SetItemTransmogInfo`, `:SetSheathed` / `:GetSheathed`, `:SetSheathedCategory`, `:UseUnitSheatheCategory`, `:SetAutoDress` / `:GetAutoDress`, `:IsGeoReady`, `:ClearModel`, `:IsLoaded`, `:GetModelPath`, `:SetPosition` / `:GetPosition`, `:SetYaw` / `:GetYaw`, `:SetPitch` / `:GetPitch`, `:SetRoll` / `:GetRoll`, `:SetScale` / `:GetScale`, `:SetUseCenterForOrigin` / `:IsUsingCenterForOrigin`, `:GetActiveBoundingBox`, `:GetMaxBoundingBox`, `:Show` / `:Hide` / `:SetShown` / `:IsShown` / `:IsVisible`, `:SetAlpha` / `:GetAlpha`, `:SetAnimation` / `:GetAnimation`, `:GetAnimationVariation`, `:SetAnimationBlendOperation` / `:GetAnimationBlendOperation`, `:SetPaused` / `:GetPaused`, `:SetSpellVisualKit` / `:GetSpellVisualKit`, `:PlayAnimationKit` / `:StopAnimationKit`, `:AttachToMount`, `:DetachFromMount`, `:CalculateMountScale`, `OnLoad`, `OnUpdate`, `OnModelLoading`, `OnModelLoaded`, `OnModelCleared`, `OnAnimFinished`, `<Actor>` templates |
|
||||
| [Frame: ScrollingMessageFrame](docs/API.md#smfsethyperlinksenabledenabled--smfgethyperlinksenabled) | `:SetHyperlinksEnabled` / `:GetHyperlinksEnabled`, `:GetMessageInfo` (with the extra `:AddMessage` values), `:BackFillMessage` (adds a message as the oldest), `:RemoveMessagesByPredicate`, `:SetScrollOffset` / `:GetScrollOffset`, `:GetMaxScrollRange`, `:ScrollByAmount`, `:SetInsertMode` / `:GetInsertMode`, `:AddOnDisplayRefreshedCallback` |
|
||||
| [Frame: scripts](docs/API.md#onenable-and-ondisable-scripts) | `OnEnable`, `OnDisable`, `OnMinMaxChanged`, `OnAttributeChanged`, `OnCharComposition`, `OnTextChanged` (`userInput`), `PreClick`, `PostClick`, `SetModernScriptArgs` / `GetModernScriptArgs` |
|
||||
| [FriendList](docs/API.md#friendlist) | `AddOrRemoveFriend`, `C_FriendList.GetFriendInfo`, `C_FriendList.GetFriendInfoByIndex`, `C_FriendList.GetNumFriends`, `C_FriendList.GetNumOnlineFriends`, `C_FriendList.GetNumWhoResults`, `C_FriendList.GetWhoInfo`, `C_FriendList.IsFriend`, `C_FriendList.IsIgnored`, `C_FriendList.IsIgnoredByGuid`, `C_FriendList.IsWhoQueryPending`, `C_FriendList.SendWhoQueryByName`, `C_FriendList.SetFriendNotes`, `C_FriendList.SetFriendNotesByIndex` |
|
||||
|
||||
+34
@@ -852,6 +852,8 @@ build instructions.
|
||||
- [`actor:GetItemTransmogInfo(slot)` / `actor:GetItemTransmogInfoList()`](#actorgetitemtransmoginfoslot--actorgetitemtransmoginfolist)
|
||||
- [`actor:SetItemTransmogInfo(info [, slot, ignoreChildItems])`](#actorsetitemtransmoginfoinfo--slot-ignorechilditems)
|
||||
- [`actor:SetSheathed(sheathed [, hidden])` / `actor:GetSheathed()`](#actorsetsheathedsheathed--hidden--actorgetsheathed)
|
||||
- [`actor:SetSheathedCategory(slot, category)`](#actorsetsheathedcategoryslot-category)
|
||||
- [`actor:UseUnitSheatheCategory(useCategory)`](#actoruseunitsheathecategoryusecategory)
|
||||
- [`actor:SetAutoDress(autoDress)` / `actor:GetAutoDress()`](#actorsetautodressautodress--actorgetautodress)
|
||||
- [`actor:IsGeoReady()`](#actorisgeoready)
|
||||
- [`actor:ClearModel()` / `actor:IsLoaded()` / `actor:GetModelPath()`](#actorclearmodel--actorisloaded--actorgetmodelpath)
|
||||
@@ -19429,6 +19431,38 @@ Puts the weapons of the actor in its hands or in their sheaths. `hidden`
|
||||
set to `true` hides them. The setting also applies to items that `TryOn`
|
||||
puts on later.
|
||||
|
||||
### `actor:SetSheathedCategory(slot, category)`
|
||||
|
||||
Sets where the item in a hand hangs while the actor's weapons are sheathed.
|
||||
`slot` is `16` (main hand) or `17` (off hand). Other slots change nothing,
|
||||
because a ranged weapon is held in a hand. `category` is an
|
||||
`Enum.TransmogOutfitSlotOptionSheatheCategory` value:
|
||||
|
||||
| Value | Name | Sheathed item |
|
||||
|---|---|---|
|
||||
| `0` | `Default` | At the place of the item. |
|
||||
| `1` | `Back` | A one-handed weapon from the hip goes on the back, as a two-handed weapon does. |
|
||||
| `2` | `Side` | A weapon from the back goes on the hip. |
|
||||
| `3` | `Hide` | Not shown. |
|
||||
|
||||
A shield, and an item that has no sheath place, stay at their own place with
|
||||
`Back` and `Side`. The category stays with the hand: items that `TryOn`,
|
||||
`SetModelByUnit`, and `DressPlayerSlot` put in that hand later use it too.
|
||||
The category has no effect on an item in the hand while the weapons are not
|
||||
sheathed.
|
||||
|
||||
```lua
|
||||
actor:SetSheathed(true)
|
||||
actor:SetSheathedCategory(16, Enum.TransmogOutfitSlotOptionSheatheCategory.Side)
|
||||
```
|
||||
|
||||
### `actor:UseUnitSheatheCategory(useCategory)`
|
||||
|
||||
`useCategory` set to `true` puts each sheathed item at its own place. The
|
||||
`SetSheathedCategory` categories have no effect until a call with `false`.
|
||||
Units do not keep a sheath category, so the place of the item is the place
|
||||
of the unit. The default is `false`.
|
||||
|
||||
### `actor:SetAutoDress(autoDress)` / `actor:GetAutoDress()`
|
||||
|
||||
Sets whether the next `SetModelByUnit` call dresses the actor.
|
||||
|
||||
@@ -6126,6 +6126,15 @@ enum Offsets {
|
||||
OFF_ITEMSTATS_START_QUEST = 0x1A8,
|
||||
OFF_ITEMSTATS_MATERIAL = 0x1B0, // i32 — material type
|
||||
OFF_ITEMSTATS_SHEATH = 0x1B4, // u32 — weapon sheath style
|
||||
// OFF_ITEMSTATS_SHEATH values, as GetSheathAttachment (0x0047A070, jump
|
||||
// table 0x0047A0A8) maps them to M2 attachments (main hand / off hand):
|
||||
// 1 the back pair 26/27, 2 the large weapon on the back 30/31, 3 the hip
|
||||
// 32/33, 4 the shield 28. 0 and anything above 4 have no sheath point, so
|
||||
// AttachItemModel hangs nothing while sheathed.
|
||||
ITEM_SHEATH_NONE = 0,
|
||||
ITEM_SHEATH_BACK = 1,
|
||||
ITEM_SHEATH_LARGE_BACK = 2,
|
||||
ITEM_SHEATH_HIP = 3,
|
||||
OFF_ITEMSTATS_RANDOM_PROPERTY = 0x1B8, // i32 — random property template
|
||||
OFF_ITEMSTATS_BLOCK = 0x1BC, // u32 — shield block value
|
||||
OFF_ITEMSTATS_MAX_DURABILITY = 0x1C4, // u32
|
||||
|
||||
@@ -217,6 +217,32 @@ void HangWeapons(void *model, const Lanes &lanes, const Weapons &weapons, bool s
|
||||
HangLane(model, i, lanes[i], weapons, sheathed, hide);
|
||||
}
|
||||
|
||||
void SetSheatheType(void *model, Lanes &lanes, int i, const Weapons &weapons,
|
||||
uint8_t sheatheType, bool sheathed, bool hide) {
|
||||
if (model == nullptr || lanes[i].itemClass == 0)
|
||||
return;
|
||||
DetachLane(model, i, lanes[i]);
|
||||
lanes[i].sheatheType = sheatheType;
|
||||
HangLane(model, i, lanes[i], weapons, sheathed, hide);
|
||||
}
|
||||
|
||||
uint8_t SheatheTypeFor(uint8_t own, uint32_t category) {
|
||||
switch (category) {
|
||||
case kSheatheBack:
|
||||
if (own == Offsets::ITEM_SHEATH_HIP)
|
||||
return static_cast<uint8_t>(Offsets::ITEM_SHEATH_BACK);
|
||||
return own;
|
||||
case kSheatheSide:
|
||||
if (own == Offsets::ITEM_SHEATH_BACK || own == Offsets::ITEM_SHEATH_LARGE_BACK)
|
||||
return static_cast<uint8_t>(Offsets::ITEM_SHEATH_HIP);
|
||||
return own;
|
||||
case kSheatheHide:
|
||||
return static_cast<uint8_t>(Offsets::ITEM_SHEATH_NONE);
|
||||
default:
|
||||
return own;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t EnchantVisual(const void *display, uint32_t enchantID) {
|
||||
if (display == nullptr ||
|
||||
Model::ItemDisplay::OwnVisual(static_cast<const uint8_t *>(display)) != 0)
|
||||
|
||||
@@ -37,6 +37,21 @@ struct HeldLane {
|
||||
static_assert(sizeof(HeldLane) == 8, "ClearModel zeroes 8 bytes per lane");
|
||||
using Lanes = HeldLane[2]; // main hand, off hand
|
||||
|
||||
// Retail's Enum.TransmogOutfitSlotOptionSheatheCategory: where a held item
|
||||
// hangs while sheathed.
|
||||
enum SheatheCategory : uint32_t {
|
||||
kSheatheDefault = 0, // the item's own sheath point
|
||||
kSheatheBack = 1,
|
||||
kSheatheSide = 2,
|
||||
kSheatheHide = 3, // no sheath point: nothing shows while sheathed
|
||||
};
|
||||
|
||||
// The sheathe type an item whose own type is `own` (OFF_ITEMSTATS_SHEATH)
|
||||
// hangs with in `category`: Back moves a hip weapon to the back pair, Side
|
||||
// moves a back weapon to the hip, Hide leaves no sheath point. Every other
|
||||
// item keeps its own (a shield, an item with no sheath point).
|
||||
uint8_t SheatheTypeFor(uint8_t own, uint32_t category);
|
||||
|
||||
// The row and glow each lane's item is hung with. The lanes keep no display
|
||||
// row, so whoever re-hangs a weapon keeps these beside them.
|
||||
struct Weapons {
|
||||
@@ -70,6 +85,13 @@ void HangVisual(void *model, int attachId, uint32_t visual);
|
||||
void HangWeapons(void *model, const Lanes &lanes, const Weapons &weapons, bool sheathed,
|
||||
bool hide);
|
||||
|
||||
// Lane `i` hung again with `sheatheType`: detached at the type it hangs with
|
||||
// now (DetachHeldItemSlot finds the sheath point from it), then hung in the
|
||||
// hand or the sheath, or left off. The lane keeps the new type, so every
|
||||
// later detach finds the new sheath point.
|
||||
void SetSheatheType(void *model, Lanes &lanes, int i, const Weapons &weapons,
|
||||
uint8_t sheatheType, bool sheathed, bool hide);
|
||||
|
||||
// The glow `enchantID` gives an item shown with `display` (an ItemDisplayInfo
|
||||
// row): none when the display hangs its own (GetItemDescVisual's rule).
|
||||
uint32_t EnchantVisual(const void *display, uint32_t enchantID);
|
||||
|
||||
@@ -80,6 +80,17 @@ class Actor : public Animation::Object {
|
||||
bool autoDress = true;
|
||||
bool sheathed = false;
|
||||
bool hideWeapons = false;
|
||||
// Per lane: the SetSheathedCategory category (Outfit::SheatheCategory),
|
||||
// and the sheathe type the lane's item has of its own. The lane itself
|
||||
// holds the type it hangs with.
|
||||
uint32_t sheatheCategory[2] = {};
|
||||
uint8_t ownSheathe[2] = {};
|
||||
bool useUnitSheatheCategory = false; // UseUnitSheatheCategory
|
||||
// Lane `i` (on `onModel`, the actor's model or the copy being built) was
|
||||
// just filled with its item's own type: hang it per its category.
|
||||
void TookLane(void *onModel, int i);
|
||||
// Hangs lane `i` per its category.
|
||||
void ApplySheatheCategory(void *onModel, int i);
|
||||
// DressUpModel's ready byte: the model may take armor (not a shapeshifted
|
||||
// unit's).
|
||||
bool armorReady = true;
|
||||
|
||||
@@ -101,6 +101,17 @@
|
||||
// for one instead (Blizzard_Transmog.lua). ignoreChildItems names Legion
|
||||
// artifact parts, which 1.12 has none of.
|
||||
//
|
||||
// SetSheathedCategory moves a hand's sheath point by the item's sheathe type,
|
||||
// which AttachItemModel and DetachHeldItemSlot both turn into the attachment
|
||||
// (GetSheathAttachment 0x0047A070): Back hangs a hip weapon (type 3) as a
|
||||
// two-hander (type 1, the back pair), Side a back weapon (1 or 2) at the hip,
|
||||
// Hide with type 0, which has no sheath point. The lane keeps the type it hangs
|
||||
// with, so every detach (Undress, UndressSlot, TryOn's eviction) finds it; the
|
||||
// actor keeps the item's own type beside it. Each lane write (SetModelByUnit,
|
||||
// TryOn, DressPlayerSlot) puts the item's own type in the lane, then the
|
||||
// category hangs it again. UseUnitSheatheCategory takes the unit's categories:
|
||||
// 1.12 units have none, so every hand takes its own sheath point.
|
||||
//
|
||||
// SetModelByUnitCreatureDisplayID shows the display the unit shows now
|
||||
// (UNIT_FIELD_DISPLAYID) the way SetModelByCreatureDisplayID shows one: a
|
||||
// player shows its race's bare display, a pet its creature's.
|
||||
@@ -277,6 +288,8 @@ bool Actor::SetUnitModel(uint64_t guid) {
|
||||
closeHand(copy, 0);
|
||||
if (autoDress) {
|
||||
Outfit::HangWeapons(copy, lanes, weapons, sheathed, hideWeapons);
|
||||
TookLane(copy, 0);
|
||||
TookLane(copy, 1);
|
||||
} else {
|
||||
Outfit::Undress(copy, dresser, lanes, true);
|
||||
Outfit::TrimWorn(dresser, lanes, worn);
|
||||
@@ -294,6 +307,21 @@ void Actor::ApplyWeapons() {
|
||||
Model::DisplayInfo::LightChildren(SceneFrame(), model);
|
||||
}
|
||||
|
||||
void Actor::TookLane(void *onModel, int i) {
|
||||
ownSheathe[i] = lanes[i].sheatheType;
|
||||
ApplySheatheCategory(onModel, i);
|
||||
}
|
||||
|
||||
void Actor::ApplySheatheCategory(void *onModel, int i) {
|
||||
if (onModel == nullptr || lanes[i].itemClass == 0)
|
||||
return;
|
||||
const uint32_t category =
|
||||
useUnitSheatheCategory ? Outfit::kSheatheDefault : sheatheCategory[i];
|
||||
const uint8_t type = Outfit::SheatheTypeFor(ownSheathe[i], category);
|
||||
if (type != lanes[i].sheatheType)
|
||||
Outfit::SetSheatheType(onModel, lanes, i, weapons, type, sheathed, hideWeapons);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// The worker's answer for `record` on the actor: what TryOnItem's gates allow.
|
||||
@@ -343,6 +371,7 @@ void PutOn(Actor &actor, const TryOn::Request &request, const uint8_t *record) {
|
||||
const int lane = invSlot == Offsets::INVSLOT_OFFHAND ? 1 : 0;
|
||||
if (actor.weapons.visual[lane] != 0)
|
||||
slot.enchant = request.enchant;
|
||||
actor.TookLane(actor.model, lane);
|
||||
}
|
||||
Outfit::TrimWorn(actor.dresser, actor.lanes, actor.worn);
|
||||
Model::DisplayInfo::LightChildren(actor.SceneFrame(), actor.model);
|
||||
@@ -692,6 +721,8 @@ int __fastcall Script_DressPlayerSlot(void *L) {
|
||||
actor->hideWeapons);
|
||||
if (actor->model == nullptr || unit == nullptr)
|
||||
return 0;
|
||||
if (invSlot == Offsets::INVSLOT_MAINHAND || invSlot == Offsets::INVSLOT_OFFHAND)
|
||||
actor->TookLane(actor->model, invSlot == Offsets::INVSLOT_OFFHAND ? 1 : 0);
|
||||
// The slot wears what the unit wears there; the hand's row and glow are
|
||||
// the unit's now.
|
||||
if (invSlot >= 1 && invSlot <= Outfit::kInventorySlots) {
|
||||
@@ -787,6 +818,40 @@ int __fastcall Script_GetSheathed(void *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// A hand's sheath point while sheathed. 1.12 has no ranged slot to hang
|
||||
// (a ranged weapon is held in a hand), so other slots change nothing.
|
||||
int __fastcall Script_SetSheathedCategory(void *L) {
|
||||
Actor *actor = Self(L);
|
||||
if (actor == nullptr || !NumberArgs(L, 2, 2, actor->DisplayName(),
|
||||
"SetSheathedCategory(inventorySlots, category)"))
|
||||
return 0;
|
||||
const int invSlot = static_cast<int>(Game::Lua::ToNumber(L, 2));
|
||||
if (invSlot != Offsets::INVSLOT_MAINHAND && invSlot != Offsets::INVSLOT_OFFHAND)
|
||||
return 0;
|
||||
const int lane = invSlot == Offsets::INVSLOT_OFFHAND ? 1 : 0;
|
||||
actor->sheatheCategory[lane] = static_cast<uint32_t>(Game::Lua::ToNumber(L, 3));
|
||||
if (actor->model != nullptr) {
|
||||
actor->ApplySheatheCategory(actor->model, lane);
|
||||
Model::DisplayInfo::LightChildren(actor->SceneFrame(), actor->model);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The unit's own categories in place of SetSheathedCategory's: a 1.12 unit
|
||||
// has none, so each hand takes its item's own sheath point.
|
||||
int __fastcall Script_UseUnitSheatheCategory(void *L) {
|
||||
Actor *actor = Self(L);
|
||||
if (actor == nullptr)
|
||||
return 0;
|
||||
actor->useUnitSheatheCategory = Game::Lua::ToBoolean(L, 2) != 0;
|
||||
if (actor->model != nullptr) {
|
||||
actor->ApplySheatheCategory(actor->model, 0);
|
||||
actor->ApplySheatheCategory(actor->model, 1);
|
||||
Model::DisplayInfo::LightChildren(actor->SceneFrame(), actor->model);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __fastcall Script_SetAutoDress(void *L) {
|
||||
if (Actor *actor = Self(L))
|
||||
actor->autoDress = Game::Lua::ToBoolean(L, 2) != 0;
|
||||
@@ -1124,6 +1189,13 @@ const Game::Lua::EnumIntegerEntry kModelBlendOperation[] = {
|
||||
{"Anim", 1},
|
||||
};
|
||||
|
||||
const Game::Lua::EnumIntegerEntry kSheatheCategory[] = {
|
||||
{"Default", Outfit::kSheatheDefault},
|
||||
{"Back", Outfit::kSheatheBack},
|
||||
{"Side", Outfit::kSheatheSide},
|
||||
{"Hide", Outfit::kSheatheHide},
|
||||
};
|
||||
|
||||
const Game::Lua::FrameMethodEntry kMethods[] = {
|
||||
{"GetObjectType", &Animation::Script_GetObjectType},
|
||||
{"IsObjectType", &Animation::Script_IsObjectType},
|
||||
@@ -1150,6 +1222,8 @@ const Game::Lua::FrameMethodEntry kMethods[] = {
|
||||
{"SetItemTransmogInfo", &Script_SetItemTransmogInfo},
|
||||
{"SetSheathed", &Script_SetSheathed},
|
||||
{"GetSheathed", &Script_GetSheathed},
|
||||
{"SetSheathedCategory", &Script_SetSheathedCategory},
|
||||
{"UseUnitSheatheCategory", &Script_UseUnitSheatheCategory},
|
||||
{"SetAutoDress", &Script_SetAutoDress},
|
||||
{"GetAutoDress", &Script_GetAutoDress},
|
||||
{"IsGeoReady", &Script_IsGeoReady},
|
||||
@@ -1366,6 +1440,22 @@ const Game::Doc::Function kSetSheathed{
|
||||
"Puts the held items in the hands or the sheaths, or hides them.", kSheathedArgs, {}};
|
||||
const Game::Doc::Function kGetSheathed{"Returns whether the held items are sheathed.", {},
|
||||
kSheathedRet};
|
||||
const Game::Doc::Field kSheathedCategoryArgs[] = {
|
||||
Req("inventorySlots", "number", "16 or 17: the hand. Other slots change nothing."),
|
||||
Req("category", "TransmogOutfitSlotOptionSheatheCategory"),
|
||||
};
|
||||
const Game::Doc::Function kSetSheathedCategory{
|
||||
"Sets where the item in a hand hangs while sheathed: its own place, the back, the side, or "
|
||||
"hidden.",
|
||||
kSheathedCategoryArgs, {}};
|
||||
const Game::Doc::Field kUseUnitSheatheCategoryArgs[] = {
|
||||
Req("useCategory", "bool",
|
||||
"True puts each held item at its own sheath place, in place of the SetSheathedCategory "
|
||||
"categories."),
|
||||
};
|
||||
const Game::Doc::Function kUseUnitSheatheCategory{
|
||||
"Sets whether the held items hang at the unit's sheath places.", kUseUnitSheatheCategoryArgs,
|
||||
{}};
|
||||
const Game::Doc::Function kSetAutoDress{
|
||||
"Sets whether SetModelByUnit dresses the actor.", kAutoDressArg, {}};
|
||||
const Game::Doc::Function kGetAutoDress{
|
||||
@@ -1453,6 +1543,8 @@ const Game::Doc::Method kMethodDocs[] = {
|
||||
{"SetItemTransmogInfo", &kSetItemTransmogInfo},
|
||||
{"SetSheathed", &kSetSheathed},
|
||||
{"GetSheathed", &kGetSheathed},
|
||||
{"SetSheathedCategory", &kSetSheathedCategory},
|
||||
{"UseUnitSheatheCategory", &kUseUnitSheatheCategory},
|
||||
{"SetAutoDress", &kSetAutoDress},
|
||||
{"GetAutoDress", &kGetAutoDress},
|
||||
{"IsGeoReady", &kIsGeoReady},
|
||||
@@ -1511,6 +1603,8 @@ void RegisterActorClass() {
|
||||
Animation::RegisterClass(Actor::s_class);
|
||||
Game::Lua::RegisterIntegerEnum("Enum", "ModelBlendOperation", kModelBlendOperation,
|
||||
"ModelAnimationShared");
|
||||
Game::Lua::RegisterIntegerEnum("Enum", "TransmogOutfitSlotOptionSheatheCategory",
|
||||
kSheatheCategory, "TransmogOutfitConstants");
|
||||
Api::Documentation::NameWidgetSystem(&Actor::s_class, "FrameAPIModelSceneFrameActor");
|
||||
Api::Documentation::RecordFrameMethods(&Actor::s_class, kMethods, kMethodDocs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user