A lot of bot updates

This commit is contained in:
dginovker 2019-11-08 00:01:04 -05:00
parent b24957bd06
commit 235cdf653f
30 changed files with 5423 additions and 67 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
name=Crandor name=2009scape
beta=false beta=false
sql=true sql=true
devMode=true devMode=true

View file

@ -1,4 +1,4 @@
name=Crandor name=2009scape
beta=false beta=false
sql=true sql=true
devMode=true devMode=true

View file

@ -1,4 +1,4 @@
name=Crandor name=2009scape
beta=false beta=false
sql=true sql=true
devMode=true devMode=true

View file

@ -302,7 +302,6 @@ public class RenderAnimationDefinition {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
System.out.print(Array.get(object, i) + (i < (length - 1) ? ", " : "]")); System.out.print(Array.get(object, i) + (i < (length - 1) ? ", " : "]"));
} }
System.out.println();
continue; continue;
} }
} }
@ -319,7 +318,6 @@ public class RenderAnimationDefinition {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
System.out.print(Array.get(object, i) + (i < (length - 1) ? ", " : "]")); System.out.print(Array.get(object, i) + (i < (length - 1) ? ", " : "]"));
} }
System.out.println();
continue; continue;
} }
} }

View file

@ -44,6 +44,11 @@ public final class Skills {
*/ */
public static final int ATTACK = 0, DEFENCE = 1, STRENGTH = 2, HITPOINTS = 3, RANGE = 4, PRAYER = 5, MAGIC = 6, COOKING = 7, WOODCUTTING = 8, FLETCHING = 9, FISHING = 10, FIREMAKING = 11, CRAFTING = 12, SMITHING = 13, MINING = 14, HERBLORE = 15, AGILITY = 16, THIEVING = 17, SLAYER = 18, FARMING = 19, RUNECRAFTING = 20, HUNTER = 21, CONSTRUCTION = 22, SUMMONING = 23; public static final int ATTACK = 0, DEFENCE = 1, STRENGTH = 2, HITPOINTS = 3, RANGE = 4, PRAYER = 5, MAGIC = 6, COOKING = 7, WOODCUTTING = 8, FLETCHING = 9, FISHING = 10, FIREMAKING = 11, CRAFTING = 12, SMITHING = 13, MINING = 14, HERBLORE = 15, AGILITY = 16, THIEVING = 17, SLAYER = 18, FARMING = 19, RUNECRAFTING = 20, HUNTER = 21, CONSTRUCTION = 22, SUMMONING = 23;
/**
* Number of skills in game
*/
public static final int NUM_SKILLS = 24;
/** /**
* Represents the entity instance. * Represents the entity instance.
*/ */

View file

@ -47,7 +47,7 @@ public final class RareDropTable {
int id = Integer.parseInt(arg[1]); int id = Integer.parseInt(arg[1]);
int amount = 1; int amount = 1;
int amount2 = amount; int amount2 = amount;
System.out.println(id); System.out.println("Rare drop table: " + id);
if (arg[2].contains("-")) { if (arg[2].contains("-")) {
String[] amt = arg[2].split("-"); String[] amt = arg[2].split("-");
amount = Integer.parseInt(amt[0]); amount = Integer.parseInt(amt[0]);

View file

@ -59,8 +59,8 @@ public final class AIPBuilder {
{ {
final AIPlayer bot = new AIPlayer(loc); final AIPlayer bot = new AIPlayer(loc);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init();
bot.getSkills().setStaticLevel(Skills.MAGIC, RandomFunction.getRandom(99)); bot.getSkills().setStaticLevel(Skills.MAGIC, RandomFunction.getRandom(99));
bot.getSkills().setStaticLevel(Skills.DEFENCE, RandomFunction.getRandom(99)); bot.getSkills().setStaticLevel(Skills.DEFENCE, RandomFunction.getRandom(99));

View file

@ -6,6 +6,7 @@ import java.util.*;
import org.crandor.game.content.dialogue.DialoguePlugin; import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.tutorial.CharacterDesign; import org.crandor.game.content.global.tutorial.CharacterDesign;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.DestinationFlag; import org.crandor.game.interaction.DestinationFlag;
import org.crandor.game.interaction.MovementPulse; import org.crandor.game.interaction.MovementPulse;
import org.crandor.game.interaction.Option; import org.crandor.game.interaction.Option;
@ -15,11 +16,13 @@ import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.npc.NPC; import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player; import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.info.PlayerDetails; import org.crandor.game.node.entity.player.info.PlayerDetails;
import org.crandor.game.node.entity.player.link.appearance.Gender;
import org.crandor.game.node.item.Item; import org.crandor.game.node.item.Item;
import org.crandor.game.world.map.Direction; import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location; import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager; import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.map.path.Pathfinder; import org.crandor.game.world.map.path.Pathfinder;
import org.crandor.game.world.repository.Repository;
import org.crandor.net.packet.in.InteractionPacket; import org.crandor.net.packet.in.InteractionPacket;
import org.crandor.plugin.Plugin; import org.crandor.plugin.Plugin;
import org.crandor.tools.RandomFunction; import org.crandor.tools.RandomFunction;
@ -82,8 +85,24 @@ public class AIPlayer extends Player {
super.setLocation(startLocation = l); super.setLocation(startLocation = l);
super.artificial = true; super.artificial = true;
super.getDetails().setSession(ArtificialSession.getSingleton()); super.getDetails().setSession(ArtificialSession.getSingleton());
Repository.getPlayers().add(this);
this.username = StringUtils.formatDisplayName(name + (currentUID + 1)); this.username = StringUtils.formatDisplayName(name + (currentUID + 1));
this.uid = currentUID++; this.uid = currentUID++;
this.generateRandomValues();
this.init();
}
private void generateRandomValues() {
this.getAppearance().setGender(RandomFunction.random(5) == 1 ? Gender.FEMALE : Gender.MALE);
for (int i = 0; i < Skills.NUM_SKILLS; i++) {
this.getSkills().setLevel(i, RandomFunction.random(99));
this.getSkills().setStaticLevel(i, RandomFunction.random(99));
}
this.setDirection(Direction.values()[new Random().nextInt(Direction.values().length)]); //Random facing dir
this.getSkills().updateCombatLevel();
this.getAppearance().sync();
} }
public static String retrieveRandomName() //Reads a random line from the file O_O public static String retrieveRandomName() //Reads a random line from the file O_O
@ -396,7 +415,7 @@ public class AIPlayer extends Player {
@Override @Override
public void clear() { public void clear() {
botMapping.remove(uid); botMapping.remove(uid);
super.clear(); super.clear(true);
} }
@Override @Override
@ -423,6 +442,7 @@ public class AIPlayer extends Player {
AIPlayer player = botMapping.get(uid); AIPlayer player = botMapping.get(uid);
if (player != null) { if (player != null) {
player.clear(); player.clear();
Repository.getPlayers().remove(player);
return; return;
} }
System.err.println("Could not deregister AIP#" + uid + ": UID not added to the mapping!"); System.err.println("Could not deregister AIP#" + uid + ": UID not added to the mapping!");

View file

@ -15,7 +15,7 @@ public class GeneralBotCreator {
public GeneralBotCreator(Location loc, Script botScript) public GeneralBotCreator(Location loc, Script botScript)
{ {
botScript.bot = AIPBuilder.create(loc); botScript.bot = AIPBuilder.create(loc);
Repository.getPlayers().add(botScript.bot);
botScript.init(); botScript.init();
GameWorld.submit(new Pulse(1, botScript.bot) { GameWorld.submit(new Pulse(1, botScript.bot) {

View file

@ -52,7 +52,7 @@ public class LobsterCatcher extends Script {
Pathfinder.find(bot, Location.create(2837, 3435, 0)).walk(bot); Pathfinder.find(bot, Location.create(2837, 3435, 0)).walk(bot);
if (spot != null) { if (spot != null) {
System.out.println(spot.getLocation().toString()); System.out.println("LobsterCatcher: " + spot.getLocation().toString());
spot.getInteraction().handle(bot, spot.getInteraction().get(0)); spot.getInteraction().handle(bot, spot.getInteraction().get(0));
} }
@ -61,6 +61,6 @@ public class LobsterCatcher extends Script {
bank.getInteraction().handle(bot, bank.getInteraction().get(2)); bank.getInteraction().handle(bot, bank.getInteraction().get(2));
} }
System.out.println(tick); System.out.println("LobsterCatcher: " + tick);
} }
} }

View file

@ -0,0 +1,34 @@
package org.crandor.game.node.entity.player.ai.lumbridge;
import org.crandor.game.node.entity.player.ai.AIPlayer;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.zone.ZoneBorders;
import org.crandor.tools.RandomFunction;
public class DeadIdler extends AIPlayer {
//Recreation of players I saw in w417 who seemed to have quit their computer after dying.
private int tick = RandomFunction.random(500);
public DeadIdler()
{
super(getRandomRespawnLoc());
this.setCustomState("Lumbridge Bot");
}
@Override
public void tick()
{
super.tick();
if (this.tick > 0)
{
tick --;
} else {
AIPlayer.deregister(this.getUid());
}
}
private static Location getRandomRespawnLoc() {
return new ZoneBorders(3219, 3218, 3223, 3219).getRandomLoc();
}
}

View file

@ -0,0 +1,32 @@
package org.crandor.game.node.entity.player.ai.lumbridge;
import org.crandor.tools.RandomFunction;
import java.util.concurrent.Executors;
/**
* Creates a few random bots around Lumbridge area.
* Code by Red Bracket
*/
public class LumbridgeBotHandler {
public static void immersiveLumbridge()
{
//Generate a few random bots here and there
generateDeadIdlers();
}
private static void generateDeadIdlers() {
Executors.newSingleThreadExecutor().execute(() -> {
while (true) //Would probably be better if this could be "while game is running"
{
new DeadIdler();
try {
Thread.sleep(RandomFunction.random(300_000));
} catch (InterruptedException e) {
System.out.println("LumbridgeBotHandler can't sleep!!?");
}
}
});
}
}

View file

@ -7,7 +7,6 @@ public class LowestBot extends PvMBots{
public LowestBot(Location l) { public LowestBot(Location l) {
super(l); super(l);
// TODO Auto-generated constructor stub
} }
private int tick = 0; private int tick = 0;

View file

@ -26,7 +26,6 @@ public class PvMBots extends AIPlayer {
public PvMBots(Location l) { public PvMBots(Location l) {
super(l); super(l);
// TODO Auto-generated constructor stub
} }
@ -95,10 +94,13 @@ public class PvMBots extends AIPlayer {
this.tick++; this.tick++;
//Despawn //Despawn
if (this.getSkills().getLifepoints() == 0) if (this.getSkills().getLifepoints() == 0){
//TODO: Just respawn a new bot (not sure how you'd do that :L)
// Maybe make all PvMBots know what to do if they aren't in right area? I.e. pest control bots teleport to PC
//this.teleport(new Location(500, 500)); //this.teleport(new Location(500, 500));
//Despawning not being delayed causes 3 errors in the console //Despawning not being delayed causes 3 errors in the console
AIPlayer.deregister(this.getUid()); AIPlayer.deregister(this.getUid());
}
//Npc Combat //Npc Combat
if (this.tick % 10 == 0) { if (this.tick % 10 == 0) {

View file

@ -11,7 +11,6 @@ import org.crandor.game.node.entity.player.link.SpellBookManager;
import org.crandor.game.node.entity.player.link.appearance.Gender; import org.crandor.game.node.entity.player.link.appearance.Gender;
import org.crandor.game.node.item.Item; import org.crandor.game.node.item.Item;
import org.crandor.game.world.map.Location; import org.crandor.game.world.map.Location;
import org.crandor.game.world.repository.Repository;
import org.crandor.tools.RandomFunction; import org.crandor.tools.RandomFunction;
public final class PvMBotsBuilder{ public final class PvMBotsBuilder{
@ -64,11 +63,11 @@ public final class PvMBotsBuilder{
p.getSkills().updateCombatLevel(); p.getSkills().updateCombatLevel();
p.getAppearance().sync(); p.getAppearance().sync();
p.getEquipment().replace(new Item(4720) ,EquipmentContainer.SLOT_CHEST); p.getEquipment().replace(new Item(4720), EquipmentContainer.SLOT_CHEST);
p.getEquipment().replace(new Item(4722) ,EquipmentContainer.SLOT_LEGS); p.getEquipment().replace(new Item(4722), EquipmentContainer.SLOT_LEGS);
p.getEquipment().replace(new Item(4716) ,EquipmentContainer.SLOT_HAT); p.getEquipment().replace(new Item(4716), EquipmentContainer.SLOT_HAT);
p.getEquipment().replace(new Item(4718) ,EquipmentContainer.SLOT_WEAPON); p.getEquipment().replace(new Item(4718), EquipmentContainer.SLOT_WEAPON);
p.getEquipment().replace(new Item(-1) ,EquipmentContainer.SLOT_SHIELD); p.getEquipment().replace(new Item(-1), EquipmentContainer.SLOT_SHIELD);
p.getInventory().add(new Item(952)); p.getInventory().add(new Item(952));
p.getInventory().add(new Item(33)); p.getInventory().add(new Item(33));
@ -77,7 +76,7 @@ public final class PvMBotsBuilder{
public static void generateMinLevels(PvMBots p) public static void generateMinLevels(PvMBots p)
{ {
//Slayer so they can attack alls monsters //Slayer so they can attack all monsters
p.getSkills().setLevel(Skills.SLAYER, 99); p.getSkills().setLevel(Skills.SLAYER, 99);
p.getSkills().setStaticLevel(Skills.SLAYER, 99); p.getSkills().setStaticLevel(Skills.SLAYER, 99);
int combatType = RandomFunction.getRandom(2); int combatType = RandomFunction.getRandom(2);
@ -145,7 +144,7 @@ public final class PvMBotsBuilder{
} }
} }
public static void createPestControlBot(PestControlTestBot p) public static void customizePestControlBot(PestControlTestBot p)
{ {
p.getSkills().setLevel(Skills.SLAYER, 99); p.getSkills().setLevel(Skills.SLAYER, 99);
p.getSkills().setStaticLevel(Skills.SLAYER, 99); p.getSkills().setStaticLevel(Skills.SLAYER, 99);
@ -469,37 +468,29 @@ public final class PvMBotsBuilder{
{ {
final PvMBots bot = PvMBotsBuilder.create(loc); final PvMBots bot = PvMBotsBuilder.create(loc);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init();
} }
public static void spawnPestControlTestBot(Location loc) public static void spawnPestControlTestBot(Location loc)
{ {
final PestControlTestBot bot = PvMBotsBuilder.createPestControlTestBot(loc); final PestControlTestBot bot = PvMBotsBuilder.createPestControlTestBot(loc);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init(); customizePestControlBot(bot);
createPestControlBot(bot);
} }
public static void spawnLowest(Location loc) public static void spawnLowest(Location loc)
{ {
final LowestBot bot = PvMBotsBuilder.createLowest(loc); final LowestBot bot = PvMBotsBuilder.createLowest(loc);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init();
generateMinLevels(bot); generateMinLevels(bot);
} }
public static void spawnNoob(Location loc) public static void spawnNoob(Location loc)
{ {
final NoobBot bot = PvMBotsBuilder.createNoob(loc); final NoobBot bot = PvMBotsBuilder.createNoob(loc);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init();
createNoob(bot); createNoob(bot);
} }
@ -507,8 +498,8 @@ public final class PvMBotsBuilder{
{ {
final DragonKiller bot = PvMBotsBuilder.createDragonKiller(loc); final DragonKiller bot = PvMBotsBuilder.createDragonKiller(loc);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init();
createDragonKiller(bot); createDragonKiller(bot);
} }
@ -518,8 +509,8 @@ public final class PvMBotsBuilder{
final GiantMoleBot bot = PvMBotsBuilder.createGiantMoleBot(new Location(0, 0)); final GiantMoleBot bot = PvMBotsBuilder.createGiantMoleBot(new Location(0, 0));
bot.teleport(loc); bot.teleport(loc);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init();
generateGiantMoleBot(bot); generateGiantMoleBot(bot);
} }

View file

@ -41,7 +41,7 @@ public class ResourceAIPActions {
ov = 0; ov = 0;
} }
// ov = 0; // ov = 0;
System.out.println(ov); System.out.println("ResourceAIPActions" + ov);
return false; return false;
} }
}); });

View file

@ -2,6 +2,7 @@ package org.crandor.game.node.entity.player.ai.resource;
import org.crandor.game.node.entity.player.Player; import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.ai.AIPBuilder; import org.crandor.game.node.entity.player.ai.AIPBuilder;
import org.crandor.game.node.entity.player.ai.lumbridge.LumbridgeBotHandler;
import org.crandor.game.node.entity.player.ai.pvmbots.PvMBotsBuilder; import org.crandor.game.node.entity.player.ai.pvmbots.PvMBotsBuilder;
import org.crandor.game.node.entity.player.ai.resource.task.ResourceTask; import org.crandor.game.node.entity.player.ai.resource.task.ResourceTask;
import org.crandor.game.node.entity.player.ai.resource.task.ResourceTasks; import org.crandor.game.node.entity.player.ai.resource.task.ResourceTasks;
@ -37,8 +38,9 @@ public class ResourceAIPManager {
public void immerseWorld() { //There's probably a better place for this (it adds bot at bootup) public void immerseWorld() { //There's probably a better place for this (it adds bot at bootup)
PvMBotsBuilder.immersiveSpawns(); PvMBotsBuilder.immersiveSpawns();
AIPBuilder.immersiveSpawns(); LumbridgeBotHandler.immersiveLumbridge();
SkillingBotsBuilder.immersiveSpawnsSkillingBots(); //AIPBuilder.immersiveSpawns();
//SkillingBotsBuilder.immersiveSpawnsSkillingBots();
System.out.println("Loaded immerseWorld"); System.out.println("Loaded immerseWorld");
} }
@ -96,7 +98,7 @@ public class ResourceAIPManager {
continue; continue;
StringBuilder query = new StringBuilder(); StringBuilder query = new StringBuilder();
query.append("UPDATE `members` SET `taskName`='" + entry.getKey().getTaskName() + "',`taskTime`='" + entry.getValue() + "' WHERE `username`='" + player.getUsername() + "'"); query.append("UPDATE `members` SET `taskName`='" + entry.getKey().getTaskName() + "',`taskTime`='" + entry.getValue() + "' WHERE `username`='" + player.getUsername() + "'");
System.out.println(query.toString()); System.out.println("ResourceAIPManager: " + query.toString());
GameWorld.getDatabaseManager().update("global", query.toString()); GameWorld.getDatabaseManager().update("global", query.toString());
} }

View file

@ -11,7 +11,7 @@ import org.crandor.game.node.entity.player.ai.AIPlayer;
import org.crandor.game.node.item.Item; import org.crandor.game.node.item.Item;
import org.crandor.net.packet.in.InteractionPacket; import org.crandor.net.packet.in.InteractionPacket;
public class SkillingBot extends AIPlayer{ public class SkillingBot extends AIPlayer {
private int tick = 5; private int tick = 5;
private ArrayList<Integer> interactNodeIds; private ArrayList<Integer> interactNodeIds;
@ -24,7 +24,6 @@ public class SkillingBot extends AIPlayer{
super(l); super(l);
this.fromWhereDoIdrop = 0; this.fromWhereDoIdrop = 0;
this.interactionRange = 15; this.interactionRange = 15;
// TODO Auto-generated constructor stub
} }
public SkillingBot(Location l, int skill, ArrayList<Integer> entrys) public SkillingBot(Location l, int skill, ArrayList<Integer> entrys)

View file

@ -23,8 +23,8 @@ public final class SkillingBotsBuilder extends AIPlayer {
{ {
SkillingBot bot = new SkillingBot(loc, Skills.MINING, entrys); SkillingBot bot = new SkillingBot(loc, Skills.MINING, entrys);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init();
bot.getEquipment().replace(new Item(1265), EquipmentContainer.SLOT_WEAPON); bot.getEquipment().replace(new Item(1265), EquipmentContainer.SLOT_WEAPON);
return bot; return bot;
} }
@ -33,8 +33,8 @@ public final class SkillingBotsBuilder extends AIPlayer {
{ {
SkillingBot bot = new SkillingBot(loc, Skills.WOODCUTTING, entrys); SkillingBot bot = new SkillingBot(loc, Skills.WOODCUTTING, entrys);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
bot.init();
bot.getEquipment().replace(new Item(1351), EquipmentContainer.SLOT_WEAPON); bot.getEquipment().replace(new Item(1351), EquipmentContainer.SLOT_WEAPON);
return bot; return bot;
} }
@ -44,8 +44,8 @@ public final class SkillingBotsBuilder extends AIPlayer {
SkillingBot bot = new SkillingBot(loc, Skills.FISHING, entrys); SkillingBot bot = new SkillingBot(loc, Skills.FISHING, entrys);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
CharacterDesign.randomize(bot, false); CharacterDesign.randomize(bot, false);
Repository.getPlayers().add(bot);
bot.init();
return bot; return bot;
} }

View file

@ -518,9 +518,9 @@ public final class PvPBotsBuilder{
final WildernessBot bot = PvPBotsBuilder.create(new Location(0, 0)); final WildernessBot bot = PvPBotsBuilder.create(new Location(0, 0));
bot.teleport(loc); bot.teleport(loc);
bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); bot.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(bot);
generateClass(bot); generateClass(bot);
bot.init();
} }
private static void correctHitpointsStat(AIPlayer player) { private static void correctHitpointsStat(AIPlayer player) {

View file

@ -153,7 +153,7 @@ public class WildernessBot extends AIPlayer {
private void checkBarrowsSwitch() private void checkBarrowsSwitch()
{ {
System.out.println(this.getSkills().getLifepoints()); System.out.println("WildernessBot: " + this.getSkills().getLifepoints());
Entity target = getTarget(); Entity target = getTarget();
if (target == null) if (target == null)
return; return;

View file

@ -106,7 +106,7 @@ public class SpawnData implements SavingModule {
case 7: case 7:
for (int i = 0; i < PKPackage.values().length; i++) { for (int i = 0; i < PKPackage.values().length; i++) {
purchased = PKPackage.values()[i].ordinal(); purchased = PKPackage.values()[i].ordinal();
System.out.println(PKPackage.values()[i].ordinal()); System.out.println("SpawnData: " + PKPackage.values()[i].ordinal());
} }
break; break;
} }

View file

@ -43,7 +43,7 @@ public final class CheckRandomCondition extends ScriptContext {
@Override @Override
public boolean execute(Object... args) { public boolean execute(Object... args) {
System.out.println( (String) ((Entity) args[0]).getAttribute("asc_random") ); System.out.println("CheckRandomCondition:" + (String) ((Entity) args[0]).getAttribute("asc_random") );
return ((Entity) args[0]).getAttribute("asc_random", 0) == value; return ((Entity) args[0]).getAttribute("asc_random", 0) == value;
} }

View file

@ -89,7 +89,7 @@ public final class OptionDialInstruction extends ScriptContext {
@Override @Override
public ScriptContext create(String args) { public ScriptContext create(String args) {
System.out.println(args); System.out.println("OptionDialInstruction: " + args);
ScriptContext context = super.create(args); ScriptContext context = super.create(args);
if (context != null) { if (context != null) {

View file

@ -221,9 +221,8 @@ public final class ZoneBorders {
} }
public Location getRandomLoc() { public Location getRandomLoc() {
int x = northEastX - southWestX == 0 ? southWestX : new Random().nextInt(northEastX - southWestX) + southWestX; int x = northEastX - southWestX == 0 ? southWestX : new Random().nextInt(northEastX - southWestX + 1) + southWestX;
int y = northEastY - southWestY == 0 ? southWestY : new Random().nextInt(northEastY - southWestY) + southWestY; int y = northEastY - southWestY == 0 ? southWestY : new Random().nextInt(northEastY - southWestY + 1) + southWestY;
//System.out.println("Generated x,y " + x + ", " + y);
return new Location(x, y); return new Location(x, y);
} }

View file

@ -93,6 +93,9 @@ public class RandomFunction {
return RANDOM.nextInt(val); return RANDOM.nextInt(val);
} }
/*
* Generates a random number likely closer to the middle of i
*/
public static int normalRandDist(int i, int intensity) { public static int normalRandDist(int i, int intensity) {
int sum = 0; int sum = 0;
for (int j = 0; j < intensity; j++) { for (int j = 0; j < intensity; j++) {
@ -105,6 +108,9 @@ public class RandomFunction {
return (RANDOM.nextInt(i) + RANDOM.nextInt(i))/2; return (RANDOM.nextInt(i) + RANDOM.nextInt(i))/2;
} }
/*
* Generates a random number likely in the area above val (I think)
*/
public static int normalPlusWeightRandDist(int val, int weight) public static int normalPlusWeightRandDist(int val, int weight)
{ {
int normalDistRand = (RANDOM.nextInt(val) + RANDOM.nextInt(val))/2; int normalDistRand = (RANDOM.nextInt(val) + RANDOM.nextInt(val))/2;

View file

@ -91,7 +91,7 @@ public final class AIPCommandPlugin extends CommandPlugin {
case "aip": case "aip":
name = args.length < 2 ? player.getName() : args[1]; name = args.length < 2 ? player.getName() : args[1];
AIPlayer p = AIPBuilder.copy(player, player.getLocation().transform(0, 1, 0)); AIPlayer p = AIPBuilder.copy(player, player.getLocation().transform(0, 1, 0));
Repository.getPlayers().add(p);
p.init(); p.init();
Interaction.sendOption(player, 7, "Control"); Interaction.sendOption(player, 7, "Control");
@ -110,7 +110,7 @@ public final class AIPCommandPlugin extends CommandPlugin {
// message // message
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
final AIPlayer aip = AIPBuilder.copy(player, last.getLocation().transform(0, 1, 0)); final AIPlayer aip = AIPBuilder.copy(player, last.getLocation().transform(0, 1, 0));
Repository.getPlayers().add(aip);
aip.init(); aip.init();
if (legion.isEmpty()) { if (legion.isEmpty()) {
aip.setAttribute("aip_legion", legion); aip.setAttribute("aip_legion", legion);
@ -148,7 +148,7 @@ public final class AIPCommandPlugin extends CommandPlugin {
final AIPlayer aip = AIPBuilder.create( generateLocation(player)); final AIPlayer aip = AIPBuilder.create( generateLocation(player));
aip.setControler(player); aip.setControler(player);
aip.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); aip.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(aip);
aip.init(); aip.init();
PVPAIPBuilderUtils.generateClass(aip); PVPAIPBuilderUtils.generateClass(aip);
@ -170,7 +170,7 @@ public final class AIPCommandPlugin extends CommandPlugin {
final AIPlayer aip = AIPBuilder.create(generateLocation(player)); final AIPlayer aip = AIPBuilder.create(generateLocation(player));
aip.setControler(player); aip.setControler(player);
aip.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); aip.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
Repository.getPlayers().add(aip);
aip.init(); aip.init();
PVPAIPBuilderUtils.generateClass(aip); PVPAIPBuilderUtils.generateClass(aip);

View file

@ -82,6 +82,7 @@ public final class BetaCommandPlugin extends CommandPlugin {
case "pos": case "pos":
case "position": case "position":
case "coords":
case "loc": case "loc":
final Location l = player.getLocation(); final Location l = player.getLocation();
final Region r = player.getViewport().getRegion(); final Region r = player.getViewport().getRegion();

View file

@ -26,7 +26,6 @@ public class BasicStarter implements Plugin<Player> {
@Override @Override
public Plugin<Player> newInstance(Player player) throws Throwable { public Plugin<Player> newInstance(Player player) throws Throwable {
System.out.println(player.getDetails().getLastLogin());
if (player.getDetails().getLastLogin() == 0) { if (player.getDetails().getLastLogin() == 0) {
for (int[] item : STARTER_ITEMS) { for (int[] item : STARTER_ITEMS) {
player.getInventory().add(new Item(item[0], item[1])); player.getInventory().add(new Item(item[0], item[1]));