diff --git a/rogueviz/ru/classes.cpp b/rogueviz/ru/classes.cpp index 87da840e..3177ff48 100644 --- a/rogueviz/ru/classes.cpp +++ b/rogueviz/ru/classes.cpp @@ -60,6 +60,7 @@ struct power { power& while_dead(); power& identified_name(string, string); power& be_wearable(string wear_effect, string remove_effect, string worn = " (worn)"); + power& be_armor(const vector>& v); power& be_jewelry(string jtype, string desc); power& be_potion(); power& gain(int qf, int qo) { qty_filled += qf; qty_owned += qo; return self; } @@ -73,6 +74,7 @@ flagtype IDENTIFIED = Flag(1); flagtype ACTIVE = Flag(2); flagtype PARTIAL = Flag(4); flagtype WEAPON = Flag(8); +flagtype ARMOR = Flag(16); struct bbox { int minx, miny, maxx, maxy; @@ -901,4 +903,5 @@ struct vision : public entity { vector> visions; +extern int statseed; } diff --git a/rogueviz/ru/powers.cpp b/rogueviz/ru/powers.cpp index 5332c094..e6213c38 100644 --- a/rogueviz/ru/powers.cpp +++ b/rogueviz/ru/powers.cpp @@ -39,6 +39,58 @@ power& power::be_weapon() { return self; } +power& power::be_armor(const vector>& v) { + flags |= ARMOR; + picked_up = [this] (int x) { qty_owned += x; qty_filled = max(qty_filled, x); }; + + auto gn = get_name; get_name = [gn, this] { + string s = gn(); + s += " [" + its(qty_filled) + "]"; + if(qty_owned > qty_filled) s += " (+" + its(qty_owned - qty_filled) + ")"; + return s; + }; + + auto gd = get_desc; + get_desc = [this, gd, v] () -> string { + auto desc = gd(); + std::mt19937 armorgen; + armorgen.seed(statseed ^ v[0][0][0] ^ (v[1][0][0] << 8)); + println(hlog, "after armorgen"); + vector qty(v.size(), 0); + for(int i=0; i 1) desc += ", "; + if(q <= isize(vi)) desc += vi[q-1]; + else if(vi.back().substr(0, 2) == "a ") desc += "a +" + its(q - isize(vi)) + " " + vi.back().substr(2); + else if(vi.back().substr(0, 3) == "an ") desc += "an +" + its(q - isize(vi)) + " " + vi.back().substr(3); + else desc += "+" + its(q - isize(vi)) + " " + vi.back(); + } + desc += ".\n"; + if(qty_owned == qty_filled + 1) + desc += "\nYou have also found another piece that must be tailored to fit your size."; + else if(qty_owned > qty_filled) + desc += "\nYou have also found " + its(qty_owned - qty_filled) +" pieces that must be tailored to fit your size."; + return desc; + }; + + return self; + } + power& power::be_resource(string s) { get_name = [this, s] { return its(qty_filled) + " " + s; }; return self; @@ -301,6 +353,28 @@ void gen_powers() { [] (data& d) { }).is_starting().while_paused().be_wearable("You concentrate.", "You calm down.", " (on)"), + gen_power('h', "heavy armor", + "This kind of armor reduces the amount of damage you take from hits.", + "]", 0xC0C0C0FF, + [] (data& d) {}).be_armor({{"a chain shirt", "plate armor"}, {"an iron cap", "an iron helmet"}, {"an iron gorget"}, {"bracers"}, {"gauntlets"}, {"iron-shod boots"}, {"greaves"}}), + + gen_power('k', "thief garments", + "This outfit makes it harder for enemies to notice or hit you.", + "]", 0xC08000FF, + [] (data& d) {}).be_armor({{"a leather vest"}, {"a hood"}, {"comfortable boots", "muffled boots", "boots of dodging"}, {"a cloak", "chameleon cloak"}, {"leather gloves"}, {"leather pants"}}), + + gen_power('n', "wizard attire", + "This outfit provides a magical aura that prevents you from taking damage. However, eventually, " + "with lots of attacks, the aura will lose its power. You need to spend some time without being attacked to " + "regenerate it.", + "]", 0x0080C0FF, + [] (data& d) {}).be_armor({{"a simple magic robe", "embroidered robe"}, {"a wizard hat"}, {"runed boots", "silk runed boots"}, {"runed gloves", "silk runed gloves"}, {"a silver circlet", "a golden circlet"}}), + + gen_power('v', "druid outfit", + "This outfit reduces the damage you take from hits, makes it harder for enemies to hit you, and also provides some magical aura protection.", + "]", 0x40C040FF, + [] (data& d) {}).be_armor({{"a light fur", "a heavy fur"}, {"a horned cap", "a horned helmet"}, {"enchanted cloak"}, {"furry gloves", "beast gloves"}, {"furry boots"}, {"bracers"}}), + gen_power(' ', "dagger", "This sharp dagger is very useful during the preparation of alchemical ingredients, but it works as a basic weapon too.", ")", 0xFFFFFFFF, diff --git a/rogueviz/ru/stats.cpp b/rogueviz/ru/stats.cpp index 7202bd5f..10700076 100644 --- a/rogueviz/ru/stats.cpp +++ b/rogueviz/ru/stats.cpp @@ -202,15 +202,19 @@ void stat_screen(bool editable) { switch(m.profession) { case stat::str: find_power("axe").gain(1, 1); + find_power("heavy armor").gain(2, 2); break; case stat::con: find_power("polymorph").gain(1, 1).flags |= IDENTIFIED | PARTIAL; + find_power("druid outfit").gain(2, 2); break; case stat::dex: find_power("the thief").gain(1, 1).flags |= IDENTIFIED | PARTIAL; + find_power("thief garments").gain(2, 2); break; case stat::wis: find_power("fire").gain(1, 1).flags |= IDENTIFIED | PARTIAL; + find_power("wizard attire").gain(2, 2); break; } });