mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
Bomb-Omb Buddy sanity improvement (#51)
This commit is contained in:
parent
a1af1c2ffb
commit
e52173f109
5 changed files with 65 additions and 19 deletions
2
Makefile
2
Makefile
|
@ -1469,4 +1469,4 @@ MAKEFLAGS += --no-builtin-rules
|
||||||
|
|
||||||
-include $(DEP_FILES)
|
-include $(DEP_FILES)
|
||||||
|
|
||||||
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
|
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
|
|
@ -301,25 +301,26 @@ void bhv_bobomb_buddy_init(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void bobomb_buddy_act_idle(void) {
|
void bobomb_buddy_act_idle(void) {
|
||||||
UNUSED u8 filler[4];
|
s16 animFrame = o->header.gfx.animInfo.animFrame;
|
||||||
s16 sp1a = o->header.gfx.animInfo.animFrame;
|
|
||||||
UNUSED s16 collisionFlags = 0;
|
|
||||||
|
|
||||||
o->oBobombBuddyPosXCopy = o->oPosX;
|
o->oBobombBuddyPosXCopy = o->oPosX;
|
||||||
o->oBobombBuddyPosYCopy = o->oPosY;
|
o->oBobombBuddyPosYCopy = o->oPosY;
|
||||||
o->oBobombBuddyPosZCopy = o->oPosZ;
|
o->oBobombBuddyPosZCopy = o->oPosZ;
|
||||||
|
|
||||||
collisionFlags = object_step();
|
object_step();
|
||||||
|
|
||||||
if ((sp1a == 5) || (sp1a == 16))
|
if ((animFrame == 5) || (animFrame == 16)) {
|
||||||
cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK);
|
cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK);
|
||||||
|
}
|
||||||
|
|
||||||
struct Object* player = nearest_player_to_object(o);
|
struct Object* player = nearest_player_to_object(o);
|
||||||
if (dist_between_objects(o, player) < 1000.0f)
|
if (dist_between_objects(o, player) < 1000.0f) {
|
||||||
o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, obj_angle_to_object(o, player), 0x140);
|
o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, obj_angle_to_object(o, player), 0x140);
|
||||||
|
}
|
||||||
|
|
||||||
if (o->oInteractStatus == INT_STATUS_INTERACTED)
|
if (o->oInteractStatus == INT_STATUS_INTERACTED) {
|
||||||
o->oAction = BOBOMB_BUDDY_ACT_TURN_TO_TALK;
|
o->oAction = BOBOMB_BUDDY_ACT_TURN_TO_TALK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -345,24 +346,27 @@ void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText) {
|
||||||
forceCannonOpen = FALSE;
|
forceCannonOpen = FALSE;
|
||||||
|
|
||||||
cannonClosed = cur_obj_nearest_object_with_behavior(bhvCannonClosed);
|
cannonClosed = cur_obj_nearest_object_with_behavior(bhvCannonClosed);
|
||||||
if (cannonClosed != 0)
|
if (cannonClosed != 0) {
|
||||||
o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_OPENING;
|
o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_OPENING;
|
||||||
else
|
} else {
|
||||||
o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_STOP_TALKING;
|
o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_STOP_TALKING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BOBOMB_BUDDY_CANNON_OPENING:
|
case BOBOMB_BUDDY_CANNON_OPENING:
|
||||||
cannonClosed = cur_obj_nearest_object_with_behavior(bhvCannonClosed);
|
cannonClosed = cur_obj_nearest_object_with_behavior(bhvCannonClosed);
|
||||||
cutscene = cutscene_object(CUTSCENE_PREPARE_CANNON, cannonClosed);
|
cutscene = cutscene_object(CUTSCENE_PREPARE_CANNON, cannonClosed);
|
||||||
if (cutscene == -1)
|
if (cutscene == -1) {
|
||||||
o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_OPENED;
|
o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_OPENED;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BOBOMB_BUDDY_CANNON_OPENED:
|
case BOBOMB_BUDDY_CANNON_OPENED:
|
||||||
buddyText = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogSecondText);
|
buddyText = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogSecondText);
|
||||||
if (buddyText != 0)
|
if (buddyText != 0) {
|
||||||
o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_STOP_TALKING;
|
o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_STOP_TALKING;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BOBOMB_BUDDY_CANNON_STOP_TALKING:
|
case BOBOMB_BUDDY_CANNON_STOP_TALKING:
|
||||||
|
@ -400,25 +404,28 @@ void bobomb_buddy_act_talk(void) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BOBOMB_BUDDY_ROLE_CANNON:
|
case BOBOMB_BUDDY_ROLE_CANNON:
|
||||||
if (gCurrCourseNum == COURSE_BOB)
|
if (gCurrCourseNum == COURSE_BOB) {
|
||||||
bobomb_buddy_cannon_dialog(DIALOG_004, DIALOG_105);
|
bobomb_buddy_cannon_dialog(DIALOG_004, DIALOG_105);
|
||||||
else
|
} else {
|
||||||
bobomb_buddy_cannon_dialog(DIALOG_047, DIALOG_106);
|
bobomb_buddy_cannon_dialog(DIALOG_047, DIALOG_106);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bobomb_buddy_act_turn_to_talk(void) {
|
void bobomb_buddy_act_turn_to_talk(void) {
|
||||||
s16 sp1e = o->header.gfx.animInfo.animFrame;
|
s16 animFrame = o->header.gfx.animInfo.animFrame;
|
||||||
if ((sp1e == 5) || (sp1e == 16))
|
if ((animFrame == 5) || (animFrame == 16)) {
|
||||||
cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK);
|
cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK);
|
||||||
|
}
|
||||||
|
|
||||||
struct Object* player = nearest_player_to_object(o);
|
struct Object *player = nearest_interacting_player_to_object(o);
|
||||||
s32 angleToPlayer = obj_angle_to_object(o, player);
|
s32 angleToPlayer = obj_angle_to_object(o, player);
|
||||||
o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, angleToPlayer, 0x1000);
|
o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, angleToPlayer, 0x1000);
|
||||||
if ((s16) o->oMoveAngleYaw == (s16) angleToPlayer)
|
if ((s16) o->oMoveAngleYaw == (s16) angleToPlayer) {
|
||||||
o->oAction = BOBOMB_BUDDY_ACT_TALK;
|
o->oAction = BOBOMB_BUDDY_ACT_TALK;
|
||||||
|
}
|
||||||
|
|
||||||
cur_obj_play_sound_2(SOUND_ACTION_READ_SIGN);
|
cur_obj_play_sound_2(SOUND_ACTION_READ_SIGN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,4 +327,4 @@ void bhv_treasure_chest_loop(void) {
|
||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -597,6 +597,43 @@ struct Object* nearest_player_to_object(struct Object *obj) {
|
||||||
return nearest->marioObj;
|
return nearest->marioObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns closest MarioState that's interacting with the object.
|
||||||
|
*/
|
||||||
|
struct MarioState *nearest_interacting_mario_state_to_object(struct Object *obj) {
|
||||||
|
struct MarioState *nearest = NULL;
|
||||||
|
f32 nearestDist = 0;
|
||||||
|
u8 checkActive = TRUE;
|
||||||
|
do {
|
||||||
|
for (s32 i = 0; i < MAX_PLAYERS; i++) {
|
||||||
|
if (gMarioStates[i].marioObj == obj) { continue; }
|
||||||
|
if (gMarioStates[i].interactObj != obj) { continue; }
|
||||||
|
if (checkActive && !is_player_active(&gMarioStates[i])) { continue; }
|
||||||
|
float dist = dist_between_objects(obj, gMarioStates[i].marioObj);
|
||||||
|
if (nearest == NULL || dist < nearestDist) {
|
||||||
|
nearest = &gMarioStates[i];
|
||||||
|
nearestDist = dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!checkActive) { break; }
|
||||||
|
checkActive = FALSE;
|
||||||
|
} while (nearest == NULL);
|
||||||
|
|
||||||
|
if (nearest == NULL) {
|
||||||
|
nearest = &gMarioStates[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return nearest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns closest marioObj that's interacting with the object.
|
||||||
|
*/
|
||||||
|
struct Object *nearest_interacting_player_to_object(struct Object *obj) {
|
||||||
|
struct MarioState *nearest = nearest_interacting_mario_state_to_object(obj);
|
||||||
|
return nearest->marioObj;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the MarioState is the closet MarioState
|
* Returns whether or not the MarioState is the closet MarioState
|
||||||
* to the object.
|
* to the object.
|
||||||
|
|
|
@ -167,6 +167,8 @@ u8 is_other_player_active(void);
|
||||||
u8 is_player_in_local_area(struct MarioState* m);
|
u8 is_player_in_local_area(struct MarioState* m);
|
||||||
struct MarioState* nearest_mario_state_to_object(struct Object* obj);
|
struct MarioState* nearest_mario_state_to_object(struct Object* obj);
|
||||||
struct Object* nearest_player_to_object(struct Object* obj);
|
struct Object* nearest_player_to_object(struct Object* obj);
|
||||||
|
struct MarioState *nearest_interacting_mario_state_to_object(struct Object *obj);
|
||||||
|
struct Object *nearest_interacting_player_to_object(struct Object *obj);
|
||||||
u8 is_nearest_mario_state_to_object(struct MarioState* m, struct Object* obj);
|
u8 is_nearest_mario_state_to_object(struct MarioState* m, struct Object* obj);
|
||||||
u8 is_nearest_player_to_object(struct Object* m, struct Object* obj);
|
u8 is_nearest_player_to_object(struct Object* m, struct Object* obj);
|
||||||
#endif // OBJ_BEHAVIORS_H
|
#endif // OBJ_BEHAVIORS_H
|
||||||
|
|
Loading…
Reference in a new issue