Skip to content

Commit

Permalink
make spectral blades follow the mob owner
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Nov 9, 2023
1 parent 86e3c41 commit 1d5c5c2
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 10 deletions.
14 changes: 9 additions & 5 deletions python/things/buffs/buff_permanent_multiplicity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@


def on_owner_attack_dmg_melee(me, owner, victim, x, y, damage):
# my.con("x,y {},{}".format(x, y))
# my.con("me {} {:X}".format(my.thing_name_get(me), me))
# my.con("owner {} {:X}".format(my.thing_name_get(owner), owner))
# my.con("victim {} {:X}".format(my.thing_name_get(victim), victim))
# my.con("damage {}".format(damage))
if not my.level_is_spectral_blade_at(me, x, y):
if my.level_is_alive_monst_at(me, x, y) or my.level_is_monst_at(me, x, y):
vx, vy = my.thing_coords_get(victim)
if not my.level_is_spectral_blade_at(me, vx, vy):
if my.level_is_alive_monst_at(me, vx, vy) or my.level_is_monst_at(me, vx, vy):
roll = my.py_d100()
if roll < 10 + my.thing_enchant_count_get(me) * 5:
my.place_at(me, "spectral_blade", x, y)
if roll < 100 + my.thing_enchant_count_get(me) * 5:
it = my.spawn_at_my_position(victim, "spectral_blade_companion")
if it != 0:
my.thing_set_mob(it, owner)
return damage


Expand All @@ -37,7 +41,7 @@ def tp_init(name, text_long_name, text_short_name):


def init():
tp_init(name="buff_permanent_multiplicity", text_long_name="multiplicity weapon", text_short_name="multiplicity weapon")
tp_init(name="buff_permanent_multiplicity", text_long_name="multiplicity", text_short_name="multiplicity")


init()
128 changes: 128 additions & 0 deletions python/things/monsters/spectral_blade_companion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import my
import tp


def on_death(me, x, y):
my.thing_msg(me, "The spectral blade vanishes!")


def tp_init(name, text_long_name, text_short_name):
self = tp.Tp(name, text_long_name, text_short_name)
# begin sort marker
my.aggression_pct(self, 100)
my.ai_resent_count(self, 100)
my.ai_wanderer(self, True)
my.attack_humanoid(self, True)
my.chance_d1000_tameable(self, 0)
my.collision_check(self, True)
my.collision_hit_priority(self, 20)
my.distance_minion_from_mob_max(self, 2)
my.distance_minion_vision_shared(self, True)
my.distance_vision(self, 8)
my.dmg_chance_d1000_nat_att(self, 0, 1000)
my.dmg_nat_att_dice(self, "1d3")
my.dmg_nat_att_type(self, "slices")
my.dmg_num_of_attacks(self, 1)
my.dmg_rcv_doubled_from_fire(self, True)
my.gfx_ascii_fade_with_dist(self, True)
my.gfx_ascii_shown(self, True)
my.gfx_pixelart_animated(self, True)
my.gfx_pixelart_oversized_and_centered(self, True)
my.gfx_pixelart_reflection(self, True)
my.gfx_pixelart_wobbles_when_hit(self, True)
my.health_initial_dice(self, "1")
my.is_able_to_be_teleported(self, True)
my.is_able_to_see_in_the_dark(self, True)
my.is_able_to_shoot_at_close_range(self, True)
my.is_attackable_by_monst(self, True)
my.is_attackable_by_player(self, True)
my.is_biome_chasms(self, True)
my.is_biome_dungeon(self, True)
my.is_biome_ice(self, True)
my.is_buffable(self, True)
my.is_described_in_leftbar(self, True)
my.is_described_when_hovering_over(self, True)
my.is_ethereal(self, True)
my.is_fearless(self, True)
my.is_floating(self, True)
my.is_hittable(self, True)
my.is_immune_to_blinding(self, True)
my.is_immune_to_confusion(self, True)
my.is_immune_to_entrancement(self, True)
my.is_immune_to_necrosis(self, True)
my.is_immune_to_paralysis(self, True)
my.is_immune_to_poison(self, True)
my.is_immune_to_vorpal_weapon(self, True)
my.is_interesting(self, True)
my.is_lifeless(self, True)
my.is_loggable(self, True)
my.is_magical(self, True)
my.is_minion(self, True)
my.is_monst_class_B(self, True)
my.is_monst(self, True)
my.is_moveable(self, True)
my.is_not_shown_as_a_pet(self, True)
my.is_shootable(self, True)
my.is_tickable(self, True)
my.light_color(self, "white")
my.light_dist(self, 1)
my.move_speed(self, 200)
my.noise_decibels_hearing(self, 0)
my.noise_on_moving(self, 0)
my.normal_placement_rules(self, True)
my.on_death_do(self, "me.on_death()")
my.rarity(self, my.RARITY_UNIQUE) # how rare within this monster class
my.stat_con(self, 10)
my.stat_def(self, 10)
my.stat_dex(self, 10)
my.stat_luck(self, 10)
my.stat_psi(self, 0)
my.stat_str(self, 10)
my.temperature_max(self, 50)
my.temperature_min(self, -50)
my.temperature(self, 0)
my.temperature_sensitive(self, True)
my.text_a_or_an(self, "a")
my.text_description_long(self, "A companion phantom blade that just wants to play.")
my.text_description_short(self, "A spectral blde.")
my.text_hits(self, "slices")
my.thing_size(self, my.THING_SIZE_NORMAL)
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
my.z_depth(self, my.MAP_DEPTH_OBJ)
my.z_prio(self, my.MAP_Z_PRIO_MONST)
# end sort marker

delay = 25
name = "spectral_blade"

my.tile(self,
ascii_fg_char="/", ascii_fg_col_name="white",
tile=name + ".1", delay_ms=delay)
my.tile(self,
ascii_fg_char="|", ascii_fg_col_name="white",
tile=name + ".2", delay_ms=delay)
my.tile(self,
ascii_fg_char="\\", ascii_fg_col_name="white",
tile=name + ".3", delay_ms=delay)
my.tile(self,
ascii_fg_char="-", ascii_fg_col_name="white",
tile=name + ".4", delay_ms=delay)
my.tile(self,
ascii_fg_char="/", ascii_fg_col_name="white",
tile=name + ".5", delay_ms=delay)
my.tile(self,
ascii_fg_char="|", ascii_fg_col_name="white",
tile=name + ".6", delay_ms=delay)
my.tile(self,
ascii_fg_char="\\", ascii_fg_col_name="white",
tile=name + ".7", delay_ms=delay)
my.tile(self,
ascii_fg_char="-", ascii_fg_col_name="white",
tile=name + ".8", delay_ms=delay)


def init():
tp_init(name="spectral_blade_companion", text_long_name="spectral blade", text_short_name="spectral blade")


init()
9 changes: 9 additions & 0 deletions src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ void Game::place_player(void)
}
level->thing_new("tentacleye", point(x + 1, y));
}
if (1) {
auto w = level->thing_new("mace", point(x, y));
t->carry(w, carry_options);
if (1) {
auto r = tp_find("buff_permanent_multiplicity");
w->runic_name_set(r->name());
}
level->thing_new("dogman", point(x + 1, y));
}
if (0) {
level->thing_new("skeleton", point(x, y + 3));
auto w = level->thing_new("sword_holy", point(x, y));
Expand Down
11 changes: 11 additions & 0 deletions src/thing_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,17 @@ void Thing::ai_choose_can_see_goals(std::multiset< Goal > &goals, int minx, int
}
}

//
// If a spectral blade is too far from its multiplicity owner, move toward it
//
auto m = top_mob();
if (m) {
if (too_far_from_mob()) {
point p = m->curr_at;
GOAL_ADD(GOAL_PRIO_HIGH, 100, "follow-mob", l);
}
}

dbg2("Choose can see goals between %d,%d and %d,%d", minx, miny, maxx, maxy);
TRACE_NO_INDENT();

Expand Down
2 changes: 1 addition & 1 deletion src/thing_stat_att.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int Thing::stat_att_penalties_total(void)
penalty += p;
if (penalty != prev) {
prev = penalty;
dbg("Att penalty: weapon min str not reached %d", p);
dbg("Att penalty: weapon min str not reached, penalty %d", p);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/thing_template_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ std::initializer_list< std::string > tps = {
"somekindofmeat",
"spectral_blade",
"spectral_blade_minion",
"spectral_blade_companion",
"spectral_mob",
"spellbook1",
"spellbook2",
Expand Down
20 changes: 16 additions & 4 deletions src/wid_thing_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ WidPopup *Game::wid_thing_info_create_popup(Thingp t, point tl, point br)
if (rune) {
wid_popup_window->log(UI_LOGGING_EMPTY_LINE);
wid_popup_window->log("%%fg=yellow$This weapon is inscribed with");
wid_popup_window->log("%%fg=yellow$a magical " + rune->text_long_name() + " rune!");
wid_popup_window->log("%%fg=yellow$a magical rune:");
wid_popup_window->log("%%fg=gold$" + rune->text_long_name());
}
}
}
Expand Down Expand Up @@ -2459,6 +2460,11 @@ void Game::wid_thing_info_add_stat_str(WidPopup *w, Thingp t)
TRACE_AND_INDENT();
char tmp[ MAXSHORTSTR ];

auto player = game->level->player;
if (! player) {
return;
}

if (t->is_alive_monst() || t->is_player()) {
auto stat = t->stat_str_total();
char tmp2[ MAXSHORTSTR ];
Expand Down Expand Up @@ -2598,9 +2604,15 @@ void Game::wid_thing_info_add_stat_str(WidPopup *w, Thingp t)
}

if (t->stat_str_min()) {
auto stat = t->stat_str_min();
snprintf(tmp, sizeof(tmp) - 1, "%%fg=gray$Strength min needed %4u", stat);
w->log(tmp);
if (player->stat_str_total() > t->stat_str_min()) {
auto stat = t->stat_str_min();
snprintf(tmp, sizeof(tmp) - 1, "%%fg=gray$Strength requirement %4u", stat);
w->log(tmp);
} else {
auto stat = t->stat_str_min();
snprintf(tmp, sizeof(tmp) - 1, "%%fg=red$Strength min needed %4u", stat);
w->log(tmp);
}
}
}

Expand Down

0 comments on commit 1d5c5c2

Please sign in to comment.