forked from 2009Scape/Server
Merge pull request #7 from dginovker/pestcontrol
Pest control bots are now beautiful
This commit is contained in:
commit
c01e89ef59
11 changed files with 397 additions and 198 deletions
|
|
@ -17,9 +17,11 @@ import org.crandor.game.node.entity.npc.NPC;
|
|||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.entity.player.info.PlayerDetails;
|
||||
import org.crandor.game.node.item.Item;
|
||||
import org.crandor.game.world.map.Direction;
|
||||
import org.crandor.game.world.map.Location;
|
||||
import org.crandor.game.world.map.RegionManager;
|
||||
import org.crandor.game.world.map.path.Pathfinder;
|
||||
import org.crandor.net.packet.in.InteractionPacket;
|
||||
import org.crandor.plugin.Plugin;
|
||||
import org.crandor.tools.RandomFunction;
|
||||
import org.crandor.tools.StringUtils;
|
||||
|
|
@ -128,13 +130,23 @@ public class AIPlayer extends Player {
|
|||
}
|
||||
}, "movement");
|
||||
}
|
||||
|
||||
|
||||
public void randomWalkAroundPoint(Location point, int radius)
|
||||
{
|
||||
Pathfinder.find(this, point.transform(RandomFunction.random(radius, (radius * -1)), RandomFunction.random(radius, (radius * -1)), 0), true, Pathfinder.SMART).walk(this);
|
||||
}
|
||||
|
||||
public void randomWalk(int radiusX, int radiusY)
|
||||
{
|
||||
Pathfinder.find(this, this.getLocation().transform(RandomFunction.random(radiusX, (radiusX * -1)), RandomFunction.random(radiusY, (radiusY * -1)), 0), false, Pathfinder.SMART).walk(this);
|
||||
}
|
||||
|
||||
protected void walkToPosSmart(Location loc) {
|
||||
public void walkToPosSmart(int x, int y)
|
||||
{
|
||||
walkToPosSmart(new Location(x, y));
|
||||
}
|
||||
|
||||
public void walkToPosSmart(Location loc) {
|
||||
Pathfinder.find(this, loc, true, Pathfinder.SMART).walk(this);
|
||||
}
|
||||
|
||||
|
|
@ -172,6 +184,10 @@ public class AIPlayer extends Player {
|
|||
//int meX2 = this.getLocation().getX();
|
||||
//System.out.println("local " + meX + " real x? " + meX2 );
|
||||
ArrayList<Node> nodes = new ArrayList<Node>();
|
||||
for (NPC npc : RegionManager.getLocalNpcs(this, range)) {
|
||||
if (npc.getId() == entry)
|
||||
nodes.add(npc);
|
||||
}
|
||||
for (int x = 0; x < range; x++)
|
||||
{
|
||||
for (int y = 0; y < range - x; y++)
|
||||
|
|
@ -204,6 +220,10 @@ public class AIPlayer extends Player {
|
|||
//int meX2 = this.getLocation().getX();
|
||||
//System.out.println("local " + meX + " real x? " + meX2 );
|
||||
ArrayList<Node> nodes = new ArrayList<Node>();
|
||||
for (NPC npc : RegionManager.getLocalNpcs(this, range)) {
|
||||
if (entrys.contains(npc.getId()))
|
||||
nodes.add(npc);
|
||||
}
|
||||
for (int x = 0; x < range; x++)
|
||||
{
|
||||
for (int y = 0; y < range - x; y++)
|
||||
|
|
@ -229,6 +249,18 @@ public class AIPlayer extends Player {
|
|||
return nodes;
|
||||
}
|
||||
|
||||
public Node getClosestNodeWithEntryAndDirection(int range, int entry, Direction direction)
|
||||
{
|
||||
ArrayList<Node> nodeList = getNodeInRange(range, entry);
|
||||
if (nodeList.isEmpty())
|
||||
{
|
||||
//System.out.println("nodelist empty");
|
||||
return null;
|
||||
}
|
||||
Node node = getClosestNodeinNodeListWithDirection(nodeList, direction);
|
||||
return node;
|
||||
}
|
||||
|
||||
public Node getClosestNodeWithEntry(int range, int entry)
|
||||
{
|
||||
ArrayList<Node> nodeList = getNodeInRange(range, entry);
|
||||
|
|
@ -296,6 +328,28 @@ public class AIPlayer extends Player {
|
|||
return npcReturn;
|
||||
}
|
||||
|
||||
private Node getClosestNodeinNodeListWithDirection(ArrayList<Node> nodes, Direction direction)
|
||||
{
|
||||
if (nodes.isEmpty())
|
||||
{
|
||||
//System.out.println("nodelist empty");
|
||||
return null;
|
||||
}
|
||||
|
||||
double distance = 0;
|
||||
Node nodeReturn = null;
|
||||
for (Node node : nodes)
|
||||
{
|
||||
double nodeDistance = this.getLocation().getDistance(node.getLocation());
|
||||
if ((nodeReturn == null || nodeDistance < distance) && node.getDirection() == direction)
|
||||
{
|
||||
distance = nodeDistance;
|
||||
nodeReturn = node;
|
||||
}
|
||||
}
|
||||
return nodeReturn;
|
||||
}
|
||||
|
||||
private Node getClosestNodeinNodeList(ArrayList<Node> nodes)
|
||||
{
|
||||
if (nodes.isEmpty())
|
||||
|
|
@ -391,4 +445,10 @@ public class AIPlayer extends Player {
|
|||
public void setControler(Player controler) {
|
||||
this.controler = controler;
|
||||
}
|
||||
|
||||
|
||||
public void interact(Node n)
|
||||
{
|
||||
InteractionPacket.handleObjectInteraction(this, 0, n.getLocation(), n.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
package org.crandor.game.node.entity.player.ai.minigamebots.pestcontrol;
|
||||
|
||||
import org.crandor.game.content.skill.Skills;
|
||||
import org.crandor.game.node.Node;
|
||||
import org.crandor.game.node.entity.player.link.prayer.PrayerType;
|
||||
import org.crandor.game.world.map.Direction;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static plugin.activity.pestcontrol.PestControlHelper.*;
|
||||
|
||||
public class CombatState {
|
||||
private PestControlTestBot bot;
|
||||
private Random Random = new Random(); //Ya idc if that's bad java, it's killing me right now lmfao
|
||||
|
||||
public CombatState(PestControlTestBot pestControlTestBot) {
|
||||
this.bot = pestControlTestBot;
|
||||
}
|
||||
|
||||
public void goToPortals() {
|
||||
bot.setCustomState("I'm at portals.");
|
||||
Node gate = bot.getClosestNodeWithEntry(75, GATE_ENTRIES);
|
||||
Node portal = bot.getClosestNodeWithEntry(75, PORTAL_ENTRIES);
|
||||
if (bot.justStartedGame && new Random().nextInt(2) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (bot.justStartedGame || gate == null && portal == null)
|
||||
{
|
||||
bot.setCustomState("Walking randomly");
|
||||
bot.justStartedGame = false;
|
||||
bot.randomWalkAroundPoint(getMyPestControlSession(bot).getSquire().getLocation(), 15);
|
||||
bot.movetimer = new Random().nextInt(7) + 6;
|
||||
return;
|
||||
}
|
||||
if (gate != null)
|
||||
{
|
||||
bot.setCustomState("Interacting gate ID " + gate.getId());
|
||||
bot.interact(gate);
|
||||
bot.openedGate = true;
|
||||
if (Random.nextInt(4) == 1 && bot.randomType < 40)
|
||||
{
|
||||
bot.movetimer = Random.nextInt(2) + 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (portal != null)
|
||||
{
|
||||
bot.setCustomState("Walking to portals");
|
||||
bot.randomWalkAroundPoint(portal.getLocation(), 5);
|
||||
bot.movetimer = new Random().nextInt(5) + 5;
|
||||
}
|
||||
bot.setCustomState("Absolutely nothing. Everything is dead");
|
||||
}
|
||||
|
||||
public void fightNPCs() {
|
||||
bot.setCustomState("Fight NPCs");
|
||||
//Npc Combat
|
||||
if (bot.tick == 0)
|
||||
{
|
||||
if (!bot.inCombat())
|
||||
bot.AttackNpcsInRadius(15);
|
||||
bot.tick = 10;
|
||||
}
|
||||
else
|
||||
bot.tick--;
|
||||
|
||||
bot.eat(379);
|
||||
bot.getSkills().setLevel(Skills.PRAYER, 99);
|
||||
bot.getSkills().setStaticLevel(Skills.PRAYER, 99);
|
||||
if (!(bot.getPrayer().getActive().contains(PrayerType.PROTECT_FROM_MELEE)))
|
||||
bot.getPrayer().toggle(PrayerType.PROTECT_FROM_MELEE);
|
||||
|
||||
if (!bot.inCombat())
|
||||
{
|
||||
if (bot.combatMoveTimer <= 0)
|
||||
{
|
||||
if (bot.FindTargets(bot, 5) == null)
|
||||
bot.randomWalk(5, 5);
|
||||
bot.combatMoveTimer = 5;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void goToEastPortals() {
|
||||
bot.setCustomState("Go to east portals");
|
||||
|
||||
Node easternGate = bot.getClosestNodeWithEntryAndDirection(75, 14233, Direction.SOUTH);
|
||||
Node easternPortal = getMyPestControlSession(bot).getPortals()[1];
|
||||
if (easternGate != null)
|
||||
{
|
||||
bot.interact(easternGate);
|
||||
} else if (easternPortal != null ){
|
||||
bot.walkToPosSmart(easternPortal.getLocation());
|
||||
} else {
|
||||
bot.setCustomState("Everything is null!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +1,34 @@
|
|||
package org.crandor.game.node.entity.player.ai.minigamebots;
|
||||
package org.crandor.game.node.entity.player.ai.minigamebots.pestcontrol;
|
||||
|
||||
import org.crandor.game.content.skill.Skills;
|
||||
import org.crandor.game.node.Node;
|
||||
import org.crandor.game.node.entity.Entity;
|
||||
import org.crandor.game.node.entity.player.ai.pvmbots.PvMBots;
|
||||
import org.crandor.game.node.entity.player.link.prayer.*;
|
||||
import org.crandor.game.world.map.Location;
|
||||
import org.crandor.net.packet.in.InteractionPacket;
|
||||
import org.crandor.tools.RandomFunction;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static plugin.activity.pestcontrol.PestControlHelper.*;
|
||||
|
||||
public class PestControlTestBot extends PvMBots {
|
||||
|
||||
private int tick = 0;
|
||||
private int combatMoveTimer = 0;
|
||||
private int movetimer = 0;
|
||||
public int tick = 0;
|
||||
public int combatMoveTimer = 0;
|
||||
public boolean justStartedGame = true;
|
||||
public int movetimer = 0;
|
||||
|
||||
private int randomType;
|
||||
public int randomType;
|
||||
public boolean openedGate;
|
||||
private BoatInfo myBoat = BoatInfo.NOVICE;
|
||||
|
||||
private CombatState combathandler = new CombatState(this);
|
||||
|
||||
enum State {
|
||||
OUTSIDE_GANGPLANK,
|
||||
WAITING_IN_BOAT,
|
||||
NPC_COMBAT,
|
||||
PLAY_GAME,
|
||||
GET_TO_PC
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +51,7 @@ public class PestControlTestBot extends PvMBots {
|
|||
{
|
||||
movetimer = 0;
|
||||
State state = getState();
|
||||
this.setCustomState(String.valueOf(state));
|
||||
this.setCustomState(String.valueOf(state) + movetimer);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
|
|
@ -60,7 +64,7 @@ public class PestControlTestBot extends PvMBots {
|
|||
case WAITING_IN_BOAT:
|
||||
idleInBoat();
|
||||
break;
|
||||
case NPC_COMBAT:
|
||||
case PLAY_GAME:
|
||||
attackNPCs();
|
||||
break;
|
||||
}
|
||||
|
|
@ -74,7 +78,7 @@ public class PestControlTestBot extends PvMBots {
|
|||
}
|
||||
if (isInPestControlInstance(this))
|
||||
{
|
||||
return State.NPC_COMBAT;
|
||||
return State.PLAY_GAME;
|
||||
}
|
||||
if (outsideGangplankContainsLoc(this.getLocation()))
|
||||
{
|
||||
|
|
@ -84,41 +88,46 @@ public class PestControlTestBot extends PvMBots {
|
|||
}
|
||||
|
||||
private void attackNPCs() {
|
||||
List<Entity> creatures = FindTargets(this, 15);
|
||||
if (creatures == null || creatures.isEmpty())
|
||||
{
|
||||
if (randomType > 15)
|
||||
{
|
||||
this.setCustomState("Going to portals");
|
||||
combathandler.goToPortals();
|
||||
} else {
|
||||
randomWalkAroundPoint(getMyPestControlSession(this).getSquire().getLocation(), 3);
|
||||
movetimer = new Random().nextInt(15) + 6;
|
||||
}
|
||||
} else {
|
||||
if (randomType < 15 && new Random().nextInt(5) == 0)
|
||||
{
|
||||
randomWalkAroundPoint(getMyPestControlSession(this).getSquire().getLocation(), 3);
|
||||
movetimer = new Random().nextInt(15) + 6;
|
||||
} else {
|
||||
this.setCustomState("Fighting NPCs");
|
||||
combathandler.fightNPCs();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (randomType < 20)
|
||||
{
|
||||
this.getUpdateMasks().register(new ChatFlag(new ChatMessage(this, "Meee", 0, 0)));
|
||||
}
|
||||
Node test = getClosestNodeWithEntry(5, GATE_ENTRIES);
|
||||
if (!this.inCombat() && test != null) {
|
||||
InteractionPacket.handleObjectInteraction(this, 0, test.getLocation(), test.getId());
|
||||
}
|
||||
|
||||
//Npc Combat
|
||||
if (tick == 0)
|
||||
{
|
||||
if (!this.inCombat())
|
||||
AttackNpcsInRadius(this, 15);
|
||||
this.tick = 10;
|
||||
}
|
||||
else
|
||||
this.tick--;
|
||||
|
||||
this.eat(379);
|
||||
this.getSkills().setLevel(Skills.PRAYER, 99);
|
||||
this.getSkills().setStaticLevel(Skills.PRAYER, 99);
|
||||
if (!(this.getPrayer().getActive().contains(PrayerType.PROTECT_FROM_MELEE)))
|
||||
this.getPrayer().toggle(PrayerType.PROTECT_FROM_MELEE);
|
||||
|
||||
if (!this.inCombat())
|
||||
{
|
||||
if (combatMoveTimer <= 0)
|
||||
{
|
||||
if (this.FindTargets(this, 5) == null)
|
||||
this.randomWalk(5, 5);
|
||||
this.combatMoveTimer = 5;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private int insideBoatWalks = 3;
|
||||
private void idleInBoat() {
|
||||
if (randomType < 15) //He's the type of guy to walk around the boat
|
||||
justStartedGame = true;
|
||||
openedGate = false;
|
||||
if (randomType < 35) //He's the type of guy to walk around the boat
|
||||
{
|
||||
if (new Random().nextInt(insideBoatWalks) <= 1)
|
||||
{
|
||||
|
|
@ -142,22 +151,19 @@ public class PestControlTestBot extends PvMBots {
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (randomType > 20 && new Random().nextInt(4) == 0) //Idle outside ladder
|
||||
if (new Random().nextInt(5) == 1) //Missclick the ladder
|
||||
{
|
||||
movetimer = new Random().nextInt(2);
|
||||
this.walkToPosSmart(myBoat.outsideBoatBorder.getWeightedRandomLoc(2));
|
||||
}
|
||||
if (randomType > 20 && new Random().nextInt(6) == 0) //Idle outside ladder
|
||||
{
|
||||
if (new Random().nextInt(16) == 0)
|
||||
{
|
||||
this.walkToPosSmart(myBoat.outsideBoatBorder.getRandomLoc());
|
||||
movetimer += RandomFunction.normalPlusWeightRandDist(400, 200);
|
||||
//System.out.println("Rare movetimer set on " + this.getName());
|
||||
}
|
||||
movetimer = RandomFunction.normalPlusWeightRandDist(100, 50);
|
||||
//System.out.println("Set movetimer to " + movetimer + " on " + this.getName());
|
||||
return;
|
||||
}
|
||||
if (randomType < 60 && new Random().nextInt(6) == 1) //Missclick the ladder
|
||||
{
|
||||
movetimer = new Random().nextInt(2);
|
||||
this.walkToPosSmart(myBoat.outsideBoatBorder.getWeightedRandomLoc(3));
|
||||
return;
|
||||
}
|
||||
Node test = getClosestNodeWithEntry(15, myBoat.ladderId);
|
||||
|
|
@ -56,21 +56,35 @@ public class PvMBots extends AIPlayer {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void AttackNpcsInRadius(Player bot, int radius) {
|
||||
public boolean AttackNpcsInRadius(int radius)
|
||||
{
|
||||
return AttackNpcsInRadius(this, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attacks NPCs in radius of bot
|
||||
* @param bot
|
||||
* @param radius
|
||||
* @return true if bot will be fighting
|
||||
*/
|
||||
public boolean AttackNpcsInRadius(Player bot, int radius) {
|
||||
if (bot.inCombat())
|
||||
return;
|
||||
return true;
|
||||
List<Entity> creatures = FindTargets(bot, radius);
|
||||
if (creatures == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (!(creatures.isEmpty())) {
|
||||
bot.attack(creatures.get(RandomFunction.getRandom((creatures.size() - 1))));
|
||||
return;
|
||||
return true;
|
||||
} else {
|
||||
creatures = FindTargets(bot, radius);
|
||||
if (!creatures.isEmpty())
|
||||
{
|
||||
bot.attack(creatures.get(RandomFunction.getRandom((creatures.size() - 1))));
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.crandor.game.container.impl.EquipmentContainer;
|
|||
import org.crandor.game.content.skill.Skills;
|
||||
import org.crandor.game.node.entity.combat.CombatSpell;
|
||||
import org.crandor.game.node.entity.player.ai.AIPlayer;
|
||||
import org.crandor.game.node.entity.player.ai.minigamebots.PestControlTestBot;
|
||||
import org.crandor.game.node.entity.player.ai.minigamebots.pestcontrol.PestControlTestBot;
|
||||
import org.crandor.game.node.entity.player.link.SpellBookManager;
|
||||
import org.crandor.game.node.entity.player.link.appearance.Gender;
|
||||
import org.crandor.game.node.item.Item;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.crandor.game.world.map.zone;
|
||||
|
||||
import org.crandor.game.node.Node;
|
||||
import org.crandor.game.node.entity.player.ai.minigamebots.pestcontrol.PestControlTestBot;
|
||||
import org.crandor.game.world.map.Location;
|
||||
import org.crandor.tools.RandomFunction;
|
||||
|
||||
|
|
@ -257,4 +258,8 @@ public final class ZoneBorders {
|
|||
public void setPlane(int plane) {
|
||||
this.plane = plane;
|
||||
}
|
||||
|
||||
public boolean insideRegion(Node n) {
|
||||
return insideBorder(n.getLocation().getRegionX(), n.getLocation().getRegionY());
|
||||
}
|
||||
}
|
||||
|
|
@ -97,6 +97,16 @@ public final class PCPortalNPC extends AbstractNPC {
|
|||
*/
|
||||
private NPC[] brawlers = new NPC[2];
|
||||
|
||||
|
||||
/**
|
||||
* The portal ids?
|
||||
*/
|
||||
final static Integer[] portalIds = new Integer[] { 6142, 6143, 6144, 6145, 6146, 6147, 6148, 6149,
|
||||
|
||||
6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157,
|
||||
|
||||
7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558 };
|
||||
|
||||
/**
|
||||
* Constructs a new {@code PCPortalNPC} {@code Object}.
|
||||
*/
|
||||
|
|
@ -282,9 +292,9 @@ public final class PCPortalNPC extends AbstractNPC {
|
|||
public int[] getIds() {
|
||||
return new int[] { 6142, 6143, 6144, 6145, 6146, 6147, 6148, 6149,
|
||||
|
||||
6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157,
|
||||
6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157,
|
||||
|
||||
7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558 };
|
||||
7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558 };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -314,5 +324,4 @@ public final class PCPortalNPC extends AbstractNPC {
|
|||
}
|
||||
return (getId() - 6142) % 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -78,9 +78,9 @@ public final class PestControlActivityPlugin extends ActivityPlugin {
|
|||
ticks++;
|
||||
if (waitingPlayers.size() >= MAX_TEAM_SIZE && ticks < 475)
|
||||
{
|
||||
ticks = 485;
|
||||
ticks = 495;
|
||||
}
|
||||
if ((ticks < 450 && ticks % 100 == 0) || (ticks % 50 == 0) || ticks == 485) {
|
||||
if ((ticks < 450 && ticks % 100 == 0) || (ticks % 50 == 0) || ticks == 495) {
|
||||
for (Player p : waitingPlayers) {
|
||||
updateTime(p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class PestControlHelper {
|
|||
}
|
||||
|
||||
public static List<Integer> GATE_ENTRIES = Arrays.asList(14233, 14235);
|
||||
public static List<Integer> PORTAL_ENTRIES = Arrays.asList(PCPortalNPC.portalIds);
|
||||
|
||||
public static final Location PestControlIslandLocation = Location.create(2659, 2649, 0);
|
||||
|
||||
|
|
@ -49,6 +50,10 @@ public class PestControlHelper {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
public static PestControlSession getMyPestControlSession(Player p)
|
||||
{
|
||||
return p.getExtension(PestControlSession.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public final class PestControlSession {
|
|||
/**
|
||||
* The object ids of non-attackable barricades/gates.
|
||||
*/
|
||||
public static final int[] INVALID_OBJECT_IDS = { 14230, 14231, 14232, // Barricades
|
||||
public static final int[] INVALID_OBJECT_IDS = {14230, 14231, 14232, // Barricades
|
||||
14245, 14246, 14247, 14248, // Gates
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,153 +38,153 @@ public final class PlayerCommandPlugin extends CommandPlugin {
|
|||
public boolean parse(Player player, String name, String[] arguments) {
|
||||
switch (name) {
|
||||
|
||||
case "shutdowninterface":
|
||||
player.getInterfaceManager().close();
|
||||
break;
|
||||
case "shutdowninterface":
|
||||
player.getInterfaceManager().close();
|
||||
break;
|
||||
|
||||
case "tut":
|
||||
int stage = Integer.parseInt(arguments[1]);
|
||||
TutorialStage.load(player, stage, false);
|
||||
break;
|
||||
|
||||
case "resettabs":
|
||||
for (int i = 0; i < player.getBank().getTabStartSlot().length; i++) {
|
||||
player.getBank().getTabStartSlot()[i] = 0;
|
||||
}
|
||||
player.getBank().setTabIndex(10);
|
||||
if (player.getBank().isOpen()) {
|
||||
player.getInterfaceManager().close();
|
||||
}
|
||||
player.getPacketDispatch().sendMessage("Bank tabs are reset!");
|
||||
return true;
|
||||
case "resetpin":
|
||||
if (arguments.length < 2) {
|
||||
player.sendMessage("Syntax error: ::resetpin oldpin");
|
||||
return true;
|
||||
}
|
||||
String oldPin = arguments[1];
|
||||
if (oldPin == null) {
|
||||
return true;
|
||||
}
|
||||
if (!player.getBankPinManager().hasPin()) {
|
||||
player.sendMessage("You don't have a pin.");
|
||||
return true;
|
||||
}
|
||||
if (!oldPin.equals(player.getBankPinManager().getPin())) {
|
||||
player.sendMessage("Your old pin doesn't match your current pin.");
|
||||
return true;
|
||||
}
|
||||
player.getBankPinManager().setPin(null);
|
||||
player.sendMessage("Your pin has been reset.");
|
||||
return true;
|
||||
case "bank":// The players want OSRS content, let's give it to em
|
||||
if (!player.isAdmin()) {
|
||||
player.sendChat("Hey, everyone, I just tried to do something very silly!");
|
||||
}
|
||||
break;
|
||||
case "players":
|
||||
int count = Repository.getPlayers().size();
|
||||
int ironCount = 1;
|
||||
int ultIronCount = 0;
|
||||
for (Player p : Repository.getPlayers()) {
|
||||
if (p.getIronmanManager().checkRestriction(IronmanMode.ULTIMATE)) {
|
||||
ultIronCount++;
|
||||
|
||||
case "resettabs":
|
||||
for (int i = 0; i < player.getBank().getTabStartSlot().length; i++) {
|
||||
player.getBank().getTabStartSlot()[i] = 0;
|
||||
}
|
||||
if (p.getIronmanManager().checkRestriction(IronmanMode.STANDARD)) {
|
||||
ironCount++;
|
||||
player.getBank().setTabIndex(10);
|
||||
if (player.getBank().isOpen()) {
|
||||
player.getInterfaceManager().close();
|
||||
}
|
||||
}
|
||||
int regular = count - ironCount - ultIronCount;
|
||||
if (count == 1) {
|
||||
player.getPacketDispatch().sendMessage("There is 1 active player in this world.");
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("There are " + count + " active players in this world: " + regular + " regular, " + ironCount + " iron, and " + ultIronCount + " ultimate iron.");
|
||||
}
|
||||
return player.getRights() == Rights.REGULAR_PLAYER;
|
||||
case "yell":
|
||||
if (!player.isDonator() && !player.isAdmin()) {
|
||||
player.getPacketDispatch().sendMessages("Join clan chat \"" + GameWorld.getName() + "\" to talk globally, or become a donator to have access to", "this benefit.");
|
||||
player.getPacketDispatch().sendMessage("Bank tabs are reset!");
|
||||
return true;
|
||||
}
|
||||
if (player.getDetails().isMuted()) {
|
||||
player.getPacketDispatch().sendMessage("You have been " + (player.getDetails().isPermMute() ? "permanently" : "temporarily") + " muted due to breaking a rule.");
|
||||
return true;
|
||||
}
|
||||
if(WorldCommunicator.isEnabled()){
|
||||
if(ClanRepository.getDefault().isBanned(player.getName())){
|
||||
player.sendMessages("You are temporarily unable to yell as you are banned from the main clan chat.", "Don't be annoying!");
|
||||
case "resetpin":
|
||||
if (arguments.length < 2) {
|
||||
player.sendMessage("Syntax error: ::resetpin oldpin");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (player.getAttribute("yell-delay", 0.0) > GameWorld.getTicks()) {
|
||||
player.sendMessages("You have yelled in the last " + player.getDonatorType().getCooldown() + " seconds. Upgrade to an extreme donator to have", "unlimited yelling abilities.");
|
||||
return true;
|
||||
}
|
||||
String text = getArgumentLine(arguments);
|
||||
if(text.contains("<img=") || text.contains("<br>") || text.contains("<col=") || text.contains("<shad=")){
|
||||
player.sendMessage("Bad! No images/text effects allowed in yell chat.");
|
||||
return true;
|
||||
}
|
||||
if(text.contains("aq p")){
|
||||
return true;
|
||||
}
|
||||
int length = text.length();
|
||||
if (length > 100) {
|
||||
length = 100;
|
||||
}
|
||||
if (text.length() >= 2) {
|
||||
if (Character.isLowerCase(text.charAt(0))) {
|
||||
text = Character.toUpperCase(text.charAt(0)) + text.substring(1, length);
|
||||
String oldPin = arguments[1];
|
||||
if (oldPin == null) {
|
||||
return true;
|
||||
}
|
||||
text = getYellPrefix(player) + text + "</col>";
|
||||
if (!player.getBankPinManager().hasPin()) {
|
||||
player.sendMessage("You don't have a pin.");
|
||||
return true;
|
||||
}
|
||||
if (!oldPin.equals(player.getBankPinManager().getPin())) {
|
||||
player.sendMessage("Your old pin doesn't match your current pin.");
|
||||
return true;
|
||||
}
|
||||
player.getBankPinManager().setPin(null);
|
||||
player.sendMessage("Your pin has been reset.");
|
||||
return true;
|
||||
case "bank":// The players want OSRS content, let's give it to em
|
||||
if (!player.isAdmin()) {
|
||||
player.sendChat("Hey, everyone, I just tried to do something very silly!");
|
||||
}
|
||||
break;
|
||||
case "players":
|
||||
int count = Repository.getPlayers().size();
|
||||
int ironCount = 1;
|
||||
int ultIronCount = 0;
|
||||
for (Player p : Repository.getPlayers()) {
|
||||
if (p.isActive()) {
|
||||
p.getPacketDispatch().sendMessage(text);
|
||||
if (p.getIronmanManager().checkRestriction(IronmanMode.ULTIMATE)) {
|
||||
ultIronCount++;
|
||||
}
|
||||
if (p.getIronmanManager().checkRestriction(IronmanMode.STANDARD)) {
|
||||
ironCount++;
|
||||
}
|
||||
}
|
||||
if (player.getDonatorType().getCooldown() > 0 && !player.isStaff()) {
|
||||
player.setAttribute("yell-delay", (int) GameWorld.getTicks() + (player.getDonatorType().getCooldown() / 0.6));
|
||||
int regular = count - ironCount - ultIronCount;
|
||||
if (count == 1) {
|
||||
player.getPacketDispatch().sendMessage("There is 1 active player in this world.");
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("There are " + count + " active players in this world: " + regular + " regular, " + ironCount + " iron, and " + ultIronCount + " ultimate iron.");
|
||||
}
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("Your message was too short.");
|
||||
}
|
||||
return true;
|
||||
case "togglenews":
|
||||
player.getSavedData().getGlobalData().setDisableNews(!player.getSavedData().getGlobalData().isDisableNews());
|
||||
player.sendMessage("<col=FF0000>" + (player.getSavedData().getGlobalData().isDisableNews() ? "You will no longer see news notifications." : "You will now see news notifications."));
|
||||
return true;
|
||||
case "commands":
|
||||
case "command":
|
||||
case "commandlist":
|
||||
sendCommands(player);
|
||||
return true;
|
||||
case "quests":
|
||||
sendQuests(player);
|
||||
return true;
|
||||
case "donate":
|
||||
sendDonationInfo(player);
|
||||
return true;
|
||||
case "reply":
|
||||
if(player.getInterfaceManager().isOpened()){
|
||||
player.sendMessage("Please finish what you're doing first.");
|
||||
return true;
|
||||
}
|
||||
if (player.getAttributes().containsKey("replyTo")) {
|
||||
player.setAttribute("keepDialogueAlive", true);
|
||||
final String replyTo = (String) player.getAttribute("replyTo", "").replaceAll("_", " ");
|
||||
player.setAttribute("runscript", new RunScript() {
|
||||
@Override
|
||||
public boolean handle() {
|
||||
CommunicationInfo.sendMessage(player, replyTo.toLowerCase(), (String) getValue());
|
||||
player.removeAttribute("keepDialogueAlive");
|
||||
return player.getRights() == Rights.REGULAR_PLAYER;
|
||||
case "yell":
|
||||
if (!player.isDonator() && !player.isAdmin()) {
|
||||
player.getPacketDispatch().sendMessages("Join clan chat \"" + GameWorld.getName() + "\" to talk globally, or become a donator to have access to", "this benefit.");
|
||||
return true;
|
||||
}
|
||||
if (player.getDetails().isMuted()) {
|
||||
player.getPacketDispatch().sendMessage("You have been " + (player.getDetails().isPermMute() ? "permanently" : "temporarily") + " muted due to breaking a rule.");
|
||||
return true;
|
||||
}
|
||||
if(WorldCommunicator.isEnabled()){
|
||||
if(ClanRepository.getDefault().isBanned(player.getName())){
|
||||
player.sendMessages("You are temporarily unable to yell as you are banned from the main clan chat.", "Don't be annoying!");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
player.getDialogueInterpreter().sendMessageInput(StringUtils.formatDisplayName(replyTo));
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("You have not recieved any recent messages to which you can reply.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (player.getAttribute("yell-delay", 0.0) > GameWorld.getTicks()) {
|
||||
player.sendMessages("You have yelled in the last " + player.getDonatorType().getCooldown() + " seconds. Upgrade to an extreme donator to have", "unlimited yelling abilities.");
|
||||
return true;
|
||||
}
|
||||
String text = getArgumentLine(arguments);
|
||||
if(text.contains("<img=") || text.contains("<br>") || text.contains("<col=") || text.contains("<shad=")){
|
||||
player.sendMessage("Bad! No images/text effects allowed in yell chat.");
|
||||
return true;
|
||||
}
|
||||
if(text.contains("aq p")){
|
||||
return true;
|
||||
}
|
||||
int length = text.length();
|
||||
if (length > 100) {
|
||||
length = 100;
|
||||
}
|
||||
if (text.length() >= 2) {
|
||||
if (Character.isLowerCase(text.charAt(0))) {
|
||||
text = Character.toUpperCase(text.charAt(0)) + text.substring(1, length);
|
||||
}
|
||||
text = getYellPrefix(player) + text + "</col>";
|
||||
for (Player p : Repository.getPlayers()) {
|
||||
if (p.isActive()) {
|
||||
p.getPacketDispatch().sendMessage(text);
|
||||
}
|
||||
}
|
||||
if (player.getDonatorType().getCooldown() > 0 && !player.isStaff()) {
|
||||
player.setAttribute("yell-delay", (int) GameWorld.getTicks() + (player.getDonatorType().getCooldown() / 0.6));
|
||||
}
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("Your message was too short.");
|
||||
}
|
||||
return true;
|
||||
case "togglenews":
|
||||
player.getSavedData().getGlobalData().setDisableNews(!player.getSavedData().getGlobalData().isDisableNews());
|
||||
player.sendMessage("<col=FF0000>" + (player.getSavedData().getGlobalData().isDisableNews() ? "You will no longer see news notifications." : "You will now see news notifications."));
|
||||
return true;
|
||||
case "commands":
|
||||
case "command":
|
||||
case "commandlist":
|
||||
sendCommands(player);
|
||||
return true;
|
||||
case "quests":
|
||||
sendQuests(player);
|
||||
return true;
|
||||
case "donate":
|
||||
sendDonationInfo(player);
|
||||
return true;
|
||||
case "reply":
|
||||
if(player.getInterfaceManager().isOpened()){
|
||||
player.sendMessage("Please finish what you're doing first.");
|
||||
return true;
|
||||
}
|
||||
if (player.getAttributes().containsKey("replyTo")) {
|
||||
player.setAttribute("keepDialogueAlive", true);
|
||||
final String replyTo = (String) player.getAttribute("replyTo", "").replaceAll("_", " ");
|
||||
player.setAttribute("runscript", new RunScript() {
|
||||
@Override
|
||||
public boolean handle() {
|
||||
CommunicationInfo.sendMessage(player, replyTo.toLowerCase(), (String) getValue());
|
||||
player.removeAttribute("keepDialogueAlive");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
player.getDialogueInterpreter().sendMessageInput(StringUtils.formatDisplayName(replyTo));
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("You have not recieved any recent messages to which you can reply.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -250,14 +250,14 @@ public final class PlayerCommandPlugin extends CommandPlugin {
|
|||
if (player.getDetails().getRights().isVisible(player)) {
|
||||
Rights right = player.getAttribute("visible_rank", player.getDetails().getRights());
|
||||
switch (right) {
|
||||
case ADMINISTRATOR:
|
||||
color = "<col=009999>";
|
||||
break;
|
||||
case PLAYER_MODERATOR:
|
||||
color = "<col=81819B>";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case ADMINISTRATOR:
|
||||
color = "<col=009999>";
|
||||
break;
|
||||
case PLAYER_MODERATOR:
|
||||
color = "<col=81819B>";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (player.isDonator() && !player.isStaff()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue