Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
thokkat committed Sep 8, 2024
1 parent 9c570c8 commit 1b62d5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions game/graphics/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions game/world/objects/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
12 changes: 6 additions & 6 deletions game/world/worldobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,16 +972,16 @@ void WorldObjects::setMobState(std::string_view scheme, int32_t st) {
}

template<class T>
T& deref(std::unique_ptr<T>& x){ return *x; }
static T& deref(std::unique_ptr<T>& x){ return *x; }

template<class T>
T& deref(T* x){ return *x; }
static T& deref(T* x){ return *x; }

template<class T>
T& deref(T& x){ return x; }
static T& deref(T& x){ return x; }

template<class T>
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)
Expand All @@ -1000,7 +1000,7 @@ static bool checkFlag(Interactive& i,WorldObjects::SearchFlg f){
}

template<class T>
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)))
Expand All @@ -1021,7 +1021,7 @@ static bool checkTargetType(Npc& n, TargetType t) {
}

template<class T>
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);
Expand Down

0 comments on commit 1b62d5b

Please sign in to comment.