diff options
author | shennetsind <ind@henn.et> | 2013-11-06 21:10:05 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-11-06 21:10:05 -0200 |
commit | eaf04b9a2f0b399027df251c5d19d58d74e24e6a (patch) | |
tree | d4481d98fbaea267c6a7906c06c3f2af6bc9dca7 /npc/custom | |
parent | 665f1306a130d4b8c359972bf4e58ef9d3bd9cd8 (diff) | |
download | hercules-eaf04b9a2f0b399027df251c5d19d58d74e24e6a.tar.gz hercules-eaf04b9a2f0b399027df251c5d19d58d74e24e6a.tar.bz2 hercules-eaf04b9a2f0b399027df251c5d19d58d74e24e6a.tar.xz hercules-eaf04b9a2f0b399027df251c5d19d58d74e24e6a.zip |
BG Queue Update
Enabled Party/Guild joining methods, Implements first attempt at the splitting algorithm (Thanks to jaBote!)
Checks item 1 on issue #69
Help us test! -- http://hercules.ws/board/topic/1302-bg-queue-debug/
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'npc/custom')
-rw-r--r-- | npc/custom/bgqueue/flavius.txt | 90 |
1 files changed, 79 insertions, 11 deletions
diff --git a/npc/custom/bgqueue/flavius.txt b/npc/custom/bgqueue/flavius.txt index b3db9f81d..45b261175 100644 --- a/npc/custom/bgqueue/flavius.txt +++ b/npc/custom/bgqueue/flavius.txt @@ -3,7 +3,7 @@ //===== By: ================================================== //= L0ne_W0lf //===== Current Version: ===================================== -//= 1.4 +//= 1.5 //===== Description: ========================================= //= [AEGIS Conversion] //= Flavius Battleground. @@ -15,6 +15,7 @@ //= 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] +//= 1.5 Attempt at implementing BG Queue team-algorithm [jaBote] //============================================================ @@ -36,20 +37,87 @@ OnPlayerListReady: 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) ) { - 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); + copyarray .@bg_member[0],$@bg_member[0],$@bg_member_size; + copyarray .@bg_member_group[0],$@bg_member_group[0],$@bg_member_size; + copyarray .@bg_member_type[0],$@bg_member_type[0],$@bg_member_size; + + freeloop(1); + // Counting all participants and determining sizes, condensing .@bg_member_group + set .@nogroupcount, 0; + for (set .@i, 0; .@i < getarraysize(.@bg_member); set .@i, .@i + 1) { + // check if .@bg_member_group and .@bg_member_type already exists on these groups. + for (set .@j, 0; .@j <= getarraysize(.@bg_groups); set .@j, .@j + 1) { // <= since it has to start working even if the array is still blank + if (.@bg_member_group[.@i] == 0) { // Just count them + set .@nogroupcount, .@nogroupcount + 1; + break; + } + else if ( (.@bg_member_group[.@i] == .@bg_groups[.@j]) && (.@bg_member_type[.@i] == .@bg_types[.@j]) ) { + set .@bg_count[.@j], .@bg_count[.@j] + 1; + break; + } + else if (.@j == (getarraysize(.@bg_groups)) ) { // It isn't there, insert a new entry at j+1 since j is the last known member + set .@bg_groups[.@j], .@bg_member_group[.@i]; + set .@bg_types[.@j], .@bg_member_type[.@i]; + set .@bg_count[.@j], 1; + break; + } + // Else keep running the loop until we find there's a group already made or make a new one + } + } + + // Now, sorting the group arrays from amount of population descending! Bubble sort powers, I call upon thee! + // Type doesn't matter here for precedence checks, but also needs to be sorted the same way along with groups + for (set .@i, 0; .@i < getarraysize(.@bg_groups); set .@i, .@i + 1) { + for (set .@j, 0; .@j < (getarraysize(.@bg_groups) - .@i); set .@j, .@j + 1) { + if (.@bg_count[.@j] < .@bg_count[.@j+1]){ + set .@temp1, .@bg_groups[.@j]; + set .@temp2, .@bg_types[.@j]; + set .@temp3, .@bg_count[.@j]; + set .@bg_groups[.@j], .@bg_groups[.@j+1]; + set .@bg_types[.@j], .@bg_types[.@j+1]; + set .@bg_count[.@j], .@bg_count[.@j+1]; + set .@bg_groups[.@j+1], .@temp1; + set .@bg_types[.@j+1], .@temp2; + set .@bg_count[.@j+1], .@temp3; + } + } + } + + // Add the groups to the queues! :D + for (set .@i, 0; .@i < getarraysize(.@bg_groups); set .@i, .@i + 1){ + if (queuesize($@Croix_QueueBG1) <= queuesize($@Guill_QueueBG1)){ // Catch'em all and add to the queue! + for (set .@j, 0; .@j < getarraysize(.@bg_member); set .@j, .@j + 1) { + if ( (.@bg_groups[.@i] == .@bg_member_group[.@j]) && (.@bg_types[.@i] == .@bg_member_type[.@j]) ) { + bg_join_team($@FlaviusBG1_id1,.@bg_member[.@j]); + queueadd($@Croix_QueueBG1, .@bg_member[.@j]); + } + } + } + else { + for (set .@j, 0; .@j < getarraysize(.@bg_member); set .@j, .@j + 1) { + if ( (.@bg_groups[.@i] == .@bg_member_group[.@j]) && (.@bg_types[.@i] == .@bg_member_type[.@j]) ) { + bg_join_team($@FlaviusBG1_id2,.@bg_member[.@j]); + queueadd($@Guill_QueueBG1, .@bg_member[.@j]); + } + } + } + } + // Don't forget the people that go on their own! + for (set .@i, 0; .@i <= getarraysize(.@bg_member); set .@i, .@i+1) { + if (.@bg_member_group[.@i] == 0) { // Get alone people only + if (queuesize($@Croix_QueueBG1) <= queuesize($@Guill_QueueBG1)) { + bg_join_team($@FlaviusBG1_id1,.@bg_member[.@i]); + queueadd($@Croix_QueueBG1, .@bg_member[.@i]); + } + else { + bg_join_team($@FlaviusBG1_id2,.@bg_member[.@i]); + queueadd($@Guill_QueueBG1, .@bg_member[.@i]); + } } - set .@i,.@i + 1; } - qiclear(.@it); + freeloop(0); set $@FlaviusBG1, 1; set $@FlaviusBG1_Victory, 0; |