Skip to content

Commit

Permalink
Separate "Splits When Hit" from "Immune to Assassinate"
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Oct 2, 2015
1 parent 0a97824 commit f6183ca
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions rsrc/dialogs/edit-monster-abils.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<text top='246' left='273' width='40' height='16'>Poison:</text>
<field name='poison-res' top='245' left='320' width='80' height='16'/>
<led name='mindless' top='215' left='415' width='70'>Mindless</led>
<led name='amorph' top='230' left='415' width='70'>Amorphous</led>
<led name='invuln' top='245' left='415' width='70'>Invulnerable</led>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='158' height='16'>Edit Monster Abilities</text>
Expand Down
1 change: 1 addition & 0 deletions rsrc/schemas/monsters.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
<xs:element name="demon" type="xs:integer" minOccurs="0"/>
<xs:element name="all" type="bool" minOccurs="0"/>
<xs:element name="fear" type="bool" minOccurs="0"/>
<xs:element name="assassinate" type="bool" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
Expand Down
2 changes: 1 addition & 1 deletion src/boe.combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ void pc_attack_weapon(short who_att,iLiving& target,short hit_adj,short dam_adj,
if(primary) {
bool splits = false;
if(cCreature* who = dynamic_cast<cCreature*>(&target))
splits = who->abil[eMonstAbil::SPLITS].active;
splits = who->amorphous;
// assassinate
r1 = get_ran(1,1,100);
int assassin = univ.party[who_att].skill(eSkill::ASSASSINATION);
Expand Down
3 changes: 2 additions & 1 deletion src/classes/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ std::map<eMonstAbil,uAbility>::iterator cMonster::addAbil(eMonstAbilTemplate wha
// Misc abilities
case eMonstAbilTemplate::SPLITS:
abil[eMonstAbil::SPLITS].special = {true, 1000, 0, 0};
amorphous = true;
return abil.find(eMonstAbil::SPLITS);
case eMonstAbilTemplate::MARTYRS_SHIELD:
abil[eMonstAbil::MARTYRS_SHIELD].special = {true, 1000, 100, 0};
Expand Down Expand Up @@ -386,7 +387,7 @@ cMonster::cMonster(){
}
// And just in case something weird happens:
resist[eDamageType::MARKED] = 100;
mindless = invuln = guard = invisible = false;
amorphous = mindless = invuln = guard = invisible = false;
level = m_health = armor = skill = 0;
speed = 4;
default_facial_pic = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/classes/monster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class cMonster {
item_num_t corpse_item;
short corpse_item_chance;
std::map<eDamageType, int> resist;
bool mindless, invuln, invisible, guard;
bool mindless, invuln, invisible, guard, amorphous;
unsigned int x_width,y_width;
eAttitude default_attitude;
unsigned int summon_type;
Expand Down
3 changes: 3 additions & 0 deletions src/scenedit/scen.core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ static void put_monst_abils_in_dlog(cDialog& me, cMonster& monst) {
me["onsee"].setTextToNum(monst.see_spec);
me["snd"].setTextToNum(monst.ambient_sound);

if(monst.amorphous)
dynamic_cast<cLed&>(me["amorph"]).setState(led_red);
if(monst.mindless)
dynamic_cast<cLed&>(me["mindless"]).setState(led_red);
if(monst.invuln)
Expand Down Expand Up @@ -939,6 +941,7 @@ static bool save_monst_abils(cDialog& me, cMonster& monst) {
monst.see_spec = me["onsee"].getTextAsNum();
monst.ambient_sound = me["snd"].getTextAsNum();

monst.amorphous = dynamic_cast<cLed&>(me["amorph"]).getState() != led_off;
monst.mindless = dynamic_cast<cLed&>(me["mindless"]).getState() != led_off;
monst.invuln = dynamic_cast<cLed&>(me["invuln"]).getState() != led_off;
monst.invisible = dynamic_cast<cLed&>(me["invis"]).getState() != led_off;
Expand Down
1 change: 1 addition & 0 deletions src/scenedit/scen.fileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ void writeMonstersToXml(ticpp::Printer&& data, cScenario& scenario) {
data.PushElement(boost::lexical_cast<std::string>(dmg), monst.resist[dmg]);
}
if(monst.mindless) data.PushElement("fear", true);
if(monst.amorphous) data.PushElement("assassinate", true);
if(monst.invuln) data.PushElement("all", true);
data.CloseElement("immunity");

Expand Down
4 changes: 4 additions & 0 deletions src/tools/fileio_scen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,10 @@ void readMonstersFromXml(ticpp::Document&& data, cScenario& scenario) {
resist->GetText(&val);
if(val == "true")
the_mon.mindless = true;
} else if(type == "assassinate") {
resist->GetText(&val);
if(val == "true")
the_mon.amorphous = true;
} else try {
eDamageType dmg = boost::lexical_cast<eDamageType>(type);
resist->GetText(&the_mon.resist[dmg]);
Expand Down
1 change: 1 addition & 0 deletions test/files/monsters/immunity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<immunity>
<all>true</all>
<fear>true</fear>
<assassinate>true</assassinate>
<fire>10</fire>
<cold>20</cold>
<magic>30</magic>
Expand Down
1 change: 1 addition & 0 deletions test/monst_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ TEST_CASE("Converting monsters from legacy scenarios") {
REQUIRE(new_monst.abil.size() == 1);
REQUIRE(new_monst.abil[eMonstAbil::SPLITS].active);
CHECK(new_monst.abil[eMonstAbil::SPLITS].special.extra1 == 1000);
CHECK(new_monst.amorphous);
}
SECTION("Mindless") {
old_monst.spec_skill = 13;
Expand Down
1 change: 1 addition & 0 deletions test/monst_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ TEST_CASE("Loading a monster type definition") {
doc = xmlDocFromStream(fin, "immunity.xml");
REQUIRE_NOTHROW(readMonstersFromXml(move(doc), scen));
REQUIRE(scen.scen_monsters.size() >= 2);
CHECK(scen.scen_monsters[1].amorphous);
CHECK(scen.scen_monsters[1].mindless);
CHECK(scen.scen_monsters[1].invuln);
CHECK(scen.scen_monsters[1].resist[eDamageType::FIRE] == 10);
Expand Down
2 changes: 2 additions & 0 deletions test/monst_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ TEST_CASE("Saving monster types") {
scen.scen_monsters[1].treasure = 4;
scen.scen_monsters[1].corpse_item = 128;
scen.scen_monsters[1].corpse_item_chance = 35;
scen.scen_monsters[1].amorphous = true;
scen.scen_monsters[1].mindless = true;
scen.scen_monsters[1].invuln = true;
scen.scen_monsters[1].invisible = true;
Expand All @@ -112,6 +113,7 @@ TEST_CASE("Saving monster types") {
CHECK(scen.scen_monsters[1].treasure == 4);
CHECK(scen.scen_monsters[1].corpse_item == 128);
CHECK(scen.scen_monsters[1].corpse_item_chance == 35);
CHECK(scen.scen_monsters[1].amorphous);
CHECK(scen.scen_monsters[1].mindless);
CHECK(scen.scen_monsters[1].invuln);
CHECK(scen.scen_monsters[1].invisible);
Expand Down

0 comments on commit f6183ca

Please sign in to comment.