Better noclip (#103)

* remove unused noclip control defines

* rework player noclip controls

* fix whitespace
This commit is contained in:
krm01
2024-05-06 09:30:23 -07:00
committed by GitHub
parent a10bfb24e5
commit 521cbb3f3f
2 changed files with 99 additions and 42 deletions

View File

@@ -11,26 +11,6 @@
// -------------------------------------------
/**** [NO CLIP CONTROLS] ****/
// Controller port to use
#define NOCLIP_CONTROLLER_PORT CONTROLLER_PORT_1
// Set to true to use a button combo
#define NOCLIP_USE_BTN_COMBO true
#define NOCLIP_BTN_HOLD_FOR_COMBO BTN_L
// Control to enable no clip
#define NOCLIP_TOGGLE_BTN BTN_DRIGHT
// Control to hold to go faster
#define NOCLIP_FAST_BTN BTN_R
// Controls to move Link up and down
#define NOCLIP_GO_UP BTN_B
#define NOCLIP_GO_DOWN BTN_A
// -------------------------------------------
/**** [CUTSCENE FEATURES] ****/
// Controller port to use
#define CS_CTRL_CONTROLLER_PORT CONTROLLER_PORT_1

View File

@@ -13694,6 +13694,7 @@ void Player_Action_8084FBF4(Player* this, PlayState* play) {
* @return true if Noclip is disabled, false if enabled
*/
s32 Player_UpdateNoclip(Player* this, PlayState* play) {
static s32 cameraMode = 0;
if (ENABLE_NO_CLIP) {
sControlInput = &play->state.input[0];
@@ -13703,14 +13704,14 @@ s32 Player_UpdateNoclip(Player* this, PlayState* play) {
CHECK_BTN_ALL(sControlInput->press.button, BTN_DRIGHT))) {
sNoclipEnabled ^= 1;
if (sNoclipEnabled) {
Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_AIM);
}
cameraMode = 0;
}
if (sNoclipEnabled) {
Camera* cam = GET_ACTIVE_CAM(play);
f32 speed;
s32 mod = 0;
f32 yvel = 0.0f;
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) {
speed = 100.0f;
@@ -13718,41 +13719,117 @@ s32 Player_UpdateNoclip(Player* this, PlayState* play) {
speed = 20.0f;
}
if (CHECK_BTN_ALL(sControlInput->press.button, BTN_Z)) {
cameraMode ^= 1;
}
if (cameraMode == 0) {
if (cam->mode != CAM_MODE_Z_PARALLEL) {
Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_PARALLEL);
}
} else {
if (cam->mode != CAM_MODE_NORMAL) {
Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_NORMAL);
}
}
if (cameraMode == 1) {
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_CRIGHT)) {
cam->eye.x += Math_SinS(Camera_GetCamDirYaw(cam) + 0x3FFF) * Math_Vec3f_DistXYZ(&cam->eye, &cam->at) * 0.15f;
cam->eye.z += Math_CosS(Camera_GetCamDirYaw(cam) + 0x3FFF) * Math_Vec3f_DistXYZ(&cam->eye, &cam->at) * 0.15f;
cam->eyeNext = cam->eye;
mod = true;
}
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_CLEFT)) {
cam->eye.x += Math_SinS(Camera_GetCamDirYaw(cam) - 0x3FFF) * Math_Vec3f_DistXYZ(&cam->eye, &cam->at) * 0.15f;
cam->eye.z += Math_CosS(Camera_GetCamDirYaw(cam) - 0x3FFF) * Math_Vec3f_DistXYZ(&cam->eye, &cam->at) * 0.15f;
cam->eyeNext = cam->eye;
mod = true;
}
} else {
Parallel1* parallel = &cam->paramData.para1;
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_CRIGHT)) {
parallel->rwData.yawTarget -= DEG_TO_BINANG(7);
mod = true;
}
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_CLEFT)) {
parallel->rwData.yawTarget += DEG_TO_BINANG(7);
mod = true;
}
}
if (mod) {
this->actor.shape.rot.y = Camera_GetCamDirYaw(cam);
}
DebugCamera_ScreenText(3, 2, "DEBUG MODE");
if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_L)) {
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) {
this->actor.world.pos.y += speed;
} else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A)) {
this->actor.world.pos.y -= speed;
yvel = 1.0f;
}
if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DUP | BTN_DLEFT | BTN_DDOWN | BTN_DRIGHT)) {
s16 angle;
s16 temp;
else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A)) {
yvel = -1.0f;
}
angle = temp = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play));
OSContPad* ctrl = &play->state.input[0].cur;
Vec3f zero = { 0.0f, 0.0f, 0.0f };
Vec3f conpos = {
.x = -((f32)ctrl->stick_x / 128),
.y = 0.0f,
.z = (f32)ctrl->stick_y / 128,
};
s16 angle;
f32 speedC = Math_Vec3f_DistXZ(&zero, &conpos);
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DDOWN)) {
angle = temp + 0x8000;
} else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DLEFT)) {
angle = temp + 0x4000;
} else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DRIGHT)) {
angle = temp - 0x4000;
if (speedC <= 0.1f) {
speedC = 0.0f;
}
angle = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play));
if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT)) {
if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DUP)) {
conpos.z = 1.0f;
}
this->actor.world.pos.x += speed * Math_SinS(angle);
this->actor.world.pos.z += speed * Math_CosS(angle);
if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DDOWN)) {
conpos.z = -1.0f;
}
if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DLEFT)) {
conpos.x = 1.0f;
}
if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DRIGHT)) {
conpos.x = -1.0f;
}
speedC = 1.0f;
}
angle += Math_Vec3f_Yaw(&zero, &conpos);
this->actor.world.pos.x += speed * Math_SinS(angle) * speedC;
this->actor.world.pos.z += speed * Math_CosS(angle) * speedC;
this->actor.world.pos.y += speed * yvel * 0.5f;
}
Player_ZeroSpeedXZ(this);
this->actor.gravity = 0.0f;
this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f;
this->actor.velocity.z = 0.0f;
this->actor.velocity.y = 0.0f;
this->actor.velocity.x = 0.0f;
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) &&
CHECK_BTN_ALL(sControlInput->press.button, BTN_DLEFT)) {
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DLEFT)) {
Flags_SetTempClear(play, play->roomCtx.curRoom.num);
}