1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

- first sketch of Commanders

- accumulateBonus should make mechanics simpler
This commit is contained in:
DjWarmonger 2012-04-04 17:41:55 +00:00
parent 2193f8912e
commit 038d105bcc
7 changed files with 64 additions and 7 deletions

View File

@ -175,9 +175,6 @@
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="mapHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CAnimation.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -235,11 +232,25 @@
<ClInclude Include="UIFramework\SDL_Extensions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\hch\CArtHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\hch\CBuildingHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\hch\CHeroHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\hch\CObjectHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\hch\CVideoHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\ChangeLog" />
<None Include="vcmi.ico" />
<None Include="ClassDiagram21.cd" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="VCMI_client.rc" />

View File

@ -109,11 +109,17 @@ public:
std::vector<si8> factionAlignments; //1 for good, 0 for neutral and -1 for evil with faction ID as index
int factionToTurretCreature[GameConstants::F_NUMBER]; //which creature's animation should be used to dispaly creature in turret while siege
//stack exp
std::map<TBonusType, std::pair<std::string, std::string> > stackBonuses; // bonus => name, description
std::vector<std::vector<ui32> > expRanks; // stack experience needed for certain rank, index 0 for other tiers (?)
std::vector<ui32> maxExpPerBattle; //%, tiers same as above
si8 expAfterUpgrade;//multiplier in %
//Commanders
std::map <ui8, ui32> factionCommanders;
std::vector< std::vector <ui8> > skillLevels; //how much of a bonus will be given to commander with every level. We assume that number of casts equals skill level
std::vector <std::pair <Bonus, std::pair <ui8, ui8> > > skillRequirements; // first - Bonus, second - which two skills are needed to use it
BonusList commanderLevelPremy; //bonus values added with each level-up
void deserializationFix();
void loadCreatures();
@ -138,6 +144,7 @@ public:
//TODO: should be optimized, not all these informations needs to be serialized (same for ccreature)
h & notUsedMonsters & creatures & nameToID & idToProjectile & idToProjectileSpin & factionToTurretCreature;
h & stackBonuses & expRanks & maxExpPerBattle & expAfterUpgrade;
h & factionCommanders & skillLevels & skillRequirements & commanderLevelPremy;
h & allCreatures;
h & creaturesOfLevel;
BONUS_TREE_DESERIALIZATION_FIX

View File

@ -49,10 +49,10 @@ public:
std::string bonusToString(Bonus *bonus, bool description) const; // how would bonus description look for this particular type of node
std::string bonusToGraphics(Bonus *bonus) const; //file name of graphics from StackSkills , in future possibly others
ui64 getPower() const;
virtual ui64 getPower() const;
int getQuantityID() const;
std::string getQuantityTXT(bool capitalized = true) const;
int getExpRank() const;
virtual int getExpRank() const;
si32 magicResistance() const;
int getCreatureID() const; //-1 if not available
std::string getName() const; //plural or singular
@ -71,6 +71,26 @@ public:
void deserializationFix();
};
class DLL_LINKAGE CCommanderInstance : public CStackInstance
{
//TODO: what if Commander is not a part of creature set?
//commander class is determined by its base creature
ui8 alive;
std::string name; // each Commander has different name
std::vector <std::pair <ui8, ui8> > secondarySkills; //ID, level
//std::vector <CArtifactInstance *> arts;
ui64 getPower() const {return 0;};
int getExpRank() const {return 0;};
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CStackInstance&>(*this);
h & alive & name & secondarySkills;
}
};
DLL_LINKAGE std::ostream & operator<<(std::ostream & str, const CStackInstance & sth);
typedef std::map<TSlot, CStackInstance*> TSlots;

View File

@ -51,6 +51,7 @@ struct UpdateHeroSpeciality;
struct NewArtifact;
class CGBoat;
class CArtifactSet;
class CCommanderInstance;
class DLL_LINKAGE CQuest
{
@ -285,6 +286,7 @@ public:
ui8 sex;
ui8 inTownGarrison; // if hero is in town garrison
ConstTransitivePtr<CGTownInstance> visitedTown; //set if hero is visiting town or in the town garrison
ConstTransitivePtr<CCommanderInstance> commander;
const CGBoat *boat; //set to CGBoat when sailing

View File

@ -170,6 +170,11 @@ namespace EBattleStackState
enum EBattleStackState{ALIVE = 180, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING, FEAR};
}
namespace ECommander
{
enum SecondarySkills {ATTACK, DEFENSE, HEALTH, DAMAGE, SPEED, SPELL_POWER};
}
namespace Obj
{
enum

View File

@ -654,6 +654,15 @@ void CBonusSystemNode::addNewBonus(Bonus *b)
CBonusSystemNode::treeChanged++;
}
void CBonusSystemNode::accumulateBonus(Bonus *b)
{
Bonus *bonus = bonuses.getFirst(Selector::typeSubtype(b->type, b->subtype)); //only local bonuses are interesting //TODO: what about value type?
if(bonus)
bonus += b->val;
else
addNewBonus(b);
}
void CBonusSystemNode::removeBonus(Bonus *b)
{
exportedBonuses -= b;

View File

@ -175,7 +175,9 @@ namespace PrimarySkill
BONUS_NAME(SPECIFIC_SPELL_POWER) /* value used for Thunderbolt and Resurrection casted by units, subtype - spell id */\
BONUS_NAME(CREATURE_SPELL_POWER) /* value per unit, divided by 100 (so faerie Dragons have 800)*/ \
BONUS_NAME(CREATURE_ENCHANT_POWER) /* total duration of spells casted by creature */ \
BONUS_NAME(REBIRTH) /* val - percent of life restored, subtype = 0 - regular, 1 - at least one unit (sacred Phoenix) */
BONUS_NAME(REBIRTH) /* val - percent of life restored, subtype = 0 - regular, 1 - at least one unit (sacred Phoenix) */\
BONUS_NAME(ADDITIONAL_UNITS) /*val of units with id = subtype will be added to hero's army at the beginning of battle */\
BONUS_NAME(SPOILS_OF_WAR) /*val * 10^-6 * gained exp resources of subtype will be given to hero after battle*/
/// Struct for handling bonuses of several types. Can be transferred to any hero
struct DLL_LINKAGE Bonus
@ -564,6 +566,7 @@ public:
void detachFrom(CBonusSystemNode *parent);
void detachFromAll();
void addNewBonus(Bonus *b); //b will be deleted with destruction of node
void accumulateBonus(Bonus *b); //add value of bonus with same type/subtype or create new
void newChildAttached(CBonusSystemNode *child);
void childDetached(CBonusSystemNode *child);