sm64pc/src/game/behaviors/moving_coin.inc.c

268 lines
6.2 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
// coin.c.inc
// sp18 = collisionFlagsPtr
static struct ObjectHitbox sMovingYellowCoinHitbox = {
/* interactType: */ INTERACT_COIN,
/* downOffset: */ 0,
/* damageOrCoinValue: */ 1,
/* health: */ 0,
/* numLootCoins: */ 0,
/* radius: */ 100,
/* height: */ 64,
/* hurtboxRadius: */ 0,
/* hurtboxHeight: */ 0,
};
static struct ObjectHitbox sMovingBlueCoinHitbox = {
/* interactType: */ INTERACT_COIN,
/* downOffset: */ 0,
/* damageOrCoinValue: */ 5,
/* health: */ 0,
/* numLootCoins: */ 0,
/* radius: */ 100,
/* height: */ 64,
/* hurtboxRadius: */ 0,
/* hurtboxHeight: */ 0,
};
2020-03-02 03:42:52 +00:00
s32 coin_step(s16 *collisionFlagsPtr) {
2019-12-02 02:52:53 +00:00
*collisionFlagsPtr = object_step();
2019-08-25 04:46:40 +00:00
2019-12-02 02:52:53 +00:00
obj_check_floor_death(*collisionFlagsPtr, sObjFloor);
2019-08-25 04:46:40 +00:00
if ((*collisionFlagsPtr & 0x1) != 0 && (*collisionFlagsPtr & 0x8) == 0) /* bit 0, bit 3 */
{
2020-03-02 03:42:52 +00:00
cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP);
2019-08-25 04:46:40 +00:00
return 1;
}
return 0;
}
2020-03-02 03:42:52 +00:00
void moving_coin_flicker(void) {
2019-08-25 04:46:40 +00:00
s16 collisionFlags;
2020-03-02 03:42:52 +00:00
coin_step(&collisionFlags);
2019-12-02 02:52:53 +00:00
obj_flicker_and_disappear(o, 0);
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void coin_collected(void) {
2019-08-25 04:46:40 +00:00
spawn_object(o, MODEL_SPARKLES, bhvGoldenCoinSparkles);
o->activeFlags = 0;
}
void bhv_moving_yellow_coin_init(void) {
o->oGravity = 3.0f;
o->oFriction = 1.0f;
o->oBuoyancy = 1.5f;
2020-03-02 03:42:52 +00:00
obj_set_hitbox(o, &sMovingYellowCoinHitbox);
2019-08-25 04:46:40 +00:00
}
void bhv_moving_yellow_coin_loop(void) {
s16 collisionFlags;
switch (o->oAction) {
case MOV_YCOIN_ACT_IDLE:
2020-03-02 03:42:52 +00:00
coin_step(&collisionFlags);
2019-08-25 04:46:40 +00:00
if (o->oTimer < 10)
2020-03-02 03:42:52 +00:00
cur_obj_become_intangible();
2019-08-25 04:46:40 +00:00
else
2020-03-02 03:42:52 +00:00
cur_obj_become_tangible();
2019-08-25 04:46:40 +00:00
if (o->oTimer >= 301)
o->oAction = 1;
break;
case MOV_YCOIN_ACT_BLINKING:
2020-03-02 03:42:52 +00:00
moving_coin_flicker();
2019-08-25 04:46:40 +00:00
break;
case MOV_YCOIN_ACT_LAVA_DEATH:
o->activeFlags = 0;
break;
case MOV_YCOIN_ACT_DEATH_PLANE_DEATH:
o->activeFlags = 0;
break;
}
if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */
{
2020-03-02 03:42:52 +00:00
coin_collected();
2019-08-25 04:46:40 +00:00
o->oInteractStatus = 0;
}
}
void bhv_moving_blue_coin_init(void) {
o->oGravity = 5.0f;
o->oFriction = 1.0f;
o->oBuoyancy = 1.5f;
2020-03-02 03:42:52 +00:00
obj_set_hitbox(o, &sMovingBlueCoinHitbox);
2019-08-25 04:46:40 +00:00
}
void bhv_moving_blue_coin_loop(void) {
2019-09-01 19:50:50 +00:00
#ifdef VERSION_EU
s32 collisionFlags;
#else
2019-08-25 04:46:40 +00:00
s16 collisionFlags;
2019-09-01 19:50:50 +00:00
#endif
2019-08-25 04:46:40 +00:00
switch (o->oAction) {
case MOV_BCOIN_ACT_STILL:
2020-04-03 18:57:26 +00:00
if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1500))
2019-08-25 04:46:40 +00:00
o->oAction = 1;
break;
case MOV_BCOIN_ACT_MOVING:
2019-12-02 02:52:53 +00:00
collisionFlags = object_step();
2020-04-03 18:57:26 +00:00
if ((collisionFlags & OBJ_COL_FLAG_GROUNDED)) /* bit 0 */
2019-08-25 04:46:40 +00:00
{
o->oForwardVel += 25.0f;
2020-04-03 18:57:26 +00:00
if (!(collisionFlags & OBJ_COL_FLAG_NO_Y_VEL))
2020-03-02 03:42:52 +00:00
cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP); /* bit 3 */
2019-08-25 04:46:40 +00:00
} else
o->oForwardVel *= 0.98;
if (o->oForwardVel > 75.0)
o->oForwardVel = 75.0f;
2019-12-02 02:52:53 +00:00
obj_flicker_and_disappear(o, 600);
2019-08-25 04:46:40 +00:00
break;
}
if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */
{
2020-03-02 03:42:52 +00:00
coin_collected();
2019-08-25 04:46:40 +00:00
o->oInteractStatus = 0;
}
}
void bhv_blue_coin_sliding_jumping_init(void) {
o->oGravity = 3.0;
o->oFriction = 0.98;
o->oBuoyancy = 1.5;
2020-03-02 03:42:52 +00:00
obj_set_hitbox(o, &sMovingBlueCoinHitbox);
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void blue_coin_sliding_away_from_mario(void) {
2019-08-25 04:46:40 +00:00
s16 collisionFlags;
o->oForwardVel = 15.0;
o->oMoveAngleYaw = o->oAngleToMario + 0x8000;
2020-03-02 03:42:52 +00:00
if (coin_step(&collisionFlags) != 0)
2019-08-25 04:46:40 +00:00
o->oVelY += 18.0f;
if ((collisionFlags & 0x2) != 0)
o->oAction = 3; /* bit 1 */
if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1000) == 0)
o->oAction = 2;
}
2020-03-02 03:42:52 +00:00
void blue_coin_sliding_slow_down(void) {
2019-08-25 04:46:40 +00:00
s16 collisionFlags;
2020-03-02 03:42:52 +00:00
coin_step(&collisionFlags);
2019-08-25 04:46:40 +00:00
if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 500) == 1)
o->oAction = 1;
if (o->oTimer >= 151)
o->oAction = 3;
}
void bhv_blue_coin_sliding_loop(void) {
s16 collisionFlags;
switch (o->oAction) {
case 0:
if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 500) == 1)
o->oAction = 1;
2019-12-02 02:52:53 +00:00
set_object_visibility(o, 3000);
2019-08-25 04:46:40 +00:00
break;
case 1:
2020-03-02 03:42:52 +00:00
blue_coin_sliding_away_from_mario();
2019-08-25 04:46:40 +00:00
break;
case 2:
2020-03-02 03:42:52 +00:00
blue_coin_sliding_slow_down();
2019-12-02 02:52:53 +00:00
set_object_visibility(o, 3000);
2019-08-25 04:46:40 +00:00
break;
case 3:
2020-03-02 03:42:52 +00:00
coin_step(&collisionFlags);
2019-08-25 04:46:40 +00:00
if (o->oTimer >= 61)
o->oAction = 4;
break;
case 4:
2020-03-02 03:42:52 +00:00
moving_coin_flicker();
2019-08-25 04:46:40 +00:00
break;
case 100:
o->activeFlags = 0;
break;
case 101:
o->activeFlags = 0;
break;
}
if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */
{
2020-03-02 03:42:52 +00:00
coin_collected();
2019-08-25 04:46:40 +00:00
o->oInteractStatus = 0;
}
}
void bhv_blue_coin_jumping_loop(void) {
s16 collisionFlags;
switch (o->oAction) {
case 0:
if (o->oTimer == 0) {
2020-03-02 03:42:52 +00:00
cur_obj_become_intangible();
2019-08-25 04:46:40 +00:00
o->oVelY = 50.0;
}
2019-12-02 02:52:53 +00:00
object_step();
2019-08-25 04:46:40 +00:00
if (o->oTimer == 15) {
2020-03-02 03:42:52 +00:00
cur_obj_become_tangible();
2019-08-25 04:46:40 +00:00
o->oAction = 1;
}
break;
case 1:
2020-03-02 03:42:52 +00:00
blue_coin_sliding_away_from_mario();
2019-08-25 04:46:40 +00:00
break;
case 2:
2020-03-02 03:42:52 +00:00
blue_coin_sliding_slow_down();
2019-12-02 02:52:53 +00:00
set_object_visibility(o, 3000);
2019-08-25 04:46:40 +00:00
break;
case 3:
2020-03-02 03:42:52 +00:00
coin_step(&collisionFlags);
2019-08-25 04:46:40 +00:00
if (o->oTimer >= 61)
o->oAction = 4;
break;
case 4:
2020-03-02 03:42:52 +00:00
moving_coin_flicker();
2019-08-25 04:46:40 +00:00
break;
}
if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */
{
2020-03-02 03:42:52 +00:00
coin_collected();
2019-08-25 04:46:40 +00:00
o->oInteractStatus = 0;
}
}