Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ban Perks feature with support for GLASS_CANNON #193

Merged
merged 7 commits into from
Sep 22, 2024

Conversation

Shortman422
Copy link
Contributor

@Shortman422 Shortman422 commented Aug 1, 2024

Issue

For large room Noita-Together games hosted by DunkOrSlam with Death Penalty as Respawn Penalty and Kick on death as true the community has identified an issue where the game can end abruptly as a result of 1 player picking up Glass Cannon, or using Heart Mage trick, and rapidly reaching the <25 max HP threshold to end the game for all players.

Notes

I am not familiar with LUA nor have I developed for Noita before. Please review/test thoroughly. Feel free to disregard or request major changes if design does not align with Noita-Together standards.

New Feature

Ban Perks
The intent of this feature is to:

  1. Allow a list of perks to be banned from Noita
  2. Modify the perk generation so that a banned perk will not spawn while NT_ban_perks is true (including in Gamble)
  3. Modify perk pickup to prevent banned perks from being obtained through cheats or from perks that spawned in world while NT_ban_perks was false
  4. Create an event to remove a players banned perks when NT_ban_perks is updated to true
  5. Maintain compatibility with other options such as NT_sync_perks, NT_team_perks, and Hourglass Events.

The feature has been created as a single toggle option with a list containing only the perk.id value GLASS_CANNON but should be capable of extension to allowing a selection or named sets of perks from the Noita Together App with minor development.

Testing

Testing was supported by utilizing the CheatGUI steam mod. With simple tests also run without CheatGUI enabled.
Testing was done on Seed 1000041222 which contains Glass Cannon in the first Holy Mountain.

Scenarios

Functionality

  1. Pass - Spawn Glass Cannon when NT_ban_perks false
    1. Start run with NT_ban_perks false and NT_world_randomize_loot false
    2. Teleport/walk to holy mountain
    3. Verify Glass Cannon present
  2. Pass - Do not spawn Glass Cannon when NT_ban_perks true
    1. Start run with NT_ban_perks true and NT_world_randomize_loot false
    2. Teleport/walk to holy mountain
    3. Verify Glass Cannon not present
    4. Repeated to verify perk_deck is still deterministic with Bombs Materialized, Angry Ghost, and Projectile Duplication being the spawned perks.
  3. Pass - Allow pickup of spawned Glass Cannon when NT_ban_perks is false
    1. Start run with NT_ban_perks false
    2. Teleport/walk to holy mountain
    3. Verify perk can be picked up and other perks removed
    4. Repeat test with toggling Ban Glass Cannon on/off a few times as well.
  4. Pass - Do not allow perk pickup of spawned Glass Cannon when NT_ban_perks is true
    1. Start run with NT_ban_perks false
    2. Teleport/walk to holy mountain
    3. Verify Glass Cannon present
    4. Apply NT_ban_perks true from Noita Together App
    5. Verify perk not picked up and other perks not removed
    6. Verify Glass Cannon is not applied and instead spawned in-world as a perk
    7. Verify spark bolt graphic does not include glass cannon reddening effect
    8. Verify spark bolt non-crit damage is 3 and glass cannon DAMAGE_MULTIPLIER game effect is not active
    9. Repeat test with toggling Ban Glass Cannon on/off a few times as well.
  5. Pass - Do not allow forced Glass Cannon perk pickup when NT_ban_perk is true
    1. Start run with NT_ban_perks true
    2. Using CheatGUI apply perk GLASS_CANNON
    3. Verify Glass Cannon is not applied and instead spawned in-world as a perk
    4. Verify spark bolt graphic does not include glass cannon reddening effect
    5. Teleport to holy mountain
    6. Verify spark bolt non-crit damage is 3 and glass cannon DAMAGE_MULTIPLIER game effect is not active
  6. Pass - Remove all copies of Glass Cannon from non-polymorphed/non-cessastion'd player when NT_ban_perks true is applied from Noita Together App.
    1. Start run with NT_ban_perks false
    2. Using CheatGUI apply perk GLASS_CANNON (also tested with picking up Glass Cannon from holy mountain)
    3. Apply NT_ban_perks true from Noita Together App
    4. Verify game message displayed to player
    5. Verify game screen effect displayed to player (unsure if this is a desired feature? I wanted to make sure the player was aware since perks spawned in world can spawn behind terrain.)
    6. Verify glass cannon removed and placed above player
    7. Verify other perks not removed
    8. Verify health has been reset to 100 hp
    9. Verify spark bolt graphic does not include glass cannon reddening effect
    10. Verify spark bolt non-crit damage is 3 and glass cannon DAMAGE_MULTIPLIER game effect is not active
    11. Repeat test with multiple copies of Glass Cannon and verifying world placement is consistent Examples in #dev-and-tech Noita-Together thread
    12. Repeat test with additional other perks
  7. Pass - Do not disrupt player without Glass Cannon when no perks are removed and NT_ban_perks true is applied from Noita Together App.
    1. Start run with NT_ban_perks false
    2. Apply NT_ban_perks true
    3. Verify no message
    4. Verify no screen effect
    5. Verify other perks are not removed
    6. Repeat with other perks applied through CheatGUI
  8. Pass - Do not remove Glass Cannon from polymorphed/cessation'd player (There was complexity with being able to remove the perks from the player but not being able to access the player components in order to remove the effects. I considered the test of "Remove Glass Cannon from polymorphed/cessation'd player" to be a fail with a confusing player state)
    1. Start run with NT_ban_perks false
    2. Using CheatGUI apply perk GLASS_CANNON
    3. Break starter flask chaotic polymorphine at feet / Create a [Increase Lifetime, Increase Lifetime, Cessastion] wand and cast
    4. Apply NT_ban_perks true
    5. Verify no message
    6. Verify no screen effect
    7. Await for polymorph effect / cessation to end
    8. Verify spark bolt graphic includes glass cannon reddening effect
    9. Verify spark bolt non-crit damage is 15 (with 1x Glass Cannon) or 75 (with 2+ Glass Cannon)
    10. Verify other perks are not removed
    11. Repeat test with multiple copies of Glass Cannon
    12. Repeat test with copies of other perks applied by CheatGUI
  9. Pass? - Ensure perks that are removed from player do not trigger removal of other perks when picked up
    1. Start run with NT_ban_perks false
    2. Teleport to holy mountain
    3. Using CheatGUI apply perk GLASS_CANNON
    4. Stand on stainless armor perk
    5. Apply NT_ban_perks true
    6. Apply NT_ban_perks false
    7. Pick up Glass Cannon from above stainless armor
    8. Verify other perks do not disappear (perk altar does activate water/bleed though)
    9. Pick up Glass Cannon from left side of perk altar
    10. Verify other perks disappear
    11. Repeat with attempting to pick up each Glass Cannon independently and then both after step v. Apply NT_ban_perks true
  10. Pass - Ensure Gamble does not apply Glass Cannon when NT_ban_perks true
    1. Start run with NT_ban_perks true
    2. Using CheatGUI spam apply Gamble
    3. Verify Glass Cannon is not applied by watching HP and occasionally stopping to shoot spark bolt

Compatibility

I attempted to resolve potential conflicts with other Noita Together features but lot of them required more than 1 player so I am unsure if compatibility was achieved.

  1. ??? - Ensure Glass Cannon is shared with NT_ban_perks false, NT_sync_perks true, NT_team_perks false
  2. ??? - Ensure Glass Cannon is not shared when attempted to be picked up with NT_ban_perks true, NT_sync_perks true, NT_team_perks false
  3. ??? - Ensure Glass Cannon that has been removed from player is not shared with NT_ban_perks false, NT_sync_perks true, NT_team_perks false
    1. Start run with NT_ban_perks false
    2. Using CheatGUI apply perk GLASS_CANNON
    3. Apply NT_ban_perks true
    4. Apply NT_ban_perks false
    5. Pick up Glass Cannon
    6. Verify Glass Cannon is not shared
  4. ??? - Ensure Hourglass Boon from Berserkium is not removed when NT_ban_perks true is applied

Comment Update: Corrected some test scenario inaccuracies with true/false listed incorrectly

…ariables to adjust it server side without pushing new code
…end-timeouts-login

Extend access token and refresh token timeouts
end

if (perk_data.game_effect2 ~= nil) then
-- local comp = GameGetGameEffect( player_id, perk_data.game_effect2 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code like this should be removed, or add a comment to why it could be beneficial to keep in here


local _item_pickup = item_pickup

function item_pickup( entity_item, entity_who_picked, item_name )
function item_pickup(entity_item, entity_who_picked, item_name)
GamePrint("started item_pickup")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some logging was not removed. Should only be the last line, and not the first 2
image

GlobalsSetValue(flag_name .. "_PICKUP_COUNT", tostring(pickup_count))

if (perk_data.game_effect ~= nil) then
-- local comp = GameGetGameEffect( player_id, perk_data.game_effect )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code like this should be removed, or add a comment to why it could be beneficial to keep in here

@SkyeOfBreeze
Copy link
Member

not sure if the spawning perks when banned is necessary. I still need to do some multiplayer tests with it later btw. I tested it in a solo lobby so far, but not thoroughly

@Shortman422
Copy link
Contributor Author

Changes

Amended commit with changes.
Addressed issues with picking up in world perks by adding a banned perk entity along with a lua script component to both real and banned perks for conversion.

Alternatives/Performance notes

banned_perk.xml
LuaComponent script_collision_trigger_hit with CollisionTriggerComponent width, height, radius, and destroy_this_entity_when_triggered="0" is an alternative that executes more times per frame
bannable_perk_check.lua simply needs wrapped in a function collision_trigger( colliding_entity_id ) to test this method. The data/scripts/lib/utilities.lua script_wait_frames function can be used to preemptively return from collision_trigger without calculations but resulted in the player needed to leave and return to the CollisionTriggerComponent boundaries.

perk.lua
Alternative to fully overwriting the base game method is to handle banned perks by using base game perk_spawn and then always overwriting components for bannable perks. It would also duplicating a majority of the perk_spawn code for spawning a banned perks entity that has most of the perk components from the base perk_spawn anyways.

Functionality

Testing scenarios were re-run and recorded.

https://www.youtube.com/watch?v=E078WnDHoB8

  1. Pass - Spawn Glass Cannon when NT_ban_perks false
    1. Start run with NT_ban_perks false and NT_world_randomize_loot false
    2. Teleport/walk to holy mountain
    3. Verify Glass Cannon present
  2. Pass - Do not spawn Glass Cannon when NT_ban_perks true
    1. Start run with NT_ban_perks true and NT_world_randomize_loot false
    2. Teleport/walk to holy mountain
    3. Verify Glass Cannon not present
    4. Repeated to verify perk_deck is still deterministic with Bombs Materialized, Angry Ghost, and Projectile Duplication being the spawned perks.
  3. Pass - Allow pickup of spawned Glass Cannon when NT_ban_perks is false
    1. Start run with NT_ban_perks false
    2. Teleport/walk to holy mountain
    3. Verify perk can be picked up and other perks removed
    4. Repeat test with toggling Ban Glass Cannon on/off a few times as well.
  4. Pass - Do not allow perk pickup of spawned Glass Cannon when NT_ban_perks is true
    1. Start run with NT_ban_perks false
    2. Teleport/walk to holy mountain
    3. Verify Glass Cannon present
    4. Apply NT_ban_perks true from Noita Together App
    5. Either forcibly convert perk by immediatly attempting to pickup or wait for perk to convert automatically
    6. Verify perk not picked up and other perks not removed
    7. Verify conversion to banned perk which is not interactible
    8. Verify spark bolt graphic does not include glass cannon reddening effect
    9. Verify spark bolt non-crit damage is 3 and glass cannon DAMAGE_MULTIPLIER game effect is not active
    10. Repeat test with other either option and toggling Ban Glass Cannon on/off a few times.
  5. Pass - Do not allow forced Glass Cannon perk pickup when NT_ban_perk is true
    1. Start run with NT_ban_perks true
    2. Using CheatGUI apply perk GLASS_CANNON
    3. Verify Glass Cannon is not applied and instead spawned in-world as a perk
    4. Verify spark bolt graphic does not include glass cannon reddening effect
    5. Teleport to holy mountain
    6. Verify spark bolt non-crit damage is 3 and glass cannon DAMAGE_MULTIPLIER game effect is not active
  6. Pass - Remove all copies of Glass Cannon from non-polymorphed/non-cessastion'd player when NT_ban_perks true is applied from App.
    1. Start run with NT_ban_perks false
    2. Using CheatGUI apply perk GLASS_CANNON (also tested with picking up Glass Cannon from holy mountain)
    3. Apply NT_ban_perks true from Noita Together App
    4. Verify game message displayed to player
    5. Verify game screen effect displayed to player (unsure if this is a desired feature? I wanted to make sure the player was aware since perks spawned in world can spawn behind terrain.)
    6. Verify glass cannon removed and placed above player
    7. Verify other perks not removed
    8. Verify health has been reset to 100 hp
    9. Verify spark bolt graphic does not include glass cannon reddening effect
    10. Verify spark bolt non-crit damage is 3 and glass cannon DAMAGE_MULTIPLIER game effect is not active
    11. Repeat test with multiple copies of Glass Cannon and verifying world placement is consistent Examples in #dev-and-tech Noita-Together thread
    12. Repeat test with additional other perks
  7. Pass - Do not disrupt player without Glass Cannon when no perks are removed and NT_ban_perks true is applied from App.
    1. Start run with NT_ban_perks false
    2. Apply NT_ban_perks true
    3. Verify no message
    4. Verify no screen effect
    5. Verify other perks are not removed
    6. Repeat with other perks applied through CheatGUI
  8. Pass - Do not remove Glass Cannon from polymorphed/cessation'd player (There was complexity with being able to remove the perks from the player but not being able to access the player components in order to remove the effects. I considered the test of "Remove Glass Cannon from polymorphed/cessation'd player" to be a fail with a confusing player state)
    1. Start run with NT_ban_perks false
    2. Using CheatGUI apply perk GLASS_CANNON
    3. Break starter flask chaotic polymorphine at feet / Create a [Increase Lifetime, Increase Lifetime, Cessastion] wand and cast
    4. Apply NT_ban_perks true
    5. Verify no message
    6. Verify no screen effect
    7. Await for polymorph effect / cessation to end
    8. Verify spark bolt graphic includes glass cannon reddening effect
    9. Verify spark bolt non-crit damage is 15 (with 1x Glass Cannon) or 75 (with 2+ Glass Cannon)
    10. Verify other perks are not removed
    11. Repeat test with multiple copies of Glass Cannon
    12. Repeat test with copies of other perks applied by CheatGUI
  9. Pass? - Ensure perks that are removed from player do not trigger removal of other perks when picked up
    1. Start run with NT_ban_perks false
    2. Teleport to holy mountain
    3. Grab Glass Cannon from first holy mountain
    4. Teleport to second holy mountain and stand on altar
    5. Apply NT_ban_perks true
    6. Apply NT_ban_perks false
    7. Either Pick up Low Recoil & Verify other perks do disappear or Pick up Glass Cannon & Verify other perks do not disappear
    8. Repeat with omission of step 6. Apply NT_ban_perks false to verify banned perk also disappears when Low Recoil picked up
  10. Pass - Ensure Gamble does apply Glass Cannon when NT_ban_perks false
    1. Start run with NT_ban_perks false
    2. Using CheatGUI apply Gamble, or spam apply if on a diferent seed
    3. Verify Glass Cannon is applied
  11. Pass - Ensure Gamble does not apply Glass Cannon when NT_ban_perks true
    1. Start run with NT_ban_perks true
    2. Optional: Apply a few perks so that Gamble perk count can be reviewed from in game UI
    3. Using CheatGUI spam apply Gamble
    4. Verify Glass Cannon is not applied by watching HP and reviewing all perks

Compatibility

I attempted to resolve potential conflicts with other Noita Together features but lot of them required more than 1 player so I am unsure if compatibility was achieved.

  1. ??? - Ensure Glass Cannon is shared with NT_ban_perks false, NT_sync_perks true, NT_team_perks false
  2. ??? - Ensure Glass Cannon is not shared when attempted to be picked up with NT_ban_perks true, NT_sync_perks true, NT_team_perks false
  3. ??? - Ensure Glass Cannon that has been removed from player is not shared with NT_ban_perks false, NT_sync_perks true, NT_team_perks false
  4. ??? - Ensure all Nullification Altar perks are not shared with NT_sync_perks true, NT_team_perks false
  5. ??? - Ensure Hourglass Boon from Berserkium is not removed when NT_ban_perks true is applied

@Shortman422
Copy link
Contributor Author

noita_mod/core/files/items_gfx/banned_perks/glass_cannon.png idea and image is from https://github.com/WUOTE

Copy link
Member

@SkyeOfBreeze SkyeOfBreeze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good. still need to test it locally

@SkyeOfBreeze SkyeOfBreeze merged commit c99d27c into Noita-Together:next Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants