summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/battlegrounds.conf12
-rw-r--r--db/const.txt6
-rw-r--r--doc/script_commands.txt2
-rw-r--r--npc/custom/bgqueue/flavius.txt58
-rw-r--r--src/map/battleground.c40
-rw-r--r--src/map/battleground.h2
6 files changed, 62 insertions, 58 deletions
diff --git a/conf/battlegrounds.conf b/conf/battlegrounds.conf
index 1c32d32ce..9412829b2 100644
--- a/conf/battlegrounds.conf
+++ b/conf/battlegrounds.conf
@@ -34,7 +34,7 @@ battlegrounds: (
minPlayers: 6 /* minimum amount of players to start */
maxPlayers: 60 /* maximum amount of players */
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 */
+ delay_var: "Tierra_BG_Tick" /* char 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 */
@@ -48,10 +48,10 @@ battlegrounds: (
loss: 3
draw: 3
}
- minPlayers: 3 /* minimum amount of players to start (DEBUG VALUE, CHANGE BACK) */
+ minPlayers: 2 /* 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 */
+ delay_var: "Flavius_BG_Tick" /* char 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 */
@@ -68,7 +68,7 @@ battlegrounds: (
minPlayers: 4 /* minimum amount of players to start */
maxPlayers: 60 /* maximum amount of players */
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 */
+ delay_var: "KVM_BG_Tick" /* char 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 */
@@ -85,7 +85,7 @@ battlegrounds: (
minPlayers: 4 /* minimum amount of players to start */
maxPlayers: 60 /* maximum amount of players */
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 */
+ delay_var: "KVM_BG_Tick" /* char 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 */
@@ -102,7 +102,7 @@ battlegrounds: (
minPlayers: 4 /* minimum amount of players to start */
maxPlayers: 60 /* maximum amount of players */
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 */
+ delay_var: "KVM_BG_Tick" /* char 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 */
diff --git a/db/const.txt b/db/const.txt
index 4a5b0f4a3..d479e79cd 100644
--- a/db/const.txt
+++ b/db/const.txt
@@ -3160,6 +3160,6 @@ IT_AMMO 10
IT_DELAYCONSUME 11
IT_CASH 18
-HQO_OnDeath 0
-HQO_OnLogout 1
-HQO_OnMapChange 2
+HQO_OnDeath 1
+HQO_OnLogout 2
+HQO_OnMapChange 3
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 2cb0a55c0..471f98d03 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -8146,7 +8146,7 @@ Modifies <queue_id>'s <optionType>. When <option val> is not present
<queue_id>'s <optionType> with the new <option val> value.
Currently 3 options are available:
-HQO_OnDeath (0), HQO_OnLogout (1), HQO_OnMapChange (2)
+HQO_OnDeath (1), HQO_OnLogout (2), HQO_OnMapChange (3)
Note: The constant names are not final.
diff --git a/npc/custom/bgqueue/flavius.txt b/npc/custom/bgqueue/flavius.txt
index ee729783f..8f195f288 100644
--- a/npc/custom/bgqueue/flavius.txt
+++ b/npc/custom/bgqueue/flavius.txt
@@ -74,8 +74,12 @@ OnPlayerListReady:
disablenpc "Vintenar#bat_b01_bover";
bg_warp $@FlaviusBG1_id1,"bat_b01",87,75;
bg_warp $@FlaviusBG1_id2,"bat_b01",311,224;
+
+ /* after warp */
+ queueopt($@Guill_QueueBG1,HQO_OnMapChange,"start#bat_b01::OnGuillaumeQuit");
+ queueopt($@Croix_QueueBG1,HQO_OnMapChange,"start#bat_b01::OnCroixQuit");
+
donpcevent "countdown#bat_b01::OnEnable";
- initnpctimer;
end;
OnReset:
@@ -98,20 +102,31 @@ OnReset:
bg_warp $@FlaviusBG1_id2,"bat_b01",311,224;
end;
-OnGuillaumeQuit:
OnCroixQuit:
- bg_leave;
+ queueremove($@Croix_QueueBG1,getcharid(3));
+ callsub L_OnPlayerQuit;
end;
-OnTimer10000:
- stopnpctimer;
- donpcevent "#bat_b01_timer::OnEnable";
+OnGuillaumeQuit:
+ queueremove($@Guill_QueueBG1,getcharid(3));
+ callsub L_OnPlayerQuit;
+ end;
+
+L_OnPlayerQuit:
+ bg_leave;
+ setd $@bg_delay_var$,gettimetick(2);
+ if( queuesize($@Guill_QueueBG1) == 0 || queuesize($@Croix_QueueBG1) == 0 ) /* todo check score and decide a winner if anyone left */
+ callsub OnMatchOver;
end;
OnMatchOver:
- bg_match_over("Flavius");
- queuedel($@Croix_QueueBG1);
- queuedel($@Guill_QueueBG1);
+ if( $@FlaviusBG1_id1 || $@FlaviusBG1_id2 ) {
+ bg_match_over("Flavius");
+ queuedel($@Croix_QueueBG1);
+ queuedel($@Guill_QueueBG1);
+ }
+ if( $@FlaviusBG1_id1 ) { bg_destroy $@FlaviusBG1_id1; set $@FlaviusBG1_id1, 0; }
+ if( $@FlaviusBG1_id2 ) { bg_destroy $@FlaviusBG1_id2; set $@FlaviusBG1_id2, 0; }
end;
}
@@ -140,37 +155,12 @@ OnMyMobDead:
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) {
- 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";
diff --git a/src/map/battleground.c b/src/map/battleground.c
index b557bee8e..fe1c078d8 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -110,7 +110,7 @@ int bg_team_join(int bg_id, struct map_session_data *sd)
int bg_team_leave(struct map_session_data *sd, int flag)
{ // Single Player leaves team
int i, bg_id;
- struct battleground_data *bg;
+ struct battleground_data *bg_data;
char output[128];
if( sd == NULL || !sd->bg_id )
@@ -120,24 +120,27 @@ int bg_team_leave(struct map_session_data *sd, int flag)
bg_id = sd->bg_id;
sd->bg_id = 0;
- if( (bg = bg_team_search(bg_id)) == NULL )
+ if( (bg_data = bg_team_search(bg_id)) == NULL )
return 0;
- ARR_FIND(0, MAX_BG_MEMBERS, i, bg->members[i].sd == sd);
+ ARR_FIND(0, MAX_BG_MEMBERS, i, bg_data->members[i].sd == sd);
if( i < MAX_BG_MEMBERS ) // Removes member from BG
- memset(&bg->members[i], 0, sizeof(bg->members[0]));
- bg->count--;
+ memset(&bg_data->members[i], 0, sizeof(bg_data->members[0]));
+ bg_data->count--;
if( flag )
sprintf(output, "Server : %s has quit the game...", sd->status.name);
else
sprintf(output, "Server : %s is leaving the battlefield...", sd->status.name);
- clif->bg_message(bg, 0, "Server", output, strlen(output) + 1);
+ clif->bg_message(bg_data, 0, "Server", output, strlen(output) + 1);
- if( bg->logout_event[0] && flag )
- npc_event(sd, bg->logout_event, 0);
+ if( bg_data->logout_event[0] && flag )
+ npc_event(sd, bg_data->logout_event, 0);
- return bg->count;
+ if( sd->bg_queue.arena )
+ bg->queue_pc_cleanup(sd);
+
+ return bg_data->count;
}
int bg_member_respawn(struct map_session_data *sd)
@@ -392,6 +395,7 @@ void bg_config_read(void) {
bg->arena[i]->fillup_timer = INVALID_TIMER;
bg->arena[i]->pregame_duration = pregame_duration;
bg->arena[i]->fillup_duration = fillup_duration;
+ bg->arena[i]->ongoing = false;
}
bg->arenas = arena_count;
@@ -463,6 +467,9 @@ void bg_match_over(struct bg_arena *arena, bool canceled) {
struct hQueue *queue = &script->hq[arena->queue_id];
int i;
+ if( !arena->ongoing )
+ return;
+
for( i = 0; i < queue->items; i++ ) {
struct map_session_data * sd = NULL;
@@ -470,11 +477,15 @@ void bg_match_over(struct bg_arena *arena, bool canceled) {
bg->queue_pc_cleanup(sd);
if( canceled )
clif->colormes(sd->fd,COLOR_RED,"BG Match Cancelled: not enough players");
+ else {
+ pc_setglobalreg(sd, arena->delay_var, time(NULL));
+ }
}
}
- bg->arena[i]->begin_timer = INVALID_TIMER;
- bg->arena[i]->fillup_timer = INVALID_TIMER;
+ arena->begin_timer = INVALID_TIMER;
+ arena->fillup_timer = INVALID_TIMER;
+ arena->ongoing = false;
/* reset queue */
script->queue_clear(arena->queue_id);
}
@@ -496,7 +507,9 @@ void bg_begin(struct bg_arena *arena) {
if( count < arena->min_players ) {
bg->match_over(arena,true);
} else {
+ arena->ongoing = true;
mapreg_setreg(add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */
+ mapreg_setregstr(add_str("$@bg_delay_var$"),bg->gdelay_var);
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 */
@@ -506,6 +519,7 @@ void bg_begin(struct bg_arena *arena) {
}
int bg_begin_timer(int tid, unsigned int tick, int id, intptr_t data) {
bg->begin(bg->arena[id]);
+ bg->arena[id]->begin_timer = INVALID_TIMER;
return 0;
}
@@ -524,12 +538,12 @@ void bg_queue_pregame(struct bg_arena *arena) {
}
int bg_fillup_timer(int tid, unsigned int tick, int id, intptr_t data) {
bg->queue_pregame(bg->arena[id]);
+ bg->arena[id]->fillup_timer = INVALID_TIMER;
return 0;
}
void bg_queue_check(struct bg_arena *arena) {
int count = script->hq[arena->queue_id].items;
-
if( count == arena->max_players ) {
if( arena->fillup_timer != INVALID_TIMER ) {
iTimer->delete_timer(arena->fillup_timer,bg_fillup_timer);
@@ -642,7 +656,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
return BGQA_FAIL_DESERTER;
}
- if ( ( tick = pc_readglobalreg(sd, arena->cooldown_variable) ) && tsec < tick ) {
+ if ( ( tick = pc_readglobalreg(sd, arena->delay_var) ) && tsec < tick ) {
char response[100];
if( (tick-tsec) > 60 )
sprintf(response, "You can't reapply to this arena so fast. Apply to the different arena or wait %d minute(s)",(tick-tsec)/60);
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 36f6f0cee..b6d95b813 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -67,7 +67,6 @@ struct bg_arena {
short min_players;
short max_players;
short min_team_players;
- char cooldown_variable[NAME_LENGTH];
char delay_var[NAME_LENGTH];
unsigned short maxDuration;
int queue_id;
@@ -76,6 +75,7 @@ struct bg_arena {
int game_timer;
unsigned short fillup_duration;
unsigned short pregame_duration;
+ bool ongoing;
};
/* battleground.c interface (incomplete) */