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:
@@ -55,6 +55,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import scripting.event.EventInstanceManager;
|
||||
@@ -65,7 +66,9 @@ import server.maps.MaplePlayerShop;
|
||||
import server.maps.MaplePlayerShopItem;
|
||||
import server.maps.AbstractMapleMapObject;
|
||||
import net.server.worker.CharacterAutosaverWorker;
|
||||
import net.server.worker.FishingWorker;
|
||||
import net.server.worker.HiredMerchantWorker;
|
||||
import net.server.worker.MapOwnershipWorker;
|
||||
import net.server.worker.MountTirednessWorker;
|
||||
import net.server.worker.PetFullnessWorker;
|
||||
import net.server.worker.ServerMessageWorker;
|
||||
@@ -86,6 +89,10 @@ import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantLock;
|
||||
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import net.server.coordinator.MapleInviteCoordinator;
|
||||
import net.server.coordinator.MapleInviteCoordinator.InviteResult;
|
||||
import net.server.coordinator.MapleInviteCoordinator.InviteType;
|
||||
import tools.packets.Fishing;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -94,7 +101,7 @@ import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
*/
|
||||
public class World {
|
||||
|
||||
private int id, flag, exprate, droprate, bossdroprate, mesorate, questrate, travelrate;
|
||||
private int id, flag, exprate, droprate, bossdroprate, mesorate, questrate, travelrate, fishingrate;
|
||||
private String eventmsg;
|
||||
private List<Channel> channels = new ArrayList<>();
|
||||
private Map<Integer, Byte> pnpcStep = new HashMap<>();
|
||||
@@ -155,10 +162,14 @@ public class World {
|
||||
private ScheduledFuture<?> timedMapObjectsSchedule;
|
||||
private MonitoredReentrantLock timedMapObjectLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.WORLD_MAPOBJS, true);
|
||||
|
||||
private Map<MapleCharacter, Integer> fishingAttempters = Collections.synchronizedMap(new WeakHashMap<MapleCharacter, Integer>());
|
||||
|
||||
private ScheduledFuture<?> charactersSchedule;
|
||||
private ScheduledFuture<?> marriagesSchedule;
|
||||
private ScheduledFuture<?> mapOwnershipSchedule;
|
||||
private ScheduledFuture<?> fishingSchedule;
|
||||
|
||||
public World(int world, int flag, String eventmsg, int exprate, int droprate, int bossdroprate, int mesorate, int questrate, int travelrate) {
|
||||
public World(int world, int flag, String eventmsg, int exprate, int droprate, int bossdroprate, int mesorate, int questrate, int travelrate, int fishingrate) {
|
||||
this.id = world;
|
||||
this.flag = flag;
|
||||
this.eventmsg = eventmsg;
|
||||
@@ -168,7 +179,8 @@ public class World {
|
||||
this.mesorate = mesorate;
|
||||
this.questrate = questrate;
|
||||
this.travelrate = travelrate;
|
||||
runningPartyId.set(1);
|
||||
this.fishingrate = fishingrate;
|
||||
runningPartyId.set(1000000001); // partyid must not clash with charid to solve update item looting issues, found thanks to Vcoc
|
||||
runningMessengerId.set(1);
|
||||
|
||||
petUpdate = Server.getInstance().getCurrentTime();
|
||||
@@ -186,6 +198,8 @@ public class World {
|
||||
timedMapObjectsSchedule = tman.register(new TimedMapObjectWorker(this), 60 * 1000, 60 * 1000);
|
||||
charactersSchedule = tman.register(new CharacterAutosaverWorker(this), 60 * 60 * 1000, 60 * 60 * 1000);
|
||||
marriagesSchedule = tman.register(new WeddingReservationWorker(this), ServerConstants.WEDDING_RESERVATION_INTERVAL * 60 * 1000, ServerConstants.WEDDING_RESERVATION_INTERVAL * 60 * 1000);
|
||||
mapOwnershipSchedule = tman.register(new MapOwnershipWorker(this), 20 * 1000, 20 * 1000);
|
||||
fishingSchedule = tman.register(new FishingWorker(this), 10 * 1000, 10 * 1000);
|
||||
|
||||
}
|
||||
|
||||
@@ -362,14 +376,22 @@ public class World {
|
||||
return travelrate;
|
||||
}
|
||||
|
||||
public void setTravelRate(int quest) {
|
||||
this.travelrate = quest;
|
||||
public void setTravelRate(int travel) {
|
||||
this.travelrate = travel;
|
||||
}
|
||||
|
||||
public int getTransportationTime(int travelTime) {
|
||||
return (int) Math.ceil(travelTime / travelrate);
|
||||
}
|
||||
|
||||
public int getFishingRate() {
|
||||
return fishingrate;
|
||||
}
|
||||
|
||||
public void setFishingRate(int quest) {
|
||||
this.fishingrate = quest;
|
||||
}
|
||||
|
||||
public void loadAccountCharactersView(Integer accountId, List<MapleCharacter> chars) {
|
||||
SortedMap<Integer, MapleCharacter> charsMap = new TreeMap<>();
|
||||
for(MapleCharacter chr : chars) {
|
||||
@@ -985,14 +1007,23 @@ public class World {
|
||||
|
||||
public void messengerInvite(String sender, int messengerid, String target, int fromchannel) {
|
||||
if (isConnected(target)) {
|
||||
MapleMessenger messenger = getPlayerStorage().getCharacterByName(target).getMessenger();
|
||||
if (messenger == null) {
|
||||
getPlayerStorage().getCharacterByName(target).getClient().announce(MaplePacketCreator.messengerInvite(sender, messengerid));
|
||||
MapleCharacter from = getChannel(fromchannel).getPlayerStorage().getCharacterByName(sender);
|
||||
from.getClient().announce(MaplePacketCreator.messengerNote(target, 4, 1));
|
||||
} else {
|
||||
MapleCharacter from = getChannel(fromchannel).getPlayerStorage().getCharacterByName(sender);
|
||||
from.getClient().announce(MaplePacketCreator.messengerChat(sender + " : " + target + " is already using Maple Messenger"));
|
||||
MapleCharacter targetChr = getPlayerStorage().getCharacterByName(target);
|
||||
if (targetChr != null) {
|
||||
MapleMessenger messenger = targetChr.getMessenger();
|
||||
if (messenger == null) {
|
||||
MapleCharacter from = getChannel(fromchannel).getPlayerStorage().getCharacterByName(sender);
|
||||
if (from != null) {
|
||||
if (MapleInviteCoordinator.createInvite(InviteType.MESSENGER, from, messengerid, targetChr.getId())) {
|
||||
targetChr.getClient().announce(MaplePacketCreator.messengerInvite(sender, messengerid));
|
||||
from.getClient().announce(MaplePacketCreator.messengerNote(target, 4, 1));
|
||||
} else {
|
||||
from.announce(MaplePacketCreator.messengerChat(sender + " : " + target + " is already managing a Maple Messenger invitation"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MapleCharacter from = getChannel(fromchannel).getPlayerStorage().getCharacterByName(sender);
|
||||
from.getClient().announce(MaplePacketCreator.messengerChat(sender + " : " + target + " is already using Maple Messenger"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1043,11 +1074,13 @@ public class World {
|
||||
}
|
||||
}
|
||||
|
||||
public void declineChat(String target, String namefrom) {
|
||||
if (isConnected(target)) {
|
||||
MapleCharacter chr = getPlayerStorage().getCharacterByName(target);
|
||||
if (chr != null && chr.getMessenger() != null) {
|
||||
chr.getClient().announce(MaplePacketCreator.messengerNote(namefrom, 5, 0));
|
||||
public void declineChat(String sender, MapleCharacter player) {
|
||||
if (isConnected(sender)) {
|
||||
MapleCharacter senderChr = getPlayerStorage().getCharacterByName(sender);
|
||||
if (senderChr != null && senderChr.getMessenger() != null) {
|
||||
if (MapleInviteCoordinator.answerInvite(InviteType.MESSENGER, player.getId(), senderChr.getMessenger().getId(), false).getLeft() == InviteResult.DENIED) {
|
||||
senderChr.getClient().announce(MaplePacketCreator.messengerNote(player.getName(), 5, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1890,6 +1923,44 @@ public class World {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean registerFisherPlayer(MapleCharacter chr, int baitLevel) {
|
||||
synchronized (fishingAttempters) {
|
||||
if (fishingAttempters.containsKey(chr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fishingAttempters.put(chr, baitLevel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public int unregisterFisherPlayer(MapleCharacter chr) {
|
||||
Integer baitLevel = fishingAttempters.remove(chr);
|
||||
if (baitLevel != null) {
|
||||
return baitLevel;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void runCheckFishingSchedule() {
|
||||
double[] fishingLikelihoods = Fishing.fetchFishingLikelihood();
|
||||
double yearLikelihood = fishingLikelihoods[0], timeLikelihood = fishingLikelihoods[1];
|
||||
|
||||
if (!fishingAttempters.isEmpty()) {
|
||||
List<MapleCharacter> fishingAttemptersList;
|
||||
|
||||
synchronized (fishingAttempters) {
|
||||
fishingAttemptersList = new ArrayList<>(fishingAttempters.keySet());
|
||||
}
|
||||
|
||||
for (MapleCharacter chr : fishingAttemptersList) {
|
||||
int baitLevel = unregisterFisherPlayer(chr);
|
||||
Fishing.doFishing(chr, baitLevel, yearLikelihood, timeLikelihood);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clearWorldData() {
|
||||
List<MapleParty> pList;
|
||||
partyLock.lock();
|
||||
@@ -1966,6 +2037,16 @@ public class World {
|
||||
marriagesSchedule = null;
|
||||
}
|
||||
|
||||
if(mapOwnershipSchedule != null) {
|
||||
mapOwnershipSchedule.cancel(false);
|
||||
mapOwnershipSchedule = null;
|
||||
}
|
||||
|
||||
if(fishingSchedule != null) {
|
||||
fishingSchedule.cancel(false);
|
||||
fishingSchedule = null;
|
||||
}
|
||||
|
||||
players.disconnectAll();
|
||||
players = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user