Skip to content

Commit

Permalink
bug: devoted thrust rounding errors
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Jul 16, 2023
1 parent 6fa34a8 commit 3c9e381
Show file tree
Hide file tree
Showing 37 changed files with 157 additions and 42 deletions.
Binary file modified data/gfx.tgz
Binary file not shown.
18 changes: 9 additions & 9 deletions python/gfx.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,24 +399,24 @@ def init_tiles_16x16_main():
"bug",
############################################################
"",
"skill_devoted_thrust_activated",
"skill_devoted_thrust",
"skill_double_strike_activated",
"skill_devoted_thrust_activated",
"skill_double_strike",
"skill_gold_to_health_activated",
"skill_double_strike_activated",
"skill_gold_to_health",
"skill_artful_dodging_activated",
"skill_gold_to_health_activated",
"skill_artful_dodging",
"skill_primal_rage_activated",
"skill_artful_dodging_activated",
"skill_primal_rage",
"skill_healing_activated",
"skill_primal_rage_activated",
"skill_healing",
"skill_vampiric_touch_activated",
"skill_healing_activated",
"skill_vampiric_touch",
"skill_intimidating_strength_activated",
"skill_vampiric_touch_activated",
"skill_intimidating_strength",
"skill_super_health_activated",
"skill_intimidating_strength_activated",
"skill_super_health",
"skill_super_health_activated",
############################################################
"",
"spell_magic_missile",
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_artful_dodging0.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ def tp_init(self):
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_prio(self, my.MAP_Z_PRIO_ALWAYS_BEHIND)
# end sort marker
my.tile(self, tile="skill_artful_dodging_activated")
my.tile(self, tile="skill_artful_dodging")
my.tile(self, tile="skill_artful_dodging_activated")
4 changes: 2 additions & 2 deletions python/things/skills/skill_devoted_thrust0.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def tp_init(self):
my.is_skill(self, True)
my.is_tickable(self, True)
my.on_tick_when_activated_do(self, "me.on_tick_when_activated()")
my.on_use_do(self, "me.on_use()")
my.on_use_skill_do(self, "me.on_use_skill()")
my.skill_base_name(self, "skill_devoted_thrust")
my.text_description_long2(self, "The Devoted Thrust skill directs your stamina into sheer vanquishing power.")
my.text_description_long3(self, "Be warned that at high levels of this skill, you will become drained very quickly and may render yourself unable to move or jump, or escape a trap.")
Expand All @@ -17,5 +17,5 @@ def tp_init(self):
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_prio(self, my.MAP_Z_PRIO_ALWAYS_BEHIND)
# end sort marker
my.tile(self, tile="skill_devoted_thrust_activated")
my.tile(self, tile="skill_devoted_thrust")
my.tile(self, tile="skill_devoted_thrust_activated")
5 changes: 3 additions & 2 deletions python/things/skills/skill_devoted_thrust1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
if not target:
return
my.spawn_using_items_radius_range(owner, skill, target, "skill_devoted_thrust_effect")
bonus = int(my.thing_stamina(owner) / 100) * 20
bonus = int(float(my.thing_stamina(owner) / 100.0) * 20.0)

if bonus > 1:
if my.thing_is_player(owner):
my.thing_msg(owner, f"%%fg=yellow$You strike with a mighty thrust of {bonus} additional damage.%%fg=reset$")
my.thing_dmg_current_incr(owner, bonus)
my.thing_stamina_decr(owner, bonus)
else:
if my.thing_is_player(owner):
my.thing_msg(owner, "You run out of devotion.")
Expand Down
5 changes: 3 additions & 2 deletions python/things/skills/skill_devoted_thrust2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
if not target:
return
my.spawn_using_items_radius_range(owner, skill, target, "skill_devoted_thrust_effect")
bonus = int(my.thing_stamina(owner) / 100) * 30
bonus = int(float(my.thing_stamina(owner) / 100.0) * 30.0)

if bonus > 1:
if my.thing_is_player(owner):
my.thing_msg(owner, f"%%fg=yellow$You strike with a mighty thrust of {bonus} additional damage.%%fg=reset$")
my.thing_dmg_current_incr(owner, bonus)
my.thing_stamina_decr(owner, bonus)
else:
if my.thing_is_player(owner):
my.thing_msg(owner, "You run out of devotion.")
Expand Down
5 changes: 3 additions & 2 deletions python/things/skills/skill_devoted_thrust3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
if not target:
return
my.spawn_using_items_radius_range(owner, skill, target, "skill_devoted_thrust_effect")
bonus = int(my.thing_stamina(owner) / 100) * 50
bonus = int(float(my.thing_stamina(owner) / 100.0) * 50.0)

if bonus > 1:
if my.thing_is_player(owner):
my.thing_msg(owner, f"%%fg=yellow$You strike with a mighty thrust of {bonus} additional damage.%%fg=reset$")
my.thing_dmg_current_incr(owner, bonus)
my.thing_stamina_decr(owner, bonus)
else:
if my.thing_is_player(owner):
my.thing_msg(owner, "You run out of devotion.")
Expand Down
5 changes: 3 additions & 2 deletions python/things/skills/skill_devoted_thrust4.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
if not target:
return
my.spawn_using_items_radius_range(owner, skill, target, "skill_devoted_thrust_effect")
bonus = int(my.thing_stamina(owner) / 100) * 75
bonus = int(float(my.thing_stamina(owner) / 100.0) * 75.0)

if bonus > 1:
if my.thing_is_player(owner):
my.thing_msg(owner, f"%%fg=yellow$You strike with a mighty thrust of {bonus} additional damage.%%fg=reset$")
my.thing_dmg_current_incr(owner, bonus)
my.thing_stamina_decr(owner, bonus)
else:
if my.thing_is_player(owner):
my.thing_msg(owner, "You run out of devotion.")
Expand Down
5 changes: 3 additions & 2 deletions python/things/skills/skill_devoted_thrust5.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
my.spawn_using_items_radius_range(owner, skill, target, "skill_devoted_thrust_effect")
bonus = int(my.thing_stamina(owner) / 100) * 90
bonus = int(float(my.thing_stamina(owner) / 100.0) * 90.0)

if bonus > 1:
if my.thing_is_player(owner):
my.thing_msg(owner, f"%%fg=yellow$You strike with a mighty thrust of {bonus} additional damage.%%fg=reset$")
my.thing_dmg_current_incr(owner, bonus)
my.thing_stamina_decr(owner, bonus)
else:
if my.thing_is_player(owner):
my.thing_msg(owner, "You run out of devotion.")
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_double_strike0.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def tp_init(self):
my.is_skill(self, True)
my.is_tickable(self, True)
my.on_tick_when_activated_do(self, "me.on_tick_when_activated()")
my.on_use_do(self, "me.on_use()")
my.on_use_skill_do(self, "me.on_use_skill()")
my.skill_base_name(self, "skill_double_strike")
my.text_description_long(self, "With this skill you will develop the ability to deliver a deadly second strike. Initially the extra damage will be minimal but over time you will become a true force to be reckoned with.")
my.text_description_short(self, "Double strike skill.")
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 @@ -11,7 +11,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
attack = my.thing_attack_num_get(owner)
if attack == 0:
return
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 @@ -11,7 +11,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
attack = my.thing_attack_num_get(owner)
if attack == 0:
return
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 @@ -11,7 +11,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
attack = my.thing_attack_num_get(owner)
if attack == 0:
return
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 @@ -11,7 +11,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
attack = my.thing_attack_num_get(owner)
if attack == 0:
return
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_double_strike5.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
attack = my.thing_attack_num_get(owner)
if attack == 0:
return
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_gold_to_health0.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ def tp_init(self):
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_prio(self, my.MAP_Z_PRIO_ALWAYS_BEHIND)
# end sort marker
my.tile(self, tile="skill_gold_to_health")
my.tile(self, tile="skill_gold_to_health_activated")
my.tile(self, tile="skill_gold_to_health")
2 changes: 1 addition & 1 deletion python/things/skills/skill_healing0.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def tp_init(self):
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_prio(self, my.MAP_Z_PRIO_ALWAYS_BEHIND)
# end sort marker
my.tile(self, tile="skill_healing_activated")
my.tile(self, tile="skill_healing")
my.tile(self, tile="skill_healing_activated")
2 changes: 1 addition & 1 deletion python/things/skills/skill_intimidating_strength0.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def tp_init(self):
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_prio(self, my.MAP_Z_PRIO_ALWAYS_BEHIND)
# end sort marker
my.tile(self, tile="skill_intimidating_strength_activated")
my.tile(self, tile="skill_intimidating_strength")
my.tile(self, tile="skill_intimidating_strength_activated")
4 changes: 2 additions & 2 deletions python/things/skills/skill_primal_rage0.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ def tp_init(self):
my.is_tickable(self, True)
my.on_tick_when_activated_do(self, "me.on_tick_when_activated()")
my.on_tick_when_deactivated_do(self, "me.on_tick_when_deactivated()")
my.on_use_do(self, "me.on_use()")
my.on_use_skill_do(self, "me.on_use_skill()")
my.skill_base_name(self, "skill_primal_rage")
my.text_description_long2(self, "When raging your stamina will drain rapidly.")
my.text_description_long(self, "Engage your primal spirit with the ability to rage when low on health. In such a state of frenzy you will gain strength, to-hit and damage bonuses.")
my.text_description_short(self, "primal rage skill.")
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_prio(self, my.MAP_Z_PRIO_ALWAYS_BEHIND)
# end sort marker
my.tile(self, tile="skill_primal_rage_activated")
my.tile(self, tile="skill_primal_rage")
my.tile(self, tile="skill_primal_rage_activated")
2 changes: 1 addition & 1 deletion python/things/skills/skill_primal_rage1.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
my.spawn_using_items_radius_range(owner, skill, target, "skill_primal_rage_effect")
bonus = 2
my.thing_dmg_current_incr(owner, bonus)
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_primal_rage2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
if not target:
return
my.spawn_using_items_radius_range(owner, skill, target, "skill_primal_rage_effect")
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_primal_rage3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
my.spawn_using_items_radius_range(owner, skill, target, "skill_primal_rage_effect")
bonus = 6
my.thing_dmg_current_incr(owner, bonus)
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_primal_rage4.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
my.spawn_using_items_radius_range(owner, skill, target, "skill_primal_rage_effect")
bonus = 6
my.thing_dmg_current_incr(owner, bonus)
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_primal_rage5.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def on_tick_when_activated(owner, skill, x, y):
return False # didn't do anything


def on_use(owner, skill, target, x, y):
def on_use_skill(owner, skill, target, x, y):
if not target:
return
my.spawn_using_items_radius_range(owner, skill, target, "skill_primal_rage_effect")
Expand Down
2 changes: 1 addition & 1 deletion python/things/skills/skill_super_health0.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ def tp_init(self):
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_prio(self, my.MAP_Z_PRIO_ALWAYS_BEHIND)
# end sort marker
my.tile(self, tile="skill_super_health_activated")
my.tile(self, tile="skill_super_health")
my.tile(self, tile="skill_super_health_activated")
2 changes: 1 addition & 1 deletion python/things/skills/skill_vampiric_touch0.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ def tp_init(self):
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_prio(self, my.MAP_Z_PRIO_ALWAYS_BEHIND)
# end sort marker
my.tile(self, tile="skill_vampiric_touch_activated")
my.tile(self, tile="skill_vampiric_touch")
my.tile(self, tile="skill_vampiric_touch_activated")
3 changes: 2 additions & 1 deletion src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void Game::place_player(void)
auto b = level->thing_new("enchantstone", point(x, y));
t->carry(b, carry_options);
}
if (0) {
if (1) {
{
for (auto sk = 0; sk < 1; sk++) {
auto b = level->thing_new("skillstone", point(x, y));
Expand Down Expand Up @@ -360,6 +360,7 @@ 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("exit1", point(x - 3, y + 2));
level->thing_new("gnome_rock", point(x + 2, y + 1));
Expand Down
1 change: 1 addition & 0 deletions src/my_py_tp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ TP_SET_PROTO(on_tick_when_activated_do)
TP_SET_PROTO(on_tick_when_deactivated_do)
TP_SET_PROTO(on_unequip_do)
TP_SET_PROTO(on_use_do)
TP_SET_PROTO(on_use_skill_do)
TP_SET_PROTO(on_waiting_do)
TP_SET_PROTO(on_want_to_shoot_at_do)
TP_SET_PROTO(on_you_are_declared_a_follower_do)
Expand Down
3 changes: 3 additions & 0 deletions src/my_thing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,7 @@ typedef class Thing_
const std::string &on_tick_when_deactivated_do(void);
const std::string &on_unequip_do(void);
const std::string &on_use_do(void);
const std::string &on_use_skill_do(void);
const std::string &on_waiting_do(void);
const std::string &on_want_to_shoot_at_do(void);
const std::string &on_you_are_declared_a_follower_do(void);
Expand Down Expand Up @@ -2860,6 +2861,8 @@ typedef class Thing_
void on_thrown_callback(ThingId owner_id_when_thrown);
void on_thrown(ThingId owner_id_when_thrown);
void on_unequip(Thingp what);
void on_use_skill(Thingp what);
void on_use_skill(Thingp what, Thingp target);
void on_use(Thingp what);
void on_use(Thingp what, Thingp target);
void on_waiting(void);
Expand Down
3 changes: 3 additions & 0 deletions src/my_thing_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ class Tp
std::string _on_tick_when_deactivated_do;
std::string _on_unequip_do;
std::string _on_use_do;
std::string _on_use_skill_do;
std::string _on_waiting_do;
std::string _on_want_to_shoot_at_do;
std::string _on_you_are_declared_a_follower_do;
Expand Down Expand Up @@ -1399,6 +1400,7 @@ class Tp
const std::string &on_tick_when_deactivated_do(void) const;
const std::string &on_unequip_do(void) const;
const std::string &on_use_do(void) const;
const std::string &on_use_skill_do(void) const;
const std::string &on_waiting_do(void) const;
const std::string &on_want_to_shoot_at_do(void) const;
const std::string &on_you_are_declared_a_follower_do(void) const;
Expand Down Expand Up @@ -3041,6 +3043,7 @@ class Tp
void on_tick_when_deactivated_do_set(const std::string &v);
void on_unequip_do_set(const std::string &v);
void on_use_do_set(const std::string &v);
void on_use_skill_do_set(const std::string &v);
void on_waiting_do_set(const std::string &v);
void on_want_to_shoot_at_do_set(const std::string &v);
void on_you_are_declared_a_follower_do_set(const std::string &v);
Expand Down
1 change: 1 addition & 0 deletions src/py_tp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,7 @@ TP_BODY_SET_STRING(on_tick_when_activated_do)
TP_BODY_SET_STRING(on_tick_when_deactivated_do)
TP_BODY_SET_STRING(on_unequip_do)
TP_BODY_SET_STRING(on_use_do)
TP_BODY_SET_STRING(on_use_skill_do)
TP_BODY_SET_STRING(on_waiting_do)
TP_BODY_SET_STRING(on_want_to_shoot_at_do)
TP_BODY_SET_STRING(on_you_are_declared_a_follower_do)
Expand Down
1 change: 1 addition & 0 deletions src/python_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,7 @@ static PyMethodDef python_c_METHODS[] = {
MY_ADD_PYTHON_TP_FUNCTION(on_tick_when_deactivated_do),
MY_ADD_PYTHON_TP_FUNCTION(on_unequip_do),
MY_ADD_PYTHON_TP_FUNCTION(on_use_do),
MY_ADD_PYTHON_TP_FUNCTION(on_use_skill_do),
MY_ADD_PYTHON_TP_FUNCTION(on_waiting_do),
MY_ADD_PYTHON_TP_FUNCTION(on_want_to_shoot_at_do),
MY_ADD_PYTHON_TP_FUNCTION(on_you_are_declared_a_follower_do),
Expand Down
6 changes: 6 additions & 0 deletions src/thing_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4520,6 +4520,12 @@ const std::string &Thing::on_use_do(void)
return (tp()->on_use_do());
}

const std::string &Thing::on_use_skill_do(void)
{
TRACE_NO_INDENT();
return (tp()->on_use_skill_do());
}

const std::string &Thing::on_swing_do(void)
{
TRACE_NO_INDENT();
Expand Down

0 comments on commit 3c9e381

Please sign in to comment.