MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / isValidTarget

Method isValidTarget

source/game/scripting/StarEntityLuaBindings.cpp:44–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44bool LuaBindings::EntityCallbacks::isValidTarget(Entity const* entity, EntityId entityId) {
45 auto target = entity->world()->entity(entityId);
46
47 if (!target || !entity->getTeam().canDamage(target->getTeam(), false))
48 return false;
49
50 if (auto monster = as<Monster>(target))
51 return monster->aggressive();
52
53 if (auto npc = as<Npc>(target)) {
54 if (auto attackerNpc = as<Npc>(entity))
55 return npc->aggressive() || attackerNpc->aggressive();
56 return true;
57 }
58
59 return is<Player>(target);
60}
61
62Vec2F LuaBindings::EntityCallbacks::distanceToEntity(Entity const* entity, EntityId entityId) {
63 Vec2F dist;

Callers

nothing calls this directly

Calls 5

canDamageMethod · 0.80
entityMethod · 0.45
worldMethod · 0.45
getTeamMethod · 0.45
aggressiveMethod · 0.45

Tested by

no test coverage detected