Compare commits

...

16 Commits

Author SHA1 Message Date
Ponk
058f034c2b Merge pull request #209 from yuzumika/minigame-npc-dispose #patch
Minigame NPC (Casey) tweaks
2024-01-03 20:13:59 +01:00
yuzumika
9c54f3a8ea minigame npc: add more disposes, fix typo 2023-12-27 15:35:45 -08:00
yuzumika
ee8cb545e1 minigame npc: use omokamount constant consistently; tiny text tweak to
make it more GMS-like
2023-12-27 15:18:22 -08:00
yuzumika
64bbff462d minigame npc: dispose after creating a set of match cards 2023-12-27 14:54:10 -08:00
Ponk
f63f7e13d4 Merge pull request #205 from yuzumika/face-hair-dedup #patch
use isFace and isHair in ItemInformationProvider.getStringData
2023-12-10 09:49:55 +01:00
yuzumika
db8666fc71 use isFace and isHair in ItemInformationProvider.getStringData 2023-11-24 01:38:34 -08:00
Ponk
93ea66e6fe Merge pull request #202 from peamy/master #patch
Bugfix: unable to complete scipted quests remotely
2023-11-10 21:11:37 +01:00
Ice Bear
7131e39c96 Merge pull request #1 from P0nk/master
Pull cosmic master into Peamy master
2023-11-10 11:40:55 +01:00
remsus
b80e9a3310 Bugfix: unable to complete scipted quests remotely 2023-11-10 00:20:52 +01:00
Ponk
03802666ef Merge pull request #190 from ormizj/character-exp-log #minor
added logs for character exp gain
2023-11-08 21:16:57 +01:00
Ponk
ecd155f2bb Merge pull request #201 from peamy/master #patch
BugFix: can't give CASH items to player (prepareInventoryItemList)
2023-11-08 20:50:50 +01:00
remsus
d6147d5191 Fix preparation of invList (CASH was skipped) in prepareInventoryItemList (AbstractPlayerInteraction) 2023-11-08 11:26:55 +01:00
ormizj
c145a53688 fixed wrong method call 2023-09-15 01:04:22 +03:00
spiderpig60
c744935dd0 changed starting server to vanilla values 2023-09-10 21:48:02 +03:00
spiderpig60
90b44c3a8b added timed thread, added batch, cleaned code
changed starting value to false
2023-09-10 21:36:52 +03:00
spiderpig60
60a44252ea added logs for character exp gain 2023-09-10 01:53:53 +03:00
9 changed files with 133 additions and 7 deletions

View File

@@ -234,6 +234,7 @@ server:
USE_STARTING_AP_4: false #Use early-GMS 4/4/4/4 starting stats. To overcome AP shortage, this gives 4AP/5AP at 1st/2nd job advancements.
USE_AUTOBAN: false #Commands the server to detect infractors automatically.
USE_AUTOBAN_LOG: true #Log autoban related messages. Still logs even with USE_AUTOBAN disabled.
USE_EXP_GAIN_LOG: false #Logs characters exp gains; logs world rate & coupon exp, total gained exp, and current exp, level can be calculated from "ExpTable".
USE_AUTOSAVE: true #Enables server autosaving feature (saves characters to DB each 1 hour).
USE_SERVER_AUTOASSIGNER: false #HeavenMS-builtin autoassigner, uses algorithm based on distributing AP accordingly with required secondary stat on equipments.
USE_REFRESH_RANK_MOVE: true

View File

@@ -21484,6 +21484,17 @@ CREATE TABLE IF NOT EXISTS `worldtransfers` (
INDEX (characterid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `characterexplogs` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`world_exp_rate` INT,
`exp_coupon` INT,
`gained_exp` BIGINT,
`current_exp` INT,
`exp_gain_time` DATETIME,
`charid` int(11) NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`charid`) REFERENCES `characters`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
ALTER TABLE `dueyitems`
ADD CONSTRAINT `dueyitems_ibfk_1` FOREIGN KEY (`PackageId`) REFERENCES `dueypackages` (`PackageId`) ON DELETE CASCADE;

View File

@@ -31,7 +31,7 @@ function action(mode, type, selection) {
}
if (status == 0) {
cm.sendSimple("Hey, you look like you need a breather. You should be enjoying the life, just like I am. Well, if you have a couple of items, I can trade you for an item you can play minigames with. Now... what can I do for you?#b\r\n#L0#Create a minigame item#l\r\n#L1#Explain to me what the minigames are about#l#k");
cm.sendSimple("Hey, you look like you need a breather from all that hunting. You should be enjoying the life, just like I am. Well, if you have a couple of items, I can trade you for an item you can play minigames with. Now... what can I do for you?#b\r\n#L0#Create a minigame item#l\r\n#L1#Explain to me what the minigames are about#l#k");
} else if (status == 1) {
if (selection == 0) {
@@ -57,6 +57,7 @@ function action(mode, type, selection) {
if (cm.haveItem(4030012, 15)) {
cm.gainItem(4030012, -15);
cm.gainItem(4080100, 1);
cm.dispose();
} else {
cm.sendNext("You want #bA set of Match Cards#k? Hmm...to make A set of Match Cards, you'll need some #bMonster Cards#k. Monster Card can be obtained by taking out the monsters all around the island. Collect 15 Monster Cards and you can make a set of A set of Match Cards."); //Lmfao a set of A set xD
cm.dispose();
@@ -81,7 +82,7 @@ function action(mode, type, selection) {
if (current == 1 || current == 2) {
cm.sendNextPrev("Enter the room, and when you're ready to play, click on #bReady#k.\r\nOnce the visitor clicks on #bReady#k, the room owner can press #bStart#k to begin the game. If an unwanted visitor walks in, and you don't want to play with that person, the room owner has the right to kick the visitor out of the room. There will be a square box with x written on the right of that person. Click on that for a cold goodbye, okay?"); //Oh yeah, because people WALK in Omok Rooms.
} else if (current == 3) {
if (cm.haveItem(omok1piece[selection], 99) && cm.haveItem(omok2piece[selection], 99) && cm.haveItem(4030009, 1)) {
if (cm.haveItem(omok1piece[selection], omokamount) && cm.haveItem(omok2piece[selection], omokamount) && cm.haveItem(4030009, 1)) {
cm.gainItem(omok1piece[selection], -omokamount);
cm.gainItem(omok2piece[selection], -omokamount);
cm.gainItem(4030009, -1);
@@ -95,7 +96,7 @@ function action(mode, type, selection) {
} else if (status == 5) {
if (current == 1) {
cm.sendNextPrev("When the first fame starts, #bthe room owner goes first#k. Beward that you'll be given a time limit, and you may lose your turn if you don't make your move on time. Normally, 3 x 3 is not allowed, but if there comes a point that it's absolutely necessary to put your piece there or face ending the game, then you can put it there. 3 x 3 is allowed as the last line of defense! Oh, and it won't count if it's #r6 or 7 straight#k. Only 5!");
cm.sendNextPrev("When the first game starts, #bthe room owner goes first#k. Beward that you'll be given a time limit, and you may lose your turn if you don't make your move on time. Normally, 3 x 3 is not allowed, but if there comes a point that it's absolutely necessary to put your piece there or face ending the game, then you can put it there. 3 x 3 is allowed as the last line of defense! Oh, and it won't count if it's #r6 or 7 straight#k. Only 5!");
} else if (current == 2) {
cm.sendNextPrev("Oh, and unlike Omok, when you create the game room for Match Cards, you'll need to set your game on the number of cards you'll use for the game. There are 3 modes avaliable, 3x4, 4x5, and 5x6, which will require 12, 20, and 30 cards respectively. Remember that you won't beable to change it up once the room is open, so if you really wish to change it up, you may have to close the room and open another one.");
}
@@ -110,12 +111,14 @@ function action(mode, type, selection) {
} else if (status == 7) {
if (current == 1) {
cm.sendPrev("When the next game starts, the loser will go first. Also, no one is allowed to leave in the middle of a game. If you do, you may need to request either a #bforfeit or tie#k. (Of course, if you request a forfeit, you'll lose the game.) And if you click on 'Leave' in the middle of the game and call to leave after the game, you'll leave the room right after the game is over. This will be a much more useful way to leave.");
cm.dispose();
} else if (current == 2) {
cm.sendNextPrev("If you and your opponent have the same number of matched pairs, then whoever had a longer streak of matched pairs will win. If you ever feel the need to go to the bathroom, or take an extended break, you can request a #btie#k. The game will end in a tie if the opponent accepts the request. Tip: this may be a good way to keep your friendships in tact.");
}
} else if (status == 8) {
if (current == 2) {
cm.sendPrev("When the next game starts, the loser will go first. Also, no one is allowed to leave in the middle of a game. If you do, you may need to request either a #bforfeit or tie#k. (Of course, if you request a forfeit, you'll lose the game.) And if you click on 'Leave' in the middle of the game and call to leave after the game, you'll leave the room right after the game is over. This will be a much more useful way to leave.");
cm.dispose();
}
}
}

View File

@@ -59,6 +59,7 @@ import scripting.AbstractPlayerInteraction;
import scripting.event.EventInstanceManager;
import scripting.item.ItemScriptManager;
import server.*;
import server.ExpLogger.ExpLogRecord;
import server.ItemInformationProvider.ScriptedItem;
import server.events.Events;
import server.events.RescueGaga;
@@ -150,6 +151,7 @@ public class Character extends AbstractCharacterObject {
private final AtomicInteger gachaexp = new AtomicInteger();
private final AtomicInteger meso = new AtomicInteger();
private final AtomicInteger chair = new AtomicInteger(-1);
private long totalExpGained = 0;
private int merchantmeso;
private BuddyList buddylist;
private EventInstanceManager eventInstance = null;
@@ -3092,6 +3094,7 @@ public class Character extends AbstractCharacterObject {
leftover = nextExp - Integer.MAX_VALUE;
}
updateSingleStat(Stat.EXP, exp.addAndGet((int) total));
totalExpGained += total;
if (show) {
announceExpGain(gain, equip, party, inChat, white);
}
@@ -3108,6 +3111,20 @@ public class Character extends AbstractCharacterObject {
gainExpInternal(leftover, equip, party, false, inChat, white);
} else {
lastExpGainTime = System.currentTimeMillis();
if (YamlConfig.config.server.USE_EXP_GAIN_LOG) {
ExpLogRecord expLogRecord = new ExpLogger.ExpLogRecord(
getWorldServer().getExpRate(),
expCoupon,
totalExpGained,
exp.get(),
new Timestamp(lastExpGainTime),
id
);
ExpLogger.putExpLogRecord(expLogRecord);
}
totalExpGained = 0;
}
}
}

View File

@@ -82,6 +82,7 @@ public class ServerConfig {
public boolean USE_STARTING_AP_4;
public boolean USE_AUTOBAN;
public boolean USE_AUTOBAN_LOG;
public boolean USE_EXP_GAIN_LOG;
public boolean USE_AUTOSAVE;
public boolean USE_SERVER_AUTOASSIGNER;
public boolean USE_REFRESH_RANK_MOVE;

View File

@@ -291,7 +291,7 @@ public class AbstractPlayerInteraction {
int size = Math.min(itemids.size(), quantity.size());
List<List<Pair<Integer, Integer>>> invList = new ArrayList<>(6);
for (int i = InventoryType.UNDEFINED.getType(); i < InventoryType.CASH.getType(); i++) {
for (int i = InventoryType.UNDEFINED.getType(); i <= InventoryType.CASH.getType(); i++) {
invList.add(new LinkedList<>());
}

View File

@@ -107,7 +107,7 @@ public class QuestScriptManager extends AbstractScriptManager {
public void end(Client c, short questid, int npc) {
Quest quest = Quest.getInstance(questid);
if (!c.getPlayer().getQuest(quest).getStatus().equals(QuestStatus.Status.STARTED) || !c.getPlayer().getMap().containsNPC(npc)) {
if (!c.getPlayer().getQuest(quest).getStatus().equals(QuestStatus.Status.STARTED) || (!c.getPlayer().getMap().containsNPC(npc) && !quest.isAutoComplete())) {
dispose(c);
return;
}

View File

@@ -0,0 +1,93 @@
package server;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.sql.Timestamp;
import static java.util.concurrent.TimeUnit.*;
import config.YamlConfig;
import tools.DatabaseConnection;
public class ExpLogger {
private static final LinkedBlockingQueue<ExpLogRecord> expLoggerQueue = new LinkedBlockingQueue<>();
private static final short EXP_LOGGER_THREAD_SLEEP_DURATION_SECONDS = 60;
private static final short EXP_LOGGER_THREAD_SHUTDOWN_WAIT_DURATION_MINUTES = 5;
public record ExpLogRecord(int worldExpRate, int expCoupon, long gainedExp, int currentExp,Timestamp expGainTime, int charid) {}
public static void putExpLogRecord(ExpLogRecord expLogRecord) {
try {
expLoggerQueue.put(expLogRecord);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
static private ScheduledExecutorService schdExctr = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setPriority(Thread.MIN_PRIORITY);
return t;
}
});
private static Runnable saveExpLoggerToDBRunnable = new Runnable() {
@Override
public void run() {
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO characterexplogs (world_exp_rate, exp_coupon, gained_exp, current_exp, exp_gain_time, charid) VALUES (?, ?, ?, ?, ?, ?)")) {
List<ExpLogRecord> drainedExpLogs = new ArrayList<>();
expLoggerQueue.drainTo(drainedExpLogs);
for (ExpLogRecord expLogRecord : drainedExpLogs) {
ps.setInt(1, expLogRecord.worldExpRate);
ps.setInt(2, expLogRecord.expCoupon);
ps.setLong(3, expLogRecord.gainedExp);
ps.setInt(4, expLogRecord.currentExp);
ps.setTimestamp(5, expLogRecord.expGainTime);
ps.setInt(6, expLogRecord.charid);
ps.addBatch();
}
ps.executeBatch();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
};
private static void startExpLogger() {
schdExctr.scheduleWithFixedDelay(saveExpLoggerToDBRunnable, EXP_LOGGER_THREAD_SLEEP_DURATION_SECONDS, EXP_LOGGER_THREAD_SLEEP_DURATION_SECONDS, SECONDS);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
stopExpLogger();
}));
}
private static boolean stopExpLogger() {
schdExctr.shutdown();
try {
schdExctr.awaitTermination(EXP_LOGGER_THREAD_SHUTDOWN_WAIT_DURATION_MINUTES, MINUTES);
Thread runThreadBeforeShutdown = new Thread(saveExpLoggerToDBRunnable);
runThreadBeforeShutdown.setPriority(Thread.MIN_PRIORITY);
runThreadBeforeShutdown.start();
return true;
} catch (InterruptedException e) {
e.printStackTrace();
return false;
}
}
static {
if (YamlConfig.config.server.USE_EXP_GAIN_LOG) {
startExpLogger();
}
}
}

View File

@@ -204,13 +204,13 @@ public class ItemInformationProvider {
} else if (itemId >= 1040000 && itemId < 1050000) {
theData = eqpStringData;
cat = "Eqp/Coat";
} else if (itemId >= 20000 && itemId < 22000) {
} else if (ItemConstants.isFace(itemId)) {
theData = eqpStringData;
cat = "Eqp/Face";
} else if (itemId >= 1080000 && itemId < 1090000) {
theData = eqpStringData;
cat = "Eqp/Glove";
} else if (itemId >= 30000 && itemId < 35000) {
} else if (ItemConstants.isHair(itemId)) {
theData = eqpStringData;
cat = "Eqp/Hair";
} else if (itemId >= 1050000 && itemId < 1060000) {