Fix unarmed attack mode reset when using inventory

This commit is contained in:
Alexander Batalov 2022-08-11 14:12:29 +03:00
parent ca78b94a7d
commit 1ca08cb97a
1 changed files with 19 additions and 0 deletions

View File

@ -1240,7 +1240,11 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
leftItemState->itemFid = itemGetInventoryFid(item1); leftItemState->itemFid = itemGetInventoryFid(item1);
} }
} else { } else {
Object* oldItem = leftItemState->item;
int oldAction = leftItemState->action;
leftItemState->item = item1; leftItemState->item = item1;
if (item1 != NULL) { if (item1 != NULL) {
leftItemState->isDisabled = _can_use_weapon(item1); leftItemState->isDisabled = _can_use_weapon(item1);
leftItemState->primaryHitMode = HIT_MODE_LEFT_WEAPON_PRIMARY; leftItemState->primaryHitMode = HIT_MODE_LEFT_WEAPON_PRIMARY;
@ -1267,6 +1271,12 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
// SFALL // SFALL
leftItemState->primaryHitMode = unarmedGetPunchHitMode(false); leftItemState->primaryHitMode = unarmedGetPunchHitMode(false);
leftItemState->secondaryHitMode = unarmedGetPunchHitMode(true); leftItemState->secondaryHitMode = unarmedGetPunchHitMode(true);
// SFALL: Keep selected attack mode.
// CE: Implementation is different.
if (oldItem == NULL) {
leftItemState->action = oldAction;
}
} }
} }
@ -1279,6 +1289,9 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
rightItemState->itemFid = itemGetInventoryFid(rightItemState->item); rightItemState->itemFid = itemGetInventoryFid(rightItemState->item);
} }
} else { } else {
Object* oldItem = rightItemState->item;
int oldAction = rightItemState->action;
rightItemState->item = item2; rightItemState->item = item2;
if (item2 != NULL) { if (item2 != NULL) {
@ -1306,6 +1319,12 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
// SFALL // SFALL
rightItemState->primaryHitMode = unarmedGetKickHitMode(false); rightItemState->primaryHitMode = unarmedGetKickHitMode(false);
rightItemState->secondaryHitMode = unarmedGetKickHitMode(true); rightItemState->secondaryHitMode = unarmedGetKickHitMode(true);
// SFALL: Keep selected attack mode.
// CE: Implementation is different.
if (oldItem == NULL) {
rightItemState->action = oldAction;
}
} }
} }