From f66b8df39b2007ddaa5f8cf6feda03801f3bc48b Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Wed, 6 Jul 2022 14:23:06 +0300 Subject: [PATCH] Group damage flags --- src/animation.cc | 4 ++-- src/combat.cc | 4 ++-- src/combat_ai.cc | 2 +- src/critter.cc | 2 +- src/interpreter_extra.cc | 2 +- src/obj_types.h | 4 +++- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/animation.cc b/src/animation.cc index 934104f..6461531 100644 --- a/src/animation.cc +++ b/src/animation.cc @@ -516,7 +516,7 @@ int reg_anim_obj_run_to_obj(Object* owner, Object* destination, int actionPoints animationDescription->owner = owner; animationDescription->destinationObj = destination; - if ((owner->fid & 0xF000000) >> 24 == 1 && (owner->data.critter.combat.results & (DAM_CRIP_LEG_LEFT | DAM_CRIP_LEG_RIGHT)) + if ((owner->fid & 0xF000000) >> 24 == 1 && (owner->data.critter.combat.results & DAM_CRIP_LEG_ANY) || owner == gDude && dudeHasState(0) && !perkGetRank(gDude, PERK_SILENT_RUNNING) || !artExists(buildFid((owner->fid & 0xF000000) >> 24, owner->fid & 0xFFF, ANIM_RUNNING, 0, owner->rotation + 1))) { animationDescription->anim = ANIM_WALK; @@ -631,7 +631,7 @@ int reg_anim_obj_run_to_tile(Object* obj, int tile_num, int elev, int actionPoin animationDescription->elevation = elev; // TODO: Check. - if ((obj->fid & 0xF000000) >> 24 == 1 && (obj->data.critter.combat.results & (DAM_CRIP_LEG_LEFT | DAM_CRIP_LEG_RIGHT)) + if ((obj->fid & 0xF000000) >> 24 == 1 && (obj->data.critter.combat.results & DAM_CRIP_LEG_ANY) || obj == gDude && dudeHasState(0) && !perkGetRank(gDude, PERK_SILENT_RUNNING) || !artExists(buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, ANIM_RUNNING, 0, obj->rotation + 1))) { animationDescription->anim = ANIM_WALK; diff --git a/src/combat.cc b/src/combat.cc index 129668a..68016ee 100644 --- a/src/combat.cc +++ b/src/combat.cc @@ -4616,7 +4616,7 @@ static void _set_new_results(Object* critter, int flags) queueAddEvent(10 * (35 - 3 * endurance), critter, NULL, EVENT_TYPE_KNOCKOUT); } - if (critter == gDude && (flags & (DAM_CRIP_ARM_LEFT | DAM_CRIP_ARM_RIGHT)) != 0) { + if (critter == gDude && (flags & DAM_CRIP_ARM_ANY) != 0) { critter->data.critter.combat.results |= flags & (DAM_KNOCKED_OUT | DAM_KNOCKED_DOWN | DAM_CRIP | DAM_DEAD | DAM_LOSE_TURN); int leftItemAction; @@ -5460,7 +5460,7 @@ int _combat_check_bad_shot(Object* attacker, Object* defender, int hitMode, bool return 7; // both hands crippled } - if ((attacker->data.critter.combat.results & (DAM_CRIP_ARM_LEFT | DAM_CRIP_ARM_RIGHT)) != 0) { + if ((attacker->data.critter.combat.results & DAM_CRIP_ARM_ANY) != 0) { if (weaponIsTwoHanded(weapon)) { return 6; // crippled one arm for two-handed weapon } diff --git a/src/combat_ai.cc b/src/combat_ai.cc index afa5812..ac37ab7 100644 --- a/src/combat_ai.cc +++ b/src/combat_ai.cc @@ -1835,7 +1835,7 @@ static bool _ai_can_use_weapon(Object* critter, Object* weapon, int hitMode) return false; } - if ((damageFlags & (DAM_CRIP_ARM_LEFT | DAM_CRIP_ARM_RIGHT)) != 0 && weaponIsTwoHanded(weapon)) { + if ((damageFlags & DAM_CRIP_ARM_ANY) != 0 && weaponIsTwoHanded(weapon)) { return false; } diff --git a/src/critter.cc b/src/critter.cc index 7750bdb..7a357b6 100644 --- a/src/critter.cc +++ b/src/critter.cc @@ -1326,7 +1326,7 @@ int critterGetMovementPointCostAdjustedForCrippledLegs(Object* critter, int acti int flags = critter->data.critter.combat.results; if ((flags & DAM_CRIP_LEG_LEFT) != 0 && (flags & DAM_CRIP_LEG_RIGHT) != 0) { return 8 * actionPoints; - } else if ((flags & (DAM_CRIP_LEG_LEFT | DAM_CRIP_LEG_RIGHT)) != 0) { + } else if ((flags & DAM_CRIP_LEG_ANY) != 0) { return 4 * actionPoints; } else { return actionPoints; diff --git a/src/interpreter_extra.cc b/src/interpreter_extra.cc index 9fe1167..a7c1b83 100644 --- a/src/interpreter_extra.cc +++ b/src/interpreter_extra.cc @@ -3941,7 +3941,7 @@ static void opCritterInjure(Program* program) } if (critter == gDude) { - if ((flags & (DAM_CRIP_ARM_LEFT | DAM_CRIP_ARM_RIGHT)) != 0) { + if ((flags & DAM_CRIP_ARM_ANY) != 0) { int leftItemAction; int rightItemAction; interfaceGetItemActions(&leftItemAction, &rightItemAction); diff --git a/src/obj_types.h b/src/obj_types.h index f133774..0656a3c 100644 --- a/src/obj_types.h +++ b/src/obj_types.h @@ -106,7 +106,9 @@ typedef enum Dam { DAM_CRIP_RANDOM = 0x200000, DAM_BACKWASH = 0x400000, DAM_PERFORM_REVERSE = 0x800000, - DAM_CRIP = (DAM_CRIP_LEG_LEFT | DAM_CRIP_LEG_RIGHT | DAM_CRIP_ARM_LEFT | DAM_CRIP_ARM_RIGHT | DAM_BLIND), + DAM_CRIP_LEG_ANY = DAM_CRIP_LEG_LEFT | DAM_CRIP_LEG_RIGHT, + DAM_CRIP_ARM_ANY = DAM_CRIP_ARM_LEFT | DAM_CRIP_ARM_RIGHT, + DAM_CRIP = DAM_CRIP_LEG_ANY | DAM_CRIP_ARM_ANY | DAM_BLIND, } Dam; #define OBJ_LOCKED 0x02000000