Skip to content

Commit

Permalink
Remove fishing
Browse files Browse the repository at this point in the history
  • Loading branch information
MarloDelatorre committed Aug 24, 2024
1 parent 6fe45da commit c974d86
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 338 deletions.
2 changes: 0 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ worlds:
drop_rate: 10
boss_drop_rate: 10 #NOTE: Boss drop rate OVERRIDES common drop rate, for bosses-only.
quest_rate: 5 #Multiplier for Exp & Meso gains when completing a quest. Only available when USE_QUEST_RATE is true. Stacks with server Exp & Meso rates.
fishing_rate: 10 #Multiplier for success likelihood on meso thrown during fishing.
travel_rate: 10 #Means of transportation rides/departs using 1/N of the default time.

#Properties for Bera 1
Expand Down Expand Up @@ -251,7 +250,6 @@ server:
USE_ENABLE_FULL_RESPAWN: false #At respawn task, always respawn missing mobs when they're available. Spawn count doesn't depend on how many players are currently there.
USE_ENABLE_CHAT_LOG: false #Write in-game chat to log
USE_MAP_OWNERSHIP_SYSTEM: false #Flag to enable/disable map ownership system
USE_FISHING_SYSTEM: false #Flag to enable/disable custom fishing system
USE_NPCS_SCRIPTABLE: true #Flag to enable/disable serverside predefined script NPCs.

#Events/PQs Configuration
Expand Down
2 changes: 0 additions & 2 deletions scripts/npc/9977777.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ function writeFeatureTab_Serverpotentials() {
addFeature("Poison damage value visible for other players.");
addFeature("M. book announcer displays info based on demand.");
addFeature("Custom jail system.");
addFeature("Custom fishing system having 'seasonal' catch times.");
addFeature("Actual fishing handling w/ F. Net - thanks Dragohe4rt!");
addFeature("Custom map leasing system.");
addFeature("Delete Character.");
addFeature("Smooth view-all-char, now showing all account chars.");
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/client/Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -6180,13 +6180,6 @@ public boolean isGuildLeader() { // true on guild master or jr. master
return guildid > 0 && guildRank < 3;
}

public boolean attemptCatchFish(int baitLevel) {
return YamlConfig.config.server.USE_FISHING_SYSTEM && MapId.isFishingArea(mapid) &&
this.getPosition().getY() > 0 &&
ItemConstants.isFishingChair(chair.get()) &&
this.getWorldServer().registerFisherPlayer(this, baitLevel);
}

public void leaveMap() {
releaseControlledMonsters();
visibleMapObjects.clear();
Expand Down Expand Up @@ -7517,10 +7510,6 @@ private void playerDead() {
private void unsitChairInternal() {
int chairid = chair.get();
if (chairid >= 0) {
if (ItemConstants.isFishingChair(chairid)) {
this.getWorldServer().unregisterFisherPlayer(this);
}

setChair(-1);
if (unregisterChairBuff()) {
getMap().broadcastMessage(this, PacketCreator.cancelForeignChairSkillEffect(this.getId()), false);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/config/ServerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public class ServerConfig {
public boolean USE_ENABLE_FULL_RESPAWN;
public boolean USE_ENABLE_CHAT_LOG;
public boolean USE_MAP_OWNERSHIP_SYSTEM;
public boolean USE_FISHING_SYSTEM;
public boolean USE_NPCS_SCRIPTABLE;

//Events/PQs Configuration
Expand Down
1 change: 0 additions & 1 deletion src/main/java/config/WorldConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ public class WorldConfig {
public int boss_drop_rate = 1;
public int quest_rate = 1;
public int travel_rate = 1;
public int fishing_rate = 1;
}
3 changes: 1 addition & 2 deletions src/main/java/constants/id/ItemId.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class ItemId {
public static final int PENDANT_OF_THE_SPIRIT = 1122017;
public static final int HEART_SHAPED_CHOCOLATE = 5110000;
public static final int HAPPY_BIRTHDAY = 2022153;
public static final int FISHING_CHAIR = 3011000;
public static final int MINI_GAME_BASE = 4080000;
public static final int MATCH_CARDS = 4080100;
public static final int MAGICAL_MITTEN = 1472063;
Expand Down Expand Up @@ -60,7 +59,7 @@ public static boolean isDojoBuff(int itemId) {
// Chair
public static final int RELAXER = 3010000;
private static final int CHAIR_MIN = RELAXER;
private static final int CHAIR_MAX = FISHING_CHAIR;
private static final int CHAIR_MAX = 3011000;

public static boolean isChair(int itemId) {
return itemId >= CHAIR_MIN && itemId <= CHAIR_MAX;
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/constants/id/MapId.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,6 @@ public static boolean isNettsPyramid(int mapId) {
return mapId >= NETTS_PYRAMID_MIN && mapId <= NETTS_PYRAMID_MAX;
}

// Fishing
private static final int ON_THE_WAY_TO_THE_HARBOR = 120010000;
private static final int PIER_ON_THE_BEACH = 251000100;
private static final int PEACEFUL_SHIP = 541010110;

public static boolean isFishingArea(int mapId) {
return mapId == ON_THE_WAY_TO_THE_HARBOR || mapId == PIER_ON_THE_BEACH || mapId == PEACEFUL_SHIP;
}

// Wedding
public static final int AMORIA = 680000000;
public static final int CHAPEL_WEDDING_ALTAR = 680000110;
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/constants/inventory/ItemConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ public static boolean isEquipment(int itemId) {
return itemId < 2000000 && itemId != 0;
}

public static boolean isFishingChair(int itemId) {
return itemId == ItemId.FISHING_CHAIR;
}

public static boolean isMedal(int itemId) {
return itemId >= 1140000 && itemId < 1143000;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ private int initWorld() {
int bossdroprate = YamlConfig.config.worlds.get(i).boss_drop_rate;
int questrate = YamlConfig.config.worlds.get(i).quest_rate;
int travelrate = YamlConfig.config.worlds.get(i).travel_rate;
int fishingrate = YamlConfig.config.worlds.get(i).fishing_rate;

int flag = YamlConfig.config.worlds.get(i).flag;
String event_message = YamlConfig.config.worlds.get(i).event_message;
Expand All @@ -440,7 +439,7 @@ private int initWorld() {
World world = new World(i,
flag,
event_message,
exprate, droprate, bossdroprate, mesorate, questrate, travelrate, fishingrate);
exprate, droprate, bossdroprate, mesorate, questrate, travelrate);

Map<Integer, String> channelInfo = new HashMap<>();
long bootTime = getCurrentTime();
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/net/server/channel/handlers/MesoDropHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ public final void handlePacket(InPacket p, Client c) {
return;
}

if (player.attemptCatchFish(meso)) {
player.getMap().disappearingMesoDrop(meso, player, player, player.getPosition());
} else {
player.getMap().spawnMesoDrop(meso, player.getPosition(), player, player, true, (byte) 2,
(short) 0);
}
player.getMap().spawnMesoDrop(
meso,
player.getPosition(),
player,
player,
true,
(byte) 2,
(short) 0
);
}
}
37 changes: 0 additions & 37 deletions src/main/java/net/server/task/FishingTask.java

This file was deleted.

60 changes: 1 addition & 59 deletions src/main/java/net/server/world/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import net.server.task.CharacterAutosaverTask;
import net.server.task.CharacterHpDecreaseTask;
import net.server.task.FamilyDailyResetTask;
import net.server.task.FishingTask;
import net.server.task.HiredMerchantTask;
import net.server.task.MapOwnershipTask;
import net.server.task.MountTirednessTask;
Expand All @@ -74,7 +73,6 @@
import tools.DatabaseConnection;
import tools.PacketCreator;
import tools.Pair;
import tools.packets.Fishing;

import java.sql.Connection;
import java.sql.PreparedStatement;
Expand Down Expand Up @@ -125,7 +123,6 @@ public class World {
private int mesorate;
private int questrate;
private int travelrate;
private int fishingrate;
private final String eventmsg;
private final List<Channel> channels = new ArrayList<>();
private final Map<Integer, Byte> pnpcStep = new HashMap<>();
Expand Down Expand Up @@ -189,18 +186,16 @@ public class World {
private ScheduledFuture<?> timedMapObjectsSchedule;
private Lock timedMapObjectLock = new ReentrantLock(true);

private final Map<Character, Integer> fishingAttempters = Collections.synchronizedMap(new WeakHashMap<>());
private Map<Character, Integer> playerHpDec = Collections.synchronizedMap(new WeakHashMap<>());

private ScheduledFuture<?> charactersSchedule;
private ScheduledFuture<?> marriagesSchedule;
private ScheduledFuture<?> mapOwnershipSchedule;
private ScheduledFuture<?> fishingSchedule;
private ScheduledFuture<?> partySearchSchedule;
private ScheduledFuture<?> timeoutSchedule;
private ScheduledFuture<?> hpDecSchedule;

public World(int world, int flag, String eventmsg, int exprate, int droprate, int bossdroprate, int mesorate, int questrate, int travelrate, int fishingrate) {
public World(int world, int flag, String eventmsg, int exprate, int droprate, int bossdroprate, int mesorate, int questrate, int travelrate) {
this.id = world;
this.flag = flag;
this.eventmsg = eventmsg;
Expand All @@ -210,7 +205,6 @@ public World(int world, int flag, String eventmsg, int exprate, int droprate, in
this.mesorate = mesorate;
this.questrate = questrate;
this.travelrate = travelrate;
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);

Expand Down Expand Up @@ -238,7 +232,6 @@ public World(int world, int flag, String eventmsg, int exprate, int droprate, in
charactersSchedule = tman.register(new CharacterAutosaverTask(this), HOURS.toMillis(1), HOURS.toMillis(1));
marriagesSchedule = tman.register(new WeddingReservationTask(this), MINUTES.toMillis(YamlConfig.config.server.WEDDING_RESERVATION_INTERVAL), MINUTES.toMillis(YamlConfig.config.server.WEDDING_RESERVATION_INTERVAL));
mapOwnershipSchedule = tman.register(new MapOwnershipTask(this), SECONDS.toMillis(20), SECONDS.toMillis(20));
fishingSchedule = tman.register(new FishingTask(this), SECONDS.toMillis(10), SECONDS.toMillis(10));
partySearchSchedule = tman.register(new PartySearchTask(this), SECONDS.toMillis(10), SECONDS.toMillis(10));
timeoutSchedule = tman.register(new TimeoutTask(this), SECONDS.toMillis(10), SECONDS.toMillis(10));
hpDecSchedule = tman.register(new CharacterHpDecreaseTask(this), YamlConfig.config.server.MAP_DAMAGE_OVERTIME_INTERVAL, YamlConfig.config.server.MAP_DAMAGE_OVERTIME_INTERVAL);
Expand Down Expand Up @@ -450,14 +443,6 @@ public int getTransportationTime(int travelTime) {
return (int) Math.ceil((double) travelTime / travelrate);
}

public int getFishingRate() {
return fishingrate;
}

public void setFishingRate(int quest) {
this.fishingrate = quest;
}

public void loadAccountCharactersView(Integer accountId, List<Character> chars) {
SortedMap<Integer, Character> charsMap = new TreeMap<>();
for (Character chr : chars) {
Expand Down Expand Up @@ -2082,44 +2067,6 @@ public void dropMessage(int type, String message) {
}
}

public boolean registerFisherPlayer(Character chr, int baitLevel) {
synchronized (fishingAttempters) {
if (fishingAttempters.containsKey(chr)) {
return false;
}

fishingAttempters.put(chr, baitLevel);
return true;
}
}

public int unregisterFisherPlayer(Character 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<Character> fishingAttemptersList;

synchronized (fishingAttempters) {
fishingAttemptersList = new ArrayList<>(fishingAttempters.keySet());
}

for (Character chr : fishingAttemptersList) {
int baitLevel = unregisterFisherPlayer(chr);
Fishing.doFishing(chr, baitLevel, yearLikelihood, timeLikelihood);
}
}
}

public void runPartySearchUpdateSchedule() {
partySearch.updatePartySearchStorage();
partySearch.runPartySearch();
Expand Down Expand Up @@ -2190,11 +2137,6 @@ public final void shutdown() {
mapOwnershipSchedule = null;
}

if (fishingSchedule != null) {
fishingSchedule.cancel(false);
fishingSchedule = null;
}

if (partySearchSchedule != null) {
partySearchSchedule.cancel(false);
partySearchSchedule = null;
Expand Down
Loading

0 comments on commit c974d86

Please sign in to comment.