summaryrefslogtreecommitdiff
path: root/npc/003-3/malindou.txt
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2023-12-15 20:51:52 -0300
committerJesusaves <cpntb1@ymail.com>2023-12-15 20:51:52 -0300
commit98a4197cf0311fe85b85b23c7734638abddcc88f (patch)
tree7ebc438ea1b58a04bc663b1fdc4639540b172315 /npc/003-3/malindou.txt
parent1d4ea8cb18f1f1b0f4371ddc47a8a08a00073ec0 (diff)
downloadserverdata-98a4197cf0311fe85b85b23c7734638abddcc88f.tar.gz
serverdata-98a4197cf0311fe85b85b23c7734638abddcc88f.tar.bz2
serverdata-98a4197cf0311fe85b85b23c7734638abddcc88f.tar.xz
serverdata-98a4197cf0311fe85b85b23c7734638abddcc88f.zip
Lightbringer Selection
Diffstat (limited to 'npc/003-3/malindou.txt')
-rw-r--r--npc/003-3/malindou.txt313
1 files changed, 310 insertions, 3 deletions
diff --git a/npc/003-3/malindou.txt b/npc/003-3/malindou.txt
index 23038a588..c5fc5a59c 100644
--- a/npc/003-3/malindou.txt
+++ b/npc/003-3/malindou.txt
@@ -664,12 +664,318 @@ OnInit:
debugmes "* New homunculus skills";
debugmes "";
}
- // The following UPDATE value on: Sun Aug 20 05:11:46 PM CEST 2023
+ // The following UPDATE value on: Sun Aug 20 17:11:45 CEST 2023
// Typo update: FMOLY -> FYMOLY.
- if ($UPDATE < 1692544306) {
- $UPDATE = 1692544306;
+ if ($UPDATE < 1692544305) {
+ $UPDATE = 1692544305;
DelChrRegFromEveryPlayer("FMOLY_FRIEND");
}
+ // Current UPDATE value: Sex Dez 15 20:30:00 BRT 2023
+ // Find the one with highest Lightbringer score and give it
+ // Would be unfair otherwise. query_sql to select most active players
+ // Then get their points in matrix_lb so on so forth. But this is also unfair
+ // So instead, loop through accounts order by activity limit 20
+ // Select first char from each account ID, and manually run the most important
+ // parts. As we know at least one is eligible, the one with highest score is
+ // deemed the victor. Disable Lightbringer NPC afterwards (so a sleep before).
+ if ($UPDATE < 1702683000) {
+ freeloop(true);
+ DelItemFromEveryPlayer(Lightbringer);
+ $LIGHT_HOLDER$ = "Jesus Saves";
+ debugmes "PLEASE WAIT, LIGHTBRINGER SELECTION IN PROGRESS";
+ sleep(3000); // Wait long enough for Scoreboards initialization
+ .@nb = query_sql("SELECT `account_id` FROM `login` WHERE `lastlogin` > '"+escape_sql(sqldate(-6))+"' AND `group_id` < 995 ORDER BY `lastlogin` DESC LIMIT 15", .@acids); // Select the 15 most active eligible non-GM accounts FIXME GID
+ .@winner = 0; // CharID
+ .@wscore = 0;
+ for (.@xi=0; .@xi <= getarraysize(.@acids); .@xi++) {
+ .@score = 0; .@cid=0; .@name$=""; .@blvl=0; .@jlvl=0;
+ deletearray(.@quest_id);
+ deletearray(.@qv);
+ deletearray(.@var_id$);
+ deletearray(.@vv);
+ // Select only one char from the account, the one with highest job
+ .@nb = query_sql("SELECT `char_id`, `name`, `base_level`, `job_level` FROM `char` WHERE `account_id` = "+.@acids[.@xi]+" ORDER BY `job_level` DESC LIMIT 1", .@cid, .@name$, .@blvl, .@jlvl);
+ .@nb = query_sql("SELECT `quest_id`, `count1` FROM `quest` WHERE `char_id` = "+.@cid+" ORDER BY `count1` DESC LIMIT 128", .@quest_id, .@qv);
+ .@nb = query_sql("SELECT `key`, `value` FROM `char_reg_num_db` WHERE `index` = 0 AND `char_id` = "+.@cid+" ORDER BY `value` DESC LIMIT 128", .@var_id$, .@vv);
+ // Are you eligible for the Lightbringer? Otherwise, it is expensive
+ .@i = array_find(.@quest_id, General_Narrator);
+ if (.@i < 0)
+ continue;
+ if (.@qv[.@i] < 19)
+ continue;
+ // Begin score calculation
+ debugmes "Tallying %s[%d]...", .@name$, .@cid;
+ // Magic matrice
+ .@i = array_find(.@var_id$, "MAGIC_LVL");
+ if (.@i >= 0)
+ .@score += min(7, .@vv[.@i]);
+ // Deeds matrix (NOT CAPPED, unlike original)
+ if (array_find(.@var_id$, "YETIKING_WINNER") >= 0)
+ .@score += 1;
+ if (array_find(.@var_id$, "HEROESHOLD_WINNER") >= 0)
+ .@score += 1;
+ if (array_find(.@var_id$, "QUIRINO_WINNER") >= 0)
+ .@score += 1;
+ if (array_find(.@var_id$, "GEMINI_WINNER") >= 0)
+ .@score += 1;
+ if (array_find(.@var_id$, "GHQ_WINNER") >= 0)
+ .@score += 1;
+ if (array_find(.@var_id$, "FORT_1ST_VISIT") >= 0)
+ .@score += 1;
+ if (array_find(.@var_id$, "MOUBOOTAUR_WINNER") >= 0)
+ .@score += 1;
+ if (array_find(.@var_id$, "MK_WINNER") >= 0)
+ .@score += 1;
+ // Rebirth matrice
+ .@i = array_find(.@var_id$, "REBIRTH");
+ if (.@i >= 0)
+ .@score += min(10, .@vv[.@i]*2);
+ debugmes "First bout: %d points", .@score;
+ // If you didn't made at least two points, you're inelegible
+ if (.@score < 2)
+ continue;
+ // Level matrice
+ .@score += min(15, .@blvl / 10);
+ .@score += min(15, .@jlvl / 10);
+ // You're also disqualified if you have no chance to win the race
+ if (.@score <= (.@wscore - 57))
+ continue;
+ // Scoreboards matrix
+ .@br=array_find($@hoblvl_name$, .@name$);
+ .@jr=array_find($@hojlvl_name$, .@name$);
+ .@mr=array_find($@hofortune_name$, .@name$);
+ .@dr=array_find($@udt_name$, .@name$);
+ .@br=limit(0, (.@br >= 0 ? 10-.@br : 0), 10);
+ .@jr=limit(0, (.@jr >= 0 ? 10-.@jr : 0), 10);
+ .@mr=limit(0, (.@mr >= 0 ? 10-.@mr : 0), 10);
+ .@dr=limit(0, (.@dr >= 0 ? 3-.@dr : 0), 3);
+ .@score+=.@br;
+ .@score+=.@jr;
+ .@score+=.@mr;
+ .@score+=.@dr;
+ debugmes "Second bout: %d points", .@score;
+ // Before we calculate the reputation,
+ // You must have accrued a minimum of 10 points
+ // Otherwise you're disqualified (new player?)
+ if (.@score < 10)
+ continue;
+ // You're also disqualified if you have no chance to win the race
+ if (.@score <= (.@wscore - 24))
+ continue;
+ // Reputation matrix
+ // Tulimshar
+ .@i = 0; .@t = 0;
+ .@i = array_find(.@quest_id, TulimsharQuests_Fishman);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_Sarah);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_WaterForGuard);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 3 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_MobTutorial);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 8 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_Swezanne);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_Lifestone);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_Eistein);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 6 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_Hasan);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 5 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_Devoir);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_Sailors);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_DarkInvocator);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 7 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_AnwarField);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 10 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_Neko);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, MineQuest_Tycoon);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 15 ? 1 : 0);
+ .@i = array_find(.@quest_id, MineQuest_Dracoula);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, MineQuest_Caelum);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, MineQuest_Naem);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 3 ? 1 : 0);
+ .@i = array_find(.@quest_id, TulimsharQuest_WoodenSword);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ // Final result
+ .@score += min(3, (.@t*100/17) / 33);
+ // Hurnscald
+ .@i = 0; .@t = 0;
+ .@i = array_find(.@quest_id, HurnscaldQuest_ForestBow);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_HarkEye);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 6 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_TeaParty);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_Farmers);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 5 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_Bandits);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 8 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_InjuriedMouboo);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_BloodDonor);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_Woody);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 5 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_Lieutenant);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 10 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_Thorn);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_Blossom);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_LOFPass);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 3 ? 1 : 0);
+ // Final result
+ .@score += min(3, (.@t*100/12) / 33);
+ // You must have accrued a minimum of 14 points by now
+ // Otherwise you're disqualified
+ if (.@score < 14)
+ continue;
+ // Land of Fire
+ .@i = 0; .@t = 0;
+ .@i = array_find(.@quest_id, LoFQuest_EPISODE);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 6 ? 1 : 0);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 13 ? 1 : 0);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 17 ? 1 : 0);
+ .@i = array_find(.@quest_id, LoFQuest_George);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 5 ? 1 : 0);
+ .@i = array_find(.@quest_id, LoFQuest_Fairy);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 3 ? 1 : 0);
+ .@i = array_find(.@quest_id, LoFQuest_Pets);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ // Final result
+ .@score += min(3, (.@t*100/7) / 33);
+ // Nivalis
+ .@i = 0; .@t = 0;
+ .@i = array_find(.@quest_id, NivalisQuest_Well);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, NivalisQuest_Cindy);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 5 ? 1 : 0);
+ .@i = array_find(.@quest_id, NivalisQuest_BlueSage);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 12 ? 1 : 0);
+ .@i = array_find(.@quest_id, NivalisQuest_BlueSageSlimes);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, NivalisQuest_BlueSagePagemaker);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, NivalisQuest_BlueSagePagefinder);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, NivalisQuest_Henry);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ // Final result
+ .@score += min(3, (.@t*100/7) / 33);
+ // You must have accrued a minimum of 18 points by now
+ // Otherwise you're disqualified
+ if (.@score < 18)
+ continue;
+ // Halinarzo
+ .@i = 0; .@t = 0;
+ .@i = array_find(.@quest_id, HalinarzoQuest_Foxhound);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 6 ? 1 : 0);
+ .@i = array_find(.@quest_id, HalinarzoQuest_TraderKing);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, HalinarzoQuest_SickWife);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 5 ? 1 : 0);
+ .@i = array_find(.@quest_id, HalinarzoQuest_LifeDelight);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, HurnscaldQuest_ForestBow);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, HalinarzoQuest_Alvasus);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, HalinarzoQuest_Sawis);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, HalinarzoQuest_Speed);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ // Final result
+ .@score += min(3, (.@t*100/8) / 33);
+ // Frostia
+ .@i = 0; .@t = 0;
+ .@i = array_find(.@quest_id, FrostiaQuest_Homunculus);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 4 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_AFKCap);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_Jeremy);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_Erlan);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_Rydel);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_Meriel);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_Taenya);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_Talindra);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_Gaelira);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_Saevel);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FrostiaQuest_JhonH);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ // Final result
+ .@score += min(3, (.@t*100/11) / 33);
+ // You must have accrued a minimum of 22 points by now
+ // Otherwise you're disqualified
+ if (.@score < 22)
+ continue;
+
+ // Candor
+ .@i = 0; .@t = 0;
+ .@i = array_find(.@quest_id, CandorQuest_Trainer);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 14 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_Barrel);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 4 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_HAS);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 4 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_Sailors);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 3 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_SailorCure);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_Vincent);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_Tolchi);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 3 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_Maya);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 4 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_Rosen);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 3 ? 1 : 0);
+ .@i = array_find(.@quest_id, CandorQuest_Marggo);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 1 ? 1 : 0);
+ // Final result
+ .@score += min(3, (.@t*100/10) / 33);
+ // Fortress Town
+ .@i = 0; .@t = 0;
+ .@i = array_find(.@quest_id, General_Narrator);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 22 ? 2 : 0);
+ .@i = array_find(.@quest_id, FortressQuest_SlimeHunter);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FortressQuest_Over100);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ .@i = array_find(.@quest_id, FortressQuest_RangedHunt);
+ if (.@i >= 0) .@t += (.@qv[.@i] >= 2 ? 1 : 0);
+ // Final result
+ .@score += min(3, (.@t*100/5) / 33);
+ debugmes "Final bout: %d points", .@score;
+
+ // Now we determine if you have enough points to surpass #1
+ // More active players are evaluated first and have priority.
+ if (.@score > .@wscore) {
+ .@winner = .@cid;
+ .@wscore = .@score;
+ $LIGHT_HOLDER$ = .@name$;
+ }
+ }
+ freeloop(false);
+ kamibroadcast("The Lightbringer has elected "+$LIGHT_HOLDER$+" as its holder.");
+ consolewarn("Elected %s[%d] with %d points for Lightbringer.", $LIGHT_HOLDER$, .@winner, .@wscore);
+ disablenpc "Lightbringer";
+ $UPDATE = 1702683000;
+ }
+
// This mensures Contributors Credits, and changes only during updates.
// All names in lower case. Only TMW2 direct work! Non-TMW2 contributors
@@ -722,6 +1028,7 @@ OnClock0500:
if (gettime(GETTIME_DAYOFMONTH) >= 7)
query_sql("DELETE FROM `chatlog` WHERE `time` < '"+sqldate(-7)+"'");
query_sql("DELETE FROM `picklog` WHERE `time` < '"+sqldate(0, -2)+"'");
+ // TODO: Keep only 1 month of picklog and have crontab make monthly .gz backup
// Remove overhead from picklog
if (gettime(GETTIME_DAYOFMONTH) == 14)
query_sql("OPTIMIZE TABLE `picklog`");