Trade results + Map-Ownership & Fishing + P. EXP distribution rework

Fixed an issue where players could lose priority over recently dropped items after switching maps.
Adjusted EXP bonus buffs to also cover party bonus gains.
Fixed items taken back from merchants not properly checking for stacking opportunities in player inventory.
Fixed some merchant references in visitors' player object not being properly cleared when owner closes shop.
Adjusted merchants to automatically close as soon as the merchant owner finishes maintenance process with it having no items in store.
Added trade result opcodes. Trade results now should work almost as intended originally.
Implemented server-side check for portal distance when deploying player shops and merchants.
Implemented server-side check for whether local or remote IP is being used when logging in a local/remote server (this should mitigate a few of the issues people may find when trying to log in game world).
Implemented commands designed for management of opened IO sessions.
Fixed chalkboard not showing up for owner player when changing maps.
Added "time left" functionality for merchant owners managing the opened store.
Fixed skillbooks not showing properly for other players in the map.
Fixed commands using lowercased-version of content inputted by player.
Implemented the Fredrick expected fee on using the Store Bank service.
Implemented "exclusive invitation management" in the system. Inviters are notified the invited players are already managing an invite, should it be visually "in-progress" for that one.
Implemented "map ownership". Non-map owners are unable to farm in an area if they are not party members with the owner or until the ownership rescinds.
Adjusted inventory sort feature, now sorting projectile items in such a fashion that commonly stronger versions comes before the basic ones.
Added a visual effect that shows up when obtaining Aran skills.
Revised party EXP gain system. Party bonuses now accounts a fraction of the accumulated EXP gained by members when defeating a mob, and raw EXP gained by a player is kept the same regardless of him/her being in a party or not (thus a bonus being REALLY a bonus).
Implemented a custom fishing system in the source, on which during "seasonal" times (that gets arbitrarily defined by both day-of-year and time-of-day) fishes are more likely to be hooked. Such likelihood also improved depending on the amount of mesos spent as lure.
This commit is contained in:
ronancpl
2019-03-10 01:30:22 -03:00
parent 799870df63
commit 9538c415e1
86 changed files with 2992 additions and 887 deletions
+13 -6
View File
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package server.maps;
import client.MapleClient;
import client.MapleCharacter;
import constants.GameConstants;
import java.awt.Point;
import scripting.portal.PortalScriptManager;
import server.MaplePortal;
@@ -140,13 +142,18 @@ public class MapleGenericPortal implements MaplePortal {
npe.printStackTrace();
}
} else if (getTargetMapId() != 999999999) {
MapleMap to = c.getPlayer().getEventInstance() == null ? c.getChannelServer().getMapFactory().getMap(getTargetMapId()) : c.getPlayer().getEventInstance().getMapInstance(getTargetMapId());
MaplePortal pto = to.getPortal(getTarget());
if (pto == null) {// fallback for missing portals - no real life case anymore - interesting for not implemented areas
pto = to.getPortal(0);
MapleCharacter chr = c.getPlayer();
if (!(chr.getChalkboard() != null && GameConstants.isFreeMarketRoom(getTargetMapId()))) {
MapleMap to = chr.getEventInstance() == null ? c.getChannelServer().getMapFactory().getMap(getTargetMapId()) : chr.getEventInstance().getMapInstance(getTargetMapId());
MaplePortal pto = to.getPortal(getTarget());
if (pto == null) {// fallback for missing portals - no real life case anymore - interesting for not implemented areas
pto = to.getPortal(0);
}
chr.changeMap(to, pto); //late resolving makes this harder but prevents us from loading the whole world at once
changed = true;
} else {
chr.dropMessage(5, "You cannot enter this map with the chalkboard opened.");
}
c.getPlayer().changeMap(to, pto); //late resolving makes this harder but prevents us from loading the whole world at once
changed = true;
}
if (!changed) {
c.announce(MaplePacketCreator.enableActions());
+44 -14
View File
@@ -29,6 +29,7 @@ import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator;
import client.inventory.manipulator.MapleKarmaManipulator;
import client.processor.FredrickProcessor;
import com.mysql.jdbc.Statement;
import constants.ServerConstants;
import java.sql.Connection;
@@ -191,6 +192,14 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
visitorLock.unlock();
}
}
private void removeOwner(MapleCharacter owner) {
if (owner.getHiredMerchant() == this) {
owner.announce(MaplePacketCreator.hiredMerchantOwnerLeave());
owner.announce(MaplePacketCreator.leaveHiredMerchant(0x00, 0x03));
owner.setHiredMerchant(null);
}
}
public void withdrawMesos(MapleCharacter chr) {
if (isOwner(chr)) {
@@ -220,6 +229,10 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
removeFromSlot(slot);
chr.announce(MaplePacketCreator.updateHiredMerchant(this, chr));
}
if (ServerConstants.USE_ENFORCE_MERCHANT_SAVE) {
chr.saveCharToDB(false);
}
}
}
@@ -228,15 +241,17 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
}
private int getQuantityLeft(int itemid) {
int count = 0;
for (MaplePlayerShopItem mpsi : items) {
if (mpsi.getItem().getItemId() == itemid) {
count += (mpsi.getBundles() * mpsi.getItem().getQuantity());
synchronized (items) {
int count = 0;
for (MaplePlayerShopItem mpsi : items) {
if (mpsi.getItem().getItemId() == itemid) {
count += (mpsi.getBundles() * mpsi.getItem().getQuantity());
}
}
return count;
}
return count;
}
public void buy(MapleClient c, int item, short quantity) {
@@ -291,10 +306,14 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
}
}
} else {
c.getPlayer().dropMessage(1, "Your inventory is full. Please clean a slot before buying this item.");
c.getPlayer().dropMessage(1, "Your inventory is full. Please clear a slot before buying this item.");
c.announce(MaplePacketCreator.enableActions());
return;
}
} else {
c.getPlayer().dropMessage(1, "You don't have enough mesos to purchase this item.");
c.announce(MaplePacketCreator.enableActions());
return;
}
try {
this.saveItems(false);
@@ -365,17 +384,18 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
public void closeOwnerMerchant(MapleCharacter chr) {
if(this.isOwner(chr)) {
chr.announce(MaplePacketCreator.hiredMerchantOwnerLeave());
chr.announce(MaplePacketCreator.leaveHiredMerchant(0x00, 0x03));
this.closeShop(chr.getClient(), false);
chr.setHasMerchant(false);
}
}
public void closeShop(MapleClient c, boolean timeout) {
private void closeShop(MapleClient c, boolean timeout) {
map.removeMapObject(this);
map.broadcastMessage(MaplePacketCreator.removeHiredMerchantBox(ownerId));
c.getChannelServer().removeHiredMerchant(ownerId);
this.removeAllVisitors();
this.removeOwner(c.getPlayer());
try {
MapleCharacter player = c.getWorldServer().getPlayerStorage().getCharacterById(ownerId);
@@ -412,6 +432,10 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
} catch (Exception e) {
e.printStackTrace();
}
if (ServerConstants.USE_ENFORCE_MERCHANT_SAVE) {
c.getPlayer().saveCharToDB(false);
}
synchronized (items) {
items.clear();
@@ -419,7 +443,7 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
} catch (Exception e) {
e.printStackTrace();
}
Server.getInstance().getWorld(world).unregisterHiredMerchant(this);
}
@@ -611,6 +635,8 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
Connection con = DatabaseConnection.getConnection();
ItemFactory.MERCHANT.saveItems(itemsWithType, bundles, this.ownerId, con);
con.close();
FredrickProcessor.insertFredrickLog(this.ownerId);
}
private static boolean check(MapleCharacter chr, List<MaplePlayerShopItem> items) {
@@ -629,8 +655,12 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
return channel;
}
public int getTimeLeft() {
return (int) ((System.currentTimeMillis() - start) / 1000);
public int getTimeOpen() {
double openTime = (System.currentTimeMillis() - start) / 60000;
openTime /= 1440; // heuristics since engineered method to count time here is unknown
openTime *= 1318;
return (int) Math.ceil(openTime);
}
public void clearMessages() {
+95 -16
View File
@@ -31,6 +31,7 @@ import client.inventory.MapleInventoryType;
import client.inventory.MaplePet;
import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import constants.GameConstants;
import constants.ItemConstants;
import constants.ServerConstants;
import java.awt.Point;
@@ -150,6 +151,8 @@ public class MapleMap {
private Pair<Integer, String> timeMob = null;
private short mobInterval = 5000;
private boolean allowSummons = true; // All maps should have this true at the beginning
private MapleCharacter mapOwner = null;
private long mapOwnerLastActivityTime = Long.MAX_VALUE;
// HPQ
private int riceCakes = 0;
@@ -1088,6 +1091,18 @@ public class MapleMap {
mdrop.unlockItem();
}
}
public final void disappearingMesoDrop(final int meso, final MapleMapObject dropper, final MapleCharacter owner, final Point pos) {
final Point droppos = calcDropPos(pos, pos);
final MapleMapItem mdrop = new MapleMapItem(meso, droppos, dropper, owner, owner.getClient(), (byte) 1, false);
mdrop.lockItem();
try {
broadcastItemDropMessage(mdrop, dropper.getPosition(), droppos, (byte) 3, mdrop.getPosition());
} finally {
mdrop.unlockItem();
}
}
public MapleMonster getMonsterById(int id) {
objectRLock.lock();
@@ -2254,23 +2269,13 @@ public class MapleMap {
}
public MapleCharacter getAnyCharacterFromParty(int partyid) {
chrRLock.lock();
try {
Set<Integer> list = mapParty.get(partyid);
if(list == null) return null;
for(Integer cid : list) {
for (MapleCharacter c : this.characters) {
if (c.getId() == cid) {
return c;
}
}
for (MapleCharacter chr : this.getAllPlayers()) {
if (chr.getPartyId() == partyid) {
return chr;
}
return null;
} finally {
chrRLock.unlock();
}
return null;
}
private void addPartyMemberInternal(MapleCharacter chr) {
@@ -2451,6 +2456,14 @@ public class MapleMap {
chr.removeSandboxItems();
if (chr.getChalkboard() != null) {
if (!GameConstants.isFreeMarketRoom(mapid)) {
chr.announce(MaplePacketCreator.useChalkboard(chr, false)); // update player's chalkboard when changing maps found thanks to Vcoc
} else {
chr.setChalkboard(null);
}
}
if (chr.isHidden()) {
broadcastGMSpawnPlayerMapObjectMessage(chr, chr, true);
chr.announce(MaplePacketCreator.getGMEffect(0x10, (byte) 1));
@@ -2479,10 +2492,11 @@ public class MapleMap {
} finally {
objectWLock.unlock();
}
if (chr.getPlayerShop() != null) {
addMapObject(chr.getPlayerShop());
}
final MapleDragon dragon = chr.getDragon();
if (dragon != null) {
dragon.setPosition(chr.getPosition());
@@ -2557,6 +2571,19 @@ public class MapleMap {
return portal != null ? portal : getPortal(0);
}
public MaplePortal findClosestWarpPortal(Point from) {
MaplePortal closest = null;
double shortestDistance = Double.POSITIVE_INFINITY;
for (MaplePortal portal : portals.values()) {
double distance = portal.getPosition().distanceSq(from);
if (portal.getType() == MaplePortal.MAP_PORTAL && distance < shortestDistance && portal.getTargetMapId() == 999999999) {
closest = portal;
shortestDistance = distance;
}
}
return closest;
}
public MaplePortal findClosestPlayerSpawnpoint(Point from) {
MaplePortal closest = null;
double shortestDistance = Double.POSITIVE_INFINITY;
@@ -4021,6 +4048,58 @@ public class MapleMap {
}
}
public boolean claimOwnership(MapleCharacter chr) {
if (mapOwner == null) {
mapOwner = chr;
mapOwnerLastActivityTime = Server.getInstance().getCurrentTime();
getChannelServer().registerOwnedMap(this);
return true;
} else {
return chr == mapOwner;
}
}
public boolean unclaimOwnership(MapleCharacter chr) {
if (mapOwner == chr) {
mapOwner = null;
mapOwnerLastActivityTime = Long.MAX_VALUE;
getChannelServer().unregisterOwnedMap(this);
return true;
} else {
return false;
}
}
private void refreshOwnership() {
mapOwnerLastActivityTime = Server.getInstance().getCurrentTime();
}
public boolean isOwnershipRestricted(MapleCharacter chr) {
MapleCharacter owner = mapOwner;
if (owner != null) {
if (owner != chr && !owner.isPartyMember(chr)) { // thanks Vcoc & BHB for suggesting the map ownership feature
chr.showMapOwnershipInfo(owner);
return true;
} else {
this.refreshOwnership();
}
}
return false;
}
public void checkMapOwnerActivity() {
long timeNow = Server.getInstance().getCurrentTime();
if (timeNow - mapOwnerLastActivityTime > 60000) {
if (unclaimOwnership(mapOwner)) {
this.dropMessage(5, "This lawn is now free real estate.");
}
}
}
public void dispose() {
for(MapleMonster mm : this.getMonsters()) {
mm.dispose();
+2 -1
View File
@@ -146,6 +146,7 @@ public class MaplePlayerShop extends AbstractMapleMapObject {
try {
for (int i = 0; i < 3; i++) {
if (visitors[i] != null && visitors[i].getId() == visitor.getId()) {
visitors[i].setPlayerShop(null);
visitors[i] = null;
visitor.setSlot(-1);
@@ -298,7 +299,7 @@ public class MaplePlayerShop extends AbstractMapleMapObject {
}
}
} else {
c.getPlayer().dropMessage(1, "Your inventory is full. Please clean a slot before buying this item.");
c.getPlayer().dropMessage(1, "Your inventory is full. Please clear a slot before buying this item.");
c.announce(MaplePacketCreator.enableActions());
return false;
}