From 6419f953cba320e2348d2ac08f6ba662805910e4 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Sat, 19 May 2012 18:27:23 +0000 Subject: [PATCH] Some (disabled) work for commander artifacts. Hero artifacts window seems broken. Minor fixes. --- client/CCreatureWindow.cpp | 2 +- client/CHeroWindow.cpp | 24 +++++++++++++++++++++++- client/GUIClasses.cpp | 2 +- lib/CArtHandler.cpp | 28 ++++++++++++++++++++++++++++ lib/CArtHandler.h | 4 +++- lib/CCreatureSet.cpp | 6 ++++++ lib/CCreatureSet.h | 2 +- server/CGameHandler.cpp | 1 + 8 files changed, 64 insertions(+), 5 deletions(-) diff --git a/client/CCreatureWindow.cpp b/client/CCreatureWindow.cpp index 2b8a2988e..38208c0de 100644 --- a/client/CCreatureWindow.cpp +++ b/client/CCreatureWindow.cpp @@ -340,7 +340,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode * } file += sufix += ".bmp"; - auto skillGraphics = new CPicture(file, 38 + i * 84, 223); + auto skillGraphics = new CPicture(file, 37 + i * 84, 224); } } //print commander level diff --git a/client/CHeroWindow.cpp b/client/CHeroWindow.cpp index d3f178c51..112fd912e 100644 --- a/client/CHeroWindow.cpp +++ b/client/CHeroWindow.cpp @@ -22,6 +22,7 @@ #include "../lib/CHeroHandler.h" #include "../lib/CLodHandler.h" #include "../lib/CObjectHandler.h" +#include "../lib/NetPacks.h" #include "UIFramework/CGuiHandler.h" #include "UIFramework/CIntObjectClasses.h" @@ -297,7 +298,28 @@ void CHeroWindow::questlog() void CHeroWindow::commanderWindow() { - GH.pushInt(new CCreatureWindow (curHero->commander)); + //TODO: allow equipping commander artifacts by drag / drop + //bool artSelected = false; + //const CArtifactsOfHero::SCommonPart *commonInfo = artSets.front()->commonInfo; + + //if (const CArtifactInstance *art = commonInfo->src.art) + //{ + // const CGHeroInstance *srcHero = commonInfo->src.AOH->getHero(); + // artSelected = true; + // ArtifactLocation src (srcHero, commonInfo->src.slotID); + // ArtifactLocation dst (curHero->commander.get(), commonInfo->src.slotID); + // if (art->canBePutAt(dst, true)) + // { //equip clicked stack + // if(dst.getArt()) + // { + // LOCPLINT->cb->swapArtifacts (dst, ArtifactLocation(srcHero, dst.getArt()->firstBackpackSlot(srcHero))); + // } + // LOCPLINT->cb->swapArtifacts(src, dst); + // } + //} + //else + GH.pushInt(new CCreatureWindow (curHero->commander)); + } void CHeroWindow::showAll(SDL_Surface * to) diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index 9eed8825c..87fe0da2e 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -5052,7 +5052,7 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact { assert(commonInfo->dst == dst //expected movement from slot ot slot || dst.slot == dst.getHolderArtSet()->artifactsInBackpack.size() + GameConstants::BACKPACK_START //artifact moved back to backpack (eg. to make place for art we are moving) - || dst.getHolderArtSet()->bearerType() == ArtBearer::CREATURE); + || dst.getHolderArtSet()->bearerType() != ArtBearer::HERO); commonInfo->reset(); unmarkSlots(); } diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index 8f2e0e30f..deb1474df 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -238,6 +238,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt) nart.price=atoi(pom.c_str()); nart.possibleSlots[ArtBearer::HERO]; //we want to generate map entry even if it will be empty nart.possibleSlots[ArtBearer::CREATURE]; //we want to generate map entry even if it will be empty + //nart.possibleSlots[ArtBearer::COMMANDER]; for(int j=0;jpossibleSlots[ArtBearer::HERO].clear(); + //a->possibleSlots[ArtBearer::COMMANDER].clear(); } a->possibleSlots[ArtBearer::CREATURE].push_back(ArtifactPosition::CREATURE_SLOT); }; +void CArtHandler::makeItCommanderArt (int aid, bool onlyCommander /*=true*/) +{ + //CArtifact *a = artifacts[aid]; + //if (onlyCommander) + //{ + // a->possibleSlots[ArtBearer::HERO].clear(); + // a->possibleSlots[ArtBearer::CREATURE].clear(); + //} + //for (int i = ArtifactPosition::COMMANDER1; i <= ArtifactPosition::COMMANDER6; ++i) + // a->possibleSlots[ArtBearer::COMMANDER].push_back(i); +}; + void CArtHandler::addBonuses() { #define ART_PRIM_SKILL(ID, whichSkill, val) giveArtBonus(ID,Bonus::PRIMARY_SKILL,val,whichSkill) @@ -801,6 +815,13 @@ void CArtHandler::addBonuses() artifacts[156].get()->setDescription ("+2 stack HP"); } + if (GameConstants::COMMANDERS) + { + for (int i = 146; i <= 155; ++i) + { + makeItCommanderArt (i); + } + } } void CArtHandler::clear() @@ -920,6 +941,13 @@ void CArtHandler::initAllowedArtifactsList(const std::vector &allowed) if (allowed[i]) allowedArtifacts.push_back(artifacts[i]); } + //if (GameConstants::COMMANDERS) //allow all commander artifacts for testing + //{ + // for (int i = 146; i <= 155; ++i) + // { + // allowedArtifacts.push_back(artifacts[i]); + // } + //} } CArtifactInstance::CArtifactInstance() diff --git a/lib/CArtHandler.h b/lib/CArtHandler.h index 7cfc9de2b..294295390 100644 --- a/lib/CArtHandler.h +++ b/lib/CArtHandler.h @@ -28,7 +28,8 @@ namespace ArtifactPosition MACH1, MACH2, MACH3, MACH4, SPELLBOOK, MISC5, AFTER_LAST, //cres - CREATURE_SLOT = 0 + CREATURE_SLOT = 0/*, + COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6*/ }; } @@ -243,6 +244,7 @@ public: void initAllowedArtifactsList(const std::vector &allowed); //allowed[art_id] -> 0 if not allowed, 1 if allowed static int convertMachineID(int id, bool creToArt); void makeItCreatureArt (int aid, bool onlyCreature = true); + void makeItCommanderArt (int aid, bool onlyCommander = true); CArtHandler(); ~CArtHandler(); diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index f92baba6f..40efa8966 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -757,6 +757,7 @@ std::string CStackInstance::bonusToGraphics(Bonus *bonus) const fileName = "E_REBIRTH.bmp"; break; case Bonus::BLOCKS_RETALIATION: fileName = "E_RETAIL.bmp"; break; + case Bonus::UNLIMITED_RETALIATIONS: case Bonus::ADDITIONAL_RETALIATION: fileName = "E_RETAIL1.bmp"; break; case Bonus::ATTACKS_ALL_ADJACENT: @@ -1025,6 +1026,11 @@ void CCommanderInstance::levelUp () } } +ui8 CCommanderInstance::bearerType() const +{ + return ArtBearer::COMMANDER; +} + CStackBasicDescriptor::CStackBasicDescriptor() { type = NULL; diff --git a/lib/CCreatureSet.h b/lib/CCreatureSet.h index 5b9cb98ca..1fedfbbae 100644 --- a/lib/CCreatureSet.h +++ b/lib/CCreatureSet.h @@ -95,7 +95,7 @@ public: ui64 getPower() const {return 0;}; int getExpRank() const; - ui8 bearerType() const OVERRIDE {return ArtBearer::COMMANDER;}; //from CArtifactSet + ui8 bearerType() const OVERRIDE; //from CArtifactSet template void serialize(Handler &h, const int version) { diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 83d575d6f..a4e20e5a0 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -298,6 +298,7 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill) return; } + scp.accumulatedBonus.subtype = 0; scp.accumulatedBonus.additionalInfo = 0; scp.accumulatedBonus.duration = Bonus::PERMANENT; scp.accumulatedBonus.turnsRemain = 0;