From 5deddceda5db39858d036fdb8340d820d8b63ada Mon Sep 17 00:00:00 2001
From: Freeyorp <Freeyorp101@hotmail.com>
Date: Fri, 9 Apr 2010 02:52:55 +1200
Subject: Add new function to the magic system, mob_id

This takes one parameter, an entity, and returns the id of the class associated with a mob if it is a mob, and fails otherwise.
---
 src/map/magic-expr.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/map/magic-expr.c b/src/map/magic-expr.c
index e78247a..18c293d 100644
--- a/src/map/magic-expr.c
+++ b/src/map/magic-expr.c
@@ -609,6 +609,15 @@ fun_name_of (env_t * env, int args_nr, val_t * result, val_t * args)
     return 1;
 }
 
+/* [Freeyorp] I'm putting this one in as name_of seems to have issues with summoned or spawned mobs. */
+static int
+fun_mob_id (env_t * env, int args_nr, val_t * result, val_t * args)
+{
+    if (ETY (0) != BL_MOB) return 1;
+    RESULTINT = ((struct mob_data *) (ARGENTITY(0)))->class;
+    return 0;
+}
+
 #define COPY_LOCATION(dest, src) (dest).x = (src).x; (dest).y = (src).y; (dest).m = (src).m;
 
 static int
@@ -1183,6 +1192,7 @@ static fun_t functions[] = {
     BATTLE_RECORD (max_sp),
     {"dir", "e", 'd', fun_get_dir},
     {"name_of", ".", 's', fun_name_of},
+    {"mob_id", "e", 'i', fun_mob_id},
     {"location", "e", 'l', fun_location},
     {"random", "i", 'i', fun_random},
     {"random_dir", "i", 'd', fun_random_dir},
-- 
cgit v1.2.3-70-g09d2