Rewrite Mo NPC script to be GMS-like

This commit is contained in:
P0nk
2023-03-29 19:54:59 +02:00
parent 290bf78db3
commit ec1450cec1
3 changed files with 102 additions and 8 deletions

View File

@@ -36,6 +36,8 @@ import net.server.Server;
import net.server.guild.Guild;
import net.server.world.Party;
import net.server.world.PartyCharacter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scripting.event.EventInstanceManager;
import scripting.event.EventManager;
import scripting.npc.NPCScriptManager;
@@ -61,6 +63,7 @@ import java.util.*;
import static java.util.concurrent.TimeUnit.DAYS;
public class AbstractPlayerInteraction {
private static final Logger log = LoggerFactory.getLogger(AbstractPlayerInteraction.class);
public Client c;
@@ -68,6 +71,10 @@ public class AbstractPlayerInteraction {
this.c = c;
}
public void log(String message) {
log.info(message);
}
public Client getClient() {
return c;
}
@@ -1207,4 +1214,4 @@ public class AbstractPlayerInteraction {
private void sendBlueNotice(MapleMap map, String message) {
map.dropMessage(6, message);
}
}
}

View File

@@ -272,10 +272,23 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
return getPlayer().getMeso();
}
// TODO: refactor scripts to use this instead of "getMeso() < amount"
public boolean hasMeso(int amount) {
return getMeso() >= amount;
}
public void gainMeso(int gain) {
getPlayer().gainMeso(gain);
}
// TODO: refactor scripts to use this instead of "gainMeso(-amount)"
public void loseMeso(int loss) {
if (loss < 0) {
throw new IllegalArgumentException("Can only lose positive amount of mesos");
}
gainMeso(-loss);
}
public void gainExp(int gain) {
getPlayer().gainExp(gain, true, true);
}