use of de.Keyle.MyPet.api.skill.skills.Ranged in project MyPet by xXKeyleXx.
the class RangedAttack method shouldFinish.
@Override
public boolean shouldFinish() {
if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) {
return true;
}
if (this.target.getBukkitEntity() != entityMyPet.getMyPetTarget()) {
return true;
}
double meleeDamage = myPet.getDamage();
if (meleeDamage > 0 && this.entityMyPet.g(target.locX(), this.target.getBoundingBox().minY, target.locZ()) < 4) {
Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) {
return true;
}
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
return true;
}
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
if (this.target instanceof EntityTameableAnimal && ((EntityTameableAnimal) this.target).isTamed()) {
return true;
}
if (this.target instanceof EntityMyPet) {
return true;
}
if (this.target instanceof EntityPlayer) {
return true;
}
}
}
return false;
}
use of de.Keyle.MyPet.api.skill.skills.Ranged in project MyPet by xXKeyleXx.
the class RangedAttack method shouldStart.
@Override
public boolean shouldStart() {
if (myPet.getRangedDamage() <= 0) {
return false;
}
if (!entityMyPet.canMove()) {
return false;
}
if (!entityMyPet.hasTarget()) {
return false;
}
LivingEntity target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle();
if (target instanceof ArmorStand) {
return false;
}
double meleeDamage = myPet.getDamage();
if (meleeDamage > 0 && this.entityMyPet.distanceToSqr(target.getX(), target.getBoundingBox().minY, target.getZ()) < 4) {
Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) {
return false;
}
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
return false;
}
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
if (target instanceof TamableAnimal && ((TamableAnimal) target).isTame()) {
return false;
}
if (target instanceof EntityMyPet) {
return false;
}
if (target instanceof ServerPlayer) {
return false;
}
}
}
this.target = target;
return true;
}
use of de.Keyle.MyPet.api.skill.skills.Ranged in project MyPet by xXKeyleXx.
the class RangedAttack method tick.
@Override
public void tick() {
double distanceToTarget = this.entityMyPet.distanceToSqr(this.target.getX(), this.target.getBoundingBox().minY, this.target.getZ());
boolean canSee = this.entityMyPet.getSensing().hasLineOfSight(this.target);
if (canSee) {
this.lastSeenTimer++;
} else {
this.lastSeenTimer = 0;
}
if ((distanceToTarget <= this.range) && (this.lastSeenTimer >= 20)) {
this.entityMyPet.getPetNavigation().getParameters().removeSpeedModifier("RangedAttack");
this.entityMyPet.getPetNavigation().stop();
} else {
this.entityMyPet.getPetNavigation().getParameters().addSpeedModifier("RangedAttack", walkSpeedModifier);
this.entityMyPet.getPetNavigation().navigateTo(this.target.getBukkitEntity().getLocation());
}
this.entityMyPet.getLookControl().setLookAt(this.target, 30.0F, 30.0F);
if (--this.shootTimer <= 0) {
if (distanceToTarget < this.range && canSee) {
shootProjectile(this.target, (float) myPet.getRangedDamage(), getProjectile());
Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
this.shootTimer = rangedSkill.getRateOfFire().getValue();
}
}
}
use of de.Keyle.MyPet.api.skill.skills.Ranged in project MyPet by xXKeyleXx.
the class RangedAttack method tick.
@Override
public void tick() {
double distanceToTarget = this.entityMyPet.f(this.target.locX, this.target.getBoundingBox().b, this.target.locZ);
// a -> canSee
boolean canSee = this.entityMyPet.getEntitySenses().a(this.target);
if (canSee) {
this.lastSeenTimer++;
} else {
this.lastSeenTimer = 0;
}
if ((distanceToTarget <= this.range) && (this.lastSeenTimer >= 20)) {
this.entityMyPet.getPetNavigation().getParameters().removeSpeedModifier("RangedAttack");
this.entityMyPet.getPetNavigation().stop();
} else {
this.entityMyPet.getPetNavigation().getParameters().addSpeedModifier("RangedAttack", walkSpeedModifier);
this.entityMyPet.getPetNavigation().navigateTo(this.target.getBukkitEntity().getLocation());
}
this.entityMyPet.getControllerLook().a(this.target, 30.0F, 30.0F);
if (--this.shootTimer <= 0) {
if (distanceToTarget < this.range && canSee) {
shootProjectile(this.target, (float) myPet.getRangedDamage(), getProjectile());
Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
this.shootTimer = rangedSkill.getRateOfFire().getValue();
}
}
}
use of de.Keyle.MyPet.api.skill.skills.Ranged in project MyPet by xXKeyleXx.
the class RangedAttack method shouldFinish.
@Override
public boolean shouldFinish() {
if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) {
return true;
}
if (this.target.getBukkitEntity() != this.entityMyPet.getMyPetTarget()) {
return true;
}
double meleeDamage = myPet.getDamage();
if (meleeDamage > 0 && this.entityMyPet.f(target.locX, target.getBoundingBox().b, target.locZ) < 4) {
Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) {
return true;
}
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
return true;
}
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
if (this.target instanceof EntityTameableAnimal && ((EntityTameableAnimal) this.target).isTamed()) {
return true;
}
if (this.target instanceof EntityMyPet) {
return true;
}
if (this.target instanceof EntityPlayer) {
return true;
}
}
}
return false;
}
Aggregations