summaryrefslogtreecommitdiff
path: root/src/emap/script_buildins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emap/script_buildins.c')
-rw-r--r--src/emap/script_buildins.c70
1 files changed, 70 insertions, 0 deletions
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) {