From 938b078592843ffe1256d16c1243c96a1b13de56 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Sat, 28 Mar 2020 18:05:04 -0500 Subject: [PATCH] Added new player commands --- .../plugin/command/PlayerCommandPlugin.java | 120 +++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/Server/src/plugin/command/PlayerCommandPlugin.java b/Server/src/plugin/command/PlayerCommandPlugin.java index b8190196f..079ca4ca0 100644 --- a/Server/src/plugin/command/PlayerCommandPlugin.java +++ b/Server/src/plugin/command/PlayerCommandPlugin.java @@ -1,26 +1,43 @@ package plugin.command; import org.crandor.ServerConstants; +import org.crandor.cache.def.impl.ItemDefinition; +import org.crandor.cache.def.impl.NPCDefinition; import org.crandor.game.component.Component; +import org.crandor.game.content.skill.Skills; +import org.crandor.game.interaction.SpecialGroundInteraction; +import org.crandor.game.interaction.SpecialGroundItems; +import org.crandor.game.node.entity.npc.NPC; +import org.crandor.game.node.entity.npc.drop.NPCDropTables; import org.crandor.game.node.entity.player.Player; import org.crandor.game.node.entity.player.info.Rights; import org.crandor.game.node.entity.player.link.IronmanMode; import org.crandor.game.node.entity.player.link.RunScript; import org.crandor.game.node.entity.player.link.quest.Quest; import org.crandor.game.node.entity.player.link.quest.QuestRepository; +import org.crandor.game.node.item.ChanceItem; import org.crandor.game.system.command.CommandPlugin; import org.crandor.game.system.command.CommandSet; import org.crandor.game.system.communication.ClanRepository; import org.crandor.game.system.communication.CommunicationInfo; +import org.crandor.game.system.mysql.SQLManager; import org.crandor.game.world.GameWorld; +import org.crandor.game.world.map.RegionManager; import org.crandor.game.world.repository.Repository; +import org.crandor.game.world.update.flag.context.Animation; import org.crandor.net.amsc.WorldCommunicator; import org.crandor.plugin.InitializablePlugin; import org.crandor.plugin.Plugin; +import org.crandor.tools.RandomFunction; import org.crandor.tools.StringUtils; import plugin.zone.GrandExchangeZone.CreditStore; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Random; + /** * Handles a player command. * @author Vexia @@ -194,7 +211,20 @@ public final class PlayerCommandPlugin extends CommandPlugin { case "donate": sendDonationInfo(player); return true; - + case "roll": + rollSkill(player); + return true; + case "drops": + if(arguments.length > 0) { + int npcid = toInteger(arguments[1]); + getDrops(player, npcid); + } else { + player.getPacketDispatch().sendMessage("Syntax: ::getdrops id"); + } + return true; + case "npcs": + getNPCs(player); + return true; case "reply": if(player.getInterfaceManager().isOpened()){ player.sendMessage("Please finish what you're doing first."); @@ -220,6 +250,89 @@ public final class PlayerCommandPlugin extends CommandPlugin { return false; } + /** + * ::npcs lists NPCs in the area and their IDs + * @author ceik + */ + public final void getNPCs(Player player){ + player.getInterfaceManager().close(); + final List npcs = RegionManager.getLocalNpcs(player); + for (int i = 0; i < 311; i++) { + player.getPacketDispatch().sendString("", 275, i); + } + player.getPacketDispatch().sendString("Nearby NPCs", 275, 2); + int lineid = 11; + for(NPC n : npcs){ + player.getPacketDispatch().sendString("[" + n.getId() + "] " + "" + n.getName() + "",275,lineid++); + } + player.getInterfaceManager().open(new Component(275)); + } + + /** + * ::drops lists the drops for a specific NPC ID + * @author ceik + */ + public final void getDrops(Player player, int npc){ + player.getInterfaceManager().close(); + for (int i = 0; i < 311; i++) { + player.getPacketDispatch().sendString("", 275, i); + } + int lineid = 11; + List drops = NPCDefinition.forId(npc).getDropTables().getMainTable(); + ListIterator drop = drops.listIterator(); + player.getPacketDispatch().sendString("" + NPCDefinition.forId(npc).getName() + " (Level " + NPCDefinition.forId(npc).getCombatLevel() + ")", 275, 2); + while(drop.hasNext()){ + ChanceItem current = (ChanceItem) drop.next(); + String rarity = ""; + switch(current.getDropFrequency()){ + case UNCOMMON: + rarity = "UNCOMMON"; + break; + case RARE: + rarity = "RARE"; + break; + case VERY_RARE: + rarity = "VERY RARE"; + break; + case COMMON: + rarity = "COMMON"; + break; + + } + player.getPacketDispatch().sendString("(" + rarity + ") " + ((current.getMinimumAmount() - current.getMaximumAmount() != 0) ? (current.getMinimumAmount() + "-" + current.getMaximumAmount()) : "") + " " +ItemDefinition.forId(current.getId()).getName() + "", 275, lineid++); + } + player.getInterfaceManager().open(new Component(275)); + } + + /** + * ::roll command + * @author ceik + */ + public final void rollSkill(Player player){ + boolean rareEventChance = RandomFunction.random(100) == 54; + if(rareEventChance){ + int rareChoice = RandomFunction.random(2,5); + if(rareChoice % 5 == 0){ + player.sendChat("Oh god! Somebody help me!"); + player.getAnimator().reset(); + player.getAnimator().forceAnimation(new Animation(3123)); + return; + } + if(rareChoice % 2 == 0){ + player.sendChat("Yibbly jibbly dibbly nibbly doo dah"); + return; + } + if(rareChoice % 3 == 0){ + player.sendChat("Oh god! Somebody help me!"); + player.getAnimator().reset(); + player.getAnimator().forceAnimation(new Animation(92)); + return; + } + } + int skill = RandomFunction.random(0,23); + player.sendChat("I think I should train " + Skills.SKILL_NAME[skill]); + } + /** * Sends commands. * @param player the player. @@ -253,6 +366,11 @@ public final class PlayerCommandPlugin extends CommandPlugin { player.getPacketDispatch().sendString("Remove your bank pin.", 275, lineId++); player.getPacketDispatch().sendString("::bankresettabs", 275, lineId++); player.getPacketDispatch().sendString("Reset all of your bank tabs.", 275, lineId++); + player.getPacketDispatch().sendString("::stats", 275, lineId++); + player.getPacketDispatch().sendString("View a player's stats.", 275, lineId++); + player.getPacketDispatch().sendString("::roll", 275, lineId++); + player.getPacketDispatch().sendString("Picks a skill to train for you, and perhaps more?", 275, lineId++); + } /**