Skip to content

Commit 8b9be0e

Browse files
added back ttm rolling log
1 parent 44a1418 commit 8b9be0e

6 files changed

Lines changed: 110 additions & 1 deletion

File tree

data/behavior_data.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "levels/ccm/header.h"
3535
#include "levels/ttc/header.h"
3636
#include "levels/bitdw/header.h"
37+
#include "levels/ttm/header.h"
3738

3839
#include "make_const_nonconst.h"
3940
#include "behavior_data.h"
@@ -2761,6 +2762,19 @@ const BehaviorScript bhvStar[] = {
27612762
END_LOOP(),
27622763
};
27632764

2765+
const BehaviorScript bhvTTMRollingLog[] = {
2766+
BEGIN(OBJ_LIST_SURFACE),
2767+
OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE),
2768+
LOAD_COLLISION_DATA(ttm_seg7_collision_pitoune_2),
2769+
SET_HOME(),
2770+
SET_FLOAT(oCollisionDistance, 2000),
2771+
CALL_NATIVE(bhv_ttm_rolling_log_init),
2772+
BEGIN_LOOP(),
2773+
CALL_NATIVE(bhv_rolling_log_loop),
2774+
CALL_NATIVE(load_object_collision_model),
2775+
END_LOOP(),
2776+
};
2777+
27642778
const BehaviorScript bhvSmallPiranhaFlame[] = {
27652779
BEGIN(OBJ_LIST_GENACTOR),
27662780
OR_INT(oFlags, (OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)),

include/behavior_data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ extern const BehaviorScript bhvBoo[];
163163
extern const BehaviorScript bhvGhostHuntBoo[]; // we can cock about with this later
164164
extern const BehaviorScript bhvInsideCannon[];
165165
extern const BehaviorScript bhvStar[];
166+
extern const BehaviorScript bhvTTMRollingLog[];
166167
extern const BehaviorScript bhvStaticObject[];
167168
extern const BehaviorScript bhvCastleFloorTrap[];
168169
extern const BehaviorScript bhvFloorTrapInCastle[];

levels/ttm/script.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
#include "make_const_nonconst.h"
1616
#include "levels/ttm/header.h"
1717

18+
static const LevelScript script_func_local_1[] = {
19+
OBJECT(/*model*/ MODEL_TTM_ROLLING_LOG, /*pos*/ 4360, -1722, 4001, /*angle*/ 0, 48, 0, /*bhvParam*/ 0, /*bhv*/ bhvTTMRollingLog),
20+
RETURN(),
21+
};
22+
1823
const LevelScript level_ttm_entry[] = {
1924
INIT_LEVEL(),
2025
LOAD_MIO0 (/*seg*/ 0x07, _ttm_segment_7SegmentRomStart, _ttm_segment_7SegmentRomEnd),
@@ -67,7 +72,7 @@ const LevelScript level_ttm_entry[] = {
6772
WARP_NODE(/*id*/ WARP_NODE_16, /*destLevel*/ LEVEL_TTM, /*destArea*/ 1, /*destNode*/ WARP_NODE_15, /*flags*/ WARP_NO_CHECKPOINT),
6873
WARP_NODE(/*id*/ WARP_NODE_SUCCESS, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_34, /*flags*/ WARP_NO_CHECKPOINT),
6974
WARP_NODE(/*id*/ WARP_NODE_DEATH, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_66, /*flags*/ WARP_NO_CHECKPOINT),
70-
75+
JUMP_LINK(script_func_local_1),
7176
TERRAIN(/*terrainData*/ ttm_collision),
7277
//MACRO_OBJECTS(/*objList*/ ttm_seg7_area_1_macro_objs),
7378
SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0000, /*seq*/ SEQ_LEVEL_GRASS),

src/game/behavior_actions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ void bhv_red_coin_loop(void);
314314
void bhv_hidden_star_init(void);
315315
void bhv_hidden_star_loop(void);
316316
void bhv_hidden_star_trigger_loop(void);
317+
void bhv_rolling_log_loop(void);
318+
void bhv_ttm_rolling_log_init(void);
317319
void bhv_1up_common_init(void);
318320
void bhv_1up_walking_loop(void);
319321
void bhv_1up_running_away_loop(void);

src/game/behaviors/rolling_log.inc.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,92 @@
66
// hypothesis is that the object in the middle here used to be
77
// a rolling log of another variation.
88

9+
void bhv_ttm_rolling_log_init(void) {
10+
o->oPitouneUnkF8 = 3970.0f;
11+
o->oPitouneUnkFC = 3654.0f;
12+
o->oPitouneUnkF4 = 271037.0f;
13+
14+
o->oMoveAngleYaw = 8810;
15+
o->oForwardVel = 0.0f;
16+
o->oVelX = 0.0f;
17+
o->oVelZ = 0.0f;
18+
o->oFaceAnglePitch = 0;
19+
o->oAngleVelPitch = 0;
20+
}
21+
22+
void rolling_log_roll_log(void) {
23+
if (gMarioObject->platform == o) {
24+
f32 sp24 = (gMarioObject->header.gfx.pos[2] - o->oPosZ) * coss(-1*o->oMoveAngleYaw)
25+
- (gMarioObject->header.gfx.pos[0] - o->oPosX) * sins(-1*o->oMoveAngleYaw);
26+
if (sp24 > 0) {
27+
o->oAngleVelPitch += 0x10;
28+
} else {
29+
o->oAngleVelPitch -= 0x10;
30+
}
31+
32+
if (o->oAngleVelPitch > 0x200) {
33+
o->oAngleVelPitch = 0x200;
34+
}
35+
36+
if (o->oAngleVelPitch < -0x200) {
37+
o->oAngleVelPitch = -0x200;
38+
}
39+
} else {
40+
if (is_point_close_to_object(o, o->oHomeX, o->oHomeY, o->oHomeZ, 100)) {
41+
if (o->oAngleVelPitch != 0) {
42+
if (o->oAngleVelPitch > 0) {
43+
o->oAngleVelPitch -= 0x10;
44+
} else {
45+
o->oAngleVelPitch += 0x10;
46+
}
47+
48+
if (o->oAngleVelPitch < 0x10 && o->oAngleVelPitch > -0x10) {
49+
o->oAngleVelPitch = 0;
50+
}
51+
}
52+
} else {
53+
if (o->oAngleVelPitch != 0x100) {
54+
if (o->oAngleVelPitch > 0x100) {
55+
o->oAngleVelPitch -= 0x10;
56+
} else {
57+
o->oAngleVelPitch += 0x10;
58+
}
59+
60+
if (o->oAngleVelPitch < 0x110 && o->oAngleVelPitch > 0xF0) {
61+
o->oAngleVelPitch = 0x100;
62+
}
63+
}
64+
}
65+
}
66+
}
67+
68+
void bhv_rolling_log_loop(void) {
69+
f32 prevX = o->oPosX;
70+
f32 prevZ = o->oPosZ;
71+
72+
rolling_log_roll_log();
73+
74+
o->oForwardVel = o->oAngleVelPitch / 0x40;
75+
o->oVelX = o->oForwardVel * sins(o->oMoveAngleYaw);
76+
o->oVelZ = o->oForwardVel * coss(o->oMoveAngleYaw);
77+
78+
o->oPosX += o->oVelX;
79+
o->oPosZ += o->oVelZ;
80+
81+
if (o->oPitouneUnkF4 < sqr(o->oPosX - o->oPitouneUnkF8) + sqr(o->oPosZ - o->oPitouneUnkFC)) {
82+
o->oForwardVel = 0.0f;
83+
o->oPosX = prevX;
84+
o->oPosZ = prevZ;
85+
o->oVelX = 0.0f;
86+
o->oVelZ = 0.0f;
87+
}
88+
89+
o->oFaceAnglePitch += o->oAngleVelPitch;
90+
if (absf_2(o->oFaceAnglePitch & 0x1FFF) < 528.0f && o->oAngleVelPitch != 0) {
91+
cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN1_2);
92+
}
93+
}
94+
995
void volcano_act_1(void) {
1096
o->oRollingLogUnkF4 += 4.0f;
1197
o->oAngleVelPitch += o->oRollingLogUnkF4;

src/game/obj_behaviors.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ UNUSED s8 debug_sequence_tracker(s16 debugInputSequence[]) {
789789
#include "behaviors/celebration_star.inc.c"
790790
#include "behaviors/drawbridge.inc.c"
791791
#include "behaviors/bomp.inc.c"
792+
#include "behaviors/rolling_log.inc.c"
792793
#include "behaviors/sliding_platform.inc.c"
793794
#include "behaviors/sound_birds.inc.c"
794795
#include "behaviors/sound_ambient.inc.c"

0 commit comments

Comments
 (0)