summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-03-11 03:35:51 +0100
committerGitHub <noreply@github.com>2019-03-11 03:35:51 +0100
commite78a3b536566c1ff15960fa747995ac5b6307112 (patch)
treed46057baa4e501767e1dc795f7a6242a62d32c72
parentca315dcb6f8ba435beedc9c1a5bff12194bccc72 (diff)
parent433fd264ece900b8c563946737bbd4a73933c50a (diff)
downloadhercules-e78a3b536566c1ff15960fa747995ac5b6307112.tar.gz
hercules-e78a3b536566c1ff15960fa747995ac5b6307112.tar.bz2
hercules-e78a3b536566c1ff15960fa747995ac5b6307112.tar.xz
hercules-e78a3b536566c1ff15960fa747995ac5b6307112.zip
Merge pull request #2396 from AnnieRuru/67-mobattached
* Add *mobattached and *killmonstergid script command
-rw-r--r--doc/script_commands.txt23
-rw-r--r--npc/quests/quests_rachel.txt2
-rw-r--r--src/map/script.c29
3 files changed, 51 insertions, 3 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index f2852e93e..9655e907c 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -266,8 +266,8 @@ direction across Y. Walking into that area will trigger the NPC. If no
'OnTouch:' special label is present in the NPC code, the execution will
start from the beginning of the script, otherwise, it will start from the
'OnTouch:' label. Monsters can also trigger the NPC, though the label
-'OnTouchNPC:' is used in this case. If player left area npc will called
-if present label 'OnUnTouch'.
+'OnTouchNPC:' is used in this case, and using mobattached() will return
+monster GID. If player left the area will trigger the label 'OnUnTouch'.
The code part is the script code that will execute whenever the NPC is
triggered. It may contain commands and function calls, descriptions of
@@ -6507,6 +6507,14 @@ other number for this parameter won't be recognized.
---------------------------------------
+*killmonstergid(<GID>);
+
+This command will kill the specific monster GID. The difference between
+this command and 'unitkill', is this command does not trigger monster's
+event label.
+
+---------------------------------------
+
*strmobinfo(<type>, <monster id>)
This function will return information about a monster record in the
@@ -6595,6 +6603,17 @@ will run as if by donpcevent().
---------------------------------------
+*mobattached()
+
+This command will return RID of the monster running from 'OnTouchNPC:' label.
+
+
+// Kill any monster entering npc's trigger area
+OnTouchNPC:
+ killmonstergid mobattached();
+
+---------------------------------------
+
*homevolution()
This command will try to evolve the current player's homunculus.
diff --git a/npc/quests/quests_rachel.txt b/npc/quests/quests_rachel.txt
index 43e4beadb..1cc002d80 100644
--- a/npc/quests/quests_rachel.txt
+++ b/npc/quests/quests_rachel.txt
@@ -3210,7 +3210,7 @@ OnTouch:
OnTouchNPC:
emotion e_an;
- //emotion e_gg,1; //Emote on monster - unsupported
+ unitemote mobattached(), e_gg;
end;
OnMyMobDead:
diff --git a/src/map/script.c b/src/map/script.c
index b0a3b6929..23793e54a 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -11095,6 +11095,21 @@ static BUILDIN(killmonsterall)
return true;
}
+static BUILDIN(killmonstergid)
+{
+ int mobgid = script_getnum(st, 2);
+ struct mob_data *md = map->id2md(mobgid);
+
+ if (md == NULL) {
+ ShowWarning("buildin_killmonstergid: Error in finding monster GID '%d' or the target is not a monster.\n", mobgid);
+ return false;
+ }
+
+ md->state.npc_killmonster = 1;
+ status_kill(&md->bl);
+ return true;
+}
+
/*==========================================
* Creates a clone of a player.
* clone map, x, y, event, char_id, master_id, mode, flag, duration
@@ -11730,6 +11745,18 @@ static BUILDIN(playerattached)
}
/*==========================================
+ * Used by OnTouchNPC: label to return monster GID
+ *------------------------------------------*/
+static BUILDIN(mobattached)
+{
+ if (st->rid == 0 || map->id2md(st->rid) == NULL)
+ script_pushint(st, 0);
+ else
+ script_pushint(st, st->rid);
+ return true;
+}
+
+/*==========================================
*------------------------------------------*/
static BUILDIN(announce)
{
@@ -25354,6 +25381,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(areamonster,"siiiisii???"),
BUILDIN_DEF(killmonster,"ss?"),
BUILDIN_DEF(killmonsterall,"s?"),
+ BUILDIN_DEF(killmonstergid, "i"),
BUILDIN_DEF(clone,"siisi????"),
BUILDIN_DEF(doevent,"s"),
BUILDIN_DEF(donpcevent,"s"),
@@ -25370,6 +25398,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(attachnpctimer,"?"), // attached the player id to the npc timer [Celest]
BUILDIN_DEF(detachnpctimer,"?"), // detached the player id from the npc timer [Celest]
BUILDIN_DEF(playerattached,""), // returns id of the current attached player. [Skotlex]
+ BUILDIN_DEF(mobattached, ""),
BUILDIN_DEF(announce,"si?????"),
BUILDIN_DEF(mapannounce,"ssi?????"),
BUILDIN_DEF(areaannounce,"siiiisi?????"),