From 1b62d5b5c28f0e888942e2ddf1f375130c173e29 Mon Sep 17 00:00:00 2001 From: thokkat Date: Sun, 8 Sep 2024 16:43:01 +0200 Subject: [PATCH] address review --- game/graphics/effect.cpp | 7 +++++-- game/world/objects/item.cpp | 5 +++-- game/world/worldobjects.cpp | 12 ++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/game/graphics/effect.cpp b/game/graphics/effect.cpp index 94ee50ae..558ee0ba 100644 --- a/game/graphics/effect.cpp +++ b/game/graphics/effect.cpp @@ -306,6 +306,9 @@ void Effect::onCollide(World& world, const VisualFx* root, const Vec3& pos, Npc* if(npc!=nullptr) vfx = root->emFXCollDyn; + // Gothic 1 uses emFXCollDyn->sendAssessMagic as check for PERC_ASSESSMAGIC + // Gothic 2 instead introduced new vfx emFXCollDynPerc specific for this purpose + bool g2 = world.version().game==2; if(vfx!=nullptr) { Effect eff(*vfx,world,pos,SpellFxKey::Collide); eff.setSpellId(splId,world); @@ -314,7 +317,7 @@ void Effect::onCollide(World& world, const VisualFx* root, const Vec3& pos, Npc* if(npc!=nullptr) { npc ->runEffect(std::move(eff)); - if(vfx->sendAssessMagic) { + if(!g2 && vfx->sendAssessMagic) { auto oth = other==nullptr ? npc : other; npc->perceptionProcess(*oth,npc,0,PERC_ASSESSMAGIC); } @@ -323,7 +326,7 @@ void Effect::onCollide(World& world, const VisualFx* root, const Vec3& pos, Npc* } } - if(npc!=nullptr && root->emFXCollDynPerc!=nullptr) { + if(g2 && npc!=nullptr && root->emFXCollDynPerc!=nullptr) { const VisualFx* vfx = root->emFXCollDynPerc; Effect eff(*vfx,world,pos,SpellFxKey::Collide); eff.setActive(true); diff --git a/game/world/objects/item.cpp b/game/world/objects/item.cpp index a312d934..c65338da 100644 --- a/game/world/objects/item.cpp +++ b/game/world/objects/item.cpp @@ -210,8 +210,9 @@ bool Item::isSpellShoot() const { // Only hardcode Stormfist for now since other spells work with the heuristic based on target_collect_algo if(!isSpellOrRune()) return false; - bool g1 = world.version().game==1; - if(g1 && spellId()==47) + bool g1 = world.version().game==1; + const int32_t SPL_STORMFIST = 47; + if(g1 && spellId()==SPL_STORMFIST) return true; auto& spl = world.script().spellDesc(spellId()); return spl.target_collect_algo!=TargetCollect::TARGET_COLLECT_NONE && diff --git a/game/world/worldobjects.cpp b/game/world/worldobjects.cpp index 7795cf27..acaaed32 100644 --- a/game/world/worldobjects.cpp +++ b/game/world/worldobjects.cpp @@ -972,16 +972,16 @@ void WorldObjects::setMobState(std::string_view scheme, int32_t st) { } template -T& deref(std::unique_ptr& x){ return *x; } +static T& deref(std::unique_ptr& x){ return *x; } template -T& deref(T* x){ return *x; } +static T& deref(T* x){ return *x; } template -T& deref(T& x){ return x; } +static T& deref(T& x){ return x; } template -bool checkFlag(T&,WorldObjects::SearchFlg){ return true; } +static bool checkFlag(T&,WorldObjects::SearchFlg){ return true; } static bool checkFlag(Npc& n,WorldObjects::SearchFlg f){ if(n.handle().no_focus) @@ -1000,7 +1000,7 @@ static bool checkFlag(Interactive& i,WorldObjects::SearchFlg f){ } template -bool checkTargetType(T&, TargetType) { return true; } +static bool checkTargetType(T&, TargetType) { return true; } static bool checkTargetType(Npc& n, TargetType t) { if(bool(t&(TARGET_TYPE_ALL|TARGET_TYPE_NPCS))) @@ -1021,7 +1021,7 @@ static bool checkTargetType(Npc& n, TargetType t) { } template -bool canSee(const Npc&,const T&){ return true; } +static bool canSee(const Npc&,const T&){ return true; } static bool canSee(const Npc& pl, const Npc& n){ return pl.canSeeNpc(n,true);