Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up fix for TARGET_TYPE #685

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions game/world/bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ void Bullet::onCollide(zenkit::MaterialGroup matId) {
void Bullet::onCollide(Npc& npc) {
if(&npc==origin() || isFinished())
return;
if(isSpell()) {
auto& spl = npc.world().script().spellDesc(spellId());
if(!npc.isSpellTargetType(TargetType(spl.target_collect_type)))
return;
}

if(ow!=nullptr) {
// no damage between ally npc's, only emit pfx effect
Expand Down
18 changes: 18 additions & 0 deletions game/world/objects/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2815,6 +2815,24 @@ void Npc::runEffect(Effect&& e) {
visual.startEffect(owner, std::move(e), 0, true);
}

bool Npc::isSpellTargetType(TargetType t) const {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: isSpellTargetType -> isTargetableBySpell

if(bool(t&(TARGET_TYPE_ALL|TARGET_TYPE_NPCS)))
return true;
Guild gil = Guild(trueGuild());
if(bool(t&TARGET_TYPE_HUMANS) && gil<GIL_SEPERATOR_HUM)
return true;
if(bool(t&TARGET_TYPE_ORCS) && gil>GIL_SEPERATOR_ORC)
return true;
if(bool(t&TARGET_TYPE_UNDEAD)) {
if(gil == GIL_GOBBO_SKELETON || gil == GIL_SUMMONED_GOBBO_SKELETON ||
gil == GIL_SKELETON || gil == GIL_SUMMONED_SKELETON ||
gil == GIL_SKELETON_MAGE || gil == GIL_SHADOWBEAST_SKELETON ||
gil == GIL_ZOMBIE)
return true;
}
return false;
}

void Npc::commitSpell() {
auto active = invent.getItem(currentSpellCast);
if(active==nullptr || !active->isSpellOrRune())
Expand Down
1 change: 1 addition & 0 deletions game/world/objects/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ class Npc final {
void commitSpell();
void takeDamage(Npc& other, const Bullet* b);
void takeDamage(Npc& other, const Bullet* b, const VisualFx* vfx, int32_t splId);
bool isSpellTargetType(TargetType t) const;

void emitSoundEffect(std::string_view sound, float range, bool freeSlot);
void emitSoundGround(std::string_view sound, float range, bool freeSlot);
Expand Down
16 changes: 1 addition & 15 deletions game/world/worldobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,21 +1003,7 @@ template<class T>
static bool checkTargetType(T&, TargetType) { return true; }

static bool checkTargetType(Npc& n, TargetType t) {
if(bool(t&(TARGET_TYPE_ALL|TARGET_TYPE_NPCS)))
return true;
Guild gil = Guild(n.trueGuild());
if(bool(t&TARGET_TYPE_HUMANS) && gil<GIL_SEPERATOR_HUM)
return true;
if(bool(t&TARGET_TYPE_ORCS) && gil>GIL_SEPERATOR_ORC)
return true;
if(bool(t&TARGET_TYPE_UNDEAD)) {
if(gil == GIL_GOBBO_SKELETON || gil == GIL_SUMMONED_GOBBO_SKELETON ||
gil == GIL_SKELETON || gil == GIL_SUMMONED_SKELETON ||
gil == GIL_SKELETON_MAGE || gil == GIL_SHADOWBEAST_SKELETON ||
gil == GIL_ZOMBIE)
return true;
}
return false;
return n.isSpellTargetType(t);
}

template<class T>
Expand Down