Phazorknight / Cogito

Immersive Sim Template Project for GODOT 4
MIT License
717 stars 81 forks source link

Sanity Damage after Scene Transition #148

Closed ksjfhor closed 3 months ago

ksjfhor commented 3 months ago

Cogito and Godot Engine Version: Godot: 4.2.1.stable Cogito: beta 202403.25 (current master)

Description: After Scene transition the player takes sanity damage. Traversing back still gives the player damage.

Reproduction steps: DL the current master. Start a new game. Walk from the lobby to the lab. Take sanity damage. Wonder why ?

After I died, I respawned in the Lab and did not take sanity damage, as I get back to the Lobby, I get sanity damage again, so I guess it comes from the transition.

Expected behavior: I did not think that this should happen, since the areas are well lit :)

Stacktrace:

TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
CORE API HASH: 915626997
EDITOR API HASH: 1313472085
Loaded system CA certificates
Using present mode: VK_PRESENT_MODE_IMMEDIATE_KHR
CSM: Looking for file: user://COGITO_player_state_A.res
CSM: Get existing player state: No player state found for slot A
CSM: Looking for file: user://COGITO_player_state_A.res
CSM: Get existing player state: No player state found for slot A
CSM: Existing player state for slot A not found.
CSM: Active slot switched to A
CSM: Looking for file: user://COGITO_player_state_B.res
CSM: Get existing player state: No player state found for slot B
CSM: Existing player state for slot B not found.
CSM: Active slot switched to B
CSM: Looking for file: user://COGITO_player_state_C.res
CSM: Get existing player state: No player state found for slot C
CSM: Existing player state for slot C not found.
CSM: Active slot switched to C
SLOT BUTTON: No player state. Should start a new game.
CSM: Looking for file: user://COGITO_player_state_A.res
CSM: Get existing player state: No player state found for slot A
CSM: Existing player state for slot A not found.
CSM: Active slot switched to A
Loading screen: Attempting to load res://COGITO/DemoScenes/COGITO_04_Demo_Lobby.tscn
health: emitting attribute change. Current value is: 80
Cogito Attribute found: visibility
Cogito Attribute found: sanity
Cogito Attribute found: stamina
Cogito Attribute found: health
Player.gd: Options reloaded.
DynamicInputIcon: Action=inventory_drop_item. No primary keyboard/mouse input map assigned.
Loading screen: Load_mode is 2
Is in external_inventory group: kitchenFridgeContainer:<StaticBody3D#170523628559>
Quest demo_steal_laptop has been started.
Quest demo_access_archive has been started.
Creating VMA small objects pool for memory type index 3
CSM: Save doesn't exist. Creating...
persistent node 'coatRackStanding' is not an instanced scene, skipped
persistent node 'Note_Welcome' is not an instanced scene, skipped
Scene state saved as user://COGITO_scene_state_temp_Cogito04NewDemo.res
CSM: State doesn't exist. Creating for slot temp...
CSM: No screenshot to save was passed.
Player state saved as user://COGITO_player_state_temp.res
Loading screen: Attempting to load res://COGITO/DemoScenes/COGITO_05_Demo_Laboratory.tscn
health: emitting attribute change. Current value is: 80
Cogito Attribute found: visibility
Cogito Attribute found: sanity
Cogito Attribute found: stamina
Cogito Attribute found: health
Player.gd: Options reloaded.
DynamicInputIcon: Action=inventory_drop_item. No primary keyboard/mouse input map assigned.
health: emitting attribute change. Current value is: 1
health: emitting attribute change. Current value is: 1
health: emitting attribute change. Current value is: 1
health: emitting attribute change. Current value is: 1
health: emitting attribute change. Current value is: 1
health: emitting attribute change. Current value is: 3
Loading screen: Load_mode is 0
Loading screen: Attempting to load scene state: Cogito05DemoLaboratory
CSM: Load scene state for:Cogito05DemoLaboratory. Slot: temp
CSM: Scene state exists. Loading <Resource#-9223371808936294701>
Deleting existing node: chairDesk:<RigidBody3D#160205640106>
Deleting existing node: laptop:<RigidBody3D#160809619916>
Deleting existing node: laptop_real:<RigidBody3D#160994169303>
Deleting existing node: Pickup_Key:<RigidBody3D#161245827558>
Deleting existing node: chairModernFrameCushion:<RigidBody3D#166060888837>
Deleting existing node: chairModernFrameCushion2:<RigidBody3D#166178329356>
Deleting existing node: chairModernFrameCushion3:<RigidBody3D#166295769875>
Deleting existing node: chairModernFrameCushion4:<RigidBody3D#166413210394>
Deleting existing node: chairModernFrameCushion5:<RigidBody3D#166580982564>
Deleting existing node: chairModernFrameCushion6:<RigidBody3D#166698423083>
Deleting existing node: chairModernFrameCushion7:<RigidBody3D#166815863602>
Deleting existing node: chairModernFrameCushion8:<RigidBody3D#166933304121>
Deleting existing node: stoolBarSquare:<RigidBody3D#169047233463>
Deleting existing node: stoolBarSquare2:<RigidBody3D#169198228416>
Deleting existing node: chairCushion:<RigidBody3D#169969980398>
Deleting existing node: chairCushion2:<RigidBody3D#170137752568>
Deleting existing node: chairCushion3:<RigidBody3D#170305524738>
Deleting existing node: CoffeeMug:<RigidBody3D#170993390635>
Deleting existing node: CoffeeMug2:<RigidBody3D#171144385588>
Deleting existing node: CoffeeMug3:<RigidBody3D#171295380541>
Deleting existing node: CoffeeMug4:<RigidBody3D#171446375494>
Deleting existing node: CoffeeMug5:<RigidBody3D#171597370447>
Deleting existing node: chairDesk:<RigidBody3D#174684378375>
Deleting existing node: chairDesk2:<RigidBody3D#174868927762>
Deleting existing node: chairDesk3:<RigidBody3D#175053477149>
Deleting existing node: chairDesk4:<RigidBody3D#175238026536>
Deleting existing node: plantSmall2:<RigidBody3D#175422575923>
Deleting existing node: pottedPlant:<RigidBody3D#175892337999>
Deleting existing node: pottedPlant2:<RigidBody3D#176362100075>
Deleting existing node: trashcan:<RigidBody3D#176764753283>
Deleting existing node: trashcan2:<RigidBody3D#176865416585>
Deleting existing node: trashcan3:<RigidBody3D#176966079887>
Deleting existing node: coatRackStanding:<RigidBody3D#177066743189>
Deleting existing node: Hint_01_Welcome:<AnimatableBody3D#177385510312>
Deleting existing node: Hint_02_LampSwitch:<AnimatableBody3D#177955935689>
Deleting existing node: Hint_03_AdvancedSwitch:<AnimatableBody3D#178526361066>
Deleting existing node: Hint_04_Breakroom:<AnimatableBody3D#179096786443>
Deleting existing node: Hint_05_Platform:<AnimatableBody3D#179683989037>
Deleting existing node: Hint_06_AdvancedDoors:<AnimatableBody3D#180254414414>
Deleting existing node: Hint_07_Keypad:<AnimatableBody3D#180841617008>
Deleting existing node: Note_Welcome:<StaticBody3D#181428819602>
Deleting existing node: Pickup_Flashlight:<RigidBody3D#183307867905>
Deleting existing node: RippedPageA_pickup:<RigidBody3D#183509194509>
Deleting existing node: RippedPageB_pickup:<RigidBody3D#183576303377>
Deleting existing node: TargetDestructable:<RigidBody3D#284877135997>
Deleting existing node: TargetDestructable2:<RigidBody3D#284961022082>
Deleting existing node: TargetDestructable3:<RigidBody3D#285044908167>
Deleting existing node: TargetDestructable4:<RigidBody3D#285128794252>
Deleting existing node: TargetDestructable5:<RigidBody3D#285212680337>
Deleting existing node: pickup_pistol:<RigidBody3D#285296566422>
Deleting existing node: pickup_laser_ammo:<RigidBody3D#285447561375>
Deleting existing node: Pickup_LaserRifle:<RigidBody3D#285531447460>
Deleting existing node: Pickup_Pickaxe:<RigidBody3D#287511159066>
Deleting existing node: barrel2:<RigidBody3D#287662154019>
Deleting existing node: HealthPotion:<RigidBody3D#287930589491>
Deleting existing node: HealthPotion2:<RigidBody3D#288131916095>
Deleting existing node: HealthPotion3:<RigidBody3D#288333242699>
Deleting existing node: Pickup_StaminaExtension:<RigidBody3D#288534569303>
Deleting existing node: CarriableBox:<RigidBody3D#288836559207>
health: emitting attribute change. Current value is: 1
Adding to scene: @RigidBody3D@122
health: emitting attribute change. Current value is: 1
Adding to scene: @RigidBody3D@123
health: emitting attribute change. Current value is: 1
Adding to scene: @RigidBody3D@124
health: emitting attribute change. Current value is: 1
Adding to scene: @RigidBody3D@125
health: emitting attribute change. Current value is: 1
Adding to scene: @RigidBody3D@126
Adding to scene: @RigidBody3D@127
Adding to scene: @RigidBody3D@128
Adding to scene: @RigidBody3D@129
Adding to scene: @RigidBody3D@130
health: emitting attribute change. Current value is: 3
Adding to scene: barrel
Adding to scene: @RigidBody3D@131
Adding to scene: @RigidBody3D@132
Adding to scene: @RigidBody3D@133
Adding to scene: @RigidBody3D@134
Adding to scene: @RigidBody3D@135
CSM: Loading scene state finished.
CSM: Loading player state...
CSM: Player State in slot temp exists. Loading <Resource#-9223371808852408821>
Forced inventory update: <Resource#-9223371738253876408>
Is in external_inventory group: kitchenFridgeContainer:<StaticBody3D#170523628559>
Connector found, moving player to ConnectorFromLobby
Is in external_inventory group: kitchenFridgeContainer:<StaticBody3D#170523628559>
No screenshot for slot A found.

Godot is set to be verbose, so this stack may have some messages that you do not get.

Phazorknight commented 3 months ago

Thanks for the flag, but this is expected behavior if SanityAttribute is set with Decay in Darkness to On. Either switch it off or remove the SanityAttribute from the Player.

I did not think that this should happen, since the areas are well lit :) The decisive factor here is if the player is in a Lightzone or not.

To elaborate: Decay in Darkness checks if the VisibilityAttribute has changed and starts the decay if the attribute is 0. Since there are no Lightzones in the scene when the player starts, it's not triggered (which is actually something I should rectify). The check does get triggered on scene change, which is why the decay starts when you change the scene. So this is actually behaving as expected.

ksjfhor commented 3 months ago

Got it, would you close it when you added lightzones ? I guess most devs would run into that trap 🤗

Why am I always running into those things, lol.

Phazorknight commented 3 months ago

You're not the first one to run into this, I know the whole Visibilty/Sanity set-up is not very intuitive. I'm inclined to remove the SanityAttribute from the player by default, and maybe add something more intuitive like a "HungerAttribute", but that's a separate issue.

And yeah, I should take some time soon to add proper Lightzones to the new Demo Scenes. 😅

brian-holsters commented 3 months ago

isn't there still a bug in the sense that sanity does not decay on game load/start?

ksjfhor commented 3 months ago

Please dont remove it, I really like that feature. We just need a little bit more light 💡

@brian-holsters: glass shatters I just reloaded a few dozen times, and yes I got sanity damage. But I did not really care, since I was checking for different lights. But know; MRP: I started a fresh save, instantly saved and loaded: my sanity starts to drop.

Phazorknight commented 3 months ago

isn't there still a bug in the sense that sanity does not decay on game load/start?

yes, will try to fix this soon.

Please dont remove it, I really like that feature.

I wouldn't remove it completely, just not include it in the default player.tscn setup. But properly setting up the lightzones in the demo scenes is probably the better way to go. 😇

Phazorknight commented 3 months ago

isn't there still a bug in the sense that sanity does not decay on game load/start?

This should now be fixed in https://github.com/Phazorknight/Cogito/commit/893164ae6ad27f9ba97b0f41a622de24c43d1069

Going to close this issue now.