Files
sweetgum-server/tools/MapleSkillbookChanceFetcher/src/mapleskillbookchancefetcher/MapleSkillbookChanceFetcher.java
ronancpl fba27fb3b1 Boss Daily Entry + Maker enable actions + Duey Quick Delivery
Fixed Legendary Spirit UI getting stuck when trying to apply scrolls in equipments without upgrade slots available.
Revised map leasing. Players no longer lose ownership when changing maps. Players are allowed to lease one map each time.
Revised expeditions warping players out as soon as the leader leaves the event or the number of players inside gets to be less than the minimum required to enter.
Fixed start/complete quest commands not acting properly for some quests.
Refactored quest loadouts unnecessarily reloading MapleData.
Implemented support for daily boss limit entry, usable on expeditions.
Revised potential exploit cases within chair, face expression, quest action, summon damage and mob damage mob handlers.
Adjusted displayed date in Duey. Value displayed now should be consistent with the expected expiration time.
Refactored damage for friendly mobs getting handled inside packet structure.
Implemented support for Quick Delivery from Duey.
Fixed Horntail specifically not dropping loots after recent updates.
Refactored commands system. All commands are instanced at boot time instead of at every call.
Fixed usage of Maker skill not sending MAKER_RESULT packet to players. This automatically reenables the actions button (such as create) in Maker UI.
Adjusted minidungeons, now using time limits specified in their respective recipes.
Reviewed the "timeLimit" property utilized by maps, which was poised to work on 2 different concepts altogether.
Fixed Gaga space event, should be functional now.
Added RPS minigame, resources implemented by Arnah.
Fixed damage taken from mob auto-destruction not working properly.
2019-06-27 20:34:39 -03:00

160 lines
6.1 KiB
Java

/*
This file is part of the HeavenMS MapleStory Server
Copyleft (L) 2016 - 2018 RonanLana
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package mapleskillbookchancefetcher;
import life.MapleLifeFactory;
import life.MapleMonsterStats;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.io.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import tools.DatabaseConnection;
import tools.Pair;
/**
*
* @author RonanLana
*
* This application traces missing meso drop data on the underlying DB (that must be
* defined on the DatabaseConnection file of this project) and generates a
* SQL file that proposes missing drop entries for the drop_data table.
*
* The meso range is calculated accordingly with the target mob stats, such as level
* and if it's a boss or not, similarly as how it has been done for the actual meso
* drops.
*
*/
public class MapleSkillbookChanceFetcher {
private static PrintWriter printWriter;
private static String newFile = "lib/skillbook_drop_data.sql";
private static Map<Integer, MapleMonsterStats> mobStats;
private static Map<Pair<Integer, Integer>, Integer> skillbookChances = new HashMap<>();
private static List<Entry<Pair<Integer, Integer>, Integer>> sortedSkillbookChances() {
List<Entry<Pair<Integer, Integer>, Integer>> skillbookChancesList = new ArrayList<>(skillbookChances.entrySet());
Collections.sort(skillbookChancesList, new Comparator<Entry<Pair<Integer, Integer>, Integer>>() {
@Override
public int compare(Entry<Pair<Integer, Integer>, Integer> o1, Entry<Pair<Integer, Integer>, Integer> o2) {
if (o1.getKey().getLeft().equals(o2.getKey().getLeft())) {
return o1.getKey().getRight() < o2.getKey().getRight() ? -1 : (o1.getKey().getRight().equals(o2.getKey().getRight()) ? 0 : 1);
}
return (o1.getKey().getLeft() < o2.getKey().getLeft()) ? -1 : 1;
}
});
return skillbookChancesList;
}
private static boolean isLegendSkillUpgradeBook(int itemid) {
int itemidBranch = itemid / 10000;
return (itemidBranch == 228 && itemid >= 2280013 || itemidBranch == 229 && itemid >= 2290126); // drop rate of Legends are higher
}
private static void fetchSkillbookDropChances() {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT dropperid, itemid FROM drop_data WHERE itemid >= 2280000 AND itemid < 2300000");
ResultSet rs = ps.executeQuery();
while(rs.next()) {
int mobid = rs.getInt("dropperid");
int itemid = rs.getInt("itemid");
int expectedChance = 250;
if (mobStats.get(mobid) != null) {
int level = mobStats.get(mobid).getLevel();
expectedChance *= Math.max(2, (level - 80) / 15);
if (mobStats.get(mobid).isBoss()) {
expectedChance *= 20;
} else {
expectedChance *= 1;
}
} else {
expectedChance = 1287;
}
if (isLegendSkillUpgradeBook(itemid)) { // drop rate of Legends seems to be higher than explorers, in retrospect from values in DB
expectedChance *= 3;
}
skillbookChances.put(new Pair<>(mobid, itemid), expectedChance);
}
rs.close();
ps.close();
con.close();
} catch(Exception e) {
e.printStackTrace();
}
}
private static void printSkillbookChanceUpdateSqlHeader() {
printWriter.println(" # SQL File autogenerated from the MapleSkillbookChanceFetcher feature by Ronan Lana.");
printWriter.println(" # Generated data takes into account mob stats such as level and boss for the chance rates.");
printWriter.println();
printWriter.println(" REPLACE INTO drop_data (`dropperid`, `itemid`, `minimum_quantity`, `maximum_quantity`, `questid`, `chance`) VALUES");
}
private static void generateSkillbookChanceUpdateFile() {
try {
printWriter = new PrintWriter(newFile, "UTF-8");
printSkillbookChanceUpdateSqlHeader();
List<Entry<Pair<Integer, Integer>, Integer>> skillbookChancesList = sortedSkillbookChances();
for (Entry<Pair<Integer, Integer>, Integer> e : skillbookChancesList) {
printWriter.println("(" + e.getKey().getLeft() + ", " + e.getKey().getRight() + ", 1, 1, 0, " + e.getValue() + "),");
}
printWriter.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
public static void main(String[] args) {
// load mob stats from WZ
mobStats = MapleLifeFactory.getAllMonsterStats();
fetchSkillbookDropChances();
generateSkillbookChanceUpdateFile();
}
}