Skip to content

Commit

Permalink
fix(content): restore potions restoring wrong amounts and reseting bo…
Browse files Browse the repository at this point in the history
…osted stats (#559)

* fix(content): restore stats scaled off stat_base

* fix(engine): stat_heal resetting level if past baselevel

---------

Co-authored-by: tannerdino <[email protected]>
Co-authored-by: Pazaz <[email protected]>
  • Loading branch information
3 people authored Jun 10, 2024
1 parent b1ca874 commit 4280ab3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ column=consumable,obj
column=consume_sound,synth
column=stat_change,stat,int,int
column=stat_restore,stat,int,int
column=stat_heal,stat,int,int

[consume_messages_table]
column=consumable,obj
Expand Down
38 changes: 19 additions & 19 deletions data/src/scripts/player/configs/consumption/consume_effects.dbrow
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ table=consume_table
data=consumable,asgarnian_ale
data=stat_change,attack,-2,-5
data=stat_change,strength,2,0
data=stat_restore,hitpoints,2,0
data=stat_heal,hitpoints,2,0

[wizards_mind_bomb_effect]
table=consume_table
Expand All @@ -76,7 +76,7 @@ data=stat_change,magic,2,2
data=stat_change,attack,-1,-5
data=stat_change,strength,-1,-5
data=stat_change,defence,-1,-5
data=stat_restore,hitpoints,1,0
data=stat_heal,hitpoints,1,0

[greenmans_ale_effect]
table=consume_table
Expand All @@ -85,14 +85,14 @@ data=stat_change,herblore,1,0
data=stat_change,attack,-3,0
data=stat_change,strength,-3,0
data=stat_change,defence,-3,0
data=stat_restore,hitpoints,1,0
data=stat_heal,hitpoints,1,0

[dragon_bitter_effect]
table=consume_table
data=consumable,dragon_bitter
data=stat_change,strength,2,0
data=stat_change,attack,-2,-5
data=stat_restore,hitpoints,1,0
data=stat_heal,hitpoints,1,0

[dwarven_stout_effect]
table=consume_table
Expand All @@ -102,33 +102,33 @@ data=stat_change,smithing,1,0
data=stat_change,attack,-2,4
data=stat_change,strength,-2,4
data=stat_change,defence,-2,4
data=stat_restore,hitpoints,1,0
data=stat_heal,hitpoints,1,0

[grog_effect]
table=consume_table
data=consumable,grog
data=stat_change,strength,1,4
data=stat_change,attack,-5,-3
data=stat_restore,hitpoints,3,0
data=stat_heal,hitpoints,3,0

[beer_effect]
table=consume_table
data=consumable,beer
data=stat_change,strength,1,2
data=stat_change,attack,-1,-6
data=stat_restore,hitpoints,1,0
data=stat_heal,hitpoints,1,0

[wine_effect]
table=consume_table
data=consumable,jug_wine
data=stat_change,attack,-2,0
data=stat_restore,hitpoints,11,0
data=stat_heal,hitpoints,11,0

[half_wine_effect]
table=consume_table
data=consumable,half_full_wine_jug
data=stat_change,attack,-2,0
data=stat_restore,hitpoints,7,0
data=stat_heal,hitpoints,7,0

[bad_wine_effect]
table=consume_table
Expand All @@ -139,7 +139,7 @@ data=stat_change,attack,-3,0
table=consume_table
data=consumable,cabbage_draynor
data=stat_change,defence,1,2
data=stat_restore,hitpoints,1,0
data=stat_heal,hitpoints,1,0
data=consume_sound,eat

[jangerberries_effect]
Expand All @@ -148,8 +148,8 @@ data=consumable,jangerberries
data=stat_change,attack,2,0
data=stat_change,strength,1,0
data=stat_change,defence,-1,0
data=stat_restore,prayer,1,0
data=stat_restore,hitpoints,2,0
data=stat_heal,prayer,1,0
data=stat_heal,hitpoints,2,0
data=consume_sound,eat

[restore_potion_effect]
Expand Down Expand Up @@ -192,15 +192,15 @@ data=consumable,gin
data=consumable,brandy
data=stat_change,strength,1,5
data=stat_change,attack,-3,-2
data=stat_restore,hitpoints,5,0
data=stat_heal,hitpoints,5,0

[cocktail_effect1]
table=consume_table
data=consumable,premade_blurberry_special
data=consumable,blurberry_special
data=stat_change,attack,-3,-2
data=stat_change,strength,2,5
data=stat_restore,hitpoints,7,0
data=stat_heal,hitpoints,7,0

[cocktail_effect2]
table=consume_table
Expand All @@ -210,7 +210,7 @@ data=consumable,premade_drunk_dragon
data=consumable,drunk_dragon
data=stat_change,attack,-3,-2
data=stat_change,strength,2,5
data=stat_restore,hitpoints,5,0
data=stat_heal,hitpoints,5,0

[cocktail_effect3]
table=consume_table
Expand All @@ -220,15 +220,15 @@ data=consumable,premade_short_green_guy
data=consumable,short_green_guy
data=stat_change,attack,-3,-2
data=stat_change,strength,1,6
data=stat_restore,hitpoints,5,0
data=stat_heal,hitpoints,5,0

[cocktail_effect4]
table=consume_table
data=consumable,premade_pineapple_punch
data=consumable,pineapple_punch
data=consumable,premade_fruit_blast
data=consumable,fruit_blast
data=stat_restore,hitpoints,9,0
data=stat_heal,hitpoints,9,0

// really unsure if unfinished cocktails belong here
[odd_cocktail_effect]
Expand Down Expand Up @@ -262,13 +262,13 @@ data=consumable,unfinished_fruit_blast1
data=consumable,unfinished_pineapple_punch1
data=consumable,unfinished_pineapple_punch2
data=consumable,unfinished_pineapple_punch3
data=stat_restore,hitpoints,0,0
data=stat_heal,hitpoints,0,0

[tea_effect]
table=consume_table
data=consumable,cup_of_tea
data=stat_change,attack,2,2
data=stat_restore,hitpoints,3,0
data=stat_heal,hitpoints,3,0

[odd_gnomefood_effect]
table=consume_table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,16 @@ while ($i < db_getfieldcount($effect_data, consume_table:stat_change)) {
// stat restore
$i = 0;
while ($i < db_getfieldcount($effect_data, consume_table:stat_restore)) {
stat_heal(db_getfield($effect_data, consume_table:stat_restore, $i));
~stat_healbase(db_getfield($effect_data, consume_table:stat_restore, $i));
$i = calc($i + 1);
}
// stat heal
$i = 0;
while ($i < db_getfieldcount($effect_data, consume_table:stat_heal)) {
stat_heal(db_getfield($effect_data, consume_table:stat_heal, $i));
$i = calc($i + 1);
}

// start sound
~consume_effect_sound(db_getfield($effect_data, consume_table:consume_sound, 0));
// display messages
Expand Down
5 changes: 5 additions & 0 deletions data/src/scripts/player/scripts/stat.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ if (calc($level - $debuff) < $min_level) {
// subtract the debuff, with no percent
stat_sub($stat, $debuff, 0);

// stat_heal but instead of scaling based off stat, it scales off of stat_base
[proc,stat_healbase](stat $stat, int $constant, int $percent)
def_int $heal = add(scale($percent, 100, stat_base($stat)), $constant);
stat_heal($stat, $heal, 0);

[proc,stat_reset](stat $stat)
def_int $d = sub(stat($stat), stat_base($stat));

Expand Down
2 changes: 1 addition & 1 deletion src/lostcity/engine/script/handlers/PlayerOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ const PlayerOps: CommandHandlers = {
const base = player.baseLevels[stat];
const current = player.levels[stat];
const healed = current + (constant + (current * percent) / 100);
player.levels[stat] = Math.min(healed, base);
player.levels[stat] = Math.max(Math.min(healed, base), current);

if (stat === 3 && player.levels[3] >= player.baseLevels[3]) {
player.resetHeroPoints();
Expand Down

0 comments on commit 4280ab3

Please sign in to comment.