Added Puppets on Aggro + Guild/Alliance packet info patch + Pet flags

Added pet flags recognition, such as the "pet speed same as owner" mechanic.
Fixed repeatable quest "Remnants of HT..." not rewarding Dragon Stones.
Refactored character object's check slots method, now using the same algorithm from the API class.
Fixed a vunerability from before reviving/respawning players to towns, on where players would get their HP restored in area map before sending them back to safety.
Fixed some NPC gates in Mushking Empire, allowing players to access bosses free of quest requirements.
Improved dialog of NPCs for "permission to attempt Zakum expeds".
Implemented (or rather improved) item scripts, now using NPC conversation methods as it was intended originally.
Rehauled mob-skill "summon mobs" limit, now using the placeholders found in the wz to determine limit of concurrent underlings spawned, and "limit" now refers to total of underlings spawned from a mob.
Revised IoSession closing mechanics in several login classes.
Implemented automated loggedin account shutdown if another player has gained a pass from the DB to login.
Improved the server-side check for teleport rocks.
Fixed removeAfter from mobs being procced after they were disposed.
Reviewed EIM start references on several scripts, minding the latest EIM setup implementations.
Fixed equipments that were reused Scissors of Karma not not being able to sell on pshops/merchants.
Fixed a bug where entering alliances would lead a player to see information from other guilds of past alliances until an update takes place.
Padronized a few skillbook names.
Reviewed player puppets not gaining priority properly on the recent aggro system.
Improved "item sold" message of merchants, now displaying also quantity left of an item on store.
Fixed a bug with itemid limits of weapons on server.
This commit is contained in:
ronancpl
2019-02-17 16:08:53 -03:00
parent 4beea39615
commit 46fec675f1
127 changed files with 1760 additions and 608 deletions
+44 -36
View File
@@ -66,6 +66,7 @@ import net.server.world.World;
import scripting.event.EventInstanceManager;
import server.CashShop;
import server.MapleItemInformationProvider;
import server.MapleItemInformationProvider.ScriptedItem;
import server.MaplePortal;
import server.MapleShop;
import server.MapleStatEffect;
@@ -287,6 +288,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
private AutobanManager autoban;
private boolean isbanned = false;
private boolean blockCashShop = false;
private boolean allowExpGain = false;
private byte pendantExp = 0, lastmobcount = 0, doorSlot = -1;
private List<Integer> trockmaps = new ArrayList<>();
private List<Integer> viptrockmaps = new ArrayList<>();
@@ -649,6 +651,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
public void addSummon(int id, MapleSummon summon) {
summons.put(id, summon);
if (summon.isPuppet()) {
map.addPlayerPuppet(this);
}
}
public void addVisibleMapObject(MapleMapObject mo) {
@@ -805,6 +811,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
public void toggleBlockCashShop() {
blockCashShop = !blockCashShop;
}
public void toggleExpGain() {
allowExpGain = !allowExpGain;
}
public void setClient(MapleClient c) {
this.client = c;
@@ -1728,6 +1738,15 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
}
}
public Collection<MapleMonster> getControlledMonsters() {
cpnLock.lock();
try {
return new ArrayList<>(controlled);
} finally {
cpnLock.unlock();
}
}
public void releaseControlledMonsters() {
Collection<MapleMonster> controlledMonsters;
@@ -1799,7 +1818,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
mpcs = getPartyMembersOnSameMap();
}
String itemScriptName = null;
ScriptedItem itemScript = null;
mapitem.lockItem();
try {
if (mapitem.isPickedUp()) {
@@ -1872,9 +1891,9 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
this.gainMeso(mapitem.getMeso(), true, true, false);
}
} else if (mItem.getItemId() / 10000 == 243) {
MapleItemInformationProvider.scriptedItem info = ii.getScriptedItemInfo(mItem.getItemId());
if (info.runOnPickup()) {
itemScriptName = info.getScript();
ScriptedItem info = ii.getScriptedItemInfo(mItem.getItemId());
if (info != null && info.runOnPickup()) {
itemScript = info;
} else {
if (!MapleInventoryManipulator.addFromDrop(client, mItem, true)) {
client.announce(MaplePacketCreator.enableActions());
@@ -1908,11 +1927,9 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
mapitem.unlockItem();
}
if (itemScriptName != null) {
if (itemScript != null) {
ItemScriptManager ism = ItemScriptManager.getInstance();
if (ism.scriptExists(itemScriptName)) {
ism.runItemScript(client, itemScriptName);
}
ism.runItemScript(client, itemScript);
}
}
client.announce(MaplePacketCreator.enableActions());
@@ -1927,14 +1944,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
}
public boolean canHold(int itemid, int quantity) {
int hold = getCleanItemQuantity(itemid, false);
if(hold > 0) {
if(hold + quantity <= ii.getSlotMax(client, itemid))
return true;
}
return getInventory(ItemConstants.getInventoryType(itemid)).getNextFreeSlot() > -1;
return client.getAbstractPlayerInteraction().canHold(itemid, quantity);
}
public boolean isRidingBattleship() {
@@ -2907,7 +2917,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
private synchronized void gainExpInternal(long gain, int equip, int party, boolean show, boolean inChat, boolean white) { // need of method synchonization here detected thanks to MedicOP
long total = Math.max(gain, -exp.get());
if (level < getMaxLevel()) {
if (level < getMaxLevel() && (allowExpGain || this.getEventInstance() != null)) {
long leftover = 0;
long nextExp = exp.get() + total;
@@ -3464,9 +3474,11 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
getMap().broadcastMessage(MaplePacketCreator.removeSummon(summon, true), summon.getPosition());
getMap().removeMapObject(summon);
removeVisibleMapObject(summon);
summons.remove(summonId);
if (summon.getSkill() == DarkKnight.BEHOLDER) {
if (summon.isPuppet()) {
map.removePlayerPuppet(this);
} else if (summon.getSkill() == DarkKnight.BEHOLDER) {
if (beholderHealingSchedule != null) {
beholderHealingSchedule.cancel(false);
beholderHealingSchedule = null;
@@ -4602,19 +4614,19 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
}
public int getItemQuantity(int itemid, boolean checkEquipped) {
int possesed = inventory[ItemConstants.getInventoryType(itemid).ordinal()].countById(itemid);
int count = inventory[ItemConstants.getInventoryType(itemid).ordinal()].countById(itemid);
if (checkEquipped) {
possesed += inventory[MapleInventoryType.EQUIPPED.ordinal()].countById(itemid);
count += inventory[MapleInventoryType.EQUIPPED.ordinal()].countById(itemid);
}
return possesed;
return count;
}
public int getCleanItemQuantity(int itemid, boolean checkEquipped) {
int possesed = inventory[ItemConstants.getInventoryType(itemid).ordinal()].countNotOwnedById(itemid);
int count = inventory[ItemConstants.getInventoryType(itemid).ordinal()].countNotOwnedById(itemid);
if (checkEquipped) {
possesed += inventory[MapleInventoryType.EQUIPPED.ordinal()].countNotOwnedById(itemid);
count += inventory[MapleInventoryType.EQUIPPED.ordinal()].countNotOwnedById(itemid);
}
return possesed;
return count;
}
public MapleJob getJob() {
@@ -6600,13 +6612,9 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
rs = ps.executeQuery();
while (rs.next()) {
String name = rs.getString("name");
if (rs.getString("name").equals("rescueGaga")) {
if (rs.getString("name").contentEquals("rescueGaga")) {
ret.events.put(name, new RescueGaga(rs.getInt("info")));
}
//ret.events = new MapleEvents(new RescueGaga(rs.getInt("rescuegaga")), new ArtifactHunt(rs.getInt("artifacthunt")));
}
if (!ret.events.containsKey("rescueGaga")) {
ret.events.put("rescueGaga", new RescueGaga(0));
}
rs.close();
ps.close();
@@ -6988,13 +6996,12 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
}
public void respawn(EventInstanceManager eim, int returnMap) {
cancelAllBuffs(false);
updateHp(50);
setStance(0);
if (eim != null) eim.unregisterPlayer(this); // some event scripts uses this...
changeMap(returnMap);
cancelAllBuffs(false); // thanks Oblivium91 for finding out players still could revive in area and take damage before returning to town
updateHp(50);
setStance(0);
}
private void prepareDragonBlood(final MapleStatEffect bloodEffect) {
@@ -7514,6 +7521,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
this.getInventory(itEntry.getRight()).addItem(itEntry.getLeft());
}
this.events.put("rescueGaga", new RescueGaga(0));
Connection con = null;
PreparedStatement ps = null;
@@ -9733,7 +9742,6 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
events = null;
mpc = null;
mgc = null;
events = null;
party = null;
family = null;
+16 -10
View File
@@ -517,11 +517,15 @@ public class MapleClient {
}
public int login(String login, String pwd, String nibbleHwid) {
loginattempt++;
if (loginattempt > 4) {
MapleSessionCoordinator.getInstance().closeSession(session, false);
}
int loginok = 5;
loginattempt++;
if (loginattempt > 4) {
loggedIn = false;
MapleSessionCoordinator.getInstance().closeSession(session, false);
return loginok;
}
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
@@ -748,7 +752,12 @@ public class MapleClient {
return accId;
}
public void updateLoginState(int newstate) {
public void updateLoginState(int newstate) {
// rules out possibility of multiple account entries
if (newstate == LOGIN_LOGGEDIN) {
MapleSessionCoordinator.getInstance().updateOnlineSession(this.getSession());
}
try {
Connection con = DatabaseConnection.getConnection();
try (PreparedStatement ps = con.prepareStatement("UPDATE accounts SET loggedin = ?, lastlogin = ? WHERE id = ?")) {
@@ -763,6 +772,7 @@ public class MapleClient {
} catch (SQLException e) {
e.printStackTrace();
}
if (newstate == LOGIN_NOTLOGGEDIN) {
loggedIn = false;
serverTransition = false;
@@ -797,9 +807,6 @@ public class MapleClient {
MapleSessionCoordinator.getInstance().closeSession(session, null);
updateLoginState(LOGIN_NOTLOGGEDIN);
}
} else if (state == LOGIN_LOGGEDIN && player == null) {
state = LOGIN_LOGGEDIN;
updateLoginState(LOGIN_LOGGEDIN);
}
rs.close();
ps.close();
@@ -1006,8 +1013,7 @@ public class MapleClient {
Server.getInstance().unregisterLoginState(this);
this.session.setAttribute(MapleClient.CLIENT_KEY, null);
this.accountName = null;
this.accountName = null;
this.macs = null;
this.hwid = null;
this.birthday = null;
+1
View File
@@ -193,6 +193,7 @@ public class CommandsExecutor {
addCommand("int", StatIntCommand.class);
addCommand("luk", StatLukCommand.class);
addCommand("enableauth", EnableAuthCommand.class);
addCommand("toggleexp", ToggleExpCommand.class);
commandsNameDesc.add(levelCommandsCursor);
}
@@ -0,0 +1,44 @@
/*
This file is part of the HeavenMS MapleStory Server, commands OdinMS-based
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/>.
*/
/*
@Author: Ronan
*/
package client.command.commands.gm0;
import client.command.Command;
import client.MapleClient;
public class ToggleExpCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
if (c.tryacquireClient()) {
try {
c.getPlayer().toggleExpGain(); // Vcoc's idea
} finally {
c.releaseClient();
}
}
}
}
@@ -46,12 +46,19 @@ public class GotoCommand extends Command {
player.yellowMessage("Syntax: @goto <map name>");
return;
}
if (player.getEventInstance() != null || MapleMiniDungeonInfo.isDungeonMap(player.getMapId()) || FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit()) || !player.isAlive()) {
player.dropMessage(1, "This command can not be used in this map.");
if (!player.isAlive()) {
player.dropMessage(1, "This command cannot be used when you're dead.");
return;
}
if (!player.isGM()) {
if (player.getEventInstance() != null || MapleMiniDungeonInfo.isDungeonMap(player.getMapId()) || FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
player.dropMessage(1, "This command can not be used in this map.");
return;
}
}
HashMap<String, Integer> gotomaps;
if (player.isGM()) {
gotomaps = new HashMap<>(GameConstants.GOTO_AREAS); // distinct map registry for GM/users suggested thanks to Vcoc
@@ -50,11 +50,18 @@ public class WarpCommand extends Command {
return;
}
if (player.getEventInstance() != null || MapleMiniDungeonInfo.isDungeonMap(player.getMapId()) || FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit()) || !player.isAlive()) {
player.dropMessage(1, "This command cannot be used in this map.");
if (!player.isAlive()) {
player.dropMessage(1, "This command cannot be used when you're dead.");
return;
}
if (!player.isGM()) {
if (player.getEventInstance() != null || MapleMiniDungeonInfo.isDungeonMap(player.getMapId()) || FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
player.dropMessage(1, "This command cannot be used in this map.");
return;
}
}
// expedition issue with this command detected thanks to Masterrulax
player.saveLocationOnWarp();
player.changeMap(target, target.getRandomPlayerSpawnpoint());
@@ -27,6 +27,7 @@ import client.MapleStat;
import client.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import constants.ItemConstants;
import server.MapleItemInformationProvider;
public class FaceCommand extends Command {
@@ -45,7 +46,7 @@ public class FaceCommand extends Command {
try {
if (params.length == 1) {
int itemId = Integer.parseInt(params[0]);
if (!(itemId >= 20000 && itemId < 22000) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
if (!ItemConstants.isFace(itemId) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
player.yellowMessage("Face id '" + params[0] + "' does not exist.");
return;
}
@@ -55,7 +56,7 @@ public class FaceCommand extends Command {
player.equipChanged();
} else {
int itemId = Integer.parseInt(params[1]);
if (!(itemId >= 20000 && itemId < 22000) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
if (!ItemConstants.isFace(itemId) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
player.yellowMessage("Face id '" + params[1] + "' does not exist.");
}
@@ -27,6 +27,7 @@ import client.MapleStat;
import client.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import constants.ItemConstants;
import server.MapleItemInformationProvider;
public class HairCommand extends Command {
@@ -45,7 +46,7 @@ public class HairCommand extends Command {
try {
if (params.length == 1) {
int itemId = Integer.parseInt(params[0]);
if (!(itemId >= 30000 && itemId < 35000) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
if (!ItemConstants.isHair(itemId) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
player.yellowMessage("Hair id '" + params[0] + "' does not exist.");
return;
}
@@ -55,7 +56,7 @@ public class HairCommand extends Command {
player.equipChanged();
} else {
int itemId = Integer.parseInt(params[1]);
if (!(itemId >= 30000 && itemId < 35000) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
if (!ItemConstants.isHair(itemId) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
player.yellowMessage("Hair id '" + params[1] + "' does not exist.");
return;
}
+48 -5
View File
@@ -52,6 +52,21 @@ public class MaplePet extends Item {
private Point pos;
private int stance;
private boolean summoned;
private int petFlag = 0;
public enum PetFlag {
OWNER_SPEED(0x01);
private int i;
private PetFlag(int i) {
this.i = i;
}
public int getValue() {
return i;
}
}
private MaplePet(int id, short position, int uniqueid) {
super(id, position, (short) 1);
@@ -63,7 +78,7 @@ public class MaplePet extends Item {
try {
MaplePet ret = new MaplePet(itemid, position, petid);
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT name, level, closeness, fullness, summoned FROM pets WHERE petid = ?"); // Get pet details..
PreparedStatement ps = con.prepareStatement("SELECT name, level, closeness, fullness, summoned, flag FROM pets WHERE petid = ?"); // Get pet details..
ps.setInt(1, petid);
ResultSet rs = ps.executeQuery();
rs.next();
@@ -72,6 +87,7 @@ public class MaplePet extends Item {
ret.setLevel((byte) Math.min(rs.getByte("level"), 30));
ret.setFullness(Math.min(rs.getInt("fullness"), 100));
ret.setSummoned(rs.getInt("summoned") == 1);
ret.setPetFlag(rs.getInt("flag"));
rs.close();
ps.close();
con.close();
@@ -108,13 +124,14 @@ public class MaplePet extends Item {
public void saveToDb() {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE pets SET name = ?, level = ?, closeness = ?, fullness = ?, summoned = ? WHERE petid = ?");
PreparedStatement ps = con.prepareStatement("UPDATE pets SET name = ?, level = ?, closeness = ?, fullness = ?, summoned = ?, flag = ? WHERE petid = ?");
ps.setString(1, getName());
ps.setInt(2, getLevel());
ps.setInt(3, getCloseness());
ps.setInt(4, getFullness());
ps.setInt(5, isSummoned() ? 1 : 0);
ps.setInt(6, getUniqueId());
ps.setInt(6, getPetFlag());
ps.setInt(7, getUniqueId());
ps.executeUpdate();
ps.close();
con.close();
@@ -126,7 +143,7 @@ public class MaplePet extends Item {
public static int createPet(int itemid) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (petid, name, level, closeness, fullness, summoned) VALUES (?, ?, 1, 0, 100, 0)");
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (petid, name, level, closeness, fullness, summoned, flag) VALUES (?, ?, 1, 0, 100, 0, 0)");
int ret = MapleCashidGenerator.generateCashId();
ps.setInt(1, ret);
ps.setString(2, MapleItemInformationProvider.getInstance().getName(itemid));
@@ -143,7 +160,7 @@ public class MaplePet extends Item {
public static int createPet(int itemid, byte level, int closeness, int fullness) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (petid, name, level, closeness, fullness, summoned) VALUES (?, ?, ?, ?, ?, 0)");
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (petid, name, level, closeness, fullness, summoned, flag) VALUES (?, ?, ?, ?, ?, 0, 0)");
int ret = MapleCashidGenerator.generateCashId();
ps.setInt(1, ret);
ps.setString(2, MapleItemInformationProvider.getInstance().getName(itemid));
@@ -274,6 +291,32 @@ public class MaplePet extends Item {
public void setSummoned(boolean yes) {
this.summoned = yes;
}
public int getPetFlag() {
return this.petFlag;
}
private void setPetFlag(int flag) {
this.petFlag = flag;
}
public void addPetFlag(MapleCharacter owner, PetFlag flag) {
this.petFlag |= flag.getValue();
saveToDb();
Item petz = owner.getInventory(MapleInventoryType.CASH).getItem(getPosition());
if (petz != null)
owner.forceUpdateItem(petz);
}
public void removePetFlag(MapleCharacter owner, PetFlag flag) {
this.petFlag &= 0xFFFFFFFF ^ flag.getValue();
saveToDb();
Item petz = owner.getInventory(MapleInventoryType.CASH).getItem(getPosition());
if (petz != null)
owner.forceUpdateItem(petz);
}
public Pair<Integer, Boolean> canConsume(int itemId) {
return MapleItemInformationProvider.getInstance().canPetConsume(this.getItemId(), itemId);
@@ -53,6 +53,7 @@ public class MapleKarmaManipulator {
int flag = item.getFlag();
flag |= karmaFlag;
flag &= (0xFFFFFFFF ^ ItemConstants.UNTRADEABLE);
item.setFlag((byte) flag);
}
}
+1 -1
View File
@@ -218,7 +218,7 @@ public class MakerProcessor {
Map<Integer, Integer> reagentType = new LinkedHashMap<>();
List<Integer> toRemove = new LinkedList<>();
boolean isWeapon = ItemConstants.isWeapon(toCreate) || ServerConstants.USE_MAKER_PERMISSIVE_ATKUP;
boolean isWeapon = ItemConstants.isWeapon(toCreate) || ServerConstants.USE_MAKER_PERMISSIVE_ATKUP; // thanks Vcoc for finding a case where a weapon wouldn't be counted as such due to a bounding on isWeapon
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
int curRid = r.getKey();