Package net.citizensnpcs.guards

Examples of net.citizensnpcs.guards.Guard


        return !LocationUtils.withinRange(npc.getLocation(), npc.getBaseLocation(), 3.5);
    }

    private boolean findTarget(HumanNPC npc)
    {
        Guard guard = npc.getType("guard");
        if (!guard.isAggressive())
            return false;
        LivingEntity entity = Targeter.findTarget(Targeter.getNearby(npc.getPlayer(), guard.getProtectionRadius()), npc);
        if (entity != null && LocationUtils.withinRange(entity.getLocation(), npc.getBaseLocation(), guard.getProtectionRadius()))
        {
            if (entity.isDead())
            {
                return false;
            }
           
            guard.target(entity, npc);
            return true;
        }
        return false;
    }
View Full Code Here


        }
        return false;
    }

    private boolean keepAttacking(HumanNPC npc) {
        Guard guard = npc.getType("guard");
        if (npc.getHandle().getStationaryTicks() > Settings.getInt("MaxStationaryReturnTicks")) {
            npc.teleport(npc.getBaseLocation());
            npc.getHandle().cancelTarget();
        }
        return npc.getHandle().hasTarget()
                && LocationUtils.withinRange(npc.getLocation(), npc.getBaseLocation(), guard.getProtectionRadius());
    }
View Full Code Here

                && LocationUtils.withinRange(npc.getLocation(), npc.getBaseLocation(), guard.getProtectionRadius());
    }

    @Override
    public void onDamage(HumanNPC npc, LivingEntity attacker) {
        Guard guard = npc.getType("guard");
        guard.target(attacker, npc);
    }
View Full Code Here

        toRespawn.put(npc.getOwner(), new NPCLocation(npc.getLocation(), npc.getUID(), npc.getOwner()));
        NPCManager.despawn(npc.getUID(), NPCRemoveReason.DEATH);
    }

    private boolean findTarget(HumanNPC npc) {
        Guard guard = npc.getType("guard");
        Player player = Bukkit.getPlayerExact(npc.getOwner());
        if (player == null) {
            despawn(npc);
            return false;
        }
        double range = Settings.getDouble("PathfindingRange");
        if (guard.isAggressive()
                && LocationUtils.withinRange(npc.getLocation(), player.getLocation(), guard.getProtectionRadius())) {
            LivingEntity entity = Targeter.findTarget(Targeter.getNearby(player, guard.getProtectionRadius()), npc);
            if (entity != null && !entity.isDead()) {
                guard.target(entity, npc);
                return true;
            } else if (npc.getHandle().getTarget() != player) {
                PathUtils.target(npc, player, false, -1, -1, range);
            }
        } else {
View Full Code Here

        Player owner = Bukkit.getPlayerExact(npc.getOwner());
        if (owner == null) {
            despawn(npc);
            return false;
        }
        Guard guard = npc.getType("guard");
        return npc.getHandle().hasTarget()
                && LocationUtils.withinRange(owner.getLocation(), npc.getLocation(), guard.getProtectionRadius());
    }
View Full Code Here

TOP

Related Classes of net.citizensnpcs.guards.Guard

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.