diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 35f0d04e12..c72292ecb5 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -7145,6 +7145,13 @@ For the position, the x and y are given in the UnitSkillUsePos. --------------------------------------- +*unitexists ; + +Checks if the given Game ID exists. Returns false if the object doesn't exist, or true if +it does. + +--------------------------------------- + *getunittype ; Returns the type of object from the given Game ID. Returns -1 if the given GID does not diff --git a/src/map/script.c b/src/map/script.c index 615b0a6029..4db00f64db 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -16712,6 +16712,23 @@ BUILDIN_FUNC(pcstopfollow) // <--- [zBuffer] List of player cont commands // [zBuffer] List of unit control commands ---> +/// Checks to see if the unit exists. +/// +/// unitexists ; +BUILDIN_FUNC(unitexists) +{ + struct block_list* bl; + + bl = map_id2bl(script_getnum(st, 2)); + + if (!bl) + script_pushint(st, false); + else + script_pushint(st, true); + + return SCRIPT_CMD_SUCCESS; +} + /// Gets the type of the given Game ID. /// /// getunittype ; @@ -21690,6 +21707,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(pcblockmove,"ii"), // <--- [zBuffer] List of player cont commands // [zBuffer] List of unit control commands ---> + BUILDIN_DEF(unitexists,"i"), BUILDIN_DEF(getunittype,"i"), BUILDIN_DEF(getunitname,"i"), BUILDIN_DEF(setunitname,"is"),