diff options
author | Freeyorp <Freeyorp101@hotmail.com> | 2010-04-09 02:52:55 +1200 |
---|---|---|
committer | Freeyorp <Freeyorp101@hotmail.com> | 2010-04-11 12:10:57 +1200 |
commit | 5deddceda5db39858d036fdb8340d820d8b63ada (patch) | |
tree | 4da0e6093094817a4d137524d7f204f79a3035e6 /src/map/magic-expr.c | |
parent | 5aac3f90243204ae8ef222375feccb7dc1898fa0 (diff) | |
download | tmwa-5deddceda5db39858d036fdb8340d820d8b63ada.tar.gz tmwa-5deddceda5db39858d036fdb8340d820d8b63ada.tar.bz2 tmwa-5deddceda5db39858d036fdb8340d820d8b63ada.tar.xz tmwa-5deddceda5db39858d036fdb8340d820d8b63ada.zip |
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.
Diffstat (limited to 'src/map/magic-expr.c')
-rw-r--r-- | src/map/magic-expr.c | 10 |
1 files changed, 10 insertions, 0 deletions
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}, |