From cf7108f075edf4d50b53a18d43f8334d7a6e4804 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Mon, 21 Jan 2013 15:11:37 +0000 Subject: [PATCH] - Made sure that stack artifacts will not spawn when they are turned off - Description for "Spell-like attack" --- config/bonusnames.json | 1 + lib/CArtHandler.cpp | 12 +++++++++--- lib/CArtHandler.h | 1 + lib/CCreatureSet.cpp | 5 +++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config/bonusnames.json b/config/bonusnames.json index b108de6a1..011a2320c 100644 --- a/config/bonusnames.json +++ b/config/bonusnames.json @@ -8,6 +8,7 @@ { "id": "TWO_HEX_ATTACK_BREATH", "name": "Breath", "description": "Breath Attack (2-hex range)" }, { "id": "SPELL_AFTER_ATTACK", "name": "Caster - %s", "description": "%d% chance to cast after attack" }, { "id": "SPELL_BEFORE_ATTACK", "name": "Caster - %s", "description": "%d% chance to cast before attack" }, + { "id": "SPELL_LIKE_ATTACK", "name": "Spell-like attack", "description": "Attacks with %s" }, { "id": "CATAPULT", "name": "Catapult", "description": "Attacks siege walls" }, { "id": "JOUSTING", "name": "Champion Charge", "description": "+5% damage per hex travelled" }, { "id": "DOUBLE_DAMAGE_CHANCE", "name": "Death Blow", "description": "%d% chance for double damage" }, diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index 670239307..02275f60a 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -776,13 +776,20 @@ void CArtHandler::clearHlpLists() relics.clear(); } +bool CArtHandler::legalArtifact(int id) +{ + return (artifacts[id]->possibleSlots[ArtBearer::HERO].size() || + artifacts[id]->possibleSlots[ArtBearer::COMMANDER].size() && VLC->modh->modules.COMMANDERS) || + (artifacts[id]->possibleSlots[ArtBearer::CREATURE].size() && VLC->modh->modules.STACK_ARTIFACT); +} + void CArtHandler::initAllowedArtifactsList(const std::vector &allowed) { allowedArtifacts.clear(); clearHlpLists(); for (int i=0; i<144; ++i) //yes, 144 { - if (allowed[i]) + if (allowed[i] && legalArtifact(i)) allowedArtifacts.push_back(artifacts[i]); } if (VLC->modh->modules.COMMANDERS) //allow all commander artifacts for testing @@ -798,8 +805,7 @@ void CArtHandler::initAllowedArtifactsList(const std::vector &allowed) allowedArtifacts.push_back(artifacts[i]); else //check if active modules allow artifact to be every used { - if ((artifacts[i]->possibleSlots[ArtBearer::COMMANDER].size() && VLC->modh->modules.COMMANDERS) || - (artifacts[i]->possibleSlots[ArtBearer::CREATURE].size() && VLC->modh->modules.STACK_ARTIFACT)) + if (legalArtifact(i)) allowedArtifacts.push_back(artifacts[i]); //keep im mind that artifact can be worn by more than one type of bearer } diff --git a/lib/CArtHandler.h b/lib/CArtHandler.h index d9674b69d..076cff8ed 100644 --- a/lib/CArtHandler.h +++ b/lib/CArtHandler.h @@ -243,6 +243,7 @@ public: void clearHlpLists(); ui16 getRandomArt (int flags); ui16 getArtSync (ui32 rand, int flags); + bool CArtHandler::legalArtifact(int id); void getAllowedArts(std::vector > &out, std::vector *arts, int flag); void getAllowed(std::vector > &out, int flags); void erasePickedArt (TArtifactInstanceID id); diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index 64d5b4639..a346d5584 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -646,6 +646,11 @@ std::string CStackInstance::bonusToString(Bonus *bonus, bool description) const boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name); break; } + case Bonus::SPELL_LIKE_ATTACK: + { + boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name); + break; + } default: {}//TODO: allow custom bonus types... someday, somehow }