forked from 2009Scape/Server
Added bot equipment
This commit is contained in:
parent
ee5b8deacc
commit
df2528c5e8
7 changed files with 29 additions and 16 deletions
|
|
@ -61,30 +61,23 @@ public final class Interaction {
|
|||
* @param option The option used.
|
||||
*/
|
||||
public void handle(final Player player, final Option option) {
|
||||
System.out.println("In handle");
|
||||
if (player.getLocks().isInteractionLocked()) {
|
||||
System.out.println("Locked!");
|
||||
return;
|
||||
}
|
||||
boolean hasHandler = option.getHandler() != null;
|
||||
String pulseType = "interaction:" + option.getName() + ":" + node.hashCode();
|
||||
boolean walk = hasHandler && option.getHandler().isWalk();
|
||||
System.out.println("Which one will he take?");
|
||||
if (!walk && hasHandler && option.getHandler().isWalk(player, node)) {
|
||||
walk = true;
|
||||
}
|
||||
if (!hasHandler || walk) {
|
||||
handleWalkOption(player, option, pulseType);
|
||||
System.out.println("A");
|
||||
} else if (hasHandler) {
|
||||
player.debug("Option handler being used=" + option.getHandler().getClass().getSimpleName());
|
||||
handleDefaultOption(player, option, pulseType);
|
||||
System.out.println("D");
|
||||
} else {
|
||||
player.getPulseManager().runUnhandledAction(player, pulseType);
|
||||
System.out.println("C");
|
||||
}
|
||||
System.out.println("Done");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -57,11 +57,6 @@ public class AIPlayer extends Player {
|
|||
*/
|
||||
private Player controler;
|
||||
|
||||
/**
|
||||
* The scriptAPI the bot will perform
|
||||
*/
|
||||
private ScriptAPI scriptAPI;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AIPlayer} {@code Object}.
|
||||
* @param name The name of the AIP.
|
||||
|
|
@ -75,7 +70,6 @@ public class AIPlayer extends Player {
|
|||
super.getDetails().setSession(ArtificialSession.getSingleton());
|
||||
this.username = StringUtils.formatDisplayName(name);
|
||||
this.uid = currentUID++;
|
||||
this.scriptAPI = new ScriptAPI();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.crandor.game.node.entity.player.ai.general;
|
|||
import org.crandor.game.node.entity.player.ai.AIPBuilder;
|
||||
import org.crandor.game.node.entity.player.ai.AIPlayer;
|
||||
import org.crandor.game.node.entity.player.ai.general.scriptrepository.Script;
|
||||
import org.crandor.game.node.item.Item;
|
||||
import org.crandor.game.system.task.Pulse;
|
||||
import org.crandor.game.world.GameWorld;
|
||||
import org.crandor.game.world.map.Location;
|
||||
|
|
@ -18,6 +19,16 @@ public class GeneralBotCreator {
|
|||
bot.init();
|
||||
botScript.setPlayer(bot);
|
||||
|
||||
// Initialize inventory
|
||||
for (Item i : botScript.inventory)
|
||||
{
|
||||
bot.getInventory().add(i);
|
||||
}
|
||||
for (Item i : botScript.equipment)
|
||||
{
|
||||
bot.getEquipment().add(i, true, false);
|
||||
}
|
||||
|
||||
GameWorld.submit(new Pulse(1, bot) {
|
||||
int ticks = 0;
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class ScriptAPI {
|
|||
return Math.sqrt(Math.pow(n1.getLocation().getX() - n2.getLocation().getX(), 2) + Math.pow(n2.getLocation().getY() - n1.getLocation().getY(), 2));
|
||||
}
|
||||
|
||||
public Node getNearestEntity(Player me, String entityName)
|
||||
public Node getNearestNode(Player me, String entityName)
|
||||
{
|
||||
Node entity = null;
|
||||
double minDistance = Double.MAX_VALUE;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
package org.crandor.game.node.entity.player.ai.general.scriptrepository;
|
||||
|
||||
import org.crandor.game.node.Node;
|
||||
import org.crandor.game.node.item.Item;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ManThiever extends Script {
|
||||
public ManThiever()
|
||||
{
|
||||
this.equipment.addAll(Arrays.asList(new Item(1103), new Item(1139), new Item(1265)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runLoop() {
|
||||
Node man = scriptAPI.getNearestEntity(me, "Man");
|
||||
Node man = scriptAPI.getNearestNode(me, "Man");
|
||||
|
||||
if (man != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,15 @@ package org.crandor.game.node.entity.player.ai.general.scriptrepository;
|
|||
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.entity.player.ai.general.ScriptAPI;
|
||||
import org.crandor.game.node.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class Script {
|
||||
public Player me;
|
||||
public ScriptAPI scriptAPI = new ScriptAPI();
|
||||
public Player me;
|
||||
public ArrayList<Item> inventory = new ArrayList<>();
|
||||
public ArrayList<Item> equipment = new ArrayList<>();
|
||||
|
||||
public void setPlayer(Player me)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package plugin.command;
|
||||
|
||||
import org.crandor.game.container.Container;
|
||||
import org.crandor.game.interaction.Interaction;
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.entity.player.ai.AIPBuilder;
|
||||
|
|
@ -10,6 +11,7 @@ import org.crandor.game.node.entity.player.ai.pvp.PVPAIPActions;
|
|||
import org.crandor.game.node.entity.player.ai.pvp.PVPAIPBuilderUtils;
|
||||
import org.crandor.game.node.entity.player.ai.resource.ResourceAIPActions;
|
||||
import org.crandor.game.node.entity.player.link.appearance.Gender;
|
||||
import org.crandor.game.node.item.Item;
|
||||
import org.crandor.game.system.command.CommandPlugin;
|
||||
import org.crandor.game.system.command.CommandSet;
|
||||
import org.crandor.game.system.task.Pulse;
|
||||
|
|
@ -22,6 +24,7 @@ import org.crandor.plugin.InitializablePlugin;
|
|||
import org.crandor.plugin.Plugin;
|
||||
import org.crandor.tools.RandomFunction;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue