Creating a simple bot is very easy. For example a zombie.
What is done here?
-create new entity with id 42 and at the same coordinates as the selection and save it in the variable "zombie".
-the zombie should follow the player
-spawn it
if (keycode == Input.Keys.K) { Zombie zombie = (Zombie) AbstractEntity.getInstance( 43, 0, controller.getFocusentity().getPosition() ); zombie.setTarget(controller.getPlayer()); zombie.spawn(); }
What is done here?
-override the usual rendering
-render using green color
@Override public void render(View view, Camera camera, AbstractPosition pos){ render( view, camera, pos, Color.GREEN.cpy().mul(WE.getCurrentConfig().shouldAutoShade() ? Color.GRAY.cpy() : Controller.getLightEngine() != null ? Controller.getLightEngine().getColor() : Color.GRAY.cpy()) ); }
What is done here?
-walk in direction of the target (for example the player)
-update the entity as usual
-jump if standing in front of a block
@Override public void update(float delta) { if (getPosition().getCoord().onLoadedMap()) { //follow the target if (target != null) { Vector3 d = new Vector3(); d.x = target.getPosition().getAbsX()-getPosition().getAbsX(); d.y = target.getPosition().getAbsY()-getPosition().getAbsY(); d.nor(); d.z = getMovement().z; // update the movement vector setMovement(d); setSpeed(0.4f); } //update as usual super.update(delta); //if standing on same position as in last update if (Arrays.equals(getPosition().getRel(), lastPos)) runningagainstwallCounter += delta; else { runningagainstwallCounter=0; lastPos = getPosition().getRel(); } //jump after some time if (runningagainstwallCounter > 500) { jump(); setMana(0); runningagainstwallCounter=0; } } }