Fix Slug Shot action id + use adjusted action ids for actually executing actions

This commit is contained in:
Liza 2025-01-04 15:13:08 +01:00
parent 35649e8663
commit ee1d6ce15b
Signed by: liza
GPG Key ID: 2C41B84815CF6445
2 changed files with 23 additions and 17 deletions

View File

@ -48,7 +48,7 @@ public enum EAction
Katon = 2266, Katon = 2266,
Raiton = 2267, Raiton = 2267,
RabbitMedium = 2272, RabbitMedium = 2272,
SlugShot = 7412, SlugShot = 2868,
BosomBrook = 37173, BosomBrook = 37173,
Souleater = 3632, Souleater = 3632,
Fire3 = 152, Fire3 = 152,

View File

@ -206,10 +206,12 @@ internal sealed unsafe class GameFunctions
public bool UseAction(EAction action) public bool UseAction(EAction action)
{ {
if (ActionManager.Instance()->GetActionStatus(ActionType.Action, (uint)action) == 0) uint actionId = ActionManager.Instance()->GetAdjustedActionId((uint)action);
if (ActionManager.Instance()->GetActionStatus(ActionType.Action, actionId) == 0)
{ {
bool result = ActionManager.Instance()->UseAction(ActionType.Action, (uint)action); bool result = ActionManager.Instance()->UseAction(ActionType.Action, actionId);
_logger.LogInformation("UseAction {Action} result: {Result}", action, result); _logger.LogInformation("UseAction {Action} (adjusted: {AdjustedActionId}) result: {Result}", action,
actionId, result);
return result; return result;
} }
@ -219,31 +221,34 @@ internal sealed unsafe class GameFunctions
public bool UseAction(IGameObject gameObject, EAction action, bool checkCanUse = true) public bool UseAction(IGameObject gameObject, EAction action, bool checkCanUse = true)
{ {
var actionRow = _dataManager.GetExcelSheet<Action>().GetRow((uint)action); uint actionId = ActionManager.Instance()->GetAdjustedActionId((uint)action);
if (checkCanUse && !ActionManager.CanUseActionOnTarget((uint)action, (GameObject*)gameObject.Address)) var actionRow = _dataManager.GetExcelSheet<Action>().GetRow(actionId);
if (checkCanUse && !ActionManager.CanUseActionOnTarget(actionId, (GameObject*)gameObject.Address))
{ {
_logger.LogWarning("Can not use action {Action} on target {Target}", action, gameObject); _logger.LogWarning("Can not use action {Action} (adjusted: {AdjustedActionId}) on target {Target}", action,
actionId, gameObject);
return false; return false;
} }
_targetManager.Target = gameObject; _targetManager.Target = gameObject;
if (ActionManager.Instance()->GetActionStatus(ActionType.Action, (uint)action, gameObject.GameObjectId) == 0) if (ActionManager.Instance()->GetActionStatus(ActionType.Action, actionId, gameObject.GameObjectId) == 0)
{ {
bool result; bool result;
if (actionRow.TargetArea) if (actionRow.TargetArea)
{ {
Vector3 position = gameObject.Position; Vector3 position = gameObject.Position;
result = ActionManager.Instance()->UseActionLocation(ActionType.Action, (uint)action, result = ActionManager.Instance()->UseActionLocation(ActionType.Action, actionId,
location: &position); location: &position);
_logger.LogInformation("UseAction {Action} on target area {Target} result: {Result}", action, _logger.LogInformation(
gameObject, "UseAction {Action} (adjusted: {AdjustedActionId}) on target area {Target} result: {Result}",
result); action, actionId, gameObject, result);
} }
else else
{ {
result = ActionManager.Instance()->UseAction(ActionType.Action, (uint)action, gameObject.GameObjectId); result = ActionManager.Instance()->UseAction(ActionType.Action, actionId, gameObject.GameObjectId);
_logger.LogInformation("UseAction {Action} on target {Target} result: {Result}", action, gameObject, _logger.LogInformation(
result); "UseAction {Action} (adjusted: {AdjustedActionId}) on target {Target} result: {Result}", action,
actionId, gameObject, result);
} }
return result; return result;
@ -307,7 +312,7 @@ internal sealed unsafe class GameFunctions
StatusManager* statusManager = battleChara->GetStatusManager(); StatusManager* statusManager = battleChara->GetStatusManager();
return statusManager->HasStatus((uint)statusId); return statusManager->HasStatus((uint)statusId);
} }
public static bool RemoveStatus(EStatus statusId) public static bool RemoveStatus(EStatus statusId)
{ {
return StatusManager.ExecuteStatusOff((uint)statusId); return StatusManager.ExecuteStatusOff((uint)statusId);
@ -452,7 +457,8 @@ internal sealed unsafe class GameFunctions
public bool IsLoadingScreenVisible() public bool IsLoadingScreenVisible()
{ {
if (_gameGui.TryGetAddonByName("FadeMiddle", out AtkUnitBase* fade) && LAddon.IsAddonReady(fade) && fade->IsVisible) if (_gameGui.TryGetAddonByName("FadeMiddle", out AtkUnitBase* fade) && LAddon.IsAddonReady(fade) &&
fade->IsVisible)
return true; return true;
if (_gameGui.TryGetAddonByName("FadeBack", out fade) && LAddon.IsAddonReady(fade) && fade->IsVisible) if (_gameGui.TryGetAddonByName("FadeBack", out fade) && LAddon.IsAddonReady(fade) && fade->IsVisible)