1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

Implement behavior

This commit is contained in:
nordsoft 2023-04-10 05:46:45 +04:00
parent c0b90432cb
commit 464ad63749
3 changed files with 9 additions and 4 deletions

View File

@ -365,9 +365,10 @@ void CRewardableObject::grantRewardAfterLevelup(const CRewardVisitInfo & info, c
if(!info.reward.casts.empty()) if(!info.reward.casts.empty())
{ {
caster = std::make_unique<spells::OuterCaster>(hero, 3);
for(const auto & c : info.reward.casts) for(const auto & c : info.reward.casts)
{ {
cb->castSpell(hero, c, int3{-1, -1, -1}); cb->castSpell(caster.get(), c, int3{-1, -1, -1});
} }
} }

View File

@ -14,6 +14,7 @@
#include "../NetPacksBase.h" #include "../NetPacksBase.h"
#include "../ResourceSet.h" #include "../ResourceSet.h"
#include "../spells/OuterCaster.h"
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
@ -170,7 +171,7 @@ public:
std::vector<SpellID> spells; std::vector<SpellID> spells;
std::vector<CStackBasicDescriptor> creatures; std::vector<CStackBasicDescriptor> creatures;
/// actions that hero may execute /// actions that hero may execute and object caster
std::vector<SpellID> casts; std::vector<SpellID> casts;
/// list of components that will be added to reward description. First entry in list will override displayed component /// list of components that will be added to reward description. First entry in list will override displayed component
@ -321,6 +322,9 @@ protected:
bool wasVisitedBefore(const CGHeroInstance * contextHero) const; bool wasVisitedBefore(const CGHeroInstance * contextHero) const;
bool onceVisitableObjectCleared; bool onceVisitableObjectCleared;
/// caster to cast adveture spells
mutable std::unique_ptr<spells::OuterCaster> caster;
public: public:
EVisitMode getVisitMode() const; EVisitMode getVisitMode() const;

View File

@ -199,6 +199,8 @@ public:
void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, bool hide) 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; void changeFogOfWar(std::unordered_set<int3, ShashInt3> &tiles, PlayerColor player, bool hide) override;
void castSpell(const spells::Caster * caster, SpellID spellID, const int3 &pos) override;
bool isVisitCoveredByAnotherQuery(const CGObjectInstance *obj, const CGHeroInstance *hero) override; bool isVisitCoveredByAnotherQuery(const CGObjectInstance *obj, const CGHeroInstance *hero) override;
void setObjProperty(ObjectInstanceID objid, int prop, si64 val) override; void setObjProperty(ObjectInstanceID objid, int prop, si64 val) override;
@ -275,8 +277,6 @@ public:
void moveArmy(const CArmedInstance *src, const CArmedInstance *dst, bool allowMerging); void moveArmy(const CArmedInstance *src, const CArmedInstance *dst, bool allowMerging);
const ObjectInstanceID putNewObject(Obj ID, int subID, int3 pos); const ObjectInstanceID putNewObject(Obj ID, int subID, int3 pos);
void castSpell(const spells::Caster * caster, SpellID spellID, const int3 &pos);
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & QID; h & QID;