summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-07-13 18:41:29 +0000
committerJesusaves <cpntb1@ymail.com>2020-07-13 18:41:29 +0000
commit48200a8f6fb8f9e683ce7eff9d8852c482c5a8f6 (patch)
tree75d542d0810f1cf336fbb684b428b0ddaec96700
parent19d651f235973dc6bbab9489aeda6da39adad86b (diff)
parentb503fd5d03bd2b4aa496cf34dff49265372f64de (diff)
downloadplugin-48200a8f6fb8f9e683ce7eff9d8852c482c5a8f6.tar.gz
plugin-48200a8f6fb8f9e683ce7eff9d8852c482c5a8f6.tar.bz2
plugin-48200a8f6fb8f9e683ce7eff9d8852c482c5a8f6.tar.xz
plugin-48200a8f6fb8f9e683ce7eff9d8852c482c5a8f6.zip
Merge branch 'jesusalva/aggravate' into 'master'
New builtin script command: aggravate + instanceowner See merge request evol/evol-hercules!22
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/script_buildins.c73
-rw-r--r--src/emap/script_buildins.h2
3 files changed, 77 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index 9bc0324..d55845e 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -215,6 +215,8 @@ HPExport void plugin_init (void)
addScriptCommand("setitemoptionbyindex", "iii*", setItemOptionByIndex);
addScriptCommand("isinstance", "i", isInstance);
addScriptCommand("readbattleparam","ii",readBattleParam);
+ addScriptCommand("instanceowner", "i", InstanceOwner);
+ addScriptCommand("aggravate", "i", aggravate);
addScriptCommand("getnpcsubtype", "?", getNpcSubtype);
do_init_langs();
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index 4797220..3b917f6 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -15,6 +15,7 @@
#include "map/chat.h"
#include "map/chrif.h"
#include "map/instance.h"
+#include "map/mob.h"
#include "map/npc.h"
#include "map/pc.h"
#include "map/refine.h"
@@ -2463,3 +2464,75 @@ BUILDIN(readBattleParam)
return true;
}
+
+// Returns the Acc. ID of the owner of an instance
+BUILDIN(InstanceOwner)
+{
+ int instance_id = -1;
+
+ if (script_hasdata(st, 2)) {
+ instance_id = script_getnum(st, 2);
+ } else if (st->instance_id >= 0) {
+ instance_id = st->instance_id;
+ } else {
+ ShowError("buildin_instanceowner: no instance attached\n");
+ script_pushint(st, false);
+ return true;
+ }
+
+ // Do instance exists?
+ if (!instance->valid(instance_id)) {
+ script_pushint(st, false);
+ return true;
+ }
+
+ // Note: This does not returns type!
+ // using this against party/guilds instances not advised.
+ // returns 0 if either instance doesn't exists or is global
+ script_pushint(st, (int)instance->list[instance_id].owner_id);
+ return true;
+}
+
+
+// Advanced monster data overrider
+// aggravate(guid)
+BUILDIN(aggravate)
+{
+ struct block_list *bl;
+ struct map_session_data *sd = NULL;
+
+ bl = map->id2bl(script_getnum(st, 2));
+
+ // We only work with mobs
+ if (bl == NULL) {
+ ShowWarning("buildin_aggravate: Error in finding object with given GID %d!\n", script_getnum(st, 2));
+ script_pushint(st, false);
+ return false;
+ }
+
+ if (bl->type != BL_MOB) {
+ ShowWarning("buildin_aggravate: GID %d is not a monster!\n", script_getnum(st, 2));
+ script_pushint(st, false);
+ return false;
+ }
+
+ // Player must be attached
+ sd = script->rid2sd(st);
+ if (sd == NULL) {
+ ShowWarning("buildin_aggravate: Ran without player attached!");
+ script_pushint(st, false);
+ return false;
+ }
+
+ // Create monster structure
+ struct mob_data *md = BL_UCAST(BL_MOB, bl);
+
+ // Override the provoke flag
+ md->state.provoke_flag = sd->status.account_id;
+ // We could use mob->target()
+ // But I want aggravate to apply without any checks
+ // Skipping chase checks
+ md->target_id = sd->status.account_id;
+ script_pushint(st, true);
+ return true;
+}
diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h
index 8895abe..7582828 100644
--- a/src/emap/script_buildins.h
+++ b/src/emap/script_buildins.h
@@ -100,6 +100,8 @@ BUILDIN(getItemOptionParamByIndex);
BUILDIN(setItemOptionByIndex);
BUILDIN(isInstance);
BUILDIN(readBattleParam);
+BUILDIN(InstanceOwner);
+BUILDIN(aggravate);
BUILDIN(getNpcSubtype);
#endif // EVOL_MAP_SCRIPT_BUILDINS