Added return values for unit script commands (fixes #1143)

* Script commands getunitdata and setunitdata will return -1 when the given GID is not found.
* Script commands getunitname and setunitname will return Unknown when the given GID is not found.
This commit is contained in:
aleos89
2016-04-12 10:16:58 -04:00
parent ee3cf98daa
commit 4f16d82540
2 changed files with 9 additions and 1 deletions

View File

@@ -7147,7 +7147,7 @@ For the position, the x and y are given in the UnitSkillUsePos.
*getunittype <GID>;
Returns the type of object from the given Game ID. Returns -1 if the given <GID> does not
Returns the type of object from the given Game ID. Returns -1 if the given GID does not
exist.
UNITTYPE_PC 0
@@ -7177,6 +7177,8 @@ Elemental don't support custom names.
Changing a homunculus or pet name will be permanent.
Returns "Unknown" if unit is not found.
---------------------------------------
*getunitdata <GID>,<arrayname>;
@@ -7186,6 +7188,8 @@ This is used to get and set special data related to the unit.
With getunitdata, the array given will be filled with the current data. In setunitdata
the indexes in the array would be used to set that data on the unit.
Both getunitdata and setunitdata will return -1 if the given GID does not exist.
Note: When adjusting a unit's stat (STR, AGI, etc) the unit's respective statuses are
recalculated (HIT, FLEE, etc) automatically. Keep in mind that some stats don't
affect a unit's status and will have to directly be modified.

View File

@@ -16795,6 +16795,7 @@ BUILDIN_FUNC(getunitdata)
if (!bl) {
ShowWarning("buildin_getunitdata: Error in finding object with given game ID %d!\n", script_getnum(st, 2));
script_pushint(st, -1);
return SCRIPT_CMD_FAILURE;
}
@@ -17116,6 +17117,7 @@ BUILDIN_FUNC(setunitdata)
if (!bl) {
ShowWarning("buildin_setunitdata: Error in finding object with given game ID %d!\n", script_getnum(st, 2));
script_pushint(st, -1);
return SCRIPT_CMD_FAILURE;
}
@@ -17503,6 +17505,7 @@ BUILDIN_FUNC(getunitname)
if (!bl) {
ShowWarning("buildin_getunitname: Error in finding object with given game ID %d!\n", script_getnum(st, 2));
script_pushconststr(st, "Unknown");
return SCRIPT_CMD_FAILURE;
}
@@ -17527,6 +17530,7 @@ BUILDIN_FUNC(setunitname)
if (!bl) {
ShowWarning("buildin_setunitname: Error in finding object with given game ID %d!\n", script_getnum(st, 2));
script_pushconststr(st, "Unknown");
return SCRIPT_CMD_FAILURE;
}