Document ch/bat

This commit is contained in:
Banjo Kazooie
2024-09-28 14:30:14 -05:00
parent acbedad7fa
commit 65951ae11e
4 changed files with 128 additions and 125 deletions

View File

@@ -892,7 +892,7 @@ segments:
# - [0x102BF60, c, code_D6600] #DONE
# - [0x102C9A0, c, ch/termite] #DONE
# - [0x102D670, c, ch/gravestone] #DONE
# - [0x102E340, c, code_D89E0]
# - [0x102E340, c, ch/bat]
# - [0x102F700, c, ch/whipcrack] #DONE
# - [0x102FD00, c, code_DA3A0] #DONE
# - [0x10300C0, c, code_DA760] #DONE
@@ -1114,7 +1114,7 @@ segments:
# - [0x1041870, .data, code_D6600]
# - [0x10418E0, .data, ch/termite]
# - [0x1041950, .data, ch/gravestone]
# - [0x1041A60, .data, code_D89E0]
# - [0x1041A60, .data, ch/bat]
# - [0x1041AD0, .data, ch/whipcrack]
# - [0x1041B00, .data, code_DA3A0]
# - [0x1041B80, .data, code_DA760]
@@ -1367,8 +1367,8 @@ segments:
# - [0x1048240, .rodata, code_D6600]
# - [0x1048280, .rodata, ch/termite]
# - [0x10482F0, .rodata, ch/gravestone]
# - [0x1048390, .rodata, code_D89E0]
# - [0x10483C0, .rodata, code_D89E0]
# - [0x1048390, .rodata, ch/bat]
# - [0x10483C0, .rodata, ch/bat]
# - [0x1048430, .rodata, ch/whipcrack]
# - [0x1048450, .rodata, code_DA3A0]
# - [0x1048460, .rodata, code_DA760]

View File

@@ -892,7 +892,7 @@ segments:
- [0x102BF60, c, code_D6600] #DONE
- [0x102C9A0, c, ch/termite] #DONE
- [0x102D670, c, ch/gravestone] #DONE
- [0x102E340, c, code_D89E0]
- [0x102E340, c, ch/bat]
- [0x102F700, c, ch/whipcrack] #DONE
- [0x102FD00, c, code_DA3A0] #DONE
- [0x10300C0, c, code_DA760] #DONE
@@ -1113,7 +1113,7 @@ segments:
- [0x1041870, .data, code_D6600]
- [0x10418E0, .data, ch/termite]
- [0x1041950, .data, ch/gravestone]
- [0x1041A60, .data, code_D89E0]
- [0x1041A60, .data, ch/bat]
- [0x1041AD0, .data, ch/whipcrack]
- [0x1041B00, .data, code_DA3A0]
- [0x1041B80, .data, code_DA760]
@@ -1365,8 +1365,8 @@ segments:
- [0x1048240, .rodata, code_D6600]
- [0x1048280, .rodata, ch/termite]
- [0x10482F0, .rodata, ch/gravestone]
- [0x1048390, .rodata, code_D89E0]
- [0x10483C0, .rodata, code_D89E0]
- [0x1048390, .rodata, ch/bat]
- [0x10483C0, .rodata, ch/bat]
- [0x1048430, .rodata, ch/whipcrack]
- [0x1048450, .rodata, code_DA3A0]
- [0x1048460, .rodata, code_DA760]

View File

@@ -6,15 +6,26 @@
extern f32 mapModel_getFloorY(f32[3]);
extern f32 func_80257204(f32, f32, f32, f32);
typedef struct {
f32 unk0;
f32 unk4;
} ActorLocal_Core2_D89E0;
typedef enum {
CH_BAT_STATE_ROOSTING = 1,
CH_BAT_STATE_EXIT_ROOST = 2,
CH_BAT_STATE_CHASE = 3,
CH_BAT_STATE_ROAM = 4,
CH_BAT_STATE_FLY_HOME = 5,
CH_BAT_STATE_ENTER_ROOST = 6,
CH_BAT_STATE_FALL = 7,
CH_BAT_STATE_DIE = 8
} ChBatState;
void func_80360828(Actor *this);
typedef struct {
f32 cooldown; //cooldown timer after attacking the player
f32 roost_yaw;
} ChBatLocal;
void chbat_update(Actor *this);
/* .data */
ActorAnimationInfo D_80373090[] = {
ActorAnimationInfo sChBatAnimations[] = {
{0, 0.0f},
{ ASSET_AE_ANIM_BAT_ROOST, 12.0f},
{ ASSET_AD_ANIM_BAT_TAKE_FLIGHT, 0.3f},
@@ -26,53 +37,53 @@ ActorAnimationInfo D_80373090[] = {
{ ASSET_2AA_ANIM_BAT_DIE, 0.85f},
};
ActorInfo D_803730D8 = {
ActorInfo gChBat = {
MARKER_127_BAT, ACTOR_163_BAT, ASSET_3CA_MODEL_BAT,
0x1, D_80373090,
func_80360828, func_80326224, actor_draw,
CH_BAT_STATE_ROOSTING, sChBatAnimations,
chbat_update, func_80326224, actor_draw,
2500, 0, 0.9f, 0
};
/* .code */
void func_8035F970(Actor *this){
subaddie_set_state(this, 1);
void chbat_roost(Actor *this){
subaddie_set_state(this, CH_BAT_STATE_ROOSTING);
actor_loopAnimation(this);
}
void func_8035F99C(Actor *this){
void chbat_exitRoost(Actor *this){
if(!volatileFlag_get(VOLATILE_FLAG_C1_IN_FINAL_CHARACTER_PARADE)){
subaddie_set_state_with_direction(this, 2, 0.01f, 1);
subaddie_set_state_with_direction(this, CH_BAT_STATE_EXIT_ROOST, 0.01f, 1);
actor_playAnimationOnce(this);
this->actor_specific_1_f = 5.0f;
FUNC_8030E8B4(SFX_419_UNKNOWN, 1.0f, 28000, this->position, 0x4e2, 0x9c4);
}
}
void func_8035FA0C(Actor *this){
subaddie_set_state(this, 3);
void chbat_chase(Actor *this){
subaddie_set_state(this, CH_BAT_STATE_CHASE);
actor_loopAnimation(this);
this->actor_specific_1_f = 5.0f;
}
void func_8035FA48(Actor *this){
subaddie_set_state(this, 4);
void chbat_roam(Actor *this){
subaddie_set_state(this, CH_BAT_STATE_ROAM);
actor_loopAnimation(this);
}
void func_8035FA74(Actor *this){
ActorLocal_Core2_D89E0 *local = (ActorLocal_Core2_D89E0 *)&this->local;
this->yaw_ideal = local->unk4;
subaddie_set_state(this, 5);
void chbat_flyHome(Actor *this){
ChBatLocal *local = (ChBatLocal *)&this->local;
this->yaw_ideal = local->roost_yaw;
subaddie_set_state(this, CH_BAT_STATE_FLY_HOME);
actor_loopAnimation(this);
}
void func_8035FAA8(Actor *this){
subaddie_set_state_with_direction(this, 6, 0.99f, 0);
void chbat_enterRoost(Actor *this){
subaddie_set_state_with_direction(this, CH_BAT_STATE_ENTER_ROOST, 0.99f, 0);
actor_playAnimationOnce(this);
}
void func_8035FAE0(Actor *this){
subaddie_set_state_with_direction(this, 7, 0.01f, 1);
void chBat_fall(Actor *this){
subaddie_set_state_with_direction(this, CH_BAT_STATE_FALL, 0.01f, 1);
actor_loopAnimation(this);
this->yaw += 180.0f;
this->actor_specific_1_f = 20.0f;
@@ -80,7 +91,7 @@ void func_8035FAE0(Actor *this){
}
int func_8035FB48(Actor * this, s32 dist){
int chbat_isWithinHorzontalRadiusOfHome(Actor * this, s32 dist){
f32 f0 = this->position_x - this->unk1C_x;
f32 f2 = this->position_z - this->unk1C_z;
if(f0*f0 + f2*f2 < dist*dist)
@@ -89,7 +100,7 @@ int func_8035FB48(Actor * this, s32 dist){
return 0;
}
bool func_8035FBA8(Actor *arg0, s32 arg1) {
bool chbat_nearHome(Actor *arg0, s32 arg1) {
if( (arg0->position[1] < ( arg0->unk1C[1] + 0.5))
&& (( arg0->unk1C[1] - 0.5) < arg0->position[1])
) {
@@ -98,17 +109,17 @@ bool func_8035FBA8(Actor *arg0, s32 arg1) {
return FALSE;
}
void func_8035FC20(Actor *this, f32 arg1, f32 arg2){
if(this->position[1] < arg1){
this->position[1] += arg2;
if(arg1 < this->position[1]){
this->position[1] = arg1;
void chBat_updateHeight(Actor *this, f32 target_height, f32 velocity){
if(this->position[1] < target_height){
this->position[1] += velocity;
if(target_height < this->position[1]){
this->position[1] = target_height;
}
}
else if(arg1 < this->position[1]){
this->position[1] -= arg2;
if(this->position[1] < arg1){
this->position[1] = arg1;
else if(target_height < this->position[1]){
this->position[1] -= velocity;
if(this->position[1] < target_height){
this->position[1] = target_height;
}
}
}
@@ -121,13 +132,8 @@ bool func_8035FC98(Actor *this, f32 arg1){
if(this->unk38_0)
return FALSE;
sp28[0] = this->position[0];
sp28[1] = this->position[1];
sp28[2] = this->position[2];
sp1C[0] = sp28[0];
sp1C[1] = sp28[1];
sp1C[2] = sp28[2];
TUPLE_COPY(sp28, this->position);
TUPLE_COPY(sp1C, sp28);
sp1C[1] += arg1;
if (func_80309B48(sp28, sp1C, sp34, 0x5E0000) != NULL)
@@ -145,7 +151,7 @@ bool func_8035FD28(Actor *this){
return TRUE;
}
bool func_8035FDA4(Actor *this) {
bool chbat_nearPlayer(Actor *this) {
f32 sp24[3];
player_getPosition(sp24);
@@ -205,17 +211,17 @@ void func_8035FFAC(Actor *this, f32 arg1){
}
}
void func_80360044(Actor *this) {
f32 var_f0;
void chbat_updateFlyingRoll(Actor *this) {
f32 d_yaw;
var_f0 = this->yaw_ideal - this->yaw;
if (var_f0 >= 180.0f) {
var_f0 -= 360.0f;
d_yaw = this->yaw_ideal - this->yaw;
if (d_yaw >= 180.0f) {
d_yaw -= 360.0f;
}
if (var_f0 < -180.0f) {
var_f0 += 360.0f;
if (d_yaw < -180.0f) {
d_yaw += 360.0f;
}
this->velocity[2] = -var_f0;
this->velocity[2] = -d_yaw;
if (( this->roll < this->velocity[2]) && ( this->roll < 55.0f)) {
this->roll += 2.0f;
}
@@ -224,7 +230,7 @@ void func_80360044(Actor *this) {
}
}
void func_80360130(Actor *this){
void chbat_updateRollTowardsZero(Actor *this){
if(0.0f < this->roll){
this->roll -= 2.0;
}
@@ -236,11 +242,11 @@ void func_80360130(Actor *this){
bool func_80360198(Actor *this) {
f32 var_f16;
f64 temp_f0;
f64 var_f0;
f64 var_f0_2;
f64 d_yaw;
f64 d_yaw_2;
func_80328FB0(this, 5.0f);
func_80360044(this);
chbat_updateFlyingRoll(this);
this->actor_specific_1_f += (this->velocity[1] * 0.45) - (0.001 * this->actor_specific_1_f);
if (this->actor_specific_1_f > 13.0) {
this->actor_specific_1_f = 13.0f;
@@ -279,24 +285,22 @@ f32 func_803603AC(Actor *this, s32 arg1, u8 arg2){
f32 dy;
f32 D1, D2;
f32 unused;
f32 sp20[3];
f32 player_position[3];
switch (arg2) {
case 1:
player_getPosition(sp20);
player_getPosition(player_position);
break;
case 2:
sp20[0] = this->unk1C[0];
sp20[1] = this->unk1C[1];
sp20[2] = this->unk1C[2];
TUPLE_COPY(player_position, this->unk1C);
break;
}
D1 = SQ(this->position[0] - sp20[0]);
D2 = SQ(this->position[2] - sp20[2]);
D1 = SQ(this->position[0] - player_position[0]);
D2 = SQ(this->position[2] - player_position[2]);
dy = this->position[1] - sp20[1] - arg1;
dy = this->position[1] - player_position[1] - arg1;
if(dy == 0.0 || D1 + D2 == 0.0)
return 0.0f;
@@ -322,18 +326,19 @@ int func_803604E8(Actor *this){
return 1;
}
bool func_8036054C(Actor *this) {
bool chbat_updateRoam(Actor *this) {
s32 phi_v0;
s32 phi_s1;
s32 phi_s2;
if (this->lifetime_value == 0.0f) {
// fly towards home if lifetime is done
this->yaw_ideal = func_80257204(this->position[0], this->position[2], this->unk1C[0], this->unk1C[2]);
func_8035FFAC(this, func_803603AC(this, -110, 2));
}
else{
func_80328FB0(this, 5.0f);
func_80360044(this);
func_80328FB0(this, 5.0f); //update yaw
chbat_updateFlyingRoll(this);
if (func_80329480(this) != 0) {
this->lifetime_value = 0.0f;
} else {
@@ -346,9 +351,9 @@ bool func_8036054C(Actor *this) {
phi_s1 = 0;
do{
if (this->unk38_0) {
phi_v0 = func_80329140(this, (s32) this->yaw_ideal, 0xC8);
phi_v0 = func_80329140(this, (s32) this->yaw_ideal, 200);
} else {
phi_v0 = func_80329078(this, (s32) this->yaw_ideal, 0xC8);
phi_v0 = func_80329078(this, (s32) this->yaw_ideal, 200);
}
if(phi_v0 == 0){
@@ -371,64 +376,62 @@ bool func_8036054C(Actor *this) {
return TRUE;
}
void func_80360790(ActorMarker *this_marker, ActorMarker *other_marker){
void chBat_dieCollision(ActorMarker *this_marker, ActorMarker *other_marker){
Actor *this = marker_getActor(this_marker);
ActorLocal_Core2_D89E0 *local = (ActorLocal_Core2_D89E0 *)&this->local;
func_8035FAE0(this);
local->unk0 = 0.0f;
ChBatLocal *local = (ChBatLocal *)&this->local;
chBat_fall(this);
local->cooldown = 0.0f;
this->marker->collidable = FALSE;
FUNC_8030E8B4(SFX_115_BUZZBOMB_DEATH, 1.3f, 26000, this->position, 1250, 2500);
}
void func_803607FC(ActorMarker *this_marker, ActorMarker *other_marker){
void chBat_attackCollision(ActorMarker *this_marker, ActorMarker *other_marker){
Actor *this = marker_getActor(this_marker);
ActorLocal_Core2_D89E0 *local = (ActorLocal_Core2_D89E0 *)&this->local;
local->unk0 = 0.8f;
ChBatLocal *local = (ChBatLocal *)&this->local;
local->cooldown = 0.8f;
}
void func_80360828(Actor *this){
f32 sp3C = time_getDelta();
ActorLocal_Core2_D89E0 *local = (ActorLocal_Core2_D89E0 *)&this->local;
void chbat_update(Actor *this){
f32 dt = time_getDelta();
ChBatLocal *local = (ChBatLocal *)&this->local;
f32 sp34;
if(!this->initialized){
this->initialized = TRUE;
marker_setCollisionScripts(this->marker, NULL, func_803607FC, func_80360790);
marker_setCollisionScripts(this->marker, NULL, chBat_attackCollision, chBat_dieCollision);
this->unk38_0 = FALSE;
this->actor_specific_1_f = 0.0f;
this->velocity_x = 0.0f;
this->unk1C_x = this->position_x;
this->unk1C_y = this->position_y;
this->unk1C_z = this->position_z;
local->unk4 = this->yaw;
TUPLE_COPY(this->unk1C, this->position); // set roost position
local->roost_yaw = this->yaw;
}
if(local->unk0 <= 0.0){
local->unk0 = 0.0f;
if(local->cooldown <= 0.0){
local->cooldown = 0.0f;
}else{//L80360910
local->unk0 -= sp3C;
local->cooldown -= dt;
return;
}
switch(this->state){
case 1: //L80360918
if(func_8035FDA4(this)){
func_8035F99C(this);
case CH_BAT_STATE_ROOSTING: //L80360918
if(chbat_nearPlayer(this)){
chbat_exitRoost(this);
}
break;
case 2: //L80360938
case CH_BAT_STATE_EXIT_ROOST: //L80360938
if( 0.98 < animctrl_getAnimTimer(this->animctrl)
|| !func_8035FD28(this)
){
func_8035FA0C(this);
chbat_chase(this);
}
break;
case 3: //L8036097C
case CH_BAT_STATE_CHASE: //L8036097C
animctrl_setDuration(this->animctrl, 1.2 - this->velocity_y);
if(!func_8035FDA4(this)){
func_8035FA48(this);
if(!chbat_nearPlayer(this)){
chbat_roam(this);
}
else if(!func_803604E8(this)){
func_8035FA48(this);
chbat_roam(this);
this->unk38_31 = 0x3C;
}
else{
@@ -442,45 +445,45 @@ void func_80360828(Actor *this){
func_8030E878(SFX_2_CLAW_SWIPE, randf2(1.0f, 1.2f), 10000, this->position, 833.0f, 2500.0f);
}
break;
case 4: //L80360A9C
if(func_8035FDA4(this)){
func_8035FA0C(this);
} else if(func_8035FB48(this, 0x14)){
func_8035FA74(this);
case CH_BAT_STATE_ROAM: //L80360A9C
if(chbat_nearPlayer(this)){
chbat_chase(this);
} else if(chbat_isWithinHorzontalRadiusOfHome(this, 20)){
chbat_flyHome(this);
} else{
func_8036054C(this);
chbat_updateRoam(this);
}//L80360AE8
if(actor_animationIsAt(this, 0.5f)){
func_8030E878(SFX_2_CLAW_SWIPE, randf2(1.0f, 1.2f), 10000, this->position, 833.0f, 2500.0f);
}
break;
case 5: //L80360B3C
if(func_8035FDA4(this)){
func_8035FA0C(this);
} else if(func_8035FBA8(this, 1)){
func_8035FAA8(this);
case CH_BAT_STATE_FLY_HOME: //L80360B3C
if(chbat_nearPlayer(this)){
chbat_chase(this);
} else if(chbat_nearHome(this, 1)){
chbat_enterRoost(this);
} else{
func_80328FB0(this, 5.0f);
func_8035FC20(this, this->unk1C_y, 2.0f);
func_80360130(this);
}//L80360BA0
chBat_updateHeight(this, this->unk1C_y, 2.0f);
chbat_updateRollTowardsZero(this);
}
if(actor_animationIsAt(this, 0.5f)){
func_8030E878(SFX_2_CLAW_SWIPE, randf2(1.0f, 1.2f), 10000, this->position, 833.0f, 2500.0f);
}
break;
case 6: //L80360BF4
case CH_BAT_STATE_ENTER_ROOST:
if(animctrl_getAnimTimer(this->animctrl) < 0.01){
func_8035F970(this);
chbat_roost(this);
}
break;
case 7: //L80360C28
case CH_BAT_STATE_FALL: //L80360C28
sp34 = time_getDelta();
func_8032CA80(this, this->unk38_0 ? 0x13 : 0x4);
if(func_8035FC98(this, this->velocity_x * sp34)){
this->position_y = mapModel_getFloorY(this->position);
subaddie_set_state_with_direction(this, 8, 0.01f, 1);
subaddie_set_state_with_direction(this, CH_BAT_STATE_DIE, 0.01f, 1);
actor_playAnimationOnce(this);
func_8030E6A4(SFX_1F_HITTING_AN_ENEMY_3, 1.2f, 32200);
}
@@ -489,7 +492,7 @@ void func_80360828(Actor *this){
this->velocity_x -= 1600.0f * sp34;
}
break;
case 8: //L80360CF0
case CH_BAT_STATE_DIE: //L80360CF0
if(actor_animationIsAt(this, 0.3f)){
func_80326310(this);
}

View File

@@ -149,7 +149,7 @@ extern ActorInfo D_80372EE0;
extern ActorInfo chTermite; //ticker
extern ActorInfo D_80372FC0;
extern ActorInfo D_80372FE4;
extern ActorInfo D_803730D8; //nibbly
extern ActorInfo gChBat; //nibbly
extern ActorInfo D_80373100;
extern ActorInfo D_80373134;
extern ActorInfo D_80373158;
@@ -335,7 +335,7 @@ void spawnQueue_reset(void){
spawnableActorList_addIfMapVisited(&D_80372C18, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_3 | ACTOR_FLAG_UNKNOWN_5 | ACTOR_FLAG_UNKNOWN_7 | ACTOR_FLAG_UNKNOWN_8 | ACTOR_FLAG_UNKNOWN_12 | ACTOR_FLAG_UNKNOWN_17, MAP_1B_MMM_MAD_MONSTER_MANSION); //teehee
spawnableActorList_addIfMapVisited(&D_80372FC0, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_16 | ACTOR_FLAG_UNKNOWN_25, MAP_1B_MMM_MAD_MONSTER_MANSION);
spawnableActorList_addIfMapVisited(&D_80372FE4, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_10 | ACTOR_FLAG_UNKNOWN_16 | ACTOR_FLAG_UNKNOWN_25, MAP_1B_MMM_MAD_MONSTER_MANSION);
spawnableActorList_addIfMapVisited(&D_803730D8, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_5 | ACTOR_FLAG_UNKNOWN_21 |ACTOR_FLAG_UNKNOWN_25, MAP_1B_MMM_MAD_MONSTER_MANSION); //nibbly
spawnableActorList_addIfMapVisited(&gChBat, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_5 | ACTOR_FLAG_UNKNOWN_21 |ACTOR_FLAG_UNKNOWN_25, MAP_1B_MMM_MAD_MONSTER_MANSION); //nibbly
spawnableActorList_addIfMapVisited(&D_80367130, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_3 | ACTOR_FLAG_UNKNOWN_5 | ACTOR_FLAG_UNKNOWN_7 | ACTOR_FLAG_UNKNOWN_8 | ACTOR_FLAG_UNKNOWN_11 | ACTOR_FLAG_UNKNOWN_25, MAP_D_BGS_BUBBLEGLOOP_SWAMP); //buzzbomb
spawnableActorList_addIfMapVisited(&D_80372B80, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_6 | ACTOR_FLAG_UNKNOWN_8 | ACTOR_FLAG_UNKNOWN_17 | ACTOR_FLAG_UNKNOWN_25, MAP_27_FP_FREEZEEZY_PEAK);
spawnableActorList_addIfMapVisited(&chShrapnelDescription, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_8 | ACTOR_FLAG_UNKNOWN_25, MAP_7_TTC_TREASURE_TROVE_COVE); //scrapnel