1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

- Fixed and simplified Teleport casting

- Stack artifacts will now not be wearable by hero (by default)
- Fixed crash involving clone
This commit is contained in:
DjWarmonger 2012-04-18 13:24:18 +00:00
parent f9dff013eb
commit 05311dd30c
4 changed files with 44 additions and 29 deletions

View File

@ -1823,11 +1823,6 @@ void CBattleInterface::castThisSpell(int spellID)
spellSelMode = NO_LOCATION; spellSelMode = NO_LOCATION;
} }
if(sp->id == Spells::TELEPORT) //teleport
{
spellSelMode = TELEPORT; //FIXME: duplicating?
}
if(sp->range[ castingHero->getSpellSchoolLevel(sp) ].size() > 1) //spell has many-hex range if(sp->range[ castingHero->getSpellSchoolLevel(sp) ].size() > 1) //spell has many-hex range
{ {
spellSelMode = ANY_LOCATION; spellSelMode = ANY_LOCATION;
@ -2676,7 +2671,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
BOOST_FOREACH (PossibleActions action, possibleActions) BOOST_FOREACH (PossibleActions action, possibleActions)
{ {
bool legalAction = false; //this action is legal and can't be performed bool legalAction = false; //this action is legal and can't be performed
bool illegalAction = false; //this action is not legal and should display message bool notLegal = false; //this action is not legal and should display message
switch (action) switch (action)
{ {
@ -2752,7 +2747,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
if (curInt->cb->battleCanTeleportTo(activeStack, myNumber, skill)) if (curInt->cb->battleCanTeleportTo(activeStack, myNumber, skill))
legalAction = true; legalAction = true;
else else
illegalAction = true; notLegal = true;
} }
break; break;
case SACRIFICE: //TODO case SACRIFICE: //TODO
@ -2772,9 +2767,10 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
} }
if (legalAction) if (legalAction)
localActions.push_back (action); localActions.push_back (action);
else if (illegalAction) else if (notLegal)
illegalActions.push_back (action); illegalActions.push_back (action);
} }
illegalAction = INVALID; //clear it in first place
if (vstd::contains(localActions, selectedAction)) //try to use last selected action by default if (vstd::contains(localActions, selectedAction)) //try to use last selected action by default
currentAction = selectedAction; currentAction = selectedAction;
@ -2797,6 +2793,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
} }
bool isCastingPossible = false; bool isCastingPossible = false;
bool secondaryTarget = false;
if (currentAction > INVALID) if (currentAction > INVALID)
{ {
@ -2876,21 +2873,16 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[27]) % sp->name % shere->getName()); //Cast %s on %s consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[27]) % sp->name % shere->getName()); //Cast %s on %s
switch (sp->id) switch (sp->id)
{ {
case Spells::TELEPORT: //don't cast spell yet, only select target case Spells::TELEPORT:
possibleActions.clear();
possibleActions.push_back (TELEPORT);
break;
case Spells::SACRIFICE: case Spells::SACRIFICE:
possibleActions.clear(); secondaryTarget = true;
possibleActions.push_back (SACRIFICE);
break;
default:
isCastingPossible = true;
break; break;
} }
isCastingPossible = true;
} }
else //spell is random else //spell is random
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[301]) % shere->getName()); //Cast a spell on % consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[301]) % shere->getName()); //Cast a spell on %
//we assume that teleport / sacrifice will never be avaliable as random spell
break; break;
case TELEPORT: case TELEPORT:
consoleMsg = CGI->generaltexth->allTexts[25]; //Teleport Here consoleMsg = CGI->generaltexth->allTexts[25]; //Teleport Here
@ -2912,6 +2904,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
case CATAPULT: case CATAPULT:
cursorFrame = ECursor::COMBAT_SHOOT_CATAPULT; cursorFrame = ECursor::COMBAT_SHOOT_CATAPULT;
realizeAction = [=]{ giveCommand(BattleAction::CATAPULT, myNumber, activeStack->ID); }; realizeAction = [=]{ giveCommand(BattleAction::CATAPULT, myNumber, activeStack->ID); };
break;
case CREATURE_INFO: case CREATURE_INFO:
{ {
cursorFrame = ECursor::COMBAT_QUERY; cursorFrame = ECursor::COMBAT_QUERY;
@ -2964,6 +2957,21 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % sp->name); //Cast %s consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % sp->name); //Cast %s
realizeAction = [=] realizeAction = [=]
{
if (secondaryTarget) //select that target now
{
possibleActions.clear();
switch (sp->id)
{
case Spells::TELEPORT: //don't cast spell yet, only select target
possibleActions.push_back (TELEPORT);
break;
case Spells::SACRIFICE:
possibleActions.push_back (SACRIFICE);
break;
}
}
else
{ {
if(creatureCasting) if(creatureCasting)
{ {
@ -2975,6 +2983,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
curInt->cb->battleMakeAction(spellToCast); curInt->cb->battleMakeAction(spellToCast);
endCastingSpell(); endCastingSpell();
} }
}
}; };
} }

View File

@ -505,6 +505,15 @@ void CArtHandler::giveArtBonus(int aid, Bonus::BonusType type, int val, int subt
added->description = artifacts[aid]->Name(); added->description = artifacts[aid]->Name();
artifacts[aid]->addNewBonus(added); artifacts[aid]->addNewBonus(added);
} }
void CArtHandler::makeItCreatureArt (int aid, bool onlyCreature /*=true*/)
{
CArtifact *a = artifacts[aid];
if (onlyCreature)
{
a->possibleSlots[ArtBearer::HERO].clear();
}
a->possibleSlots[ArtBearer::CREATURE].push_back(ArtifactPosition::CREATURE_SLOT);
};
void CArtHandler::addBonuses() void CArtHandler::addBonuses()
{ {
@ -750,11 +759,6 @@ void CArtHandler::addBonuses()
//Stack artifact test //Stack artifact test
if (GameConstants::STACK_ARTIFACT) if (GameConstants::STACK_ARTIFACT)
{ {
auto makeItCreatureArt = [this](int aid)
{
CArtifact *a = artifacts[aid];
a->possibleSlots[ArtBearer::CREATURE].push_back(ArtifactPosition::CREATURE_SLOT);
};
makeItCreatureArt(141); makeItCreatureArt(141);
makeItCreatureArt(142); makeItCreatureArt(142);
makeItCreatureArt(143); makeItCreatureArt(143);

View File

@ -36,7 +36,7 @@ namespace ArtBearer
{ {
enum enum
{ {
HERO, CREATURE HERO, CREATURE//, COMMANDER
}; };
} }
@ -242,6 +242,7 @@ public:
// void unequipArtifact (std::map<ui16, const CArtifact*> &artifWorn, ui16 slotID) const; // void unequipArtifact (std::map<ui16, const CArtifact*> &artifWorn, ui16 slotID) const;
void initAllowedArtifactsList(const std::vector<ui8> &allowed); //allowed[art_id] -> 0 if not allowed, 1 if allowed void initAllowedArtifactsList(const std::vector<ui8> &allowed); //allowed[art_id] -> 0 if not allowed, 1 if allowed
static int convertMachineID(int id, bool creToArt); static int convertMachineID(int id, bool creToArt);
void makeItCreatureArt (int aid, bool onlyCreature = true);
CArtHandler(); CArtHandler();
~CArtHandler(); ~CArtHandler();

View File

@ -3075,7 +3075,8 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
} }
//second attack //second attack
if(curStack->valOfBonuses(Bonus::ADDITIONAL_ATTACK) > 0 if(curStack //FIXME: clones tend to dissapear during actions
&& curStack->valOfBonuses(Bonus::ADDITIONAL_ATTACK) > 0
&& !curStack->hasBonusOfType(Bonus::SHOOTER) && !curStack->hasBonusOfType(Bonus::SHOOTER)
&& curStack->alive() && curStack->alive()
&& stackAtEnd->alive() ) && stackAtEnd->alive() )