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

Ternaries in spell costs work the opposite of the way the game shows that they should #69751

Closed
Standing-Storm opened this issue Nov 25, 2023 · 4 comments · Fixed by #69760
Closed
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility

Comments

@Standing-Storm
Copy link
Contributor

Describe the bug

#69464 switched Karma Arms and a couple other spells to using a ternary to determine spell cost and casting time, so that turning them on takes time and mana and turning them off is free. This is reflected in the UI, which shows that Karma Arms costs 200 mana to cast and 0 mana to remove.

However, in-game the opposite happens--Karma Arms is free to cast and costs 200 mana to remove. Casting time works properly.

Attach save file

Ohio City-trimmed.tar.gz

Steps to reproduce

  1. Cast Karma Arms to grant the effect
  2. Note mana has not gone down.
  3. Cast it again to remove the effect
  4. Note mana has gone down.

Expected behavior

Spell casting costs work the way the spellcasting screen says they should.

Screenshots

Screenshots Turning on Karma Arms:

image

Status screen afterwards (note Mana)
image

Turning off Karma Arms:
image

Status screen afterwards (note Mana)
image

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.19045.3693 (22H2)
  • Game Version: 7560c55 [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth],
    No Rail Stations [No_Rail_Stations],
    Xedra Evolved [xedra_evolved]
    ]

Additional context

The linked PR has the same formula for both cost and time, and time works properly, so there might be something odd in the spell cost code specifically.

I also tested Stalker's Oculars and Devil's Tail and the same bug occurs (and also occurs when I tested it with a Mind Over Matter power).

@Standing-Storm Standing-Storm added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Nov 25, 2023
@GuardianDll
Copy link
Member

That is odd
To the oddities: you can see that to make casting time 20 seconds, was used not usual 2000 moves, but 200000 - for some reason the game interpret 1 second as 10000

@Standing-Storm
Copy link
Contributor Author

Is the casting time supposed to be 20 seconds? The listed casting time in the screenshot is accurate (it takes over 30 minutes to cast)

@GuardianDll
Copy link
Member

oh no, i forgot that i used debug mana that increases time to cast for 50 times;
nevermind then, it's just my memory

@andrei8l
Copy link
Contributor

andrei8l commented Nov 26, 2023

Spell cost is evaluated after casting the spell

spell_being_cast.cast_all_effects( *you, *target );
if( act->get_value( 2 ) != 0 ) {
// pay the cost
int cost = spell_being_cast.energy_cost( *you );
switch( spell_being_cast.energy_source() ) {

This should fix it
diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp
index d6b19b2ad4..6869b50647 100644
--- a/src/activity_handlers.cpp
+++ b/src/activity_handlers.cpp
@@ -3775,11 +3775,12 @@ void activity_handlers::spellcasting_finish( player_activity *act, Character *yo
             // spells with the components in hand.
             spell_being_cast.use_components( *you );
 
+            int cost = spell_being_cast.energy_cost( *you );
+
             spell_being_cast.cast_all_effects( *you, *target );
 
             if( act->get_value( 2 ) != 0 ) {
                 // pay the cost
-                int cost = spell_being_cast.energy_cost( *you );
                 switch( spell_being_cast.energy_source() ) {
                     case magic_energy_type::mana:
                         you->magic->mod_mana( *you, -cost );

But I can't say for sure it wasn't intentional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility
Projects
None yet
3 participants