static inline bool DoObjectChecks(Map *map, Scriptable *Sender, Actor *target, int &dist, bool ignoreinvis=false) { dist = SquaredMapDistance(Sender, target); // TODO: what do we check for non-actors? // non-actors have a visual range (15), we should do visual range and LOS // see voodooconst.h for more info, currently the rest of the code uses 30 for non-actors if (Sender->Type == ST_ACTOR) { Actor *source = (Actor *)Sender; // Detect() ignores invisibility completely if (!ignoreinvis && target->IsInvisibleTo(source)) { return false; } // visual range check int visualrange = source->Modified[IE_VISUALRANGE]; if (dist > visualrange*visualrange) return false; // LOS check if (!map->IsVisibleLOS(Sender->Pos, target->Pos)) return false; // protection against creature if (target->fxqueue.HasEffect(fx_protection_creature_ref)) { // TODO: de-hardcode these (may not all be correct anyway) ieDword idsStat[] = { IE_EA, IE_GENERAL, IE_RACE, IE_CLASS, IE_SPECIFIC, IE_SEX, IE_ALIGNMENT }; for (int i=0; i<7; i++) { if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, source->Modified[idsStat[i]], i+2)) return false; } } } return true; }
inline static bool DoObjectChecks(Map *map, Scriptable *Sender, Actor *target, int &dist, bool ignoreinvis=false) { dist = SquaredMapDistance(Sender, target); // TODO: what do we check for non-actors? // non-actors have a visual range (15), we should do visual range and LOS if (Sender->Type == ST_ACTOR) { Actor *source = (Actor *)Sender; // Detect() ignores invisibility completely if (!ignoreinvis) { // TODO: move this stuff into a shared function so it can be used elsewhere? // SEEINVISIBLE skips these checks :-) if (source->Modified[IE_SEEINVISIBLE] == 0) { ieDword state = target->Modified[IE_STATE_ID]; // check for invisibility if ((state & STATE_INVISIBLE) != 0) return false; // check for improved invisibility? probably not //if ((state & STATE_INVIS2) != 0) return false; } // maybe this should be setting an invis flag? // TODO: should SEEINVISIBLE ignore this? Detect()? if (target->Modified[IE_AVATARREMOVAL]) return false; } // visual range check int visualrange = source->Modified[IE_VISUALRANGE]; if (dist > visualrange*visualrange) return false; // LOS check if (!map->IsVisible(Sender->Pos, target->Pos)) return false; // protection against creature if (target->fxqueue.HasEffect(fx_protection_creature_ref)) { // TODO: de-hardcode these (may not all be correct anyway) if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 2, source->Modified[IE_EA])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 3, source->Modified[IE_GENERAL])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 4, source->Modified[IE_RACE])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 5, source->Modified[IE_CLASS])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 6, source->Modified[IE_SPECIFIC])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 7, source->Modified[IE_SEX])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 8, source->Modified[IE_ALIGNMENT])) return false; } } return true; }
static inline bool DoObjectChecks(Map *map, Scriptable *Sender, Actor *target, int &dist, bool ignoreinvis=false) { dist = SquaredMapDistance(Sender, target); // TODO: what do we check for non-actors? // non-actors have a visual range (15), we should do visual range and LOS if (Sender->Type == ST_ACTOR) { Actor *source = (Actor *)Sender; // Detect() ignores invisibility completely if (!ignoreinvis && target->IsInvisibleTo(source)) { return false; } // visual range check int visualrange = source->Modified[IE_VISUALRANGE]; if (dist > visualrange*visualrange) return false; // LOS check if (!map->IsVisibleLOS(Sender->Pos, target->Pos)) return false; // protection against creature if (target->fxqueue.HasEffect(fx_protection_creature_ref)) { // TODO: de-hardcode these (may not all be correct anyway) if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 2, source->Modified[IE_EA])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 3, source->Modified[IE_GENERAL])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 4, source->Modified[IE_RACE])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 5, source->Modified[IE_CLASS])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 6, source->Modified[IE_SPECIFIC])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 7, source->Modified[IE_SEX])) return false; if (target->fxqueue.HasEffectWithParamPair(fx_protection_creature_ref, 8, source->Modified[IE_ALIGNMENT])) return false; } } return true; }