summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-06-28 18:45:38 -0300
committershennetsind <ind@henn.et>2013-06-28 18:45:38 -0300
commit918b1123963ac2f91a4d074b092ceef1db71b4e8 (patch)
tree15eda3833d2fab779b02ef22573c21812b1c3aec
parent203e44e51c8cb133bf3fb20b372d16ea92be7667 (diff)
downloadhercules-918b1123963ac2f91a4d074b092ceef1db71b4e8.tar.gz
hercules-918b1123963ac2f91a4d074b092ceef1db71b4e8.tar.bz2
hercules-918b1123963ac2f91a4d074b092ceef1db71b4e8.tar.xz
hercules-918b1123963ac2f91a4d074b092ceef1db71b4e8.zip
BG Queue Testing
http://hercules.ws/board/topic/1302-bg-queue-debug/ Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r--conf/battlegrounds.conf14
-rw-r--r--db/const.txt4
-rw-r--r--npc/custom/bgqueue/flavius.txt726
-rw-r--r--src/common/socket.h2
-rw-r--r--src/map/battleground.c62
-rw-r--r--src/map/battleground.h2
-rw-r--r--src/map/clif.c29
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/map.c3
-rw-r--r--src/map/packets_struct.h6
-rw-r--r--src/map/script.c109
-rw-r--r--src/map/script.h2
12 files changed, 922 insertions, 39 deletions
diff --git a/conf/battlegrounds.conf b/conf/battlegrounds.conf
index b43899dd7..1c32d32ce 100644
--- a/conf/battlegrounds.conf
+++ b/conf/battlegrounds.conf
@@ -36,9 +36,11 @@ battlegrounds: (
minTeamPlayers: 6 /* minimum amount of team members required for a team (party or guild) to join */
delay_var: "Tierra_BG_Tick" /* npc variable name that will store the delay for this match */
maxDuration: 30 /* maximum duration in minutes, if reached game ends and highest score wins (or calls a draw if scores are equal) */
+ fillDuration: 20 /* time in seconds to wait for more applications when minimum has been reached */
+ pGameDuration: 20 /* time to wait for players to confirm their attendence after queueing process has finished */
},{
name: "Flavius" //must match the name in client files
- event: "Flavius_BG1::OnPlayerListReady"
+ event: "start#bat_b01::OnPlayerListReady"
minLevel: 80
maxLevel: 150
reward: {/* amount of badges awarded on each case */
@@ -46,11 +48,13 @@ battlegrounds: (
loss: 3
draw: 3
}
- minPlayers: 6 /* minimum amount of players to start */
+ minPlayers: 3 /* minimum amount of players to start (DEBUG VALUE, CHANGE BACK) */
maxPlayers: 60 /* maximum amount of players */
minTeamPlayers: 6 /* minimum amount of team members required for a team (party or guild) to join */
delay_var: "Flavius_BG_Tick" /* npc variable name that will store the delay for this match */
maxDuration: 30 /* maximum duration in minutes, if reached game ends and highest score wins (or calls a draw if scores are equal) */
+ fillDuration: 20 /* time in seconds to wait for more applications when minimum has been reached */
+ pGameDuration: 20 /* time to wait for players to confirm their attendence after queueing process has finished */
},{
name: "KVM (Level 80 and up)" //must match the name in client files
event: "KvM03_BG::OnPlayerListReady"
@@ -66,6 +70,8 @@ battlegrounds: (
minTeamPlayers: 5 /* minimum amount of team members required for a team (party or guild) to join */
delay_var: "KVM_BG_Tick" /* npc variable name that will store the delay for this match */
maxDuration: 30 /* maximum duration in minutes, if reached game ends and highest score wins (or calls a draw if scores are equal) */
+ fillDuration: 20 /* time in seconds to wait for more applications when minimum has been reached */
+ pGameDuration: 20 /* time to wait for players to confirm their attendence after queueing process has finished */
},{
name: "KVM (Level 60~79)" //must match the name in client files
event: "KvM03_BG::OnPlayerListReady"
@@ -81,6 +87,8 @@ battlegrounds: (
minTeamPlayers: 5 /* minimum amount of team members required for a team (party or guild) to join */
delay_var: "KVM_BG_Tick" /* npc variable name that will store the delay for this match */
maxDuration: 30 /* maximum duration in minutes, if reached game ends and highest score wins (or calls a draw if scores are equal) */
+ fillDuration: 20 /* time in seconds to wait for more applications when minimum has been reached */
+ pGameDuration: 20 /* time to wait for players to confirm their attendence after queueing process has finished */
},{
name: "KVM (Level 59 and below)" //must match the name in client files
event: "KvM03_BG::OnPlayerListReady"
@@ -96,6 +104,8 @@ battlegrounds: (
minTeamPlayers: 5 /* minimum amount of team members required for a team (party or guild) to join */
delay_var: "KVM_BG_Tick" /* npc variable name that will store the delay for this match */
maxDuration: 30 /* maximum duration in minutes, if reached game ends and highest score wins (or calls a draw if scores are equal) */
+ fillDuration: 20 /* time in seconds to wait for more applications when minimum has been reached */
+ pGameDuration: 20 /* time to wait for players to confirm their attendence after queueing process has finished */
}
)
}) \ No newline at end of file
diff --git a/db/const.txt b/db/const.txt
index b048dfd86..e16b1aa52 100644
--- a/db/const.txt
+++ b/db/const.txt
@@ -3159,3 +3159,7 @@ IT_PETARMOR 8
IT_AMMO 10
IT_DELAYCONSUME 11
IT_CASH 18
+
+HQO_OnDeath 0
+HQO_OnLogout 1
+HQO_OnMapChange 2 \ No newline at end of file
diff --git a/npc/custom/bgqueue/flavius.txt b/npc/custom/bgqueue/flavius.txt
new file mode 100644
index 000000000..a1606b344
--- /dev/null
+++ b/npc/custom/bgqueue/flavius.txt
@@ -0,0 +1,726 @@
+//===== Hercules Script ======================================
+// BattleGround System - Flavius
+//===== By: ==================================================
+//= L0ne_W0lf
+//===== Current Version: =====================================
+//= 1.4
+//===== Description: =========================================
+//= [AEGIS Conversion]
+//= Flavius Battleground.
+//= - Winning Team: 9 badges
+//= - Losing Team: 3 badge
+//===== Additional Comments: =================================
+//= 1.0 First Version.
+//= 1.1 Fixed pink crystal spawning as blue. [L0ne_W0lf]
+//= 1.2 Updated 'waitingroom' to support required zeny/lvl. [Kisuka]
+//= 1.3 Removed MaxLvl check in waitingrooms. Replaced setwall with setcell.
+//= 1.4 Attempt at implementing BG Queue [Ind/Hercules]
+//============================================================
+
+
+//Tacham, while the script is under testings the original will remain, meaning if you wanna test this you need to disable the other, or they'll conflict.
+bat_b01,15,15,3 script start#bat_b01 844,{
+OnInit:
+ mapwarp "bat_b01","bat_room",154,150;
+ end;
+
+//$@bg_queue_id is cleared after this event ends
+OnPlayerListReady:
+ set $@FlaviusBG1_id1, bg_create_team("bat_b01",10,290);
+ set $@FlaviusBG1_id2, bg_create_team("bat_b01",390,10);
+
+ set $@Croix_QueueBG1, queue();
+ set $@Guill_QueueBG1, queue();
+
+ queueopt($@Guill_QueueBG1,HQO_OnLogout,"start#bat_b01::OnGuillaumeQuit");
+ queueopt($@Croix_QueueBG1,HQO_OnLogout,"start#bat_b01::OnCroixQuit");
+
+ set .@it,queueiterator($@bg_queue_id);
+ set .@i, 0;
+
+ for( set .@member, qiget(.@it); qicheck(.@it); set .@member,qiget(.@it) ) {
+ announce "bg_queue:running_for:"+.@member,8;
+ if( .@i % 2 == 0 ) {
+ bg_join_team($@FlaviusBG1_id1,.@member);
+ queueadd($@Guill_QueueBG1,.@member);
+ } else {
+ bg_join_team($@FlaviusBG1_id2,.@member);
+ queueadd($@Croix_QueueBG1,.@member);
+ }
+ set .@i,.@i + 1;
+ }
+ qiclear(.@it);
+
+ set $@FlaviusBG1, 1;
+ set $@FlaviusBG1_Victory, 0;
+ set $@Croix_ScoreBG1, 0;
+ set $@Guill_ScoreBG1, 0;
+
+ bg_updatescore "bat_b01",$@Guill_ScoreBG1,$@Croix_ScoreBG1;
+
+ donpcevent "OBJ#bat_b01_a::Onkill";
+ donpcevent "OBJ#bat_b01_a::OnEnable";
+ donpcevent "OBJ#bat_b01_b::Onkill";
+ donpcevent "OBJ#bat_b01_b::OnEnable";
+ donpcevent "guardian#bat_b01_a::Onkill";
+ donpcevent "guardian#bat_b01_b::Onkill";
+ donpcevent "guardian#bat_b01_a::OnEnable";
+ donpcevent "guardian#bat_b01_b::OnEnable";
+ donpcevent "cell#bat_b01_a::Onred";
+ donpcevent "cell#bat_b01_b::Onred";
+ donpcevent "time#bat_b01::OnEnable";
+ disablenpc "Guillaume Vintenar#b01_a";
+ disablenpc "Croix Vintenar#b01_b";
+ disablenpc "Vintenar#bat_b01_aover";
+ disablenpc "Vintenar#bat_b01_bover";
+ bg_warp $@FlaviusBG1_id1,"bat_b01",87,75;
+ bg_warp $@FlaviusBG1_id2,"bat_b01",311,224;
+ donpcevent "countdown#bat_b01::OnEnable";
+ initnpctimer;
+ end;
+
+OnReset:
+ donpcevent "OBJ#bat_b01_a::Onkill";
+ donpcevent "OBJ#bat_b01_a::OnEnable";
+ donpcevent "OBJ#bat_b01_b::Onkill";
+ donpcevent "OBJ#bat_b01_b::OnEnable";
+ donpcevent "guardian#bat_b01_a::Onkill";
+ donpcevent "guardian#bat_b01_b::Onkill";
+ donpcevent "guardian#bat_b01_a::OnEnable";
+ donpcevent "guardian#bat_b01_b::OnEnable";
+ donpcevent "cell#bat_b01_a::Onred";
+ donpcevent "cell#bat_b01_b::Onred";
+ donpcevent "time#bat_b01::OnEnable";
+ disablenpc "Guillaume Vintenar#b01_a";
+ disablenpc "Croix Vintenar#b01_b";
+ disablenpc "Vintenar#bat_b01_aover";
+ disablenpc "Vintenar#bat_b01_bover";
+ bg_warp $@FlaviusBG1_id1,"bat_b01",87,75;
+ bg_warp $@FlaviusBG1_id2,"bat_b01",311,224;
+ end;
+
+OnGuillaumeQuit:
+OnCroixQuit:
+ bg_leave;
+ end;
+
+OnTimer10000:
+ stopnpctimer;
+ donpcevent "#bat_b01_timer::OnEnable";
+ end;
+
+OnMatchOver:
+ bg_match_over("Flavius");
+ queuedel($@Croix_QueueBG1);
+ queuedel($@Guill_QueueBG1);
+ end;
+}
+
+bat_b01,1,1,3 script OBJ#bat_b01_a 844,{
+OnEnable:
+ bg_monster $@FlaviusBG1_id1,"bat_b01",61,150,"Pink Crystal",1915,"OBJ#bat_b01_a::OnMyMobDead";
+ end;
+
+Onkill:
+ killmonster "bat_b01","OBJ#bat_b01_a::OnMyMobDead";
+ end;
+
+OnMyMobDead:
+ if (mobcount("bat_b01","OBJ#bat_b01_a::OnMyMobDead") < 1) {
+ mapannounce "bat_b01", "Guillaume's Crystal has been destroyed.",bc_map,"0xFFCE00";
+ if ($@Croix_ScoreBG1 > 0) {
+ set $@FlaviusBG1_Victory,2;
+ set $@Croix_ScoreBG1,$@Croix_ScoreBG1+1;
+ enablenpc "Guillaume Vintenar#b01_a";
+ enablenpc "Croix Vintenar#b01_b";
+ donpcevent "time#bat_b01::Onstop";
+ donpcevent "start#bat_b01::OnMatchOver";
+ }
+ else {
+ set $@Croix_ScoreBG1,1;
+ donpcevent "time#bat_b01::OnEnable";
+ donpcevent "start#bat_b01::onReset";
+ }
+ donpcevent "#bat_b01_timer::OnStop";
+ bg_updatescore "bat_b01",$@Guill_ScoreBG1,$@Croix_ScoreBG1;
+ bg_warp $@FlaviusBG1_id1,"bat_b01",10,290;
+ bg_warp $@FlaviusBG1_id2,"bat_b01",390,10;
+ donpcevent "#bat_b01_timer::OnEnable";
+ }
+ end;
+}
+bat_room,2,151,3 script #bat_b01_timer 844,{
+ end;
+
+OnEnable:
+ initnpctimer;
+ end;
+
+OnStop:
+ stopnpctimer;
+ end;
+
+OnTimer1000:
+ stopnpctimer;
+ initnpctimer;
+ set .@chk_bat_a01,getmapusers("bat_b01");
+ if (.@chk_bat_a01 < 1) {
+ announce "bg_destroy:running_for:"+.@chk_bat_a01,8;
+
+ set $@FlaviusBG1, 0;
+ if( $@FlaviusBG1_id1 ) { bg_destroy $@FlaviusBG1_id1; set $@FlaviusBG1_id1, 0; }
+ if( $@FlaviusBG1_id2 ) { bg_destroy $@FlaviusBG1_id2; set $@FlaviusBG1_id2, 0; }
+ }
+ end;
+}
+
+bat_b01,1,2,3 script OBJ#bat_b01_b 844,{
+OnEnable:
+ bg_monster $@FlaviusBG1_id2,"bat_b01",328,150,"Blue Crystal",1914,"OBJ#bat_b01_b::OnMyMobDead";
+ end;
+
+Onkill:
+ killmonster "bat_b01","OBJ#bat_b01_b::OnMyMobDead";
+ end;
+
+OnMyMobDead:
+ if (mobcount("bat_b01","OBJ#bat_b01_b::OnMyMobDead") < 1) {
+ mapannounce "bat_b01", "Croix's Crystal has been destroyed.",bc_map,"0xFFCE00";
+ if ($@Guill_ScoreBG1 > 0) {
+ set $@FlaviusBG1_Victory,1;
+ set $@Guill_ScoreBG1,$@Guill_ScoreBG1+1;
+ enablenpc "Guillaume Vintenar#b01_a";
+ enablenpc "Croix Vintenar#b01_b";
+ donpcevent "time#bat_b01::Onstop";
+ donpcevent "start#bat_b01::OnMatchOver";
+ }
+ else {
+ set $@Guill_ScoreBG1,1;
+ donpcevent "time#bat_b01::OnEnable";
+ donpcevent "start#bat_b01::onReset";
+ }
+ donpcevent "#bat_b01_timer::OnStop";
+ bg_updatescore "bat_b01",$@Guill_ScoreBG1,$@Croix_ScoreBG1;
+ bg_warp $@FlaviusBG1_id1,"bat_b01",10,290;
+ bg_warp $@FlaviusBG1_id2,"bat_b01",390,10;
+ donpcevent "#bat_b01_timer::OnEnable";
+ }
+ end;
+}
+
+bat_b01,1,3,3 script guardian#bat_b01_a 844,{
+OnEnable:
+ bg_monster $@FlaviusBG1_id1,"bat_b01",108,159,"Guillaume Camp Guardian",1949,"guardian#bat_b01_a::OnMyMobDead";
+ bg_monster $@FlaviusBG1_id1,"bat_b01",108,141,"Guillaume Camp Guardian",1949,"guardian#bat_b01_a::OnMyMobDead";
+ end;
+
+Onkill:
+ killmonster "bat_b01","guardian#bat_b01_a::OnMyMobDead";
+ end;
+
+OnMyMobDead:
+ if (mobcount("bat_b01","guardian#bat_b01_a::OnMyMobDead") < 1) {
+ donpcevent "cell#bat_b01_a::Ongreen";
+ mapannounce "bat_b01", "The Guardian protecting Guillaume's Crystal has been slain.",bc_map,"0xFFCE00";
+ }
+ end;
+}
+
+bat_b01,1,3,3 script guardian#bat_b01_b 844,{
+OnEnable:
+ bg_monster $@FlaviusBG1_id2,"bat_b01",307,160,"Croix Camp Guardian",1949,"guardian#bat_b01_b::OnMyMobDead";
+ bg_monster $@FlaviusBG1_id2,"bat_b01",307,138,"Croix Camp Guardian",1949,"guardian#bat_b01_b::OnMyMobDead";
+ end;
+
+Onkill:
+ killmonster "bat_b01","guardian#bat_b01_b::OnMyMobDead";
+ end;
+
+OnMyMobDead:
+ if (mobcount("bat_b01","guardian#bat_b01_b::OnMyMobDead") < 1) {
+ donpcevent "cell#bat_b01_b::Ongreen";
+ mapannounce "bat_b01", "The Guardian protecting Croix's Crystal has been slain.",bc_map,"0xFFCE00";
+ }
+ end;
+}
+
+bat_b01,1,4,3 script cell#bat_b01_a 844,{
+Onred:
+ setcell "bat_b01",62,149,60,151,cell_basilica,1;
+ setcell "bat_b01",62,149,60,151,cell_walkable,0;
+ end;
+
+Ongreen:
+ setcell "bat_b01",62,149,60,151,cell_basilica,0;
+ setcell "bat_b01",62,149,60,151,cell_walkable,1;
+ end;
+}
+
+bat_b01,1,5,3 script cell#bat_b01_b 844,{
+Onred:
+ setcell "bat_b01",327,151,329,149,cell_basilica,1;
+ setcell "bat_b01",327,151,329,149,cell_walkable,0;
+ end;
+
+Ongreen:
+ setcell "bat_b01",327,151,329,149,cell_basilica,0;
+ setcell "bat_b01",327,151,329,149,cell_walkable,1;
+ end;
+}
+
+bat_b01,1,6,1 script time#bat_b01 844,{
+OnEnable:
+ donpcevent "Battle Therapist#b01_a::OnEnable";
+ donpcevent "Battle Therapist#b01_b::OnEnable";
+ end;
+
+Onstop:
+ donpcevent "Battle Therapist#b01_a::OnStop";
+ donpcevent "Battle Therapist#b01_b::OnStop";
+ end;
+}
+
+bat_b01,10,294,3 script Battle Therapist#b01_a 95,{
+ specialeffect2 EF_HEAL;
+ mes "[Battle Therapist]";
+ mes "Just close your eyes,";
+ mes "and take a deep breath.";
+ mes "You can be free from pain.";
+ close;
+
+OnTimer25000:
+ specialeffect EF_SANCTUARY;
+ enablenpc "bat_b01_rp1_a_warp";
+ end;
+
+OnTimer26000:
+ disablenpc "bat_b01_rp1_a_warp";
+ end;
+
+OnTimer26500:
+ stopnpctimer;
+ donpcevent "Battle Therapist#b01_a::onEnable";
+ end;
+
+OnEnable:
+ initnpctimer;
+ enablenpc "Battle Therapist#b01_a";
+ end;
+
+Onstop:
+ disablenpc "bat_b01_rp1_a_warp";
+ disablenpc "Battle Therapist#b01_a";
+ stopnpctimer;
+ end;
+}
+
+bat_b01,10,290,0 script bat_b01_rp1_a_warp 45,10,10,{
+OnInit:
+ disablenpc "bat_b01_rp1_a_warp";
+ end;
+
+OnTouch:
+ percentheal 100,100;
+ warp "bat_b01",87,73;
+ end;
+}
+
+bat_b01,389,14,3 script Battle Therapist#b01_b 95,{
+ specialeffect2 EF_HEAL;
+ mes "[Battle Therapist]";
+ mes "Just close your eyes,";
+ mes "and take a deep breath.";
+ mes "You can be free from pain.";
+ close;
+
+OnTimer25000:
+ specialeffect EF_SANCTUARY;
+ enablenpc "bat_b01_rp1_b_warp";
+ end;
+
+OnTimer26000:
+ disablenpc "bat_b01_rp1_b_warp";
+ end;
+
+OnTimer26500:
+ stopnpctimer;
+ donpcevent "Battle Therapist#b01_b::OnEnable";
+ end;
+
+OnEnable:
+ initnpctimer;
+ enablenpc "Battle Therapist#b01_b";
+ end;
+
+Onstop:
+ disablenpc "bat_b01_rp1_b_warp";
+ disablenpc "Battle Therapist#b01_b";
+ stopnpctimer;
+ end;
+}
+
+bat_b01,389,10,0 script bat_b01_rp1_b_warp 45,9,9,{
+OnInit:
+ disablenpc "bat_b01_rp1_a_warp";
+ end;
+
+OnTouch:
+ percentheal 100,100;
+ warp "bat_b01",312,225;
+ end;
+}
+
+bat_b01,87,76,0 script A_CODE#bat_b01 -1,5,5,{
+OnTouch:
+ if (checkquest(2070) < 0)
+ setquest 2070;
+ end;
+}
+
+bat_b01,312,224,0 script B_CODE#bat_b01 -1,5,5,{
+OnTouch:
+ if (checkquest(2070) < 0)
+ setquest 2070;
+ end;
+}
+
+bat_b01,10,294,3 script Guillaume Vintenar#b01_a 934,{
+ if ($@FlaviusBG1_id1 == getcharid(4)) {
+ if ($@FlaviusBG1_Victory == 1) {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 8) {
+ mes "[Axl Rose]";
+ mes "Blessed Guillaume!";
+ mes "Let's enjoy our glorious victory!";
+ mes ""+strcharinfo(0)+", it's a sign reflecting victory.";
+ close2;
+ getitem 7829,9; //BF_Badge2
+ }
+ else {
+ mes "[Axl Rose]";
+ mes "Blessed Guillaume!";
+ mes "Let's enjoy our glorious victory!";
+ mes ""+strcharinfo(0)+", it's a sign reflecting victory.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ else {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 2) {
+ mes "[Axl Rose]";
+ mes "You lost, but you're dedicated to this battle.";
+ mes "This is a reward for your great dedication by Guillaume Marollo!";
+ mes "Just take this defeat as a lesson, next time you will definitely win.";
+ close2;
+ getitem 7829,3; //BF_Badge2
+ }
+ else {
+ mes "[Axl Rose]";
+ mes "You lost, but you're dedicated to this battle.";
+ mes "This is a reward for your great dedication by Guillaume Marollo!";
+ mes "Just take this defeat as a lesson, next time you will definitely win.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ }
+ bg_leave;
+ warp "bat_room",154,150;
+ end;
+
+OnInit:
+ disablenpc "Guillaume Vintenar#b01_a";
+ end;
+}
+
+bat_b01,389,14,3 script Croix Vintenar#b01_b 934,{
+ if ($@FlaviusBG1_id2 == getcharid(4)) {
+ if ($@FlaviusBG1_Victory == 2) {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 8) {
+ mes "[Swandery]";
+ mes "Blessed Croix!";
+ mes "Let's enjoy our glorious victory!";
+ mes ""+strcharinfo(0)+", it's a sign reflecting victory.";
+ close2;
+ getitem 7829,9; //BF_Badge2
+ }
+ else {
+ mes "[Swandery]";
+ mes "Blessed Croix!";
+ mes "Let's enjoy our glorious victory!";
+ mes ""+strcharinfo(0)+", it's a sign reflecting victory.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ else {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 2) {
+ mes "[Swandery]";
+ mes "Oh, "+strcharinfo(0)+". Don't be sad.";
+ mes "Even though we didn't win, we did our best.";
+ mes "This is a Royal gift from Croix, and please don't forget this battle. We will win the next one.";
+ close2;
+ getitem 7829,3; //BF_Badge2
+ }
+ else {
+ mes "[Swandery]";
+ mes "Oh, "+strcharinfo(0)+". Don't be sad.";
+ mes "Even though we didn't win, we did our best.";
+ mes "This is a Royal gift from Croix, and please don't forget this battle. We will win the next one.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ }
+ bg_leave;
+ warp "bat_room",154,150;
+ end;
+
+OnInit:
+ disablenpc "Croix Vintenar#b01_b";
+ end;
+}
+
+bat_b01,1,5,3 script countdown#bat_b01 844,{
+OnInit:
+ stopnpctimer;
+ end;
+
+OnEnable:
+ stopnpctimer;
+ initnpctimer;
+ end;
+
+Onstop:
+ stopnpctimer;
+ end;
+
+OnTimer7000:
+ mapannounce "bat_b01", "Guillaume Vintenar Axl Rose : Let's attack to destroy that Crystal!",bc_map,"0xFF9900";
+ end;
+
+OnTimer8000:
+ mapannounce "bat_b01", "Croix Vintenar Swandery : Even though Guillaume is struggling to win against us, the victory is ours. Let's show them our power.",bc_map,"0xFF99CC";
+ end;
+
+OnTimer1800000:
+ mapannounce "bat_b01", "Marollo VII : Guillaume Marollo, Croix Marollo! And their followers!",bc_map,"0x99CC00";
+ end;
+
+OnTimer1803000:
+ mapannounce "bat_b01", "Marollo VII : Both camps are competitive, so it's hard to judge which team is superior.",bc_map,"0x99CC00";
+ end;
+
+OnTimer1808000:
+ mapannounce "bat_b01", "Marollo VII : This battle of Flavian is such a waste of time. I will decide victory and defeat by your progress.",bc_map,"0x99CC00";
+ end;
+
+OnTimer1822000:
+ mapannounce "bat_b01", "Marollo VII : If you can't accept the results, try again in another valley battle!",bc_map,"0x99CC00";
+ end;
+
+OnTimer1825000:
+ mapannounce "bat_b01", "Axl Rose, Swandery : Yes, sir.",bc_map,"0x99CC00";
+ end;
+
+OnTimer1830000:
+ donpcevent "time#bat_b01::Onstop";
+ bg_warp $@FlaviusBG1_id1,"bat_b01",10,290;
+ bg_warp $@FlaviusBG1_id2,"bat_b01",390,10;
+ enablenpc "Vintenar#bat_b01_aover";
+ enablenpc "Vintenar#bat_b01_bover";
+ end;
+
+OnTimer1900000:
+ mapwarp "bat_b01","bat_room",154,150;
+ donpcevent "countdown#bat_b01::Onstop";
+ donpcevent "start#bat_b01::OnMatchOver";
+ end;
+}
+
+bat_b01,81,83,3 script Guillaume Camp#flag21 973,{ end; }
+bat_b01,94,83,3 script Guillaume Camp#flag22 973,{ end; }
+bat_b01,81,66,3 script Guillaume Camp#flag23 973,{ end; }
+bat_b01,94,66,3 script Guillaume Camp#flag24 973,{ end; }
+bat_b01,139,142,3 script Guillaume Camp#flag25 973,{ end; }
+bat_b01,139,158,3 script Guillaume Camp#flag26 973,{ end; }
+bat_b01,110,161,3 script Guillaume Camp#flag27 973,{ end; }
+bat_b01,110,137,3 script Guillaume Camp#flag28 973,{ end; }
+bat_b01,63,135,3 script Guillaume Camp#flag29 973,{ end; }
+bat_b01,63,165,3 script Guillaume Camp#flag30 973,{ end; }
+bat_b01,10,296,3 script Guillaume Camp#flag31 973,{ end; }
+
+bat_b01,306,233,3 script Croix Camp#flag21 974,{ end; }
+bat_b01,317,233,3 script Croix Camp#flag22 974,{ end; }
+bat_b01,306,216,3 script Croix Camp#flag23 974,{ end; }
+bat_b01,317,216,3 script Croix Camp#flag24 974,{ end; }
+bat_b01,257,158,3 script Croix Camp#flag25 974,{ end; }
+bat_b01,257,141,3 script Croix Camp#flag26 974,{ end; }
+bat_b01,297,164,3 script Croix Camp#flag27 974,{ end; }
+bat_b01,297,136,3 script Croix Camp#flag28 974,{ end; }
+bat_b01,336,161,3 script Croix Camp#flag29 974,{ end; }
+bat_b01,336,139,3 script Croix Camp#flag30 974,{ end; }
+bat_b01,389,16,3 script Croix Camp#flag31 974,{ end; }
+
+bat_b01,10,294,3 script Vintenar#bat_b01_aover 419,{
+ set .@A_B_gap,$@Guill_ScoreBG1 - $@Croix_ScoreBG1;
+ if ($@FlaviusBG1_id1 == getcharid(4)) {
+ if (.@A_B_gap > 0) {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 8) {
+ mes "[Axl Rose]";
+ mes "Blessed Guillaume!";
+ mes "Let's enjoy our glorious victory!";
+ mes ""+strcharinfo(0)+", it's a sign reflecting victory.";
+ close2;
+ getitem 7829,9; //BF_Badge2
+ }
+ else {
+ mes "[Axl Rose]";
+ mes "Blessed Guillaume!";
+ mes "Let's enjoy our glorious victory!";
+ mes ""+strcharinfo(0)+", it's a sign reflecting victory.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ else if (.@A_B_gap == 0) {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 2) {
+ mes "[Axl Rose]";
+ mes "You lost, but you're dedicated to this battle.";
+ mes "This is a reward for your great dedication by Guillaume Marollo!";
+ mes "Just take this defeat as a lesson, next time you will definitely win.";
+ close2;
+ getitem 7829,3; //BF_Badge2
+ }
+ else {
+ mes "[Axl Rose]";
+ mes "You lost, but you're dedicated to this battle.";
+ mes "This is a reward for your great dedication by Guillaume Marollo!";
+ mes "Just take this defeat as a lesson, next time you will definitely win.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ else {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 2) {
+ mes "[Axl Rose]";
+ mes "You lost, but you're dedicated to this battle.";
+ mes "This is a reward for your great dedication by Guillaume Marollo!";
+ mes "Just take this defeat as a lesson, next time you will definitely win.";
+ close2;
+ getitem 7829,3; //BF_Badge2
+ }
+ else {
+ mes "[Axl Rose]";
+ mes "You lost, but you're dedicated to this battle.";
+ mes "This is a reward for your great dedication by Guillaume Marollo!";
+ mes "Just take this defeat as a lesson, next time you will definitely win.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ }
+ else {
+ mes "[Axl Rose]";
+ mes "Why are you here, Croix mercenary? I am definitely sure of victory against foolish Croix such as you. Ha!";
+ close;
+ }
+ bg_leave;
+ warp "bat_room",154,150;
+ end;
+
+OnInit:
+ disablenpc "Vintenar#bat_b01_aover";
+ end;
+}
+
+bat_b01,389,14,3 script Vintenar#bat_b01_bover 415,{
+ set .@A_B_gap,$@Guill_ScoreBG1 - $@Croix_ScoreBG1;
+ if ($@FlaviusBG1_id2 == getcharid(4)) {
+ if (.@A_B_gap > 0) {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 2) {
+ mes "[Swandery]";
+ mes "Oh, "+strcharinfo(0)+". Don't be sad.";
+ mes "Even though we didn't win, we did our best.";
+ mes "This is a Royal gift from Croix, and please don't forget this battle. We will win the next one.";
+ close2;
+ getitem 7829,3; //BF_Badge2
+ }
+ else {
+ mes "[Swandery]";
+ mes "Oh, "+strcharinfo(0)+". Don't be sad.";
+ mes "Even though we didn't win, we did our best.";
+ mes "This is a Royal gift from Croix, and please don't forget this battle. We will win the next one.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ else if (.@A_B_gap == 0) {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 2) {
+ mes "[Swandery]";
+ mes "Oh, "+strcharinfo(0)+". Don't be sad.";
+ mes "Even though we didn't win, we did our best.";
+ mes "This is a Royal gift from Croix, and please don't forget this battle. We will win the next one.";
+ close2;
+ getitem 7829,3; //BF_Badge2
+ }
+ else {
+ mes "[Swandery]";
+ mes "Oh, "+strcharinfo(0)+". Don't be sad.";
+ mes "Even though we didn't win, we did our best.";
+ mes "This is a Royal gift from Croix, and please don't forget this battle. We will win the next one.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ else {
+ set .@your_medal,countitem(7829);
+ set .@medal_gap,500 - .@your_medal;
+ if (.@medal_gap > 8) {
+ mes "[Swandery]";
+ mes "Blessed Croix!";
+ mes "Let's enjoy our glorious victory!";
+ mes ""+strcharinfo(0)+", it's a sign reflecting victory.";
+ close2;
+ getitem 7829,9; //BF_Badge2
+ }
+ else {
+ mes "[Swandery]";
+ mes "Blessed Croix!";
+ mes "Let's enjoy our glorious victory!";
+ mes ""+strcharinfo(0)+", it's a sign reflecting victory.";
+ close2;
+ getitem 7829,.@medal_gap; //BF_Badge2
+ }
+ }
+ }
+ else {
+ mes "[Swandery]";
+ mes "Why do you come here as a Guillaume? You will be sent to where you should be!";
+ close;
+ }
+ bg_leave;
+ warp "bat_room",154,150;
+ end;
+
+OnInit:
+ disablenpc "Vintenar#bat_b01_bover";
+ end;
+}
diff --git a/src/common/socket.h b/src/common/socket.h
index b58cbdccf..82f8b84c3 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -50,7 +50,7 @@
} while(0)
/* [Ind/Hercules] */
-#define RFIFO2PTR(fd,len) (void*)(session[fd]->rdata + len)
+#define RFIFO2PTR(fd) (void*)(session[fd]->rdata + session[fd]->rdata_pos)
// buffer I/O macros
#define RBUFP(p,pos) (((uint8*)(p)) + (pos))
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 88cc323bf..d54178347 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -21,6 +21,7 @@
#include "pet.h"
#include "homunculus.h"
#include "mercenary.h"
+#include "mapreg.h"
#include <string.h>
#include <stdio.h>
@@ -264,7 +265,7 @@ void bg_config_read(void) {
config_setting_lookup_int(settings, "maximum_afk_seconds", &bg->mafksec);
config_setting_lookup_bool(settings, "feature_off", &offline);
-
+
if( offline == 0 )
bg->queue_on = true;
@@ -279,7 +280,7 @@ void bg_config_read(void) {
int prizeWin, prizeLoss, prizeDraw;
int minPlayers, maxPlayers, minTeamPlayers;
int maxDuration;
- int fillup_duration, pregame_duration;
+ int fillup_duration = 0, pregame_duration = 0;
bg->arena[i] = NULL;
@@ -305,7 +306,7 @@ void bg_config_read(void) {
maxLevel = MAX_LEVEL;
}
- if( !(reward = config_setting_get_member(settings, "reward")) ) {
+ if( !(reward = config_setting_get_member(arena, "reward")) ) {
ShowError("bg_config_read: failed to find 'reward' for arena '%s'/#%d\n",aName,i);
continue;
}
@@ -385,7 +386,7 @@ void bg_config_read(void) {
bg->arena[i]->min_team_players = minTeamPlayers;
safestrncpy(bg->arena[i]->delay_var, aDelayVar, NAME_LENGTH);
bg->arena[i]->maxDuration = maxDuration;
- bg->arena[i]->queue_id = -1;
+ bg->arena[i]->queue_id = script->queue_create();
bg->arena[i]->begin_timer = INVALID_TIMER;
bg->arena[i]->fillup_timer = INVALID_TIMER;
bg->arena[i]->pregame_duration = pregame_duration;
@@ -425,17 +426,35 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo
bg->queue_pc_cleanup(sd);
return;
}
- if( response ) {
+ if( !response )
+ bg->queue_pc_cleanup(sd);
+ else {
+ struct hQueue *queue = &script->hq[arena->queue_id];
+ int i, count = 0;
sd->bg_queue.ready = 1;
+
+ for( i = 0; i < queue->items; i++ ) {
+ if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
+ if( sd->bg_queue.ready == 1 )
+ count++;
+ }
+ }
/* check if all are ready then cancell timer, and start game */
- } else
- bg->queue_pc_cleanup(sd);
+ if( count == i ) {
+ iTimer->delete_timer(arena->begin_timer,bg->begin_timer);
+ arena->begin_timer = INVALID_TIMER;
+ bg->begin(arena);
+ }
+
+ }
+
}
void bg_queue_player_cleanup(struct map_session_data *sd) {
if ( sd->bg_queue.client_has_bg_data ) {
clif->bgqueue_notice_delete(sd,BGQND_CLOSEWINDOW, sd->bg_queue.arena ? sd->bg_queue.arena->id : 0);
}
- script->queue_remove(sd->bg_queue.arena->queue_id,sd->status.account_id);
+ if( sd->bg_queue.arena )
+ script->queue_remove(sd->bg_queue.arena->queue_id,sd->status.account_id);
sd->bg_queue.arena = NULL;
sd->bg_queue.ready = 0;
sd->bg_queue.client_has_bg_data = 0;
@@ -443,27 +462,27 @@ void bg_queue_player_cleanup(struct map_session_data *sd) {
}
void bg_match_over(struct bg_arena *arena, bool canceled) {
struct hQueue *queue = &script->hq[arena->queue_id];
- int i;//, count = 0;
-
- /* if( !canceled ) <check time/score> */
+ int i;
for( i = 0; i < queue->items; i++ ) {
struct map_session_data * sd = NULL;
if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
bg->queue_pc_cleanup(sd);
- clif->colormes(sd->fd,COLOR_RED,"BG Match Cancelled: not enough players");
+ if( canceled )
+ clif->colormes(sd->fd,COLOR_RED,"BG Match Cancelled: not enough players");
}
}
bg->arena[i]->begin_timer = INVALID_TIMER;
bg->arena[i]->fillup_timer = INVALID_TIMER;
/* reset queue */
+ script->queue_clear(arena->queue_id);
}
void bg_begin(struct bg_arena *arena) {
struct hQueue *queue = &script->hq[arena->queue_id];
int i, count = 0;
-
+
for( i = 0; i < queue->items; i++ ) {
struct map_session_data * sd = NULL;
@@ -476,12 +495,14 @@ void bg_begin(struct bg_arena *arena) {
}
if( count < arena->min_players ) {
- bg_match_over(arena,true);
+ bg->match_over(arena,true);
} else {
- ;
+ mapreg_setreg(add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */
+ npc_event_do(arena->npc_event);
/* we split evenly? */
/* but if a party of say 10 joins, it cant be split evenly unless by luck there are 10 soloers in the queue besides them */
/* not sure how to split T_T needs more info */
+ /* currently running only on solo mode so we do it evenly */
}
}
int bg_begin_timer(int tid, unsigned int tick, int id, intptr_t data) {
@@ -599,11 +620,12 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q
clif->bgqueue_ack(sd,BGQA_SUCCESS,arena->id);
+ bg->queue_check(arena);
}
enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) {
int tick;
unsigned int tsec;
- if ( sd->status.base_level > arena->max_level || sd->status.base_level < arena->max_level )
+ if ( sd->status.base_level > arena->max_level || sd->status.base_level < arena->min_level )
return BGQA_FAIL_LEVEL_INCORRECT;
if ( !(sd->class_&JOBL_2) ) /* TODO: maybe make this a per-arena setting, so users may make custom arenas like baby-only,whatever. */
@@ -633,6 +655,11 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
if( sd->bg_queue.arena != NULL )
return BGQA_DUPLICATE_REQUEST;
+
+ if( type != BGQT_INDIVIDUAL ) {/* until we get the damn balancing correct */
+ clif->colormes(sd->fd,COLOR_RED,"Queueing is only currently enabled only for Solo Mode");
+ return BGQA_FAIL_TEAM_COUNT;
+ }
switch(type) {
case BGQT_GUILD:
@@ -704,6 +731,7 @@ void do_init_battleground(void) {
bg_team_db = idb_alloc(DB_OPT_RELEASE_DATA);
iTimer->add_timer_func_list(bg_send_xy_timer, "bg_send_xy_timer");
iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg_send_xy_timer, 0, 0, battle_config.bg_update_interval);
+ bg->config_read();
}
void do_final_battleground(void) {
@@ -738,6 +766,8 @@ void battleground_defaults(void) {
bg->queue_pregame = bg_queue_pregame;
bg->fillup_timer = bg_fillup_timer;
bg->queue_ready_ack = bg_queue_ready_ack;
+ bg->match_over = bg_match_over;
+ bg->queue_check = bg_queue_check;
/* */
bg->config_read = bg_config_read;
}
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 030d13d90..f76d84d0c 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -97,6 +97,8 @@ struct battleground_interface {
void (*queue_pregame) (struct bg_arena *arena);
int (*fillup_timer) (int tid, unsigned int tick, int id, intptr_t data);
void (*queue_ready_ack) (struct bg_arena *arena, struct map_session_data *sd, bool response);
+ void (*match_over) (struct bg_arena *arena, bool canceled);
+ void (*queue_check) (struct bg_arena *arena);
/* */
void (*config_read) (void);
} bg_s;
diff --git a/src/map/clif.c b/src/map/clif.c
index e5132a938..373d510ba 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -545,8 +545,24 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
}
break;
+ case BG_QUEUE:
+ if( sd && sd->bg_queue.arena ) {
+ struct hQueue *queue = &script->hq[sd->bg_queue.arena->queue_id];
+
+ for( i = 0; i < queue->items; i++ ) {
+ struct map_session_data * sd = NULL;
+
+ if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
+ WFIFOHEAD(sd->fd,len);
+ memcpy(WFIFOP(sd->fd,0), buf, len);
+ WFIFOSET(sd->fd,len);
+ }
+ }
+ }
+ break;
+
default:
- ShowError("clif->send: Unrecognized type %d\n",type);
+ ShowError("clif_send: Unrecognized type %d\n",type);
return -1;
}
@@ -17317,7 +17333,6 @@ void clif_status_change_end(struct block_list *bl, int tid, enum send_target tar
}
void clif_bgqueue_ack(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_ACK response, unsigned char arena_id) {
-
switch (response) {
case BGQA_FAIL_COOLDOWN:
case BGQA_FAIL_DESERTER:
@@ -17348,15 +17363,16 @@ void clif_bgqueue_notice_delete(struct map_session_data *sd, enum BATTLEGROUNDS_
}
void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) {
- struct packet_bgqueue_register *p = P2PTR(fd, bgqueue_registerType);
+ struct packet_bgqueue_register *p = P2PTR(fd);
struct bg_arena *arena = NULL;
-
if( !bg->queue_on ) return; /* temp, until feature is complete */
if( !(arena = bg->name2arena(p->bg_name)) ) {
clif->bgqueue_ack(sd,BGQA_FAIL_BGNAME_INVALID,0);
return;
}
+ //debug
+ safestrncpy(arena->name, p->bg_name, sizeof(arena->name));
switch( (enum bg_queue_types)p->type ) {
case BGQT_INDIVIDUAL:
@@ -17387,7 +17403,6 @@ void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd) {
//struct packet_bgqueue_checkstate *p = P2PTR(fd, bgqueue_checkstateType); /* TODO: bgqueue_notice_delete should use this p->bg_name */
if( !bg->queue_on ) return; /* temp, until feature is complete */
if ( sd->bg_queue.arena && sd->bg_queue.type ) {
- sd->bg_queue.client_has_bg_data = true;
clif->bgqueue_update_info(sd,sd->bg_queue.arena->id,bg->id2pos(sd->bg_queue.arena->queue_id,sd->status.account_id));
} else
clif->bgqueue_notice_delete(sd, BGQND_FAIL_NOT_QUEUING,0);/* TODO: wrong response, should respond with p->bg_name not id 0 */
@@ -17400,10 +17415,10 @@ void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd) {
}
void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) {
- struct packet_bgqueue_battlebegin_ack *p = P2PTR(fd, bgqueue_checkstateType);
+ struct packet_bgqueue_battlebegin_ack *p = P2PTR(fd);
struct bg_arena *arena;
if( !bg->queue_on ) return; /* temp, until feature is complete */
- if( ( arena = bg->name2arena(p->bg_name) ) ) {
+ if( ( arena = bg->name2arena(p->bg_name) ) ) {
bg->queue_ready_ack(arena,sd, ( p->result == 1 ) ? true : false);
} else {
clif->bgqueue_ack(sd,BGQA_FAIL_BGNAME_INVALID, 0);
diff --git a/src/map/clif.h b/src/map/clif.h
index bea701223..81376db15 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -43,7 +43,7 @@ struct eri;
* Defines
**/
#define packet_len(cmd) packet_db[cmd].len
-#define P2PTR(fd,cmd) RFIFO2PTR(fd,packet_db[cmd].len)
+#define P2PTR(fd) RFIFO2PTR(fd)
#define clif_menuskill_clear(sd) (sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0;
#define HCHSYS_NAME_LENGTH 20
diff --git a/src/map/map.c b/src/map/map.c
index ee56f140f..99f585a8d 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1657,7 +1657,8 @@ int map_quit(struct map_session_data *sd) {
}
/* two times, the npc event above may assign a new one or delete others */
for( i = 0; i < sd->queues_count; i++ ) {
- script->queue_remove(sd->queues[i],sd->status.account_id);
+ if( sd->queues[i] != -1 )
+ script->queue_remove(sd->queues[i],sd->status.account_id);
}
npc_script_event(sd, NPCE_LOGOUT);
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index d77784dc5..8e7506686 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -404,13 +404,13 @@ struct packet_maptypeproperty2 {
struct packet_bgqueue_ack {
short PacketType;
- short type;
+ unsigned char type;
char bg_name[NAME_LENGTH];
} __attribute__((packed));
struct packet_bgqueue_notice_delete {
short PacketType;
- short type;
+ unsigned char type;
char bg_name[NAME_LENGTH];
} __attribute__((packed));
@@ -438,7 +438,7 @@ struct packet_bgqueue_revoke_req {
struct packet_bgqueue_battlebegin_ack {
short PacketType;
- short result;
+ unsigned char result;
char bg_name[NAME_LENGTH];
char game_name[NAME_LENGTH];
} __attribute__((packed));
diff --git a/src/map/script.c b/src/map/script.c
index 5cc48c7ce..354ec0522 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -17016,9 +17016,7 @@ struct hQueue *script_hqueue_get(int idx) {
return NULL;
return &script->hq[idx];
}
-/* set .@id,queue(); */
-/* creates queue, returns created queue id */
-BUILDIN(queue) {
+int script_hqueue_create(void) {
int idx = script->hqs;
int i;
@@ -17039,8 +17037,12 @@ BUILDIN(queue) {
script->hq[ idx ].onDeath[0] = '\0';
script->hq[ idx ].onLogOut[0] = '\0';
script->hq[ idx ].onMapChange[0] = '\0';
-
- script_pushint(st,idx);
+ return idx;
+}
+/* set .@id,queue(); */
+/* creates queue, returns created queue id */
+BUILDIN(queue) {
+ script_pushint(st,script->queue_create());
return true;
}
/* set .@length,queuesize(.@queue_id); */
@@ -17135,7 +17137,7 @@ bool script_hqueue_remove(int idx, int var) {
if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) {
for(i = 0; i < sd->queues_count; i++) {
- if( sd->queues[i] == var ) {
+ if( sd->queues[i] == idx ) {
break;
}
}
@@ -17237,7 +17239,33 @@ BUILDIN(queuedel) {
return true;
}
+void script_hqueue_clear(int idx) {
+ if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
+ ShowWarning("script_hqueue_clear: unknown queue id %d\n",idx);
+ return;
+ } else {
+ struct map_session_data *sd;
+ int i, j;
+
+ for(i = 0; i < script->hq[idx].items; i++) {
+ if( script->hq[idx].item[i] != -1 ) {
+ if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = iMap->id2sd(script->hq[idx].item[i])) ) {
+ for(j = 0; j < sd->queues_count; j++) {
+ if( sd->queues[j] == idx ) {
+ break;
+ }
+ }
+
+ if( j != sd->queues_count )
+ sd->queues[j] = -1;
+ }
+ script->hq[idx].item[i] = -1;
+ }
+ }
+ }
+ return;
+}
/* set .@id, queueiterator(.@queue_id); */
/* creates a new queue iterator, returns its id */
BUILDIN(queueiterator) {
@@ -17281,7 +17309,7 @@ BUILDIN(qiget) {
if( idx < 0 || idx >= script->hqis ) {
ShowWarning("buildin_qiget: unknown queue iterator id %d\n",idx);
script_pushint(st, 0);
- } else if ( script->hqi[idx].pos == script->hqi[idx].items ) {
+ } else if ( script->hqi[idx].pos -1 == script->hqi[idx].items ) {
script_pushint(st, 0);
} else {
struct hQueueIterator *it = &script->hqi[idx];
@@ -17298,7 +17326,7 @@ BUILDIN(qicheck) {
if( idx < 0 || idx >= script->hqis ) {
ShowWarning("buildin_qicheck: unknown queue iterator id %d\n",idx);
script_pushint(st, 0);
- } else if ( script->hqi[idx].pos == script->hqi[idx].items ) {
+ } else if ( script->hqi[idx].pos -1 == script->hqi[idx].items ) {
script_pushint(st, 0);
} else {
script_pushint(st, 1);
@@ -17355,7 +17383,66 @@ BUILDIN(packageitem) {
return true;
}
+/* New Battlegrounds Stuff */
+/* bg_team_create(map_name,respawn_x,respawn_y) */
+/* returns created team id or -1 when fails */
+BUILDIN(bg_create_team) {
+ const char *map_name, *ev = "", *dev = "";//ev and dev will be dropped.
+ int x, y, mapindex = 0, bg_id;
+
+ 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 true;
+ }
+ }
+
+ x = script_getnum(st,3);
+ y = script_getnum(st,4);
+
+ if( (bg_id = bg_create(mapindex, x, y, ev, dev)) == 0 ) { // Creation failed
+ script_pushint(st,-1);
+ } else
+ script_pushint(st,bg_id);
+
+ return true;
+}
+/* bg_join_team(team_id{,optional account id}) */
+/* when account id is not present it tries to autodetect from the attached player (if any) */
+/* returns 0 when successful, 1 otherwise */
+BUILDIN(bg_join_team) {
+ struct map_session_data *sd;
+ int team_id = script_getnum(st, 2);
+
+ if( script_hasdata(st, 3) )
+ sd = iMap->id2sd(script_getnum(st, 3));
+ else
+ sd = script->rid2sd(st);
+
+ if( !sd )
+ script_pushint(st, 1);
+ else
+ script_pushint(st,bg_team_join(team_id, sd)?0:1);
+
+ return true;
+}
+/* bg_match_over( arena_name {, optional canceled } ) */
+/* returns 0 when successful, 1 otherwise */
+BUILDIN(bg_match_over) {
+ bool canceled = script_hasdata(st,3) ? true : false;
+ struct bg_arena *arena = bg->name2arena((char*)script_getstr(st, 2));
+
+ if( arena ) {
+ bg->match_over(arena,canceled);
+ script_pushint(st, 0);
+ } else
+ script_pushint(st, 1);
+
+ return true;
+}
// declarations that were supposed to be exported from npc_chat.c
#ifdef PCRE_SUPPORT
BUILDIN(defpattern);
@@ -17872,6 +17959,10 @@ void script_parse_builtin(void) {
BUILDIN_DEF(packageitem,"?"),
+ /* New BG Commands [Hercules] */
+ BUILDIN_DEF(bg_create_team,"sii"),
+ BUILDIN_DEF(bg_join_team,"i?"),
+ BUILDIN_DEF(bg_match_over,"s?"),
};
int i,n, len = ARRAYLENGTH(BUILDIN), start = script->buildin_count;
char* p;
@@ -17974,4 +18065,6 @@ void script_defaults(void) {
script->queue_add = script_hqueue_add;
script->queue_del = script_hqueue_del;
script->queue_remove = script_hqueue_remove;
+ script->queue_create = script_hqueue_create;
+ script->queue_clear = script_hqueue_clear;
}
diff --git a/src/map/script.h b/src/map/script.h
index a047779a8..a77e957c0 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -383,6 +383,8 @@ struct script_interface {
bool (*queue_add) (int idx, int var);
bool (*queue_del) (int idx);
bool (*queue_remove) (int idx, int var);
+ int (*queue_create) (void);
+ void (*queue_clear) (int idx);
} script_s;
struct script_interface *script;