From 45a268ee77bec8b2f91754cb79029105b0006360 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sat, 8 May 2021 23:16:14 +0800 Subject: [PATCH] Enabled AI to use unarmed attack when switching weapons Added build folders to gitignore. --- .gitignore | 2 ++ sfall/AI.cpp | 9 +++++++++ sfall/Define.h | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index ac3390d4..e4c5a4fd 100644 --- a/.gitignore +++ b/.gitignore @@ -53,8 +53,10 @@ nb-configuration.xml # Build results [Dd]ebug/ [Dd]ebugPublic/ +[Dd]evXP/ [Rr]elease/ [Rr]eleases/ +[Ww]in2K/ x64/ x86/ build/ diff --git a/sfall/AI.cpp b/sfall/AI.cpp index 461c4e47..b5ea02f9 100644 --- a/sfall/AI.cpp +++ b/sfall/AI.cpp @@ -276,7 +276,14 @@ static long __fastcall ai_try_attack_switch_fix(TGameObj* target, long &hitMode, } return 1; // all good, execute vanilla behavior of ai_switch_weapons_ function } + // no other weapon in inventory + if (weapon) { + if (fo_item_w_range(source, ATKTYPE_PUNCH) >= fo_obj_dist(source, target)) { + hitMode = ATKTYPE_PUNCH; + return 0; // change hit mode, continue attack cycle + } + } return (weapon) ? -1 // exit, NPC has a weapon in hand slot, so we don't look for another weapon on the map : 1; // no weapon in inventory or hand slot, continue to search weapons on the map (call ai_switch_weapons_) } @@ -544,6 +551,8 @@ static void __declspec(naked) ai_try_attack_hack_check_safe_weapon() { } } +//////////////////////////////////////////////////////////////////////////////// + static void __fastcall CombatAttackHook(TGameObj* source, TGameObj* target) { sources[target] = source; // who attacked the 'target' from the last time targets[source] = target; // who was attacked by the 'source' from the last time diff --git a/sfall/Define.h b/sfall/Define.h index a7d94993..b7bd7a7c 100644 --- a/sfall/Define.h +++ b/sfall/Define.h @@ -278,15 +278,24 @@ enum ArtType : char // Some FO2 PIDs possibly used by engine enum ProtoID : unsigned long { + PID_POWERED_ARMOR = 3, PID_STIMPAK = 40, + PID_BOTTLE_CAPS = 41, PID_DYNAMITE = 51, + PID_GEIGER_COUNTER = 52, + PID_STEALTH_BOY = 54, PID_MOTION_SENSOR = 59, PID_PLASTIC_EXPLOSIVES = 85, PID_SUPER_STIMPAK = 144, + PID_ACTIVE_DYNAMITE = 206, PID_ACTIVE_GEIGER_COUNTER = 207, + PID_ACTIVE_PLASTIC_EXPLOSIVE = 209, PID_ACTIVE_STEALTH_BOY = 210, + PID_HARDENED_POWER_ARMOR = 232, PID_JET = 259, PID_HEALING_POWDER = 273, + PID_ADVANCED_POWER_ARMOR = 348, + PID_ADVANCED_POWER_ARMOR_MK2 = 349, PID_SOLAR_SCORCHER = 390, PID_CAR_TRUNK = 455, PID_JESSE_CONTAINER = 467,