Skip to content

Commit

Permalink
Bug Fixes in ExtendedBG:
Browse files Browse the repository at this point in the history
	* Added announcement of players currently playing the BG
	* Players cannot spam @joinbg
	* Removed debug messages
	* Deathmatch: Points would not reduce if player logout or quits

Other Changes:
	* Initial Changes to support Translation
  • Loading branch information
dastgirp committed Sep 30, 2018
1 parent ad582b7 commit d7a52e0
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 68 deletions.
87 changes: 53 additions & 34 deletions server/npc/eBG/bg_common.txt
@@ -1,9 +1,4 @@
/*
Done:
pc_block_si
bg_addpoints
bg_reward
Quest 8506 = bg_join_time(Variable)
Remaining:
maprespawnguildid
noemergencycall MapFlag
Expand Down Expand Up @@ -59,10 +54,10 @@ prontera,150,150,5 script Join Battleground 4_F_SURA,{
.@bg_type = .bg_change; // Save .bg_change into temporary variable.
mes("[Battleground Helper]");
mes("Would you like to join the Battleground?");
mes("Current BG: "+ getelementofarray(getvariableofnpc(.bg_name$, "BG_Settings"), .@bg_type));
mes("Status: "+ callfunc("F_eBG_Status",$@eBG_start[.@bg_type]));
mesf("Current BG: %d", getelementofarray(getvariableofnpc(.bg_name$, "BG_Settings"), .@bg_type));
mesf("Status: %s", callfunc("F_eBG_Status", $@eBG_start[.@bg_type]));
if (bg_join_time > gettimetick(2)) { // BG Cooldown is remaining
mes("Please wait for "+ (bg_join_time - gettimetick(2)) +" Seconds, to join the bg again");
mesf("Please wait for %d Seconds, to join the bg again", bg_join_time - gettimetick(2));
close;
}
if (callfunc("F_eBG_WR", .@bg_type)) { // WaitingRoom(WR) is not allowed for this BG.
Expand All @@ -73,7 +68,7 @@ prontera,150,150,5 script Join Battleground 4_F_SURA,{
mes("NOTE: ^FF0000 Not Accepting New Entries ^000000");
close;
}
switch(select("Join the BG!!: Wait, BG, ehh... No")) {
switch(select("Join the BG!!", "Wait, BG, ehh... No")) {
case 2:
close;
case 1:
Expand Down Expand Up @@ -132,8 +127,10 @@ OnInit:
* [1] = Max Player PER IP.
* [2] = Time after which BG should rotate if not enough players (in minutes).
* [3] = Reserved
* [4] = Announce Every x minutes (Players currently playing)
* [5] = Reserved
*/
setarray .bg_common, BGT_TOUCHDOWN, 3, 5, -1;
setarray .bg_common, BGT_DOM, 3, 5, -1, 1, -1;

/**
* $@eBG_start - To Track Start/End status of BG.
Expand Down Expand Up @@ -393,9 +390,16 @@ OnResetChangeTimer:
OnTimer60000:
initnpctimer;

.bg_common[5]++;
if (.bg_common[5] >= .bg_common[4] && $@eBG_start[.bg_change] != EBG_NOT_STARTED) {
callsub(OnBGAnnounce, 0, 0);
.bg_common[5] = 0;
}

// eBG is running, don't change.
if ($@eBG_start[.bg_change] != EBG_NOT_STARTED)
if ($@eBG_start[.bg_change] != EBG_NOT_STARTED) {
end;
}

// Increment the timer.
.bg_common[3]++;
Expand Down Expand Up @@ -447,37 +451,49 @@ OnChangeBG: // Called by callsub
OnBGAnnounce: // Announce remaining players
.@end = getarg(0, 1); // terminates the script if not enough player
.@onlyself = getarg(1, 0); // announce to self.
//.@min_p = .bg_minplayer[.bg_change]; // * .bg_teams[.bg_change] (remove on Release ToDo)

.@min_p = .bg_minplayer[.bg_change] * .bg_teams[.bg_change];
.@player_joined = queuesize(.queue[0]) + queuesize(.queue[1]) + queuesize(.queue[2]);

// Type of announcement, Self or all clients
if (.@onlyself == 1) {
.@type = BC_SELFEBG;
} else {
.@type = BC_EBG | bc_npc; // All Clients
}

if ($@eBG_start[.bg_change] == EBG_NOT_STARTED && .@player_joined < .@min_p) {
if (.@onlyself == 1) {
.@type = BC_SELFEBG;
} else {
.@type = BC_EBG | bc_npc; // All Clients
}
bg_announce("ExtendedBG -- " + .bg_name$[.bg_change] + " -- " + (.@min_p - .@player_joined) + " more players to start.", .@type, .bg_colors$[.bg_change]);
bg_announce(sprintf("ExtendedBG -- %s -- %d more players to start.", .bg_name$[.bg_change], (.@min_p - .@player_joined)), .@type, .bg_colors$[.bg_change]);
if (.@end == 1) {
end;
}
} else if ($@eBG_start[.bg_change] != EBG_NOT_STARTED) {
.@map$ = callsub(OnGetAltMapName, .bg_change);
.@msg$ = "";
for (.@i = 1; .@i <= .bg_teams[.bg_change]; .@i++) {
if (.@i != 1)
.@msg$ += " vs ";
.@msg$ += bg_get_data(getd("$@"+ .bg_mapname$[.bg_change] +"_BG_id"+ .@i), 0) +"/"+ .bg_maxplayer[.bg_change];
}
bg_announce(sprintf("ExtendedBG -- %s -- %s Playing", .bg_name$[.bg_change], .@msg$), .@type, .bg_colors$[.bg_change]);
}
return;

OnCheckBGEnabled:
.@type = getarg(0); // 2 = Party, 1 = Guild, 0 = None
if (.@type == 2) { // Party
if (.bg_enabled_p[.bg_change] == false) {
dispbottom("Party Join is disabled for "+ .bg_name$[.bg_change] +" BG.");
dispbottom(sprintf("Party Join is disabled for %s BG.", .bg_name$[.bg_change]));
return false;
}
} else if (.@type == 1) { // Guild
if (.bg_enabled_g[.bg_change] == false) {
dispbottom("Guild Join is disabled for "+ .bg_name$[.bg_change] +" BG.");
dispbottom(sprintf("Guild Join is disabled for %s BG.", .bg_name$[.bg_change]));
return false;
}
} else if (.@type == 0) {
if (.bg_enabled[.bg_change] == false) {
dispbottom("Individual Join is disabled for "+ .bg_name$[.bg_change] +" BG.");
dispbottom(sprintf("Individual Join is disabled for %s BG.", .bg_name$[.bg_change]));
return false;
}
}
Expand Down Expand Up @@ -505,16 +521,20 @@ OnJoinBGG: // joinbg_guild: .@type = 1
OnJoinBG: // joinbg: .@type = 0
if (callsub(OnCheckBGEnabled, .@type) == false)
end;
@BG_TeamJoin = 0;
if (@BG_GlobalQueueID > 0) {
dispbottom("You are already queued.");
end;
}
dispbottom("EBG: "+ on_ebg());
if (on_ebg() == true) {
dispbottom("You are Already on BG");
end;
}
if (bg_join_time > gettimetick(2)) {
dispbottom("Please wait for "+ (bg_join_time - gettimetick(2)) +" Seconds, to join the bg again");
dispbottom(sprintf("Please wait for %d Seconds, to join the bg again", (bg_join_time - gettimetick(2))));
end;
}
@BG_TeamJoin = 0;
switch(.bg_change) {
case BGT_RUSH:
.@bg_map$ = "ebg_rush0"+ ($bg_rush_rotate + 1);
Expand All @@ -536,6 +556,7 @@ OnJoinBG: // joinbg: .@type = 0
}
// Fallthrough
OnJoinBG2:
@BG_GlobalQueueID = .@type + 1;
queueadd(.queue[.@type], getcharid(3));
// Fallthrough
OnStartBG:
Expand Down Expand Up @@ -641,7 +662,6 @@ OnLeaveBGSource: // called from Source
end;
}


callfunc("F_resetBases", .@BG_ID);

bg_hpsp_time_del(EBG_HP_TIME | EBG_SP_TIME | EBG_EXTRA_TIME);
Expand Down Expand Up @@ -680,13 +700,15 @@ OnLeaveBGSource: // called from Source
return;
end;

OnPCLogoutEvent: // Leave the BG and set the timer
callsub(OnLeaveBGSub, true, true);
end;

OnLeaveBGSub:
.@dont_warn = getarg(0, 1);
.@ret_func = getarg(1, 1);
// Fallthrough
OnLeaveBG: // Replicate in bg_team_delete_pre (called when used .@leavebg/leaved bg via logout/mapchange)
dispbottom("TeamID: "+ @BG_Team);
dispbottom("EBG: "+ on_ebg());
OnLeaveBG: // Replicate in bg_team_delete_pre (called when used .@leavebg/leaved bg via logout/mapchange)
if (on_ebg() == false) {
if (!.@dont_warn)
dispbottom("You are Not on Any Kind of BG");
Expand Down Expand Up @@ -737,7 +759,6 @@ OnBGStart: // BG Starts
if (.uid[.@id])
callsub(OnBGStopSub); //Restarts the Timer
.uid[.@id] = bg_timer_start(24000, 1);
debugmes("Map: "+ strnpcinfo(4) +" ID: "+ .@id);
switch(.@id) {
/* CTF: 1, 2 */
/* SC: 12, 13 */
Expand Down Expand Up @@ -799,8 +820,8 @@ OnBGStart: // BG Starts
case 15: // Red Team
.@index = $bg_conquest_rotate; // Check map index
.@Castle$ = "ebg_conq0"+ (.@index + 1);
.@announce$ = "-- Reinforcements entering the Battle of Conquest --";
.@color$ = "0xFFA500"; // Color of Announce
.@announce$ = _("-- Reinforcements entering the Battle of Conquest --");
.@color$ = _("0xFFA500"); // Color of Announce
// Warp positions for Attacker and Defender
setarray .@bg_conquest_Defender_XY[0], 120, 129, // ebg_conq01
136, 188, // ebg_conq02
Expand Down Expand Up @@ -885,8 +906,8 @@ OnBGStart: // BG Starts
// Rush Map Index
.@index = $bg_rush_rotate;
.@Castle$ = "ebg_rush0"+ (.@index + 1);
.@announce$ = "-- Reinforcements entering the Battle of Rush --";
.@color$ = "0xDDA0DD";
.@announce$ = _("-- Reinforcements entering the Battle of Rush --");
.@color$ = _("0xDDA0DD");
// Defender BG Id
.@Defender = getvariableofnpc(.Defender, "eBG_Rush");

Expand Down Expand Up @@ -966,7 +987,6 @@ OnBGStart: // BG Starts
}
// Start the Timer
bg_timer_child(.uid[.@id], 1000, .@operations);
debugmes("UID Created: "+ .uid[.@id] +" ID: "+ .@id);
end;

OnBGStopSub: //called via callsub(returns instead of end)
Expand All @@ -980,7 +1000,6 @@ OnBGStop: //BG Stops
end;
}
// Stop BG Timer
debugmes("UID Stop: "+ .uid[.@id] +" ID: "+ .@id);
bg_timer_stop(.uid[.@id]);
// Unique Timer ID = 0
.uid[.@id] = 0;
Expand Down
32 changes: 12 additions & 20 deletions server/npc/eBG/bg_flavius_td.txt
@@ -1,6 +1,6 @@
// Battle Ground - Flavius Team DeathMatch(TDM)

- script TDM_Flavius -1,{
- script TDM_Flavius FAKE_NPC,{
end;

OnPCDieEvent:
Expand All @@ -10,34 +10,26 @@ OnPCLogoutEvent:
.@team = callfunc("F_ValidateeBG",BGT_TD,0);
if (.@team != GUILLAUME && .@team != CROIX)
end;
callsub(OnTeamOff, .@die, .@team);
if (.@die) {
callsub(OnTeamOff, .@team);
}
callfunc("F_warpDie", BGT_TD, .@team);
}
end;
OnTeam1Off:
callsub(OnTeamOff, false, GUILLAUME);
end;
OnTeam2Off:
callsub(OnTeamOff, false, CROIX);
end;

OnTeamOff:
.@die = getarg(0);
.@team = getarg(1);
.@team = getarg(0);
.@account_id = getcharid(3);
if (.@team == GUILLAUME)
.Team1_Score--;
else if (.@team == CROIX)
.Team2_Score--;
else
if (.@team != GUILLAUME && .@team != CROIX)
end;
if (.@die == true) {
bg_addpoints BG_TD_DIE, 1, 1;
if (attachrid(killerrid)) {
bg_addpoints BG_TD_KILL, 1, 1;
}
setd(".Team"+ .@team +"_Score", getd(".Team"+ .@team +"_Score") - 1);

bg_addpoints BG_TD_DIE, 1, 1;
if (attachrid(killerrid)) {
bg_addpoints BG_TD_KILL, 1, 1;
}
attachrid(.@account_id);

callsub(OnValidateScore, 0);
return;

Expand Down
11 changes: 6 additions & 5 deletions server/npc/eBG/bg_functions.txt
Expand Up @@ -422,9 +422,9 @@ function script F_MapToId {
return BGT_MAX;
}

/*
Checks if Person is on BG , and nullify's the variables, and returns the teamID.
*/
/**
* Checks if Person is on BG , and nullify's the variables, and returns the teamID.
*/
function script F_ValidateeBG {
.@type = getarg(0); //BGT_xxx
.@clear = getarg(1, 0); //Clear the Variables?
Expand All @@ -439,10 +439,11 @@ function script F_ValidateeBG {

if (.@check > 0 && .@clear > 0){
@BG_TeamJoin = 0;
@BG_ID = BGT_MAX;
//@BG_ID = BGT_MAX; // Handled by bg_common OnPCLogoutEvent
@BG_TeamID = 0;
@BG_Team = 0;
@bg_killer_id = 0;
@BG_GlobalQueueID = 0;
}
return .@check;
}
Expand All @@ -452,14 +453,14 @@ function script F_resetBases {
switch(.@type) {
case BGT_CTF:
case BGT_SC:
case BGT_TD:
case BGT_EOS:
getmapxy(.@mn$, @ebg_x, @ebg_y, UNITTYPE_PC);
doevent(getvariableofnpc(.bg_npcname$[.@type], "BG_Settings") +"::OnTeam"+ @BG_Team +"Off");
return 1;
case BGT_TOUCHDOWN:
setlook(LOOK_CLOTHES_COLOR, eBG_tod_pallete);
return 1;
case BGT_TD: // Don't do OnTeamOff event, can be abused
case BGT_CONQ:
case BGT_BOSS:
case BGT_RUSH:
Expand Down
6 changes: 3 additions & 3 deletions server/src/plugins/ExtendedBG-char.c
Expand Up @@ -222,8 +222,8 @@ int ebg_char_p_save_data(int fd)
if (char_id && type) {
if ((bgdb = bg_char_search(char_id)) == NULL) { // Create SQL
bgdb = ebg_fetch_sql_db(char_id, false);
ShowDebug("ebg_char_p_save_data: Player tried to save data without any previous history(CharID:%d, Type:'%"PRId64"')\n", char_id, type);
ShowDebug("Most Probably, the char-server went down. Trusting map-server data without any verification.\n");
ShowWarning("ebg_char_p_save_data: Player tried to save data without any previous history(CharID:%d, Type:'%"PRId64"')\n", char_id, type);
ShowWarning("Most Probably, the char-server went down. Trusting map-server data without any verification.\n");
}
RFIFOSKIP(fd, 18); // Skip the 18 bytes that are already read, then continue reading other.
bg_load_char_data_sub(inter->sql_handle, bgdb, char_id, fd, false, type);
Expand Down Expand Up @@ -318,7 +318,7 @@ int inter_parse_frommap_pre(int *fd_)
}

if ((len = inter->check_length(fd, packets_ebg_len[cmd - EBG_PACKET_MIN_MAP - 1])) == 0) {
ShowDebug("ExtendedBG-char: Invalid Packet Length(%d) for Packet %d\n", len, cmd);
ShowError("ExtendedBG-char: Invalid Packet Length(%d) for Packet %d\n", len, cmd);
hookStop();
return 2;
}
Expand Down
12 changes: 6 additions & 6 deletions server/src/plugins/ExtendedBG.c
Expand Up @@ -676,7 +676,7 @@ void insert_timerlog(int uid, char log[]) {
tdblog[uid].sequence = timer_seq++;
tdblog[uid].init = true;
tdblog[uid].removed = 0;
ShowDebug("insert_timerlog: Inserted %d(Reason:%s, Sequence: %d)\n",uid,log,timer_seq);
eShowDebug("insert_timerlog: Inserted %d(Reason:%s, Sequence: %d)\n",uid,log,timer_seq);
}

void check_timerlog(int uid) {
Expand All @@ -685,10 +685,10 @@ void check_timerlog(int uid) {
return;
} else {
if (!tdblog[uid].init && rtdblog[uid].sequence > 0) {
ShowDebug("check_timerlog: Previously been removed,\n");
ShowDebug("Log: %d:%d:%d, Reason: %s, Removed: %d\n",uid, rtdblog[uid].sequence, timer_seq, rtdblog[uid].log, rtdblog[uid].removed);
eShowDebug("check_timerlog: Previously been removed,\n");
eShowDebug("Log: %d:%d:%d, Reason: %s, Removed: %d\n",uid, rtdblog[uid].sequence, timer_seq, rtdblog[uid].log, rtdblog[uid].removed);
}
ShowDebug("check_timerlog: No Log found for UID:%d\n",uid);
eShowDebug("check_timerlog: No Log found for UID:%d\n",uid);
}
}
#endif
Expand Down Expand Up @@ -2221,7 +2221,7 @@ void bg_team_rewards(int bg_id, int nameid, int amount, int kafrapoints, int que
bool rank = false;

if ((bgd = bg->team_search(bg_id)) == NULL || itemdb->exists(nameid) == NULL) {
ShowDebug("bg_team_rewards: Cannot give x%d %d to BG_ID: %d\n", amount, nameid, bg_id);
ShowWarning("bg_team_rewards: Cannot give x%d %d to BG_ID: %d\n", amount, nameid, bg_id);
return;
}

Expand Down Expand Up @@ -2437,7 +2437,7 @@ void ebg_kill(struct map_session_data *killed, struct map_session_data *killer)
SQL->EscapeStringLen(map->mysql_handle, killer_name, killer->status.name, strnlen(killer->status.name, NAME_LENGTH));
SQL->EscapeStringLen(map->mysql_handle, killed_name, killed->status.name, strnlen(killed->status.name, NAME_LENGTH));

ShowDebug("%s Killed %s by %d", killer_name, killed_name, (int)skill_id);
eShowDebug("%s Killed %s by %d", killer_name, killed_name, (int)skill_id);

if (SQL_ERROR == SQL->Query(map->mysql_handle,
"INSERT INTO `char_kill_log` (`time`,`killer_name`,`killer_id`,`killed_name`,`killed_id`,`map`,`skill`,`map_type`) VALUES (NOW(), '%s', '%d', '%s', '%d', '%s', '%d', '%d')",
Expand Down

1 comment on commit d7a52e0

@dastgirp
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra changes:
Join delay would be triggered on logout

Please sign in to comment.