mirror of
https://gitlab.com/ryandwyer/perfect-dark
synced 2026-09-01 01:21:45 -04:00
Discover flank command
This commit is contained in:
@@ -15718,7 +15718,7 @@ bool chr_is_nearly_in_targets_sight(struct chrdata *chr, u32 distance)
|
||||
return cd_is_nearly_in_sight(&target->pos, target->rooms, &chr->prop->pos, distance, CDTYPE_BG);
|
||||
}
|
||||
|
||||
f32 func0f04c784(struct chrdata *chr)
|
||||
f32 chr_get_angle_from_targets_pov(struct chrdata *chr)
|
||||
{
|
||||
f32 targetfacingangle = 0;
|
||||
u32 stack;
|
||||
@@ -15743,11 +15743,11 @@ f32 func0f04c784(struct chrdata *chr)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3, u8 arg4)
|
||||
bool chr_flank(struct chrdata *chr, u32 angle360, struct coord *pos, u8 use_closest_side, u8 goposflags)
|
||||
{
|
||||
struct prop *target = chr_get_target_prop(chr);
|
||||
f32 sqdist = 0;
|
||||
f32 f24 = func0f04c784(chr);
|
||||
f32 targets_pov_angle = chr_get_angle_from_targets_pov(chr);
|
||||
f32 cosine;
|
||||
f32 sine;
|
||||
struct coord chrpos;
|
||||
@@ -15773,8 +15773,8 @@ bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3,
|
||||
angle360f -= 360;
|
||||
}
|
||||
|
||||
angle360f -= f24;
|
||||
angle360f *= 0.017450513318181f;
|
||||
angle360f -= targets_pov_angle;
|
||||
angle360f *= M_BADPI / 180.0f;
|
||||
|
||||
cosine = cosf(angle360f);
|
||||
sine = sinf(angle360f);
|
||||
@@ -15828,7 +15828,7 @@ bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3,
|
||||
}
|
||||
}
|
||||
|
||||
if (arg3) {
|
||||
if (use_closest_side) {
|
||||
xdiff = chrpos.x - pos->x;
|
||||
ydiff = chrpos.y - pos->y;
|
||||
zdiff = chrpos.z - pos->z;
|
||||
@@ -15841,7 +15841,7 @@ bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3,
|
||||
|
||||
angle360 = 360 - angle360;
|
||||
again = true;
|
||||
arg3 = 0;
|
||||
use_closest_side = 0;
|
||||
} else {
|
||||
again = false;
|
||||
}
|
||||
@@ -15862,7 +15862,7 @@ bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3,
|
||||
}
|
||||
}
|
||||
|
||||
chr_go_to_pos(chr, pos, arg4);
|
||||
chr_go_to_pos(chr, pos, goposflags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ bool (*g_CommandPointers[])(void) = {
|
||||
/*0x0136*/ ai_retreat,
|
||||
/*0x0137*/ ai_if_chr_in_squadron_doing_action,
|
||||
/*0x0138*/ ai_if_channel_free,
|
||||
/*0x0139*/ ai0139,
|
||||
/*0x0139*/ ai_flank,
|
||||
/*0x013a*/ ai_set_chr_preset_to_unalerted_teammate,
|
||||
/*0x013b*/ ai_set_squadron,
|
||||
/*0x013c*/ ai_face_cover,
|
||||
|
||||
@@ -7408,13 +7408,13 @@ bool ai_if_chr_in_squadron_doing_action(void)
|
||||
/**
|
||||
* @cmd 0139
|
||||
*/
|
||||
bool ai0139(void)
|
||||
bool ai_flank(void)
|
||||
{
|
||||
u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
|
||||
u32 angle = (cmd[3] << 16) | (cmd[4] << 8) | cmd[5] | (cmd[2] << 24);
|
||||
struct coord pos;
|
||||
|
||||
chr0f04c874(g_Vars.chrdata, angle, &pos, cmd[7], cmd[6]);
|
||||
chr_flank(g_Vars.chrdata, angle, &pos, cmd[7], cmd[6]);
|
||||
|
||||
g_Vars.aioffset += 8;
|
||||
|
||||
|
||||
+4
-4
@@ -1968,7 +1968,7 @@ u8 func0007_alerted[] = {
|
||||
label(0x13)
|
||||
dprint 'F','L','A','N','K',' ','B','E','S','T','\n',0,
|
||||
unset_self_flag_bankx(CHRFLAG1_DODGED, BANK_1)
|
||||
cmd0139(25, 0x02, TRUE)
|
||||
flank(25, GOPOSFLAG_RUN, TRUE)
|
||||
if_self_flag_bankx_eq(CHRFLAG0_CAN_FLANK, FALSE, BANK_0, /*goto*/ 0x16)
|
||||
set_team_orders(MA_FLANKLEFT, /*goto*/ 0x16)
|
||||
set_team_orders(MA_FLANKRIGHT, /*goto*/ 0x16)
|
||||
@@ -1979,7 +1979,7 @@ u8 func0007_alerted[] = {
|
||||
label(LABEL_FLANK_LEFT)
|
||||
dprint 'F','L','A','N','K',' ','L','E','F','T','\n',0,
|
||||
set_action(MA_FLANKLEFT, FALSE)
|
||||
cmd0139(335, 0x02, FALSE)
|
||||
flank(335, GOPOSFLAG_RUN, FALSE)
|
||||
if_self_flag_bankx_eq(CHRFLAG0_CAN_FLANK, FALSE, BANK_0, /*goto*/ 0x16)
|
||||
set_team_orders(MA_FLANKLEFT, /*goto*/ 0x16)
|
||||
|
||||
@@ -1993,7 +1993,7 @@ u8 func0007_alerted[] = {
|
||||
set_team_orders(MA_FLANKRIGHT, /*goto*/ 0x16)
|
||||
|
||||
label(0x16)
|
||||
cmd0139(25, 0x02, FALSE)
|
||||
flank(25, GOPOSFLAG_RUN, FALSE)
|
||||
|
||||
label(0x33)
|
||||
set_self_flag_bankx(CHRFLAG1_FLANKED, BANK_1)
|
||||
@@ -5560,7 +5560,7 @@ u8 func0023_dodge[] = {
|
||||
|
||||
// Unreachable
|
||||
label(0xbb)
|
||||
cmd0139(25, 0x01, TRUE)
|
||||
flank(25, GOPOSFLAG_JOG, TRUE)
|
||||
goto_next(0x2c)
|
||||
|
||||
// Was able to start dodge
|
||||
|
||||
+14
-10
@@ -3002,18 +3002,22 @@
|
||||
channel, \
|
||||
label,
|
||||
|
||||
// value is either 25, 70 or 335.
|
||||
// u1 is either 1 or 2.
|
||||
// It seems related to the chr's prop properties
|
||||
// Used by G5 cloaked guards, Deep Sea cloaked purple guards and globals.c
|
||||
// I think this is related to flanking, where the value arg is the angle
|
||||
// relative to the player's direction. 335 is the same as 25 degress to the
|
||||
// right (360 - 25).
|
||||
#define cmd0139(angle, u1, bool) \
|
||||
/**
|
||||
* Make the guard flank their target.
|
||||
*
|
||||
* The angle argument is in degrees (0-360). It determines the position that
|
||||
* they will run to, relative to the target's point of view. If the position is
|
||||
* out of bounds or there's no direct line to it then the position is shortened
|
||||
* to what is achievable.
|
||||
*
|
||||
* If use_closest_side is TRUE, the other side will also be tested.
|
||||
* The position closest to the chr's current position is used.
|
||||
*/
|
||||
#define flank(angle, goposflags, use_closest_side) \
|
||||
mkshort(0x0139), \
|
||||
mkword(angle), \
|
||||
u1, \
|
||||
bool,
|
||||
goposflags, \
|
||||
use_closest_side,
|
||||
|
||||
/**
|
||||
* Set the current chr's chrpreset to an unalerted teammate. The teammate must
|
||||
|
||||
@@ -208,8 +208,8 @@ bool chr_check_cover_out_of_sight(struct chrdata *chr, s32 covernum, bool soft);
|
||||
s32 chr_assign_cover_by_criteria(struct chrdata *chr, u16 arg1, s32 arg2);
|
||||
s32 chr_assign_cover_away_from_danger(struct chrdata *chr, s32 mindist, s32 maxdist);
|
||||
bool chr_run_from_pos(struct chrdata *chr, u32 goposflags, f32 distance, struct coord *frompos);
|
||||
f32 func0f04c784(struct chrdata *chr);
|
||||
bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3, u8 arg4);
|
||||
f32 chr_get_angle_from_targets_pov(struct chrdata *chr);
|
||||
bool chr_flank(struct chrdata *chr, u32 angle360, struct coord *pos, u8 use_closest_side, u8 goposflags);
|
||||
void rebuild_teams(void);
|
||||
void rebuild_squadrons(void);
|
||||
void chr_avoid(struct chrdata *chr);
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
/*0x0136*/ bool ai_retreat(void);
|
||||
/*0x0137*/ bool ai_if_chr_in_squadron_doing_action(void);
|
||||
/*0x0138*/ bool ai_if_channel_free(void);
|
||||
/*0x0139*/ bool ai0139(void);
|
||||
/*0x0139*/ bool ai_flank(void);
|
||||
/*0x013a*/ bool ai_set_chr_preset_to_unalerted_teammate(void);
|
||||
/*0x013b*/ bool ai_set_squadron(void);
|
||||
/*0x013c*/ bool ai_face_cover(void);
|
||||
|
||||
@@ -2293,7 +2293,7 @@ u8 func0412_cloak_guard[] = {
|
||||
set_target_chr(CHR_P1P2)
|
||||
label(0x06)
|
||||
restart_timer
|
||||
cmd0139(70, 0x02, TRUE)
|
||||
flank(70, GOPOSFLAG_RUN, TRUE)
|
||||
|
||||
// Wait 3 seconds or until stopped
|
||||
beginloop(0x55)
|
||||
|
||||
@@ -3163,7 +3163,7 @@ u8 func041d_sniper[] = {
|
||||
// Alive
|
||||
label(0x03)
|
||||
restart_timer
|
||||
cmd0139(70, 0x02, TRUE)
|
||||
flank(70, GOPOSFLAG_RUN, TRUE)
|
||||
|
||||
beginloop(0x63)
|
||||
chr_toggle_p1p2(CHR_SELF)
|
||||
|
||||
Reference in New Issue
Block a user