summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-12-26 08:46:29 -0300
committerJesusaves <cpntb1@ymail.com>2021-12-26 08:46:29 -0300
commitf348a04be46b9b19b59cc9937f3f7ee7aa55472f (patch)
tree4467cb4a1191d45b66d5afe59d1d5b804769234c
parent1cbda9f3c7dd27674a10f11044b325454c1d8fb4 (diff)
downloadevol-hercules-f348a04be46b9b19b59cc9937f3f7ee7aa55472f.tar.gz
evol-hercules-f348a04be46b9b19b59cc9937f3f7ee7aa55472f.tar.bz2
evol-hercules-f348a04be46b9b19b59cc9937f3f7ee7aa55472f.tar.xz
evol-hercules-f348a04be46b9b19b59cc9937f3f7ee7aa55472f.zip
Add advanced wrappers for Battle Grounds
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/script_buildins.c70
-rw-r--r--src/emap/script_buildins.h2
3 files changed, 74 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index 7355a7a..d92c48d 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -243,6 +243,8 @@ HPExport void plugin_init (void)
addScriptCommand("harm", "ii??", harm);
addScriptCommand("resetrng", "", resetrng);
addScriptCommand("getskillname", "i", getskillname);
+ addScriptCommand("bgnew", "siiss", bgnew);
+ addScriptCommand("bgjoin", "isii?", bgjoin);
// Overrides
addScriptCommand("debugmes","v*",debugmes);
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index 2bd25f1..3bd6d8e 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -17,6 +17,7 @@
#include "map/achievement.h"
#include "map/atcommand.h"
#include "map/battle.h"
+#include "map/battleground.h"
#include "map/chat.h"
#include "map/chrif.h"
#include "map/guild.h"
@@ -3514,6 +3515,75 @@ BUILDIN(getskillname)
return true;
}
+BUILDIN(bgnew)
+{
+ const char *map_name, *ev = "", *dev = "";
+ int x, y, map_index = 0, bg_id;
+
+ map_name = script_getstr(st,2);
+ if( strcmp(map_name,"-") != 0 )
+ {
+ map_index = script->mapindexname2id(st,map_name);
+ if( map_index == 0 )
+ { // Invalid Map
+ script_pushint(st,0);
+ return true;
+ }
+ }
+
+ x = script_getnum(st,3);
+ y = script_getnum(st,4);
+ ev = script_getstr(st,5); // Logout Event
+ dev = script_getstr(st,6); // Die Event
+
+ if ((bg_id = bg->create(map_index, x, y, ev, dev)) == 0) {
+ // Creation failed
+ script_pushint(st,0);
+ return true;
+ }
+
+ script_pushint(st,bg_id);
+ return true;
+}
+
+BUILDIN(bgjoin)
+{
+ int bgId = script_getnum(st, 2);
+ const char* map_name = script_getstr(st, 3);
+ int x = script_getnum(st,4);
+ int y = script_getnum(st,5);
+ struct map_session_data *sd;
+ int map_index;
+
+ if( (map_index = script->mapindexname2id(st,map_name)) == 0 )
+ return true; // Invalid Map
+
+ if (script_hasdata(st,6)) {
+ int account_id = script_getnum(st,6);
+ sd = script->id2sd(st, account_id); // <account id>
+ if (sd == NULL) {
+ return true;
+ }
+ } else {
+ sd = script->rid2sd(st);// attached player
+ if (sd == NULL)
+ return true;
+ }
+
+ if (sd == NULL)
+ return true;
+
+ if( bg->team_join(bgId, sd) )
+ {
+ pc->setpos(sd, map_index, x, y, CLR_TELEPORT);
+ script_pushint(st,1);
+ }
+ else
+ script_pushint(st,0);
+
+ return true;
+}
+
//////////////////////////////////////////////////////////
/*
switch (bl->type) {
diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h
index 740645d..3253da3 100644
--- a/src/emap/script_buildins.h
+++ b/src/emap/script_buildins.h
@@ -127,6 +127,8 @@ BUILDIN(calcdmg);
BUILDIN(harm);
BUILDIN(resetrng);
BUILDIN(getskillname);
+BUILDIN(bgnew);
+BUILDIN(bgjoin);
// Overrides
BUILDIN(countitem);