New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Battleground script command expansion #1534
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
42a63d8
Implemented 2 new battleground commands. Closes #1531.
4d48cb6
waitingroom2bg and bg_create will now check if provided event name is…
c8f77c8
Made events for bg_create and waitingroom2bg optional
3d3c3d5
Removed extra whitespaces in waitingroom2bg
6bb8e4b
Cleaned up new battleground commands and documentation
fcf18ae
Another clean up for new battleground commands
ba89941
Fixed a critical mistake in bg_create command
9ffd08c
Cleaned up bg_create
cb4cdea
Made map,x,y parameters on waitingroom2bg_single optional
7b91a5c
Added missing script_pushint in some condition.
31f7155
Fixed typo in script.c (bg_join)
db1a443
Resolved a compile warning in buildin_bg_join
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18653,28 +18653,28 @@ BUILDIN_FUNC(waitingroom2bg) | |
} | ||
|
||
map_name = script_getstr(st,2); | ||
if( strcmp(map_name,"-") != 0 ) | ||
{ | ||
mapindex = mapindex_name2id(map_name); | ||
if( mapindex == 0 ) | ||
{ // Invalid Map | ||
script_pushint(st,0); | ||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
if (strcmp(map_name, "-") != 0 && (mapindex = mapindex_name2id(map_name)) == 0) | ||
{ // Invalid Map | ||
script_pushint(st, 0); | ||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
|
||
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(script_hasdata(st,5)) | ||
ev = script_getstr(st,5); // Logout Event | ||
if(script_hasdata(st,6)) | ||
dev = script_getstr(st,6); // Die Event | ||
|
||
check_event(st, ev); | ||
check_event(st, dev); | ||
|
||
if( (bg_id = bg_create(mapindex, x, y, ev, dev)) == 0 ) | ||
{ // Creation failed | ||
script_pushint(st,0); | ||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
|
||
|
||
|
||
for (i = 0; i < cd->users; i++) { // Only add those who are in the chat room | ||
struct map_session_data *sd; | ||
if( (sd = cd->usersd[i]) != NULL && bg_team_join(bg_id, sd) ){ | ||
|
@@ -18694,15 +18694,29 @@ BUILDIN_FUNC(waitingroom2bg_single) | |
struct npc_data *nd; | ||
struct chat_data *cd; | ||
struct map_session_data *sd; | ||
struct battleground_data *bg; | ||
int x, y, mapindex, bg_id; | ||
|
||
bg_id = script_getnum(st,2); | ||
map_name = script_getstr(st,3); | ||
if( (mapindex = mapindex_name2id(map_name)) == 0 ) | ||
return SCRIPT_CMD_SUCCESS; // Invalid Map | ||
if ((bg = bg_team_search(bg_id)) == NULL) { | ||
script_pushint(st, false); | ||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
if (script_hasdata(st, 3)) { | ||
map_name = script_getstr(st, 3); | ||
if ((mapindex = mapindex_name2id(map_name)) == 0) { | ||
script_pushint(st, false); | ||
return SCRIPT_CMD_SUCCESS; // Invalid Map | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. script_pushint missing here |
||
} | ||
x = script_getnum(st, 4); | ||
y = script_getnum(st, 5); | ||
} | ||
else { | ||
mapindex = bg->mapindex; | ||
x = bg->x; | ||
y = bg->y; | ||
} | ||
|
||
x = script_getnum(st,4); | ||
y = script_getnum(st,5); | ||
nd = npc_name2id(script_getstr(st,6)); | ||
|
||
if( nd == NULL || (cd = (struct chat_data *)map_id2bl(nd->chat_id)) == NULL || cd->users <= 0 ) | ||
|
@@ -18711,13 +18725,86 @@ BUILDIN_FUNC(waitingroom2bg_single) | |
if( (sd = cd->usersd[0]) == NULL ) | ||
return SCRIPT_CMD_SUCCESS; | ||
|
||
if( bg_team_join(bg_id, sd) ) | ||
if( bg_team_join(bg_id, sd) && pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) == SETPOS_OK) | ||
{ | ||
pc_setpos(sd, mapindex, x, y, CLR_TELEPORT); | ||
script_pushint(st,1); | ||
script_pushint(st, true); | ||
} | ||
else | ||
script_pushint(st,0); | ||
script_pushint(st, false); | ||
|
||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
|
||
|
||
/// Creates an instance of battleground battle group. | ||
/// *bg_create("<map name>",<x>,<y>{,"<On Quit Event>","<On Death Event>"}); | ||
/// @author [secretdataz] | ||
BUILDIN_FUNC(bg_create) { | ||
const char *map_name, *ev = "", *dev = ""; | ||
int x, y, mapindex = 0; | ||
|
||
map_name = script_getstr(st, 2); | ||
if (strcmp(map_name, "-") != 0 && (mapindex = mapindex_name2id(map_name)) == 0) | ||
{ // Invalid Map | ||
script_pushint(st, 0); | ||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
|
||
x = script_getnum(st, 3); | ||
y = script_getnum(st, 4); | ||
if(script_hasdata(st, 5)) | ||
ev = script_getstr(st, 5); // Logout Event | ||
if(script_hasdata(st, 6)) | ||
dev = script_getstr(st, 6); // Die Event | ||
|
||
check_event(st, ev); | ||
check_event(st, dev); | ||
|
||
script_pushint(st, bg_create(mapindex, x, y, ev, dev)); | ||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
|
||
/// Adds attached player or <char id> (if specified) to an existing | ||
/// battleground group and warps it to the specified coordinates on | ||
/// the given map. | ||
/// bg_join(<battle group>,{"<map name>",<x>,<y>{,<char id>}}); | ||
/// @author [secretdataz] | ||
BUILDIN_FUNC(bg_join) { | ||
const char* map_name; | ||
struct map_session_data *sd; | ||
struct battleground_data *bg; | ||
int x, y, bg_id, mapindex; | ||
|
||
bg_id = script_getnum(st, 2); | ||
if ((bg = bg_team_search(bg_id)) == NULL) { | ||
script_pushint(st, false); | ||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
if (script_hasdata(st, 3)) { | ||
map_name = script_getstr(st, 3); | ||
if ((mapindex = mapindex_name2id(map_name)) == 0) { | ||
script_pushint(st, false); | ||
return SCRIPT_CMD_SUCCESS; // Invalid Map | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also pushint |
||
} | ||
x = script_getnum(st, 4); | ||
y = script_getnum(st, 5); | ||
} else { | ||
mapindex = bg->mapindex; | ||
x = bg->x; | ||
y = bg->y; | ||
} | ||
|
||
if (!script_charid2sd(6, sd)) { | ||
script_pushint(st, false); | ||
return SCRIPT_CMD_FAILURE; | ||
} | ||
|
||
if (bg_team_join(bg_id, sd) && pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) == SETPOS_OK) | ||
{ | ||
script_pushint(st, true); | ||
} | ||
else | ||
script_pushint(st, false); | ||
|
||
return SCRIPT_CMD_SUCCESS; | ||
} | ||
|
@@ -22217,8 +22304,8 @@ struct script_function buildin_func[] = { | |
BUILDIN_DEF(agitend2,""), | ||
BUILDIN_DEF(agitcheck2,""), | ||
// BattleGround | ||
BUILDIN_DEF(waitingroom2bg,"siiss?"), | ||
BUILDIN_DEF(waitingroom2bg_single,"isiis"), | ||
BUILDIN_DEF(waitingroom2bg,"sii???"), | ||
BUILDIN_DEF(waitingroom2bg_single,"i????"), | ||
BUILDIN_DEF(bg_team_setxy,"iii"), | ||
BUILDIN_DEF(bg_warp,"isii"), | ||
BUILDIN_DEF(bg_monster,"isiisi?"), | ||
|
@@ -22229,6 +22316,8 @@ struct script_function buildin_func[] = { | |
BUILDIN_DEF(bg_get_data,"ii"), | ||
BUILDIN_DEF(bg_getareausers,"isiiii"), | ||
BUILDIN_DEF(bg_updatescore,"sii"), | ||
BUILDIN_DEF(bg_join,"i????"), | ||
BUILDIN_DEF(bg_create,"sii??"), | ||
|
||
// Instancing | ||
BUILDIN_DEF(instance_create,"s??"), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bonus tab?