@@ -581,7 +581,8 @@ namespace TFE_DarkForces
581
581
return (ActorDispatch*)s_actorState.curLogic ;
582
582
}
583
583
584
- JBool defaultDamageFunc (ActorModule* module , MovementModule* moveMod)
584
+ // Default damage module function for "dispatch" actors
585
+ Tick defaultDamageFunc (ActorModule* module , MovementModule* moveMod)
585
586
{
586
587
DamageModule* damageMod = (DamageModule*)module ;
587
588
AttackModule* attackMod = &damageMod->attackMod ;
@@ -595,7 +596,7 @@ namespace TFE_DarkForces
595
596
actor_setCurAnimation (&attackMod->anim );
596
597
}
597
598
moveMod->updateTargetFunc (moveMod, &attackMod->target );
598
- return JFALSE ;
599
+ return 0 ;
599
600
}
600
601
601
602
if (damageMod->hp <= 0 )
@@ -607,7 +608,7 @@ namespace TFE_DarkForces
607
608
actor_setCurAnimation (&attackMod->anim );
608
609
}
609
610
moveMod->updateTargetFunc (moveMod, &attackMod->target );
610
- return JFALSE ;
611
+ return 0 ;
611
612
}
612
613
spawnHitEffect (damageMod->dieEffect , sector, obj->posWS , obj);
613
614
@@ -665,7 +666,9 @@ namespace TFE_DarkForces
665
666
return 0xffffffff ;
666
667
}
667
668
668
- JBool defaultDamageMsgFunc (s32 msg, ActorModule* module , MovementModule* moveMod)
669
+ // Default damage module message function for "dispatch" actors
670
+ // Delivers a message to the damage module
671
+ Tick defaultDamageMsgFunc (s32 msg, ActorModule* module , MovementModule* moveMod)
669
672
{
670
673
DamageModule* damageMod = (DamageModule*)module ;
671
674
AttackModule* attackMod = &damageMod->attackMod ;
@@ -738,7 +741,7 @@ namespace TFE_DarkForces
738
741
actor_setCurAnimation (&attackMod->anim );
739
742
}
740
743
moveMod->updateTargetFunc (moveMod, &attackMod->target );
741
- return JFALSE ;
744
+ return 0 ;
742
745
}
743
746
else if (msg == MSG_EXPLOSION)
744
747
{
@@ -787,7 +790,7 @@ namespace TFE_DarkForces
787
790
actor_setCurAnimation (&attackMod->anim );
788
791
}
789
792
moveMod->updateTargetFunc (moveMod, &attackMod->target );
790
- return JFALSE ;
793
+ return 0 ;
791
794
}
792
795
else if (msg == MSG_TERMINAL_VEL || msg == MSG_CRUSH)
793
796
{
@@ -810,7 +813,7 @@ namespace TFE_DarkForces
810
813
}
811
814
}
812
815
813
- return JFALSE ;
816
+ return 0 ;
814
817
}
815
818
816
819
DamageModule* actor_createDamageModule (ActorDispatch* dispatch)
@@ -837,8 +840,12 @@ namespace TFE_DarkForces
837
840
return damageMod;
838
841
}
839
842
840
- JBool defaultAttackFunc (ActorModule* module , MovementModule* moveMod)
843
+ // Default attack module function for "dispatch" actors
844
+ // The returned value is set to the module's nextTick
845
+ Tick defaultAttackFunc (ActorModule* module , MovementModule* moveMod)
841
846
{
847
+ // Note: the module passed into this function is an AttackModule*, not a DamageModule*, and should be cast directly to an AttackModule*
848
+ // however, the code casts it to a DamageModule* first (why?)
842
849
DamageModule* damageMod = (DamageModule*)module ;
843
850
AttackModule* attackMod = &damageMod->attackMod ;
844
851
ActorDispatch* logic = (ActorDispatch*)s_actorState.curLogic ;
@@ -1140,8 +1147,12 @@ namespace TFE_DarkForces
1140
1147
return attackMod->timing .delay ;
1141
1148
}
1142
1149
1143
- JBool defaultAttackMsgFunc (s32 msg, ActorModule* module , MovementModule* moveMod)
1150
+ // Default attack module message function for "dispatch" actors
1151
+ // Delivers a message to the attack module
1152
+ Tick defaultAttackMsgFunc (s32 msg, ActorModule* module , MovementModule* moveMod)
1144
1153
{
1154
+ // Note: the module passed into this function is an AttackModule*, not a DamageModule*, and should be cast directly to an AttackModule*
1155
+ // however, the code casts it to a DamageModule* first (why?)
1145
1156
DamageModule* damageMod = (DamageModule*)module ;
1146
1157
AttackModule* attackMod = &damageMod->attackMod ;
1147
1158
ActorDispatch* logic = (ActorDispatch*)s_actorState.curLogic ;
@@ -1168,7 +1179,8 @@ namespace TFE_DarkForces
1168
1179
return attackMod;
1169
1180
}
1170
1181
1171
- JBool defaultThinkerFunc (ActorModule* module , MovementModule* moveMod)
1182
+ // Default thinker module function for "dispatch" actors
1183
+ Tick defaultThinkerFunc (ActorModule* module , MovementModule* moveMod)
1172
1184
{
1173
1185
ThinkerModule* thinkerMod = (ThinkerModule*)module ;
1174
1186
SecObject* obj = thinkerMod->header .obj ;
@@ -1521,7 +1533,8 @@ namespace TFE_DarkForces
1521
1533
}
1522
1534
}
1523
1535
1524
- JBool defaultActorFunc (ActorModule* module , MovementModule* moveMod)
1536
+ // Default movement module function for "dispatch" actors
1537
+ Tick defaultActorFunc (ActorModule* module , MovementModule* moveMod)
1525
1538
{
1526
1539
moveMod->physics .wall = nullptr ;
1527
1540
moveMod->physics .u24 = 0 ;
@@ -1536,7 +1549,7 @@ namespace TFE_DarkForces
1536
1549
actor_handleMovementAndCollision (moveMod);
1537
1550
}
1538
1551
moveMod->target .flags &= ~TARGET_ALL_MOVE;
1539
- return JFALSE ;
1552
+ return 0 ;
1540
1553
}
1541
1554
1542
1555
// Updates the actor target with the passed in target based on the flags.
@@ -1906,11 +1919,13 @@ namespace TFE_DarkForces
1906
1919
actorLogic->vel .z += pushZ;
1907
1920
}
1908
1921
1909
- void actor_hitEffectMsgFunc (MessageType msg, void * logic)
1922
+ void actor_messageFunc (MessageType msg, void * logic)
1910
1923
{
1911
1924
ActorDispatch* dispatch = (ActorDispatch*)logic;
1912
1925
s_actorState.curLogic = (Logic*)logic;
1913
1926
SecObject* obj = s_actorState.curLogic ->obj ;
1927
+
1928
+ // Send the message to each module via the module's message function
1914
1929
for (s32 i = 0 ; i < ACTOR_MAX_MODULES; i++)
1915
1930
{
1916
1931
ActorModule* module = dispatch->modules [ACTOR_MAX_MODULES - 1 - i];
@@ -1924,6 +1939,7 @@ namespace TFE_DarkForces
1924
1939
}
1925
1940
}
1926
1941
1942
+ // WAKEUP, DAMAGE and EXPLOSION messages will wake (alert) the actor from an idle state
1927
1943
if (msg == MSG_WAKEUP)
1928
1944
{
1929
1945
if (dispatch->flags & ACTOR_IDLE)
@@ -1975,7 +1991,12 @@ namespace TFE_DarkForces
1975
1991
1976
1992
void actor_sendTerminalVelMsg (SecObject* obj)
1977
1993
{
1978
- message_sendToObj (obj, MSG_TERMINAL_VEL, actor_hitEffectMsgFunc);
1994
+ message_sendToObj (obj, MSG_TERMINAL_VEL, actor_messageFunc);
1995
+ }
1996
+
1997
+ void actor_sendWakeupMsg (SecObject* obj)
1998
+ {
1999
+ message_sendToObj (obj, MSG_WAKEUP, actor_messageFunc);
1979
2000
}
1980
2001
1981
2002
void actor_handlePhysics (MovementModule* moveMod, vec3_fixed* vel)
@@ -2046,6 +2067,7 @@ namespace TFE_DarkForces
2046
2067
if (TFE_Jedi::abs (vel->z ) < ACTOR_MIN_VELOCITY) { vel->z = 0 ; }
2047
2068
}
2048
2069
2070
+ // Local run func for actor task
2049
2071
void actorLogicMsgFunc (MessageType msg)
2050
2072
{
2051
2073
if (msg == MSG_FREE)
@@ -2054,7 +2076,7 @@ namespace TFE_DarkForces
2054
2076
}
2055
2077
else
2056
2078
{
2057
- actor_hitEffectMsgFunc (msg, s_msgTarget);
2079
+ actor_messageFunc (msg, s_msgTarget);
2058
2080
}
2059
2081
}
2060
2082
@@ -2081,9 +2103,9 @@ namespace TFE_DarkForces
2081
2103
if (actor_isObjectVisible (obj, s_playerObject, dispatch->fov , dispatch->awareRange ))
2082
2104
{
2083
2105
// Wake up, and alert other actors within a 150 unit range
2084
- message_sendToObj (obj, MSG_WAKEUP, actor_hitEffectMsgFunc );
2106
+ message_sendToObj (obj, MSG_WAKEUP, actor_messageFunc );
2085
2107
gameMusic_startFight ();
2086
- collision_effectObjectsInRangeXZ (obj->sector , FIXED (150 ), obj->posWS , hitEffectWakeupFunc , obj, ETFLAG_AI_ACTOR);
2108
+ collision_effectObjectsInRangeXZ (obj->sector , FIXED (150 ), obj->posWS , actor_sendWakeupMsg , obj, ETFLAG_AI_ACTOR);
2087
2109
}
2088
2110
}
2089
2111
}
0 commit comments