mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-10-19 03:32:41 +00:00
Made falling pillar multiple-player aware
This commit is contained in:
parent
5b7e1c28d8
commit
b8bdac2666
1 changed files with 9 additions and 3 deletions
|
@ -45,10 +45,12 @@ s16 bhv_falling_pillar_calculate_angle_in_front_of_mario(void) {
|
||||||
f32 targetX;
|
f32 targetX;
|
||||||
f32 targetZ;
|
f32 targetZ;
|
||||||
|
|
||||||
|
struct Object* player = nearest_player_to_object(o);
|
||||||
|
|
||||||
// Calculate target to be 500 units in front of Mario in
|
// Calculate target to be 500 units in front of Mario in
|
||||||
// the direction he is facing (angle[1] is yaw).
|
// the direction he is facing (angle[1] is yaw).
|
||||||
targetX = sins(gMarioObject->header.gfx.angle[1]) * 500.0f + gMarioObject->header.gfx.pos[0];
|
targetX = sins(player->header.gfx.angle[1]) * 500.0f + player->header.gfx.pos[0];
|
||||||
targetZ = coss(gMarioObject->header.gfx.angle[1]) * 500.0f + gMarioObject->header.gfx.pos[2];
|
targetZ = coss(player->header.gfx.angle[1]) * 500.0f + player->header.gfx.pos[2];
|
||||||
|
|
||||||
// Calculate the angle to the target from the pillar's current location.
|
// Calculate the angle to the target from the pillar's current location.
|
||||||
return atan2s(targetZ - o->oPosZ, targetX - o->oPosX);
|
return atan2s(targetZ - o->oPosZ, targetX - o->oPosX);
|
||||||
|
@ -58,13 +60,17 @@ s16 bhv_falling_pillar_calculate_angle_in_front_of_mario(void) {
|
||||||
* Falling pillar main logic loop.
|
* Falling pillar main logic loop.
|
||||||
*/
|
*/
|
||||||
void bhv_falling_pillar_loop(void) {
|
void bhv_falling_pillar_loop(void) {
|
||||||
|
struct Object* player = nearest_player_to_object(o);
|
||||||
|
int distanceToPlayer = dist_between_objects(o, player);
|
||||||
|
int angleToPlayer = obj_angle_to_object(o, player);
|
||||||
|
|
||||||
s16 angleInFrontOfMario;
|
s16 angleInFrontOfMario;
|
||||||
switch (o->oAction) {
|
switch (o->oAction) {
|
||||||
case FALLING_PILLAR_ACT_IDLE:
|
case FALLING_PILLAR_ACT_IDLE:
|
||||||
// When Mario is within 1300 units of distance...
|
// When Mario is within 1300 units of distance...
|
||||||
if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1300)) {
|
if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1300)) {
|
||||||
// Begin slightly moving towards Mario.
|
// Begin slightly moving towards Mario.
|
||||||
o->oMoveAngleYaw = o->oAngleToMario;
|
o->oMoveAngleYaw = angleToPlayer;
|
||||||
o->oForwardVel = 1.0f;
|
o->oForwardVel = 1.0f;
|
||||||
|
|
||||||
// Spawn the invisible hitboxes.
|
// Spawn the invisible hitboxes.
|
||||||
|
|
Loading…
Reference in a new issue