Fix some fizzler related issues

This commit is contained in:
James Lambert 2023-07-15 15:35:37 -06:00
parent d2c88aec0f
commit 8470c4ae22
14 changed files with 66 additions and 42 deletions

View file

@ -230,7 +230,7 @@ build/src/scene/portal.o: $(MODEL_HEADERS)
build/src/scene/signage.o: $(MODEL_HEADERS)
build/src/scene/box_dropper.o: $(MODEL_HEADERS)
build/src/scene/box_dropper.o: $(MODEL_HEADERS) build/assets/models/dynamic_model_list.h
build/src/scene/pedestal.o: $(MODEL_HEADERS)

View file

@ -158,6 +158,7 @@ make -f Makefile.docker
## Current Bug TODO List (Hardware Verified) (High->Low priority)
----------------------- v8
- [ ] Held objects to a funny rotation bit
- [ ] Player can clip through chamber 7 by walking back up the stairs (near the top).
- [ ] player can clip through back of elevator by jumping and strafeing at the back corners while inside.
- [ ] Player can trap themselves in chamber 5 by following instructions issue #75

View file

@ -0,0 +1 @@
-c 1 -r 22050

View file

@ -308,9 +308,15 @@ void soundPlayerAdjustVolume(ALSndId soundId, float newVolume) {
if (activeSound) {
if (activeSound->flags & SOUND_FLAGS_3D){
activeSound->volume = newVolume;
}else{
alSndpSetSound(&gSoundPlayer, activeSound->soundId);
alSndpSetVol(&gSoundPlayer, (short)(32767 * newVolume));
} else {
short newVolumeInt = (short)(32767 * newVolume);
short existingVolume = (short)(32767 * activeSound->volume);
if (newVolumeInt != existingVolume) {
alSndpSetSound(&gSoundPlayer, activeSound->soundId);
alSndpSetVol(&gSoundPlayer, newVolumeInt);
activeSound->volume = newVolume;
}
}
}
}

View file

@ -100,11 +100,7 @@ void decorObjectInit(struct DecorObject* object, struct DecorObjectDefinition* d
dynamicSceneSetRoomFlags(object->dynamicId, ROOM_FLAG_FROM_INDEX(room));
if (definition->soundClipId != -1) {
object->playingSound = soundPlayerPlay(definition->soundClipId, 1.0f, 1.0f, &object->rigidBody.transform.position, &object->rigidBody.velocity);
} else {
object->playingSound = SOUND_ID_NONE;
}
object->playingSound = SOUND_ID_NONE;
}
void decorObjectClenaup(struct DecorObject* decorObject) {
@ -143,7 +139,6 @@ enum FizzleCheckResult decorObjectUpdateFizzler(struct CollisionObject* collisio
collisionObject->body->flags |= RigidBodyDisableGravity;
if (*fizzleTime > 1.0f) {
collisionObject->body->flags &= ~RigidBodyFizzled;
result = FizzleCheckResultEnd;
}
}
@ -166,6 +161,10 @@ int decorObjectUpdate(struct DecorObject* decorObject) {
if (decorObject->playingSound != SOUND_ID_NONE) {
soundPlayerStop(decorObject->playingSound);
decorObject->playingSound = SOUND_ID_NONE;
if (decorObject->definition->soundFizzleId != SOUND_ID_NONE) {
decorObject->playingSound = soundPlayerPlay(decorObject->definition->soundFizzleId, 2.0f, 0.5f, &decorObject->rigidBody.transform.position, &decorObject->rigidBody.velocity);
}
}
} else if (fizzleResult == FizzleCheckResultEnd) {
if (decorObject->definition->flags & DecorObjectFlagsImportant) {
@ -174,9 +173,17 @@ int decorObjectUpdate(struct DecorObject* decorObject) {
return 1;
}
if (soundPlayerIsPlaying(decorObject->playingSound)) {
return 1;
}
return 0;
}
if (decorObject->definition->soundClipId != -1 && decorObject->playingSound == SOUND_ID_NONE && decorObject->fizzleTime == 0.0f) {
decorObject->playingSound = soundPlayerPlay(decorObject->definition->soundClipId, 1.0f, 1.0f, &decorObject->rigidBody.transform.position, &decorObject->rigidBody.velocity);
}
dynamicSceneSetRoomFlags(decorObject->dynamicId, ROOM_FLAG_FROM_INDEX(decorObject->rigidBody.currentRoom));
return 1;

View file

@ -20,6 +20,7 @@ struct DecorObjectDefinition {
short materialIndex;
short materialIndexFizzled;
short soundClipId;
short soundFizzleId;
short flags;
};

View file

@ -46,6 +46,7 @@ struct DecorObjectDefinition gDecorObjectDefinitions[] = {
PROPS_CYLINDER_TEST_DYNAMIC_MODEL,
.materialIndex = PLASTIC_PLASTICWALL001A_INDEX,
.soundClipId = -1,
.soundFizzleId = -1,
},
[DECOR_TYPE_RADIO] = {
{
@ -61,6 +62,7 @@ struct DecorObjectDefinition gDecorObjectDefinitions[] = {
.materialIndex = RADIO_INDEX,
.materialIndexFizzled = RADIO_FIZZLED_INDEX,
.soundClipId = SOUNDS_LOOPING_RADIO_MIX,
.soundFizzleId = SOUNDS_DINOSAUR_FIZZLE,
},
[DECOR_TYPE_CUBE] = {
{
@ -76,6 +78,7 @@ struct DecorObjectDefinition gDecorObjectDefinitions[] = {
.materialIndex = CUBE_INDEX,
.materialIndexFizzled = CUBE_FIZZLED_INDEX,
.soundClipId = -1,
.soundFizzleId = -1,
.flags = DecorObjectFlagsImportant,
},
[DECOR_TYPE_CUBE_UNIMPORTANT] = {
@ -92,6 +95,7 @@ struct DecorObjectDefinition gDecorObjectDefinitions[] = {
.materialIndex = CUBE_INDEX,
.materialIndexFizzled = CUBE_FIZZLED_INDEX,
.soundClipId = -1,
.soundFizzleId = -1,
},
[DECOR_TYPE_AUTOPORTAL_FRAME] = {
{
@ -106,6 +110,7 @@ struct DecorObjectDefinition gDecorObjectDefinitions[] = {
PROPS_AUTOPORTAL_FRAME_AUTOPORTAL_FRAME_DYNAMIC_MODEL,
.materialIndex = AUTOPORTAL_FRAME_INDEX,
.soundClipId = -1,
.soundFizzleId = -1,
}
};

View file

@ -20,6 +20,9 @@
#include "../build/assets/models/player/chell.h"
#include "../build/assets/materials/static.h"
#include "../debugger/debugger.h"
#include <string.h>
#define GRAB_RAYCAST_DISTANCE 2.5f
#define DROWN_TIME 2.0f
#define STEP_TIME 0.35f
@ -464,10 +467,13 @@ void playerGivePortalGun(struct Player* player, int flags) {
}
void playerUpdateSpeedSound(struct Player* player) {
float soundPlayerVolume;
soundPlayerVolume = sqrtf(vector3MagSqrd(&player->body.velocity))*(1.0f / MAX_PORTAL_SPEED);
soundPlayerVolume = clampf(soundPlayerVolume, 0.0, 1.0f);
soundPlayerAdjustVolume(player->flyingSoundLoopId, soundPlayerVolume);
// float soundPlayerVolume;
// soundPlayerVolume = sqrtf(vector3MagSqrd(&player->body.velocity))*(1.0f / MAX_PORTAL_SPEED);
// soundPlayerVolume = clampf(soundPlayerVolume, 0.0, 1.0f);
// soundPlayerAdjustVolume(player->flyingSoundLoopId, soundPlayerVolume);
// char message[32];
// gdbSendMessage(GDBDataTypeText, message, sprintf(message, "%d", (int)(soundPlayerVolume * 100.0f)));
}
void playerKill(struct Player* player, int isUnderwater) {
@ -613,10 +619,6 @@ void playerUpdate(struct Player* player) {
}
}
if (player->grabConstraint.object && controllerActionGet(ControllerActionOpenPortal0)) {
player->grabConstraint.object->body->flags |= RigidBodyFizzled;
}
targetVelocity.y = player->body.velocity.y;
float velocityDot = vector3Dot(&player->body.velocity, &targetVelocity);

View file

@ -138,7 +138,7 @@ void fizzlerInit(struct Fizzler* fizzler, struct Transform* transform, float wid
collisionSceneAddDynamicObject(&fizzler->collisionObject);
fizzler->maxExtent = (int)(width * SCENE_SCALE * 0.5f);
fizzler->maxVerticalExtent = (int)(height * SCENE_SCALE * 0.5f);
fizzler->maxVerticalExtent = (int)(height * SCENE_SCALE);
fizzler->particleCount = (int)(width * height * FIZZLER_PARTICLES_PER_1x1);

View file

@ -543,6 +543,28 @@ void sceneUpdate(struct Scene* scene) {
scene->player.flags &= ~PlayerInCutscene;
}
// objects that can fizzle need to update before the player
int decorWriteIndex = 0;
for (int i = 0; i < scene->decorCount; ++i) {
if (!decorObjectUpdate(scene->decor[i])) {
decorObjectDelete(scene->decor[i]);
continue;;
}
if (decorWriteIndex != i) {
scene->decor[decorWriteIndex] = scene->decor[i];
}
++decorWriteIndex;
}
scene->decorCount = decorWriteIndex;
for (int i = 0; i < scene->securityCameraCount; ++i) {
securityCameraUpdate(&scene->securityCameras[i]);
}
portalGunUpdate(&scene->portalGun, &scene->player);
playerUpdate(&scene->player);
sceneUpdateListeners(scene);
@ -565,10 +587,6 @@ void sceneUpdate(struct Scene* scene) {
ballCatcherUpdate(&scene->ballCatchers[i], scene->ballLaunchers, scene->ballLancherCount);
}
for (int i = 0; i < scene->securityCameraCount; ++i) {
securityCameraUpdate(&scene->securityCameras[i]);
}
cutsceneCheckTriggers(&scene->player.lookTransform.position);
signalsEvaluateSignals(gCurrentLevel->signalOperators, gCurrentLevel->signalOperatorCount);
@ -576,23 +594,6 @@ void sceneUpdate(struct Scene* scene) {
doorUpdate(&scene->doors[i]);
}
int decorWriteIndex = 0;
for (int i = 0; i < scene->decorCount; ++i) {
if (!decorObjectUpdate(scene->decor[i])) {
decorObjectDelete(scene->decor[i]);
continue;;
}
if (decorWriteIndex != i) {
scene->decor[decorWriteIndex] = scene->decor[i];
}
++decorWriteIndex;
}
scene->decorCount = decorWriteIndex;
for (int i = 0; i < scene->fizzlerCount; ++i) {
fizzlerUpdate(&scene->fizzlers[i]);
}

View file

@ -109,7 +109,7 @@ void securityCameraRender(void* data, struct DynamicRenderDataList* renderList,
}
void securityCameraInit(struct SecurityCamera* securityCamera, struct SecurityCameraDefinition* definition) {
collisionObjectInit(&securityCamera->collisionObject, &gSecurityCameraCollider, &securityCamera->rigidBody, 1.0f, COLLISION_LAYERS_TANGIBLE);
collisionObjectInit(&securityCamera->collisionObject, &gSecurityCameraCollider, &securityCamera->rigidBody, 1.0f, COLLISION_LAYERS_TANGIBLE | COLLISION_LAYERS_FIZZLER);
rigidBodyMarkKinematic(&securityCamera->rigidBody);
collisionSceneAddDynamicObject(&securityCamera->collisionObject);
@ -130,7 +130,7 @@ void securityCameraInit(struct SecurityCamera* securityCamera, struct SecurityCa
}
void securityCameraUpdate(struct SecurityCamera* securityCamera) {
if (decorObjectUpdateFizzler(&securityCamera->collisionObject, &securityCamera->fizzleTime)) {
if (decorObjectUpdateFizzler(&securityCamera->collisionObject, &securityCamera->fizzleTime) == FizzleCheckResultEnd) {
dynamicSceneRemove(securityCamera->dynamicId);
collisionSceneRemoveDynamicObject(&securityCamera->collisionObject);
securityCamera->dynamicId = INVALID_DYNAMIC_OBJECT;