summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2019-04-13 23:55:29 +0300
committerAndrei Karas <akaras@inbox.ru>2019-05-05 22:22:05 +0300
commit8d732e3127434e576fe4a1203e609a8c6cc19cee (patch)
tree3349fee1fa29f2d15088780026fc8373bd91239f
parentea7697ef7b2ef759d5fd612e919c029ea4a7fa05 (diff)
downloadhercules-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
-rw-r--r--doc/script_commands.txt15
-rw-r--r--src/map/script.c42
2 files changed, 57 insertions, 0 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 2aec07f29..cc49a9c0f 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -10441,3 +10441,18 @@ This value always smaller or equal to MAX_INVENTORY.
Size can be changed by group of functions expandInventory*
---------------------------------------
+
+*getunittitle(<GID>)
+
+Return unit title string.
+Works for 20180207 main clients, 20171129 re clients, 20171130 zero clients
+
+---------------------------------------
+
+*setunittitle(<GID>, <title>)
+
+Set unit title string.
+Invisible for players, because current implimentation using title id only.
+Works for 20180207 main clients, 20171129 re clients, 20171130 zero clients
+
+---------------------------------------
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"),