diff options
author | Andrei Karas <akaras@inbox.ru> | 2019-04-13 23:55:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2019-05-05 22:22:05 +0300 |
commit | 8d732e3127434e576fe4a1203e609a8c6cc19cee (patch) | |
tree | 3349fee1fa29f2d15088780026fc8373bd91239f /src/map | |
parent | ea7697ef7b2ef759d5fd612e919c029ea4a7fa05 (diff) | |
download | hercules-8d732e3127434e576fe4a1203e609a8c6cc19cee.tar.gz hercules-8d732e3127434e576fe4a1203e609a8c6cc19cee.tar.bz2 hercules-8d732e3127434e576fe4a1203e609a8c6cc19cee.tar.xz hercules-8d732e3127434e576fe4a1203e609a8c6cc19cee.zip |
Add commands getunittitle and setunittitle
This commands get/set title for non players bl
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/script.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index ccbe50157..eaec5a10a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -20395,6 +20395,46 @@ static BUILDIN(setunitname) return true; } +static BUILDIN(setunittitle) +{ + struct block_list *bl = map->id2bl(script_getnum(st, 2)); + if (bl == NULL) { + ShowWarning("buildin_setunittitle: Error in finding object with given game ID %d!\n", script_getnum(st, 2)); + return false; + } + + struct unit_data *ud = unit->bl2ud2(bl); + if (ud == NULL) { + ShowWarning("buildin_setunittitle: Error in finding unit_data for given game ID %d!\n", script_getnum(st, 2)); + return false; + } + + safestrncpy(ud->title, script_getstr(st, 3), NAME_LENGTH); + clif->blname_ack(0, bl); // Send update to client. + + return true; +} + +static BUILDIN(getunittitle) +{ + struct block_list *bl = map->id2bl(script_getnum(st, 2)); + if (bl == NULL) { + ShowWarning("buildin_getunitname: Error in finding object with given game ID %d!\n", script_getnum(st, 2)); + script_pushconststr(st, "Unknown"); + return false; + } + + struct unit_data *ud = unit->bl2ud(bl); + if (ud == NULL) { + ShowWarning("buildin_setunittitle: Error in finding unit_data for given game ID %d!\n", script_getnum(st, 2)); + return false; + } + + script_pushstrcopy(st, ud->title); + + return true; +} + /// Makes the unit walk to target position or target id /// Returns if it was successfull /// @@ -25771,6 +25811,8 @@ static void script_parse_builtin(void) BUILDIN_DEF(getunitdata,"ii?"), BUILDIN_DEF(getunitname,"i"), BUILDIN_DEF(setunitname,"is"), + BUILDIN_DEF(getunittitle,"i"), + BUILDIN_DEF(setunittitle,"is"), BUILDIN_DEF(unitwalk,"ii?"), BUILDIN_DEF(unitkill,"i"), BUILDIN_DEF(unitwarp,"isii"), |