Skip to content

Commit

Permalink
bug: add runics only to enchanted items
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack authored and Neil McGill committed Nov 7, 2023
1 parent 64e20bf commit 3178fdd
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 38 deletions.
2 changes: 1 addition & 1 deletion python/things/monsters/kraken_tentacle.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def tp_init(name, text_long_name):
my.temperature(self, 20)
my.temperature_sensitive(self, True)
my.text_a_or_an(self, "a")
my.text_description_long(self, "A deadly kraken tentacle. Beware its grapple attack.")
my.text_description_long(self, "A deadly kraken tentacle. Beware its grapple attack and watch out for it's poisonous ink.")
my.text_description_short(self, "A slimy tentacle.")
my.text_hits(self, "bites")
my.thing_size(self, my.THING_SIZE_NORMAL)
Expand Down
2 changes: 1 addition & 1 deletion src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void Game::place_player(void)
}
if (0) {
auto w = level->thing_new("very_broadsword", point(x + 3, y));
w->enchant_randomly();
w->add_random_enchants();
// t->carry(w,carry_options);
// t->enchant_without_stone(w);
}
Expand Down
20 changes: 10 additions & 10 deletions src/level_biome_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,14 @@ void Level::place_objects_with_normal_placement_rules(Dungeonp d)
} else if (t->is_weapon()) {
if (r && r->is_secret) {
if (d10000() < t->chance_d10000_enchanted() * 2) {
t->enchant_randomly();
t->add_random_enchants();
}
}
dbg("INF: Placed weapon '%s'", t->text_short_capitalised().c_str());
} else if (t->is_treasure_type()) {
if (r && r->is_secret) {
if (d10000() < t->chance_d10000_enchanted() * 2) {
t->enchant_randomly();
t->add_random_enchants();
}
}
dbg("INF: Placed treasure '%s'", t->text_short_capitalised().c_str());
Expand Down Expand Up @@ -577,7 +577,7 @@ void Level::place_random_treasure(Dungeonp d)
}

if (d10000() < t->chance_d10000_enchanted()) {
t->enchant_randomly();
t->add_random_enchants();
}

if (t->is_sword()) {
Expand All @@ -586,11 +586,11 @@ void Level::place_random_treasure(Dungeonp d)
// Double enchant swords in lakes :)
//
if (d->is_shallow_water(x, y)) {
t->enchant_randomly();
t->add_random_enchants();
}

if (d->is_deep_water(x, y)) {
t->enchant_randomly();
t->add_random_enchants();
}
}
} else {
Expand All @@ -599,7 +599,7 @@ void Level::place_random_treasure(Dungeonp d)
//
if (d10000() < t->chance_d10000_enchanted()) {
if (d->is_deep_water(x, y)) {
t->enchant_randomly();
t->add_random_enchants();
}
}
}
Expand Down Expand Up @@ -649,7 +649,7 @@ bool Level::place_random_named(Dungeonp d, const std::string &what)
}

if (d10000() < t->chance_d10000_enchanted()) {
t->enchant_randomly();
t->add_random_enchants();
}

if (t->is_sword()) {
Expand All @@ -658,11 +658,11 @@ bool Level::place_random_named(Dungeonp d, const std::string &what)
//
if (d10000() < t->chance_d10000_enchanted()) {
if (d->is_shallow_water(x, y)) {
t->enchant_randomly();
t->add_random_enchants();
}

if (d->is_deep_water(x, y)) {
t->enchant_randomly();
t->add_random_enchants();
}
}
} else {
Expand All @@ -671,7 +671,7 @@ bool Level::place_random_named(Dungeonp d, const std::string &what)
//
if (d10000() < t->chance_d10000_enchanted()) {
if (d->is_deep_water(x, y)) {
t->enchant_randomly();
t->add_random_enchants();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/my_level.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ class Level
bool create_biome_sewer(point3d at, uint32_t seed);
bool create_biome_sewer_pools(void);
bool create_biome_swamp(point3d at, uint32_t seed);
bool create_wandering_monster_now(void);
bool create_wandering_monster_if_unlucky(void);
bool create_wandering_monster_now(void);
bool create_wandering_monster_periodically(void);
bool cursor_path_draw_line(Thingp, const std::vector< point > &move_path);
bool cursor_path_draw_line(Thingp, point start, point end);
Expand Down
3 changes: 2 additions & 1 deletion src/my_thing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2930,7 +2930,8 @@ typedef class Thing_
void dump_equip(void);
void dump(std::string prefix, std::ostream &out);
void enchant_common(Thingp);
void enchant_randomly(void);
void add_random_enchants(void);
void add_random_runic(void);
void enemies_tick(void);
void entranced_tick(void);
void entranced_update(void);
Expand Down
7 changes: 6 additions & 1 deletion src/thing_enchant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool Thing::enchant_without_stone(Thingp what)
return true;
}

void Thing::enchant_randomly(void)
void Thing::add_random_enchants(void)
{
TRACE_NO_INDENT();

Expand All @@ -158,6 +158,11 @@ void Thing::enchant_randomly(void)
enchant_count_incr(1);
}
damaged_count_set(0);

//
// If enchanted, it can have a runic
//
add_random_runic();
}

int Thing::enchantstone_count(void)
Expand Down
23 changes: 0 additions & 23 deletions src/thing_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,29 +184,6 @@ void Thing::init(Levelp level, const std::string &name_in, const point born, Thi
new_aip();
}

//
// Weapon runic?
//
if (is_able_to_have_a_runic_inscribed()) {
new_infop();
if (d10000() < chance_d10000_runic()) {
//
// Success
//
if (is_weapon()) {
auto tp = tp_random_runic_offensive();
if (tp) {
runic_name_set(tp->name());
}
} else {
auto tp = tp_random_runic_defensive();
if (tp) {
runic_name_set(tp->name());
}
}
}
}

//
// Init the z depth
//
Expand Down
45 changes: 45 additions & 0 deletions src/thing_runic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,48 @@ void Thing::runic_name_set(const std::string &v)
new_infop();
infop()->runic_name = v;
}

void Thing::add_random_runic(void)
{
TRACE_NO_INDENT();

if (! is_enchantable()) {
return;
}

//
// If enchanted, it can have a runic
//
if (! enchant_count_get()) {
return;
}

//
// Able to have a runic?
//
if (! is_able_to_have_a_runic_inscribed()) {
return;
}

//
// Make it more likely, the more enchants
//
if (d10000() + (500 * enchant_count_get()) < chance_d10000_runic()) {
//
// Success
//
if (is_weapon()) {
auto tp = tp_random_runic_offensive();
if (tp) {
new_infop();
runic_name_set(tp->name());
}
} else {
auto tp = tp_random_runic_defensive();
if (tp) {
new_infop();
runic_name_set(tp->name());
}
}
}
}

0 comments on commit 3178fdd

Please sign in to comment.