Decompile chrGetDistanceLostToTargetInLastSecond and discover commands if_target_moving_slowly, if_target_moving_away and if_target_moving_closer

This commit is contained in:
Ryan Dwyer
2020-01-17 17:10:31 +10:00
parent bf77f6f9c0
commit 266d29a923
11 changed files with 78 additions and 132 deletions
+23 -10
View File
@@ -2503,22 +2503,35 @@
score, \
label,
// If value is nonzero then it's an chr ID. If zero then use current chr.
// This means chr ID 0 cannot be used. In practice, this command is only
// called once and it has value 0.
#define if_something_hypotenuse(value, label) \
/**
* Checks if the distance change from the current chr to the chr's target has
* not changed by more than 50 units since 1 second ago. In other words, if the
* distance between the two is somewhat constant (eg. they are both not moving
* much).
*
* It's used to decide whether to throw grenades or not.
*
* If chr is zero, compare the current chr and their target.
* If chr is non-zero, compare the given chr and their target.
*/
#define if_target_moving_slowly(chr, label) \
mkshort(0x012a), \
value, \
chr, \
label,
// Checks if the chr is within 50 units of something
#define if_something_chicago_robot(label) \
/**
* Checks if the distance between the chr and their target has decreased by at
* least 50 units in the last second.
*/
#define if_target_moving_closer(label) \
mkshort(0x012b), \
label,
// Does some math on chr's bdlist, possibly involving square roots.
// If result is > 50, goto label
#define if_distance_to_home_gt_50_maybe(label) \
/**
* Checks if the distance between the chr and their target has increased by at
* least 50 units in the last second.
*/
#define if_target_moving_away(label) \
mkshort(0x012c), \
label,
+2 -2
View File
@@ -395,8 +395,8 @@ u32 func0f04ba34(struct chrdata *chr, u16 arg1, u32 arg2);
u32 func0f04bffc(struct chrdata *chr, u32 arg1, u32 arg2);
s16 func0f04c268(struct chrdata *chr, u8 speed);
u32 func0f04c2e8(void);
u32 func0f04c444(void);
s32 func0f04c580(struct chrdata *chr);
void chrAddTargetToBdlist(struct chrdata *chr);
s32 chrGetDistanceLostToTargetInLastSecond(struct chrdata *chr);
bool func0f04c6b4(struct chrdata *chr, u32 distance);
bool func0f04c71c(struct chrdata *chr, u32 distance);
u32 func0f04c784(void);
+3 -3
View File
@@ -298,9 +298,9 @@
/*0x0127*/ bool ai0127(void);
/*0x0128*/ bool ai0128(void);
/*0x0129*/ bool ai0129(void);
/*0x012a*/ bool ai012a(void);
/*0x012b*/ bool ai012b(void);
/*0x012c*/ bool ai012c(void);
/*0x012a*/ bool aiIfTargetMovingSlowly(void);
/*0x012b*/ bool aiIfTargetMovingCloser(void);
/*0x012c*/ bool aiIfTargetMovingAway(void);
/*0x012f*/ bool ai012f(void);
/*0x0130*/ bool ai0130(void);
/*0x0131*/ bool ai0131(void);