mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Bypass initial version of spell callback
This commit is contained in:
parent
fc310c6e79
commit
e440343921
@ -231,6 +231,7 @@ public:
|
||||
void changeObjPos(ObjectInstanceID objid, int3 newPos) override {};
|
||||
void sendAndApply(CPackForClient * pack) override {};
|
||||
void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2) override {};
|
||||
void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos) override {};
|
||||
|
||||
void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, bool hide) override {}
|
||||
void changeFogOfWar(std::unordered_set<int3, ShashInt3> & tiles, PlayerColor player, bool hide) override {}
|
||||
|
@ -132,6 +132,8 @@ public:
|
||||
virtual void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)=0; //when two heroes meet on adventure map
|
||||
virtual void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, bool hide) = 0;
|
||||
virtual void changeFogOfWar(std::unordered_set<int3, ShashInt3> &tiles, PlayerColor player, bool hide) = 0;
|
||||
|
||||
virtual void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos) = 0;
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CNonConstInfoCallback : public CPrivilegedInfoCallback
|
||||
|
@ -132,6 +132,7 @@ void CRandomRewardObjectInfo::configureReward(CRewardableObject * object, CRando
|
||||
reward.artifacts = JsonRandom::loadArtifacts(source["artifacts"], rng);
|
||||
reward.spells = JsonRandom::loadSpells(source["spells"], rng, spells);
|
||||
reward.creatures = JsonRandom::loadCreatures(source["creatures"], rng);
|
||||
reward.casts = JsonRandom::loadSpells(source["casts"], rng, spells);
|
||||
|
||||
for ( auto node : source["changeCreatures"].Struct() )
|
||||
{
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "../IGameCallback.h"
|
||||
#include "../CGameState.h"
|
||||
#include "../CPlayerState.h"
|
||||
#include "../spells/CSpellHandler.h"
|
||||
#include "../spells/ISpellMechanics.h"
|
||||
|
||||
#include "CObjectClassesHandler.h"
|
||||
|
||||
@ -359,6 +361,14 @@ void CRewardableObject::grantRewardAfterLevelup(const CRewardVisitInfo & info, c
|
||||
|
||||
cb->giveCreatures(this, hero, creatures, false);
|
||||
}
|
||||
|
||||
if(!info.reward.casts.empty())
|
||||
{
|
||||
for(const auto & c : info.reward.casts)
|
||||
{
|
||||
cb->castSpell(hero, c, int3{-1, -1, -1});
|
||||
}
|
||||
}
|
||||
|
||||
if(info.reward.removeObject)
|
||||
cb->removeObject(this);
|
||||
|
@ -169,6 +169,9 @@ public:
|
||||
std::vector<ArtifactID> artifacts;
|
||||
std::vector<SpellID> spells;
|
||||
std::vector<CStackBasicDescriptor> creatures;
|
||||
|
||||
/// actions that hero may execute
|
||||
std::vector<SpellID> casts;
|
||||
|
||||
/// list of components that will be added to reward description. First entry in list will override displayed component
|
||||
std::vector<Component> extraComponents;
|
||||
@ -213,6 +216,7 @@ public:
|
||||
h & spells;
|
||||
h & creatures;
|
||||
h & creaturesChange;
|
||||
h & casts;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -6282,6 +6282,19 @@ bool CGameHandler::moveStack(const StackLocation &src, const StackLocation &dst,
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGameHandler::castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos)
|
||||
{
|
||||
const CSpell * s = spellID.toSpell();
|
||||
if(!s)
|
||||
return;
|
||||
|
||||
AdventureSpellCastParameters p;
|
||||
p.caster = hero;
|
||||
p.pos = pos;
|
||||
|
||||
s->adventureCast(spellEnv, p);
|
||||
}
|
||||
|
||||
bool CGameHandler::swapStacks(const StackLocation & sl1, const StackLocation & sl2)
|
||||
{
|
||||
if(!sl1.army->hasStackAtSlot(sl1.slot))
|
||||
@ -7343,4 +7356,4 @@ const ObjectInstanceID CGameHandler::putNewObject(Obj ID, int subID, int3 pos)
|
||||
no.pos = pos;
|
||||
sendAndApply(&no);
|
||||
return no.id; //id field will be filled during applying on gs
|
||||
}
|
||||
}
|
||||
|
@ -275,6 +275,7 @@ public:
|
||||
void moveArmy(const CArmedInstance *src, const CArmedInstance *dst, bool allowMerging);
|
||||
const ObjectInstanceID putNewObject(Obj ID, int subID, int3 pos);
|
||||
|
||||
void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user