Make open-action work as a client mod (resolve flagged issue #9)
The box-type config lives in $profile and loads server-side only, so the client-side ActionCondition could never resolve required items and the "Open lootbox" prompt would never appear. - ActionCondition: show the prompt whenever the box is locked and the player holds any item; drop the client-impossible key-item check. - OnFinishProgressServer: enforce the specific key-item requirement authoritatively; wrong/empty item now messages "Requires: X" and bails without rolling. All config stays server-only and admin-editable in $profile. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
f64425a840
commit
f38ae14409
1 changed files with 17 additions and 6 deletions
|
|
@ -38,8 +38,13 @@ class YALB_ActionOpenLootbox : ActionContinuousBase
|
|||
return ContinuousInteractActionInput;
|
||||
}
|
||||
|
||||
// Only offer the action if: target is our lootbox, it's locked,
|
||||
// and the player is holding a valid key item for it.
|
||||
// Offer the action when the target is our lootbox, it's locked, and the
|
||||
// player is holding *some* item. We deliberately do NOT check the specific
|
||||
// key item here: ActionCondition runs client-side to display the prompt,
|
||||
// but the box-type config (required items) lives in $profile and is loaded
|
||||
// server-side only, so GetTypeDef() is null on clients. The exact key-item
|
||||
// requirement is enforced authoritatively in OnFinishProgressServer; the
|
||||
// proximity "Requires: X" message tells the player what to hold.
|
||||
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
|
||||
{
|
||||
YALootBoxes_Base box = YALootBoxes_Base.Cast(target.GetObject());
|
||||
|
|
@ -49,10 +54,7 @@ class YALB_ActionOpenLootbox : ActionContinuousBase
|
|||
ItemBase handItem = player.GetItemInHands();
|
||||
if (!handItem) return false;
|
||||
|
||||
YALB_BoxTypeDef def = box.GetTypeDef();
|
||||
if (!def) return false;
|
||||
|
||||
return def.IsValidKeyItem(handItem.GetType());
|
||||
return true;
|
||||
}
|
||||
|
||||
override int GetDuration(ActionData action_data)
|
||||
|
|
@ -76,6 +78,15 @@ class YALB_ActionOpenLootbox : ActionContinuousBase
|
|||
|
||||
ItemBase handItem = player.GetItemInHands();
|
||||
|
||||
// Authoritative key-item gate (ActionCondition can't do this on the
|
||||
// client - see note there). Wrong/empty item: tell the player what's
|
||||
// needed and bail without rolling.
|
||||
if (!handItem || !def.IsValidKeyItem(handItem.GetType()))
|
||||
{
|
||||
YALB_NotifyPlayer(player, "Requires: " + def.GetRequiredItemsDisplayString());
|
||||
return;
|
||||
}
|
||||
|
||||
float roll = Math.RandomFloat01();
|
||||
if (roll <= def.openChance)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue