Fixup some portal firing logic

This commit is contained in:
James Lambert 2023-10-07 20:50:06 -06:00
parent 8b539390b6
commit 8887125fe4
6 changed files with 26 additions and 7 deletions

View file

@ -17,7 +17,7 @@ $(SKELATOOL64):
skelatool64/setup_dependencies.sh
make -C skelatool64
OPTIMIZER := -Og
OPTIMIZER := -Os
LCDEFS := -DDEBUG -g -Isrc/ -I/usr/include/n64/nustd -Werror -Wall
N64LIB := -lultra_rom -lnustd

View file

@ -142,10 +142,10 @@ That will generate the rom at `/build/portal64.z64`
## Current New Feature TODO List
- [ ] rumble pak support?
- [ ] Investigate crash after falling into death water on test chamber 8
- [ ] Add auto save checkpoints
- [ ] Correct elevator timing
- [ ] pausing while glados is speaking can end her speech early
- [x] Investigate crash after falling into death water on test chamber 8
- [x] wake up objects after opening a portal under them
- [x] button prompts
- [x] investigate no_portals surface under portal pedestal

View file

@ -42,10 +42,13 @@ unsigned short gActionSourceButtonMask[ControllerActionSourceCount] = {
};
int gActionState = 0;
int gMutedActions = 0;
struct Vector2 gDirections[2];
#define ACTION_TO_BITMASK(action) (1 << (action))
void controllerActionApply(enum ControllerAction action) {
gActionState |= (1 << action);
gActionState |= ACTION_TO_BITMASK(action);
}
#define DEADZONE_SIZE 5
@ -126,6 +129,8 @@ void controllerActionRead() {
gDirections[0] = gZeroVec2;
gDirections[1] = gZeroVec2;
int nextMutedState = 0;
for (int controllerIndex = 0; controllerIndex < 2; ++controllerIndex) {
for (int sourceIndex = 0; sourceIndex < ControllerActionSourceCount; ++sourceIndex) {
enum ControllerAction action = gSaveData.controls.controllerSettings[controllerIndex][sourceIndex];
@ -136,9 +141,13 @@ void controllerActionRead() {
if (sourceIndex == ControllerActionSourceCUpButton || sourceIndex == ControllerActionSourceDUpButton) {
sourceIndex += 3;
}
}else if (IS_HOLDABLE_ACTION(action) && controllerGetButton(controllerIndex, gActionSourceButtonMask[sourceIndex])){
controllerActionApply(action);
}else if (controllerGetButtonDown(controllerIndex, gActionSourceButtonMask[sourceIndex])) {
} else if (IS_HOLDABLE_ACTION(action) && controllerGetButton(controllerIndex, gActionSourceButtonMask[sourceIndex])) {
if (ACTION_TO_BITMASK(action) & gMutedActions) {
nextMutedState |= ACTION_TO_BITMASK(action);
} else {
controllerActionApply(action);
}
} else if (controllerGetButtonDown(controllerIndex, gActionSourceButtonMask[sourceIndex])) {
controllerActionApply(action);
}
}
@ -148,6 +157,8 @@ void controllerActionRead() {
gDirections[i].x = clampf(gDirections[i].x, -1.0f, 1.0f);
gDirections[i].y = clampf(gDirections[i].y, -1.0f, 1.0f);
}
gMutedActions = nextMutedState;
}
struct Vector2 controllerDirectionGet(enum ControllerAction direction) {
@ -162,6 +173,10 @@ int controllerActionGet(enum ControllerAction action) {
return (gActionState & (1 << action)) != 0;
}
void controllerActionMuteActive() {
gMutedActions = gActionState;
}
int controllerSourcesForAction(enum ControllerAction action, struct ControllerSourceWithController* sources, int maxSources) {
int index = 0;

View file

@ -61,6 +61,7 @@ void controllerActionRead();
void controllerSetDeadzone(float percent);
struct Vector2 controllerDirectionGet(enum ControllerAction direction);
int controllerActionGet(enum ControllerAction action);
void controllerActionMuteActive();
int controllerSourcesForAction(enum ControllerAction action, struct ControllerSourceWithController* sources, int maxSources);

View file

@ -235,6 +235,9 @@ static void gameProc(void* arg) {
levelLoadWithCallbacks(levelGetQueued());
cutsceneRunnerReset();
dynamicAssetsReset();
// if a portal fire button is being held
// don't fire portals until it is released
controllerActionMuteActive();
gSceneCallbacks->initCallback(gSceneCallbacks->data);
}

View file

@ -354,7 +354,7 @@ void sceneCheckPortals(struct Scene* scene) {
soundPlayerPlay(soundsPortalgunShoot[0], 1.0f, 1.0f, NULL, NULL);
}
if ((fireBlue || (!hasOrange && fireOrange)) && !fireOrange && hasBlue && !playerIsGrabbing(&scene->player) &&!portalGunIsFiring(&scene->portalGun)) {
if (((fireBlue && !fireOrange) || (!hasOrange && fireOrange)) && hasBlue && !playerIsGrabbing(&scene->player) && !portalGunIsFiring(&scene->portalGun)) {
portalGunFire(&scene->portalGun, 1, &raycastRay, &playerUp, scene->player.body.currentRoom);
scene->player.flags |= PlayerJustShotPortalGun;
hudPortalFired(&scene->hud, 1);