Skip to content

Commit

Permalink
bug: fix floating point damage
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Jul 16, 2023
1 parent 3c9e381 commit b4ac898
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions python/things/cloaks/cloak_stone.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def on_waiting(me, x, y):

if my.level_is_wall_at(owner, x, y):
stamina = my.thing_stamina(owner)
new_stamina = int((stamina / 100.0) * 90)
new_stamina = int(float(stamina) / 100.0 * 90.0)
my.thing_stamina_set(owner, new_stamina)
if my.thing_is_player(owner):
my.thing_msg(owner, "You wait inside the wall and feel drained.")
return True

if my.level_is_rock_at(owner, x, y):
stamina = my.thing_stamina(owner)
new_stamina = int((stamina / 100.0) * 80)
new_stamina = int(float(stamina) / 100.0 * 80.0)
my.thing_stamina_set(owner, new_stamina)
if my.thing_is_player(owner):
my.thing_msg(owner, "You wait inside solid rock and feel very drained.")
Expand All @@ -42,15 +42,15 @@ def on_move(me, x, y):

if my.level_is_wall_at(owner, x, y):
stamina = my.thing_stamina(owner)
new_stamina = int((stamina / 100.0) * 80)
new_stamina = int(float(stamina) / 100.0 * 80.0)
my.thing_stamina_set(owner, new_stamina)
if my.thing_is_player(owner):
my.thing_msg(owner, "You pass into the wall, but feel drained.")
return True

if my.level_is_rock_at(owner, x, y):
stamina = my.thing_stamina(owner)
new_stamina = int((stamina / 100.0) * 50)
new_stamina = int(float(stamina) / 100.0 * 50.0)
my.thing_stamina_set(owner, new_stamina)
if my.thing_is_player(owner):
my.thing_msg(owner, "You pass into solid rock, but feel very drained.")
Expand Down
2 changes: 1 addition & 1 deletion python/things/monsters/gargoyle_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def on_hit_and_still_alive(me, hitter, real_hitter, x, y, crit, damage):
my.thing_sound_play_channel(me, my.CHANNEL_MONST, "monster_roar")

health = my.thing_health(me)
low_health = int((my.thing_health_max(me) / 100.0) * 90)
low_health = int(float(my.thing_health_max(me)) / 100.0 * 90.0)
if health < low_health:
my.thing_speaks(me, "Free at last!")
my.thing_popup(me, "Free!")
Expand Down
4 changes: 2 additions & 2 deletions python/things/potions/potion_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def on_use(owner, item, target, x, y):
enchant = my.thing_enchant_count_get(item)

health = my.thing_health(owner)
new_health = int((my.thing_health_max(owner) / 100.0) * 80 + enchant * 10)
new_health = int((float(my.thing_health_max(owner)) / 100.0) * 80.0 + enchant * 10.0)
if new_health > health:
did_something = True
my.thing_health_set(owner, new_health)

stamina = my.thing_stamina(owner)
new_stamina = int((my.thing_stamina_max(owner) / 100.0) * 80 + enchant * 10)
new_stamina = int((float(my.thing_stamina_max(owner)) / 100.0) * 80.0 + enchant * 10.0)
if new_stamina > stamina:
did_something = True
my.thing_stamina_set(owner, new_stamina)
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_double_strike1.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def on_use_skill(owner, skill, target, x, y):
my.spawn_using_items_radius_range(owner, skill, target, "skill_double_strike_effect")

dmg = my.thing_dmg_current(owner)
dmg = int(dmg / 100) * 20
dmg = int(float(dmg) / 100.0 * 20.0)
if (dmg == 0):
dmg = 1
my.thing_dmg_current_set(owner, dmg)
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_double_strike2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def on_use_skill(owner, skill, target, x, y):
my.spawn_using_items_radius_range(owner, skill, target, "skill_double_strike_effect")

dmg = my.thing_dmg_current(owner)
dmg = int(dmg / 100) * 30
dmg = int(float(dmg) / 100.0 * 30.0)
if (dmg == 0):
dmg = 1
my.thing_dmg_current_set(owner, dmg)
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_double_strike3.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def on_use_skill(owner, skill, target, x, y):
my.spawn_using_items_radius_range(owner, skill, target, "skill_double_strike_effect")

dmg = my.thing_dmg_current(owner)
dmg = int(dmg / 100) * 50
dmg = int(float(dmg) / 100.0 * 50.0)
if (dmg == 0):
dmg = 1
my.thing_dmg_current_set(owner, dmg)
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_double_strike4.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_use_skill(owner, skill, target, x, y):
my.spawn_using_items_radius_range(owner, skill, target, "skill_double_strike_effect")

dmg = my.thing_dmg_current(owner)
dmg = int(dmg / 100) * 75
dmg = int(float(dmg) / 100.0 * 75.0)
if (dmg == 0):
dmg = 1
my.thing_dmg_current_set(owner, dmg)
Expand Down
4 changes: 2 additions & 2 deletions python/things/skills/skill_vampiric_touch0.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def do_vampiric_touch(me, owner, hitter, real_hitter, x, y, damage, damage_reduc
dmg_reduction = 0

if my.thing_is_monst(real_hitter):
dmg_reduction = int((damage / 100) * damage_reduction_percent)
dmg_reduction = int(float(damage) / 100.0 * damage_reduction_percent)
if dmg_reduction == 0:
dmg_reduction = 1

if dmg_reduction > 0:
if owner and (my.thing_health(owner) < my.thing_health_max(owner)):

health_boost = int(dmg_reduction / 2)
health_boost = int(float(dmg_reduction) / 2.0)
my.thing_health_incr(owner, health_boost)

stamina_boost = dmg_reduction
Expand Down
4 changes: 2 additions & 2 deletions src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void Game::place_player(void)
auto w = level->thing_new("skill_primal_rage1", point(x, y));
t->skill_add(w);
}
if (0) {
if (1) {
auto w = level->thing_new("skill_devoted_thrust1", point(x, y));
t->skill_add(w);
}
Expand Down Expand Up @@ -360,8 +360,8 @@ void Game::place_player(void)
auto d = level->thing_new("dogman", point(x + 2, y));
d->wake("");
}
level->thing_new("tentacleye", point(x + 1, y + 1));
if (0) {
level->thing_new("tentacleye", point(x + 1, y + 1));
level->thing_new("exit1", point(x - 3, y + 2));
level->thing_new("gnome_rock", point(x + 2, y + 1));
level->thing_new("tentacleye", point(x + 1, y + 1));
Expand Down

0 comments on commit b4ac898

Please sign in to comment.