summaryrefslogtreecommitdiff
path: root/npc/functions/filters.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/functions/filters.txt')
-rw-r--r--npc/functions/filters.txt42
1 files changed, 42 insertions, 0 deletions
diff --git a/npc/functions/filters.txt b/npc/functions/filters.txt
index cec7a15af..f47c16beb 100644
--- a/npc/functions/filters.txt
+++ b/npc/functions/filters.txt
@@ -62,6 +62,48 @@ function script filter_sameguildorpartynotyou {
return ((getcharid(1) > 0 && .@party) || (getcharid(2) > 0 && .@guild));
}
+// filter_hostile( id )
+function script filter_hostile {
+ debugmes "filter_hostile %d", getarg(0);
+ .@type=getunitdata(getarg(0), UDT_TYPE);
+ .@chkid=getarg(0);
+
+ debugmes "filter_hostile: Checking %d (BL %d)", getarg(0), .@type;
+
+ // Monsters
+ if (.@type == BL_MOB)
+ return true;
+
+ // NPCs
+ if (.@type == BL_NPC)
+ return false;
+
+ // Homunculus
+ if (.@type == BL_HOM)
+ .@chkid=charid2rid(getunitdata(getarg(0), UDT_MASTERCID));
+
+ // Pets
+ if (.@type == BL_PET)
+ .@chkid=getunitdata(getarg(0), UDT_MASTERAID);
+
+ // Mercenaries
+ if (.@type == BL_MER)
+ .@chkid=charid2rid(getunitdata(getarg(0), UDT_MASTERCID));
+
+ // Elementals
+ if (.@type == BL_ELEM)
+ .@chkid=charid2rid(getunitdata(getarg(0), UDT_MASTERCID));
+
+ debugmes "filter_hostile: Filtering %d (original %d) (BL %d)", .@chkid, getarg(0), .@type;
+ // Players (and slaves)
+ return !(filter_sameguildorparty(.@chkid));
+}
+
+// filter_friendly( id )
+function script filter_friendly {
+ return !(filter_hostile(.@chkid));
+}
+
// filter_notboss( id )
function script filter_notboss {
// 32 = MD_BOSS