1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00
This commit is contained in:
Michał W. Urbańczyk
2012-02-17 19:30:40 +00:00
parent 1abf089bc7
commit a975805ae8
6 changed files with 30 additions and 22 deletions

View File

@@ -1027,17 +1027,11 @@ void CArtifactInstance::move(ArtifactLocation &src, ArtifactLocation &dst)
tlog1 << "No source for moved artifact found!\n";
if (dst.hero)
{
putAt(dst.hero, dst.slot);
if (artType->id == 135 && dst.slot == ArtifactPosition::RIGHT_HAND && !dst.hero->hasSpellbook()) //Titan's Thunder creates new spellbook on equip
dst.hero->giveArtifact(0);
}
else if (dst.stack)
putAt(dst.stack, dst.slot);
else
tlog1 << "No destination for moved artifact found!\n";
}
CArtifactInstance * CArtifactInstance::createNewArtifactInstance(CArtifact *Art)

View File

@@ -820,7 +820,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
struct HLP
{
//it's assumed that given hero should receive the bonus
static void giveCampaignBonusToHero(CGHeroInstance * hero, const StartInfo * si, const CScenarioTravel & st )
static void giveCampaignBonusToHero(CGHeroInstance * hero, const StartInfo * si, const CScenarioTravel & st, CGameState *gs )
{
const CScenarioTravel::STravelBonus & curBonus = st.bonusesToChoose[si->choosenCampaignBonus];
if(curBonus.isBonusForHero())
@@ -844,7 +844,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
}
break;
case 3: //artifact
hero->giveArtifact(curBonus.info2);
gs->giveHeroArtifact(hero, curBonus.info2);
break;
case 4: //spell scroll
{
@@ -1325,7 +1325,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
if(maxB < 0)
tlog2 << "Warning - cannot give bonus to hero cause there are no heroes!\n";
else
HLP::giveCampaignBonusToHero(heroes[maxB], scenarioOps, campaign->camp->scenarios[scenarioOps->whichMapInCampaign].travelOptions);
HLP::giveCampaignBonusToHero(heroes[maxB], scenarioOps, campaign->camp->scenarios[scenarioOps->whichMapInCampaign].travelOptions, this);
}
else //specific hero
{
@@ -1333,7 +1333,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
{
if (heroes[b]->subID == chosenBonus.info1)
{
HLP::giveCampaignBonusToHero(heroes[b], scenarioOps, campaign->camp->scenarios[scenarioOps->whichMapInCampaign].travelOptions);
HLP::giveCampaignBonusToHero(heroes[b], scenarioOps, campaign->camp->scenarios[scenarioOps->whichMapInCampaign].travelOptions, this);
break;
}
}
@@ -1405,7 +1405,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
toGive = VLC->arth->artifacts[VLC->arth->getRandomArt (CArtifact::ART_TREASURE)];
CGHeroInstance *hero = k->second.heroes[0];
hero->giveArtifact(toGive->id);
giveHeroArtifact(hero, toGive->id);
}
break;
}
@@ -2456,6 +2456,14 @@ void CGameState::attachArmedObjects()
}
}
void CGameState::giveHeroArtifact(CGHeroInstance *h, int aid)
{
CArtifact * const artifact = VLC->arth->artifacts[aid]; //pointer to constant object
CArtifactInstance *ai = CArtifactInstance::createNewArtifactInstance(artifact);
map->addNewArtifactInstance(ai);
ai->putAt(h, ai->firstAvailableSlot(h));
}
int3 CPath::startPos() const
{
return nodes[nodes.size()-1].coord;

View File

@@ -378,6 +378,8 @@ public:
void randomizeObject(CGObjectInstance *cur);
std::pair<int,int> pickObject(CGObjectInstance *obj); //chooses type of object to be randomized, returns <type, subtype>
int pickHero(int owner);
void giveHeroArtifact(CGHeroInstance *h, int aid);
void apply(CPack *pack);
int battleGetBattlefieldType(int3 tile = int3());// 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship
UpgradeInfo getUpgradeInfo(const CStackInstance &stack);

View File

@@ -1356,16 +1356,16 @@ si32 CGHeroInstance::manaRegain() const
return 1 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, 8) + valOfBonuses(Bonus::MANA_REGENERATION); //1 + Mysticism level
}
/**
* Places an artifact in hero's backpack. If it's a big artifact equips it
* or discards it if it cannot be equipped.
*/
void CGHeroInstance::giveArtifact (ui32 aid) //use only for fixed artifacts
{
CArtifact * const artifact = VLC->arth->artifacts[aid]; //pointer to constant object
CArtifactInstance *ai = CArtifactInstance::createNewArtifactInstance(artifact);
ai->putAt(this, ai->firstAvailableSlot(this));
}
// /**
// * Places an artifact in hero's backpack. If it's a big artifact equips it
// * or discards it if it cannot be equipped.
// */
// void CGHeroInstance::giveArtifact (ui32 aid) //use only for fixed artifacts
// {
// CArtifact * const artifact = VLC->arth->artifacts[aid]; //pointer to constant object
// CArtifactInstance *ai = CArtifactInstance::createNewArtifactInstance(artifact);
// ai->putAt(this, ai->firstAvailableSlot(this));
// }
int CGHeroInstance::getBoatType() const
{

View File

@@ -381,7 +381,7 @@ public:
void putInBackpack(CArtifactInstance *art);
void initExp();
void initArmy(IArmyDescriptor *dst = NULL);
void giveArtifact (ui32 aid);
//void giveArtifact (ui32 aid);
void initHeroDefInfo();
void pushPrimSkill(int which, int val);
void UpdateSpeciality();

View File

@@ -677,6 +677,10 @@ DLL_LINKAGE void MoveArtifact::applyGs( CGameState *gs )
assert(!dst.getArt());
a->move(src, dst);
//TODO what'll happen if Titan's thunder is equiped by pickin git up or the start of game?
if (a->artType->id == 135 && dst.hero && dst.slot == ArtifactPosition::RIGHT_HAND && !dst.hero->hasSpellbook()) //Titan's Thunder creates new spellbook on equip
gs->giveHeroArtifact(dst.hero, 0);
}
DLL_LINKAGE void AssembledArtifact::applyGs( CGameState *gs )