mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added OnCombatStart, OnCombatEnd delegates
Updated version number.
This commit is contained in:
+11
-11
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "..\main.h"
|
||||
#include "..\FalloutEngine\Fallout2.h"
|
||||
#include "LoadGameHook.h"
|
||||
|
||||
#include "HookScripts\CombatHS.h"
|
||||
|
||||
@@ -58,9 +59,11 @@ fo::GameObject* AI::CheckFriendlyFire(fo::GameObject* target, fo::GameObject* at
|
||||
fo::GameObject* object = nullptr;
|
||||
fo::func::make_straight_path_func(attacker, attacker->tile, target->tile, 0, (DWORD*)&object, 32, (void*)fo::funcoffs::obj_shoot_blocking_at_);
|
||||
object = CheckShootAndFriendlyInLineOfFire(object, target->tile, attacker->critter.teamNum);
|
||||
return (!object || object->TypeFid() == fo::ObjType::OBJ_TYPE_CRITTER) ? object : nullptr; // 0 if there are no friendly critters
|
||||
return (object && object->IsCritter()) ? object : nullptr; // 0 if there are no friendly critters
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void __declspec(naked) ai_try_attack_hook_FleeFix() {
|
||||
__asm {
|
||||
or byte ptr [esi + combatState], 8; // set new 'ReTarget' flag
|
||||
@@ -440,11 +443,18 @@ static void __declspec(naked) combat_attack_hook() {
|
||||
}
|
||||
}
|
||||
|
||||
static void AICombatClear() {
|
||||
targets.clear();
|
||||
sources.clear();
|
||||
}
|
||||
|
||||
void AI::init() {
|
||||
HookCalls(combat_attack_hook, {
|
||||
0x426A95, // combat_attack_this_
|
||||
0x42A796 // ai_attack_
|
||||
});
|
||||
LoadGameHook::OnCombatStart() += AICombatClear;
|
||||
LoadGameHook::OnCombatEnd() += AICombatClear;
|
||||
|
||||
RetryCombatMinAP = GetConfigInt("Misc", "NPCsTryToSpendExtraAP", 0);
|
||||
if (RetryCombatMinAP > 0) {
|
||||
@@ -522,14 +532,4 @@ fo::GameObject* __stdcall AI::AIGetLastTarget(fo::GameObject* source) {
|
||||
return (itr != targets.end()) ? itr->second : 0;
|
||||
}
|
||||
|
||||
void __stdcall AI::AICombatStart() {
|
||||
targets.clear();
|
||||
sources.clear();
|
||||
}
|
||||
|
||||
void __stdcall AI::AICombatEnd() {
|
||||
targets.clear();
|
||||
sources.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,10 +33,6 @@ public:
|
||||
static fo::GameObject* CheckShootAndFriendlyInLineOfFire(fo::GameObject* object, long targetTile, long team);
|
||||
static fo::GameObject* CheckFriendlyFire(fo::GameObject* target, fo::GameObject* attacker);
|
||||
|
||||
// TODO: use subscription instead
|
||||
static void __stdcall AICombatStart();
|
||||
static void __stdcall AICombatEnd();
|
||||
|
||||
static fo::GameObject* __stdcall AIGetLastAttacker(fo::GameObject* target);
|
||||
static fo::GameObject* __stdcall AIGetLastTarget(fo::GameObject* source);
|
||||
};
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "..\Logging.h"
|
||||
#include "..\version.h"
|
||||
|
||||
#include "AI.h"
|
||||
#include "BugFixes.h"
|
||||
#include "CritterStats.h"
|
||||
#include "ExtraSaveSlots.h"
|
||||
@@ -63,6 +62,8 @@ static Delegate<> onAfterGameStarted;
|
||||
static Delegate<> onAfterNewGame;
|
||||
static Delegate<DWORD> onGameModeChange;
|
||||
static Delegate<> onBeforeGameClose;
|
||||
static Delegate<> onCombatStart;
|
||||
static Delegate<> onCombatEnd;
|
||||
|
||||
static DWORD inLoop = 0;
|
||||
static DWORD saveInCombatFix;
|
||||
@@ -451,17 +452,25 @@ static void __declspec(naked) WorldMapHook_End() {
|
||||
}
|
||||
}
|
||||
|
||||
static void __fastcall CombatInternal(fo::CombatGcsd* gcsd) {
|
||||
onCombatStart.invoke();
|
||||
SetInLoop(1, COMBAT);
|
||||
|
||||
__asm mov eax, gcsd;
|
||||
__asm call fo::funcoffs::combat_;
|
||||
|
||||
onCombatEnd.invoke();
|
||||
SetInLoop(0, COMBAT);
|
||||
}
|
||||
|
||||
static void __declspec(naked) CombatHook() {
|
||||
__asm {
|
||||
pushadc;
|
||||
call AI::AICombatStart;
|
||||
_InLoop2(1, COMBAT);
|
||||
popadc;
|
||||
call fo::funcoffs::combat_;
|
||||
pushadc;
|
||||
call AI::AICombatEnd;
|
||||
_InLoop2(0, COMBAT);
|
||||
popadc;
|
||||
push ecx;
|
||||
push edx;
|
||||
mov ecx, eax;
|
||||
call CombatInternal;
|
||||
pop edx;
|
||||
pop ecx;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
@@ -848,4 +857,11 @@ Delegate<>& LoadGameHook::OnBeforeGameClose() {
|
||||
return onBeforeGameClose;
|
||||
}
|
||||
|
||||
Delegate<>& LoadGameHook::OnCombatStart() {
|
||||
return onCombatStart;
|
||||
}
|
||||
|
||||
Delegate<>& LoadGameHook::OnCombatEnd() {
|
||||
return onCombatEnd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,9 @@ public:
|
||||
// Invoked before the game exits to windows
|
||||
static Delegate<>& OnBeforeGameClose();
|
||||
|
||||
static Delegate<>& OnCombatStart();
|
||||
static Delegate<>& OnCombatEnd();
|
||||
|
||||
static long interfaceWID;
|
||||
};
|
||||
|
||||
|
||||
+3
-3
@@ -23,8 +23,8 @@
|
||||
#define LEGAL_COPYRIGHT "Copyright (C) 2006-2021, sfall team"
|
||||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_BUILD 9
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_BUILD 0
|
||||
#define VERSION_REV 0
|
||||
|
||||
#define VERSION_STRING "4.2.9"
|
||||
#define VERSION_STRING "4.3"
|
||||
|
||||
Reference in New Issue
Block a user