Added a new script command unitexists

* Small follow up to 4f16d82.
* Checks to see if a unit exists or not.
This commit is contained in:
aleos89
2016-04-13 09:34:43 -04:00
parent 2874b76b98
commit 67e26c885d
2 changed files with 25 additions and 0 deletions

View File

@@ -7145,6 +7145,13 @@ For the position, the x and y are given in the UnitSkillUsePos.
---------------------------------------
*unitexists <GID>;
Checks if the given Game ID exists. Returns false if the object doesn't exist, or true if
it does.
---------------------------------------
*getunittype <GID>;
Returns the type of object from the given Game ID. Returns -1 if the given GID does not

View File

@@ -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 <unit id>;
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 <unit id>;
@@ -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"),