Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
4bd594f
Implement component on player controller for ACE radial menus
Kexanone May 5, 2025
2b56f6a
Implement inventory item based radial menu entries
Kexanone May 5, 2025
533e644
Add medical radial menu
Kexanone May 5, 2025
47cfeb9
Fix radial menu preview for epi
Kexanone May 5, 2025
c861315
Create keybind
Kexanone May 8, 2025
f37b744
Add localization
Kexanone May 8, 2025
b1f10ee
Change order of entries
Kexanone May 13, 2025
19936e8
Add inventory predicate for SCR_EConsumableType-based whitelist
Kexanone May 13, 2025
08eb026
Merge branch 'core/radial-menu' into medical/radial-menu
Kexanone May 13, 2025
18260e9
Move settings files to core and add new settings
Kexanone Jun 3, 2025
36be70e
Move and improve medical kit settings handling
Kexanone Jun 3, 2025
291c0e9
Reimplement second chance in core
Kexanone Jun 3, 2025
dfb48d6
Fix GM health tooltip
Kexanone Jun 3, 2025
3a008c3
Fix fall damage scaling
Kexanone Jun 3, 2025
d5036a3
Move stringtable to core
Kexanone Jun 3, 2025
de5197d
Move reposition to core
Kexanone Jun 3, 2025
e56eb79
Add resilience recovery scales
Kexanone Jun 4, 2025
733f2c3
Add epinephrine to core
Kexanone Jun 4, 2025
37d3de9
Add pain to core
Kexanone Jun 4, 2025
d942178
Add morphine effect override
Kexanone Jun 4, 2025
3c656a0
Trigger second chance deactivation timer when falling unconscious
Kexanone Jun 6, 2025
c13f7fb
Change second chance health recovery to damage effect
Kexanone Jun 6, 2025
efc23f0
Add centralized blood loss handling
Kexanone Jun 6, 2025
834ddd8
Replace second chance handling by a system
Kexanone Jun 6, 2025
623b236
Improve variable names
Kexanone Jun 6, 2025
c7bb8c3
Improve initialization of blood loss damage effect
Kexanone Jun 7, 2025
297b9bc
Extend pain to include new screen effects
Kexanone Jun 7, 2025
143cbb8
Replace magic speed numbers with constants
Kexanone Jun 7, 2025
8ebcbeb
Add setting for second chance on fall damage
Kexanone Jun 7, 2025
fd78b4e
Make second chance regen applicable to parent class
Kexanone Jun 8, 2025
e1cd5a9
Prefix ACE_Medical_Core folder to change loading order
Kexanone Jun 8, 2025
1a0da33
Add setting for disabling bleed outs for players
Kexanone Jun 8, 2025
d773dc1
Refactor bleed out handling to SCR_CharacterBloodHitZone
Kexanone Jun 9, 2025
91ae1cb
Move calculation of total bleeding rate from ACE_Medical_BloodLossDam…
Kexanone Jun 9, 2025
235dc56
Refactor calculation of bleeding rate for a hit zone from SCR_Bleedin…
Kexanone Jun 9, 2025
8eb2799
Get damage manager via HitZone::GetHitZoneContainer
Kexanone Jun 9, 2025
6973c99
Fix wrong bleeding rate for first bleeding on hit zone
Kexanone Jun 9, 2025
2361e9e
Slider for m_fMinHealthScaledForEpinephrine
Kexanone Jun 9, 2025
43330a2
Method for compiling attribute param array of character hit zones
Kexanone Jun 9, 2025
7063eb2
Add epi to vanilla medics
Kexanone Jun 9, 2025
6666faf
Remove old medical mod
Kexanone Jun 9, 2025
dd19503
Fix comment
Kexanone Jun 10, 2025
dc677a1
Add settings for bleeding rate and regen
Kexanone Jun 10, 2025
259e402
Refactor bleed loss calculation in ACE_Medical_BloodLossDamageEffect …
Kexanone Jun 10, 2025
2310b6b
Get max bleeding rate directly from ACE settings
Kexanone Jun 10, 2025
b623954
Rename blood loss calculation method
Kexanone Jun 10, 2025
164fb3c
Fix initial calculation of bleeding rate
Kexanone Jun 11, 2025
2aa3c81
Rename bleeding scale setting
Kexanone Jun 11, 2025
feef758
Add license and thumbail
Kexanone Jun 11, 2025
28b4e51
Add missing section divider
Kexanone Jun 11, 2025
ecf13c9
Implement base system
Kexanone Jun 13, 2025
522f727
Remove unused variable
Kexanone Jun 13, 2025
61d0832
Add ranges to float settings
Kexanone Jun 19, 2025
94d9e1c
Rename settings to core
Kexanone Jun 19, 2025
6cc440b
Add ranges to float settings
Kexanone Jun 19, 2025
f17c18b
Merge branch 'medical/rewrite' into medical/radial-menu
Kexanone Jun 20, 2025
5ff2d39
Move radial menu to core
Kexanone Jun 20, 2025
0ad1737
Reuse ACE Medical GUID for core
Kexanone Jun 22, 2025
22da178
Merge branch 'medical/rewrite' into medical/radial-menu
Kexanone Jun 22, 2025
fa43b0a
Add gproj files for dev version
Kexanone Jun 23, 2025
0c69f70
Move pain effect setting handling from SCR_HUDManagerComponent to SCR…
Kexanone Jun 28, 2025
ee14947
Update meta file
Kexanone Jun 28, 2025
dc30abd
Add medical hitzones dev.gproj
Kexanone Jun 28, 2025
1c2b044
Add dev workshop logo
Kexanone Jul 5, 2025
65a8681
Interface for frame jobs
Kexanone Jul 5, 2025
5a421bd
Implement FSM
Kexanone Jul 5, 2025
68745c6
Add ACE_FrameJobSystem
Kexanone Jul 8, 2025
f4d1e1a
Add option to suspend frame updates
Kexanone Jul 8, 2025
5ea167f
Add scheduler job for FSM-based systems
Kexanone Jul 8, 2025
acf840b
Merge branch 'dev-gproj' into medical/add-circulation
Kexanone Jul 8, 2025
19150f9
Merge branch 'medical/rewrite' into medical/add-circulation
Kexanone Jul 8, 2025
f00d808
Merge branch 'core/state-machine' into medical/add-circulation
Kexanone Jul 8, 2025
6fd21a0
Set up circulations addon
Kexanone Jul 9, 2025
c589113
Add settings
Kexanone Jul 9, 2025
d818520
Add maximum heart rate for low blood pressure threshold
Kexanone Jul 11, 2025
69fb2f5
Pass timeSlice to transition evaluation
Kexanone Jul 11, 2025
13427eb
Rename ACE_FSM_SchedulerJob to emphasize that it can be used with mor…
Kexanone Jul 11, 2025
e92b50e
Add generic job with context
Kexanone Jul 11, 2025
cc1e667
Rename member
Kexanone Jul 11, 2025
7e96893
Merge branch 'core/state-machine' into medical/add-circulation
Kexanone Jul 11, 2025
62308b6
Add vital states and transitions
Kexanone Jul 11, 2025
a59dacf
Add vital state system and component
Kexanone Jul 11, 2025
1f5687e
Add cardiac arrest damage effect
Kexanone Jul 11, 2025
88a1a98
Add brain hit zone
Kexanone Jul 11, 2025
bd4f3db
Add blood damage states
Kexanone Jul 11, 2025
f17574a
Add math operations
Kexanone Jul 11, 2025
41cdb0a
Merge branch 'medical/radial-menu' into medical/add-circulation
Kexanone Jul 15, 2025
a3a2ea0
Add validation for object context
Kexanone Jul 19, 2025
244b19d
Fix description
Kexanone Jul 19, 2025
f24ba20
Unset transition table when adding transition while not running
Kexanone Jul 19, 2025
89fbac4
Merge branch 'core/state-machine' into medical/add-circulation
Kexanone Jul 19, 2025
884cc05
Fix crash caused by Kill method
Kexanone Jul 19, 2025
a65a4a2
Add ACE_Medical_OnKilled
Kexanone Jul 19, 2025
4f990ac
Make reference to settings static
Kexanone Jul 19, 2025
e4cc504
Don't store reference to damage manager
Kexanone Jul 19, 2025
4f47184
Remove epi from old mod
Kexanone Jul 19, 2025
d8063a1
Add pain as parent via config
Kexanone Jul 19, 2025
5e02c8a
Merge branch 'medical/rewrite' into medical/add-circulation
Kexanone Jul 19, 2025
c571dd2
Add physical constants
Kexanone Jul 19, 2025
a80870e
Add diag method for selecting target character
Kexanone Jul 19, 2025
bebaf5c
Add assets
Kexanone Jul 25, 2025
576c320
Add heart beat override
Kexanone Jul 25, 2025
8af7b16
Add drug kinetics and effects
Kexanone Jul 25, 2025
685edc5
Add medication system
Kexanone Jul 25, 2025
21977ee
Add vital state machine and system
Kexanone Jul 25, 2025
eadf845
Add limits to settings
Kexanone Jul 25, 2025
9c5c242
Add additional settings
Kexanone Jul 25, 2025
2df217e
Overhaul vitals component
Kexanone Jul 25, 2025
8e2309e
Add drug gadgets
Kexanone Jul 25, 2025
e1908c4
Add diag entries
Kexanone Jul 25, 2025
f5854ad
Add medication component
Kexanone Jul 25, 2025
f96a505
Add vitals notifications
Kexanone Jul 25, 2025
1ea2a9f
Implement user actions
Kexanone Jul 25, 2025
cea2559
Add radial menu entries
Kexanone Jul 25, 2025
41c3569
Add CPR helper compartment
Kexanone Jul 25, 2025
c6d7e78
Implement brain hit zone
Kexanone Jul 25, 2025
0e98000
Add cardiac arrest screen effect
Kexanone Jul 25, 2025
1524ad1
Limit blood loss by flow scale and cardiac output
Kexanone Jul 25, 2025
92a96d4
Extend inspect casualty info
Kexanone Jul 25, 2025
c71ef4a
Add smelling salt damage effect
Kexanone Jul 25, 2025
33b2c43
Update resilience scale when waking up
Kexanone Jul 25, 2025
2f694d2
Add full heal and OnKilled handling for medication
Kexanone Jul 25, 2025
3c74adc
Add resilience and blood hanlings to damage manager
Kexanone Jul 25, 2025
e5da544
Add vitals to GM tooltip
Kexanone Jul 25, 2025
5993bee
Add language files
Kexanone Jul 25, 2025
7e6dec9
Add items to arsenals
Kexanone Jul 25, 2025
663dd65
Add systems to config
Kexanone Jul 25, 2025
7f20a0d
Overhaul blood and add brain hit zone
Kexanone Jul 25, 2025
e10c6e1
Add components and actions to character prefab
Kexanone Jul 25, 2025
afa1dcb
Add missing meta files
Kexanone Jul 25, 2025
db73050
Add language files to gproj and fix dependencies
Kexanone Jul 25, 2025
d4479a0
Add diag method for selecting target character
Kexanone Jul 19, 2025
f345a8d
Use ENABLE_DIAG preprocessor define
Kexanone Jul 25, 2025
f51a1ea
Add ACE diag menu entry
Kexanone Jul 25, 2025
f022eed
Add diag menu entry for medical
Kexanone Jul 25, 2025
f21c8a1
Merge branch 'medical/rewrite' into medical/add-circulation
Kexanone Jul 25, 2025
6952bfe
Add mod to AiO
Kexanone Jul 25, 2025
55303c3
Nerf saline bag
Kexanone Jul 31, 2025
48a436f
Fix health displayed in GM tooltip and inspection action
Kexanone Aug 7, 2025
970292d
Add GM tooltip for resilience
Kexanone Aug 7, 2025
b174ec1
Merge branch 'medical/rewrite' into medical/add-circulation
Kexanone Aug 7, 2025
9aaf559
Reduce stroke volume during CPR
Kexanone Aug 18, 2025
47abb75
Change stable GUID to prototypes
Kexanone Aug 18, 2025
77247a0
Change stable GUID to prototypes
Kexanone Aug 18, 2025
c327e59
Add brain health to GM tooltip
Kexanone Aug 18, 2025
3be7cc8
Fix second chance counting as suicide
Kexanone Aug 21, 2025
5fc998c
Fix null exception in diag
Kexanone Aug 24, 2025
c72c1e2
Fix init of derived settings
Kexanone Aug 28, 2025
e2a0e39
Medical Circulation - Fix players teleporting after CPR (#253)
nielu Sep 6, 2025
5d7ac51
Add decimal point to default float values in settings
Kexanone Sep 9, 2025
a0c7645
Handle null exception for pain HZ
Kexanone Oct 13, 2025
dbe5f67
Merge branch 'master' into medical/rewrite
Kexanone Oct 27, 2025
46b8764
Merge branch 'medical/rewrite' into medical/add-circulation
Kexanone Oct 27, 2025
8e3bd2f
Medical - Add Hitzones addon (#230)
Kexanone Oct 30, 2025
8a5bc84
Merge branch 'master' into medical/rewrite
Kexanone Oct 30, 2025
6467c86
Remove old base system and component
Kexanone Oct 30, 2025
ba0a1b1
Remove old base system state enum
Kexanone Oct 30, 2025
2d084cc
Remove p from member name
Kexanone Oct 30, 2025
ff781cd
Remove p from member name
Kexanone Oct 30, 2025
57f3487
Correct type in member variable name
Kexanone Oct 30, 2025
9d8661d
Correct type in member variable name
Kexanone Oct 30, 2025
c7897b4
Correct type in member variable name
Kexanone Oct 30, 2025
61fd8de
Update addons/medical_core/scripts/Game/@ACE_Medical_Core/Components/…
Kexanone Oct 30, 2025
4220596
Correct type in member variable name
Kexanone Oct 30, 2025
4480cd2
Correct type in member variable name
Kexanone Oct 30, 2025
b7c7e83
New signature for OnLifeStateChanged
Kexanone Aug 5, 2025
ce07724
New signature for OnDamageStateChanged
Kexanone Aug 5, 2025
2f12423
New signature for OnDamageStateChanged
Kexanone Aug 5, 2025
4bea326
Update system InitInfo
Kexanone Oct 13, 2025
07927a6
Get instance of system from correct world
Kexanone Oct 20, 2025
103f849
Get instance of system from correct world
Kexanone Oct 20, 2025
2ff876f
Merge branch 'medical/rewrite' into medical/add-circulation
Kexanone Oct 30, 2025
30dfa3e
Define neck and hips hit zones in core for compatibility
Kexanone Jul 31, 2025
65c9272
Merge branch 'medical/rewrite' into medical/add-circulation
Kexanone Oct 30, 2025
bb85c5d
Medical - Make Circulation compatible with Hitzones (#242)
Kexanone Oct 30, 2025
6b56faf
Medical Circulation - Fix errors on experimental (#243)
Kexanone Oct 30, 2025
235ff81
Remove inheritance of old base component
Kexanone Oct 30, 2025
b00991a
Remove p from member name
Kexanone Oct 30, 2025
9ccaf1c
Pass world to GetInstance
Kexanone Oct 30, 2025
82f6bef
Activate INIT event
Kexanone Oct 30, 2025
8b54347
Merge branch 'master' into medical/add-circulation
Kexanone Oct 30, 2025
fed8203
Set proper values for vitals when character gets killed
Kexanone Oct 30, 2025
52c794f
Merge branch 'medical/add-circulation' of github-kexanone:acemod/ACE-…
Kexanone Oct 30, 2025
faab725
Medical - Fix: only show CPR and Check Vitals actions for INCAPACITAT…
denispol Nov 1, 2025
3bad9e7
Medical - Fix reposition UI actions (#297)
denispol Nov 7, 2025
28d40f2
Medical Circulation - Fix reset vitals (#290)
denispol Nov 7, 2025
be390dd
Add contributors from prototypes
Kexanone Nov 8, 2025
8c401ba
Merge branch 'master' into medical/add-circulation
Kexanone Nov 20, 2025
c6e98d8
Fix stance on terminating CPR
Kexanone Dec 7, 2025
937d37c
Only allow CPR in supine position
Kexanone Dec 11, 2025
eebfa0e
Remove extra newline
Kexanone Dec 11, 2025
3c76c03
Add ref to vitals to SCR_CharacterDamageManagerComponent
Kexanone Dec 11, 2025
59b2149
Refactor patient state notification data getter for future overrides
Kexanone Dec 11, 2025
0204d30
Refactor SCR_InspectCasualtyWidget
Kexanone Dec 14, 2025
df9d3f1
Implement SCR_InventoryHitZonePointUI::ACE_Medical_ShowGlobalStatTooltip
Kexanone Dec 14, 2025
49df2f3
Use flags as attribute widget instead
Kexanone Dec 14, 2025
7b1d128
Add comments
Kexanone Dec 14, 2025
d72c4b9
Merge branch 'medical/custom-inventory-tooltip' into medical/add-circ…
Kexanone Dec 14, 2025
c8ee2f0
Reimport assets
Kexanone Dec 14, 2025
0ae3dc3
Show hemorrhage class in inventory menu
Kexanone Dec 14, 2025
115063f
Add medication info to inventory menu
Kexanone Dec 14, 2025
f75db44
Refactor medication tooltip entry to prefab
Kexanone Dec 14, 2025
4e66495
Call super for target HR
Kexanone Dec 15, 2025
b06c082
Medical Circulation - Add Chinese translation (#310)
TWYuanYu Dec 16, 2025
3e305a7
Medical - Add Russian localization (#283)
Iam1337 Dec 16, 2025
7b7c4eb
Fix string table merge
Kexanone Dec 16, 2025
cdd1d3a
Medical Circulation - Korean translations (#361)
Psycool3695 Jan 12, 2026
d01df55
Medical Circulation - Update Chinese localization (#349)
TWYuanYu Jan 12, 2026
d888529
Update stringtable runtimes
Kexanone Jan 12, 2026
d6c2bb4
Remove unused variable
Kexanone Mar 12, 2026
24ee10d
Add bisection and secant methods for finding roots
Kexanone Mar 27, 2026
6bfd8f6
Add math functions
Kexanone Mar 27, 2026
7eb459a
Add doc comments to math functions
Kexanone Mar 27, 2026
e7bcafc
Merge branch 'core/root-finder' into medical/add-circulation
Kexanone Mar 27, 2026
e74d384
Explicitly set damage type and unlimited duration for effect
Kexanone Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ veteran29

# CONTRIBUTORS
AkiKay
ArtOfWar
Badger 2-3
Caleb
denispol
dr_ext
Fedora12 <monn45888@gmail.com>
Glowbal
gnif <geoff@hostfission.com>
Jonpas <jonpas33@gmail.com>
KingDaddyBoyz / Price
LorenLuke
Mad [Hk]
OverlordZorn
Psycool
PuFu
Expand Down
2 changes: 1 addition & 1 deletion addons/all_in_one/addon.gproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GameProject {
GUID "60C4E0B49618CC62"
TITLE "ACE All in One"
Dependencies {
"58D0FB3206B6F859" "60C4CE4888FF4621" "60E573C9B04CC408" "5DBD560C5148E1DA" "5EB744C5F42E0800" "60C53A9372ED3964" "606C369BAC3F6CC3" "60C4C12DAE90727B" "65860252A17554C7" "60EAEA0389DB3CC2" "611CB1D409001EB0" "61B7763A8AEB53B7" "646D52AF8BB3FF15" "61226BB18D360BDD" "64475DC102F2BDA4" "62F802951CC8A37E"
"58D0FB3206B6F859" "60C4CE4888FF4621" "60E573C9B04CC408" "5DBD560C5148E1DA" "5EB744C5F42E0800" "60C53A9372ED3964" "606C369BAC3F6CC3" "60C4C12DAE90727B" "65860252A17554C7" "6214CEA5DA92BFF3" "60EAEA0389DB3CC2" "611CB1D409001EB0" "61B7763A8AEB53B7" "646D52AF8BB3FF15" "61226BB18D360BDD" "64475DC102F2BDA4" "62F802951CC8A37E"
}
Configurations {
GameProjectConfig PC {
Expand Down
2 changes: 1 addition & 1 deletion addons/all_in_one/dev.gproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GameProject {
GUID "65AD7BE594439A52"
TITLE "ACE All in One Dev"
Dependencies {
"58D0FB3206B6F859" "65AD7D0D9941A380" "65AD7C139EB4C1A1" "65AD7C379CBD394D" "65AD7BCC9F6B3B4E" "65AD7CF69FAF1FDD" "65AD7D2E9866FA6E" "6586079789278413" "65B343F799FB521B" "65AD7CE59E8DB349" "65AD7D4099944EBD" "65AD7D1E9EEAFA53" "65AD7C249E4ECDFB" "65AD7CB89F219E38" "65AD7C75826B46C6" "65AD7CD09CAEC4E2"
"58D0FB3206B6F859" "65AD7D0D9941A380" "65AD7C139EB4C1A1" "65AD7C379CBD394D" "65AD7BCC9F6B3B4E" "65AD7CF69FAF1FDD" "65AD7D2E9866FA6E" "6586079789278413" "65B343F799FB521B" "65AD7D4F994EA327" "65AD7CE59E8DB349" "65AD7D4099944EBD" "65AD7D1E9EEAFA53" "65AD7C249E4ECDFB" "65AD7CB89F219E38" "65AD7C75826B46C6" "65AD7CD09CAEC4E2"
}
Configurations {
GameProjectConfig PC {
Expand Down
3 changes: 3 additions & 0 deletions addons/core/Configs/Systems/ChimeraSystemsConfig.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
SystemSettings : "{45C53F06BA17238D}configs/Systems/SystemsConfig.conf" {
Systems {
ACE_FrameJobSystem "{65BD626A0110EC75}" {
SystemPoints 0x2014 0
}
ACE_LoadtimeEntityManager "{66ACC8B1AE46C9A6}" {
SystemPoints 0 0x10
}
Expand Down
8 changes: 8 additions & 0 deletions addons/core/scripts/Game/ACE_Core/FSM/ACE_FSM_EStateID.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//------------------------------------------------------------------------------------------------
//! Subclass from this enum for concrete FSM implementations
//! States IDs should be implemented as bit flags
enum ACE_FSM_EStateID
{
ANY = -1,
STOP = 0
}
29 changes: 29 additions & 0 deletions addons/core/scripts/Game/ACE_Core/FSM/ACE_FSM_IState.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//------------------------------------------------------------------------------------------------
//! Interface of FSM state
//! This object should be stateless if you want to share instances between machines (e.g. shallow copies)
//! Data should be implemented in TContext instead
class ACE_FSM_IState<Managed TContext> : Managed
{
protected ACE_FSM_EStateID m_eID;

//------------------------------------------------------------------------------------------------
void ACE_FSM_IState(ACE_FSM_EStateID id)
{
m_eID = id;
}

//------------------------------------------------------------------------------------------------
void OnUpdate(TContext context, float timeSlice);

//------------------------------------------------------------------------------------------------
void OnEnter(TContext context);

//------------------------------------------------------------------------------------------------
void OnExit(TContext context);

//------------------------------------------------------------------------------------------------
ACE_FSM_EStateID GetID()
{
return m_eID;
}
}
36 changes: 36 additions & 0 deletions addons/core/scripts/Game/ACE_Core/FSM/ACE_FSM_ITransition.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//------------------------------------------------------------------------------------------------
//! Interface of FSM transition
//! This object should be stateless if you want to share instances between machines (e.g. shallow copies)
//! Data should be implemented in TContext instead
class ACE_FSM_ITransition<Managed TContext> : Managed
{
protected ACE_FSM_EStateID m_eFromStateIDs;
protected ACE_FSM_EStateID m_eToStateID;

//------------------------------------------------------------------------------------------------
//! Multiple `from` states are possible by combining ACE_FSM_EStateID bit flags
void ACE_FSM_ITransition(ACE_FSM_EStateID fromStateIDs, ACE_FSM_EStateID toStateID)
{
m_eFromStateIDs = fromStateIDs;
m_eToStateID = toStateID;
}

//------------------------------------------------------------------------------------------------
void OnPerform(TContext context);

//------------------------------------------------------------------------------------------------
//! Add condition for the transition here
bool ShouldBePerformed(TContext context, float timeSlice);

//------------------------------------------------------------------------------------------------
ACE_FSM_EStateID GetFromStateIDs()
{
return m_eFromStateIDs;
}

//------------------------------------------------------------------------------------------------
ACE_FSM_EStateID GetToStateID()
{
return m_eToStateID;
}
}
187 changes: 187 additions & 0 deletions addons/core/scripts/Game/ACE_Core/FSM/ACE_FSM_Machine.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
//------------------------------------------------------------------------------------------------
//! Implementation of a finite state machine
//! Data to be passed to states should be defined in TContext
class ACE_FSM_Machine<Managed TContext> : ACE_IFrameJob
{
// Unique data
protected ref TContext m_pContext = null;
protected int m_iCurrentStateIdx = -1;

// Shared data (Can be shared between instances through ACE_FSM_Machine::CopyFrom)
protected ref array<ref ACE_FSM_IState<TContext>> m_aStates = {};
protected ref array<ref ACE_FSM_ITransition<TContext>> m_aTransitions = {};
protected ref array<ref array<ACE_FSM_ITransition<TContext>>> m_aTransitionTable;

//------------------------------------------------------------------------------------------------
//! Adds a state
//! If a state with the same ID already exists, it will replace it
void AddState(ACE_FSM_IState<TContext> newState)
{
ACE_FSM_EStateID newID = newState.GetID();

foreach (int i, ACE_FSM_IState<TContext> state : m_aStates)
{
if (state.GetID() == newID)
{
m_aStates[i] = newState;
return;
}
}

m_aStates.Insert(newState);

if (IsRunning())
UpdateTransitionTable();
else
m_aTransitionTable = null;
}

//------------------------------------------------------------------------------------------------
//! Adds a transition
//! If a transition between the same states already exists, it will replace it
void AddTransition(ACE_FSM_ITransition<TContext> newTransition)
{
ACE_FSM_EStateID newToIDs = newTransition.GetToStateID();
ACE_FSM_EStateID newFromID = newTransition.GetFromStateIDs();

foreach (int i, ACE_FSM_ITransition<TContext> transition : m_aTransitions)
{
if ((transition.GetToStateID() == newToIDs) && (transition.GetFromStateIDs() == newFromID))
{
m_aTransitions[i] = newTransition;
return;
}
}

m_aTransitions.Insert(newTransition);

if (IsRunning())
UpdateTransitionTable();
}

//------------------------------------------------------------------------------------------------
//! Updates current state and handles transitions
//! Reason for the order:
//! As the current state's OnUpdate often integrates context variables over timeSlice, the
//! evaulation of transition conditions should be done afterwards
override void OnUpdate(float timeSlice)
{
super.OnUpdate();
m_aStates[m_iCurrentStateIdx].OnUpdate(m_pContext, timeSlice);
HandleTransitions(timeSlice);
}

//------------------------------------------------------------------------------------------------
//! Initializes elements and transition table
override void OnStart()
{
super.OnStart();

if (!m_aTransitionTable)
UpdateTransitionTable();

ChangeStateByIdx(0);
}

//------------------------------------------------------------------------------------------------
//! Clean up current state
override void OnStop()
{
super.OnStop();
ChangeStateByIdx(-1);
}

//------------------------------------------------------------------------------------------------
void UpdateTransitionTable()
{
m_aTransitionTable = {};
m_aTransitionTable.Reserve(m_aStates.Count());

foreach (ACE_FSM_IState<TContext> state : m_aStates)
{
ACE_FSM_EStateID id = state.GetID();
array<ACE_FSM_ITransition<TContext>> availableTransitions = {};

foreach (ACE_FSM_ITransition<TContext> transition : m_aTransitions)
{
if (transition.GetFromStateIDs() & id)
availableTransitions.Insert(transition);
}

m_aTransitionTable.Insert(availableTransitions);
}
}

//------------------------------------------------------------------------------------------------
//! Checks transition conditions and performs the first eligible transition
protected void HandleTransitions(float timeSlice)
{
foreach (ACE_FSM_ITransition<TContext> transition : m_aTransitionTable[m_iCurrentStateIdx])
{
if (transition.ShouldBePerformed(m_pContext, timeSlice))
{
transition.OnPerform(m_pContext);
ChangeState(transition.GetToStateID());
return;
}
}
}

//------------------------------------------------------------------------------------------------
void ChangeState(ACE_FSM_EStateID newStateID)
{
foreach (int idx, ACE_FSM_IState<TContext> state : m_aStates)
{
if (newStateID == state.GetID())
return ChangeStateByIdx(idx);
}

if (!newStateID)
Stop();
}

//------------------------------------------------------------------------------------------------
protected void ChangeStateByIdx(int newStateIdx)
{
if (m_iCurrentStateIdx >= 0)
m_aStates[m_iCurrentStateIdx].OnExit(m_pContext);

m_iCurrentStateIdx = newStateIdx;

if (m_iCurrentStateIdx >= 0)
m_aStates[m_iCurrentStateIdx].OnEnter(m_pContext);
}

//------------------------------------------------------------------------------------------------
void SetContext(TContext context)
{
m_pContext = context;
}

//------------------------------------------------------------------------------------------------
TContext GetContext()
{
return m_pContext;
}

//------------------------------------------------------------------------------------------------
ACE_FSM_EStateID GetCurrentStateID()
{
return m_aStates[m_iCurrentStateIdx];
}

//------------------------------------------------------------------------------------------------
//! Makes a shallow copy of states and transitions of the based FSM
override void CopyFrom(ACE_IFrameJob from)
{
super.CopyFrom(from);

ACE_FSM_Machine<TContext> castedFrom = ACE_FSM_Machine<TContext>.Cast(from);
if (!castedFrom)
return;

m_aStates = castedFrom.m_aStates;
m_aTransitions = castedFrom.m_aTransitions;
m_aTransitionTable = castedFrom.m_aTransitionTable;
}
}
6 changes: 5 additions & 1 deletion addons/core/scripts/Game/ACE_Core/Global/ACE_DiagTools.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ class ACE_DiagTools
//! Return true if a target was found
static bool GetDiagTargetCharacter(out IEntity target, out string targetType)
{
CameraBase camera = GetGame().GetCameraManager().CurrentCamera();
CameraManager cameraManager = GetGame().GetCameraManager();
if (!cameraManager)
return false;

CameraBase camera = cameraManager.CurrentCamera();
if (!camera)
return false;

Expand Down
28 changes: 28 additions & 0 deletions addons/core/scripts/Game/ACE_Core/Global/ACE_Math.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//------------------------------------------------------------------------------------------------
class ACE_Math
{
//------------------------------------------------------------------------------------------------
//! Return Euler's constant raised to the power of x
static float Exp(float x)
{
return Math.Pow(Math.E, x);
}

//------------------------------------------------------------------------------------------------
//! Evaluate normalized Hill equation at x
static float Hill(float x)
{
return x / (1 + x);
}

//------------------------------------------------------------------------------------------------
//! Round float to a given precision in decimal digits
//! \param[in] value value to be rounded
//! \param[in] precision number of decimal places to round to
//! \return rounded float
static float Round(float value, int precision)
{
float scale = Math.Pow(10, precision);
return Math.Round(value * scale) / scale;
}
}
Loading