Skip to content

Commit

Permalink
fix close range angling
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 29, 2017
1 parent ba9149e commit a357ab8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/main/java/org/mcmonkey/sentinel/SentinelTrait.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public double firingMinimumRange() {

public HashMap.SimpleEntry<Location, Vector> getLaunchDetail(Location target, Vector lead) {
double speeda;
npc.faceLocation(target);
faceLocation(target);
double angt = Double.POSITIVE_INFINITY;
Location start = getLivingEntity().getEyeLocation().clone().add(getLivingEntity().getEyeLocation().getDirection().multiply(firingMinimumRange()));
double sbase = SentinelPlugin.instance.getConfig().getDouble("random.shoot speed minimum", 20);
Expand Down Expand Up @@ -566,7 +566,7 @@ public void fireArrow(ItemStack type, Location target, Vector lead) {
public void fireSnowball(Location target) {
swingWeapon();
stats_snowballsThrown++;
npc.faceLocation(target);
faceLocation(target);
Vector forward = getLivingEntity().getEyeLocation().getDirection();
Location spawnAt = getLivingEntity().getEyeLocation().clone().add(forward.clone().multiply(firingMinimumRange()));
Entity ent = spawnAt.getWorld().spawnEntity(spawnAt, EntityType.SNOWBALL);
Expand All @@ -577,7 +577,7 @@ public void fireSnowball(Location target) {
public void fireEgg(Location target) {
swingWeapon();
stats_eggsThrown++;
npc.faceLocation(target);
faceLocation(target);
Vector forward = getLivingEntity().getEyeLocation().getDirection();
Location spawnAt = getLivingEntity().getEyeLocation().clone().add(forward.clone().multiply(firingMinimumRange()));
Entity ent = spawnAt.getWorld().spawnEntity(spawnAt, EntityType.EGG);
Expand All @@ -587,16 +587,20 @@ public void fireEgg(Location target) {

public void firePearl(LivingEntity target) {
swingWeapon();
npc.faceLocation(target.getEyeLocation());
faceLocation(target.getEyeLocation());
// TODO: Maybe require entity is-on-ground?
stats_pearlsUsed++;
target.setVelocity(target.getVelocity().add(new Vector(0, getDamage(), 0)));
}

public void faceLocation(Location l) {
npc.faceLocation(l.clone().subtract(0, getLivingEntity().getEyeHeight(), 0));
}

public void fireFireball(Location target) {
swingWeapon();
stats_fireballsFired++;
npc.faceLocation(target);
faceLocation(target);
Vector forward = getLivingEntity().getEyeLocation().getDirection();
Location spawnAt = getLivingEntity().getEyeLocation().clone().add(forward.clone().multiply(firingMinimumRange()));
Entity ent = spawnAt.getWorld().spawnEntity(spawnAt, EntityType.SMALL_FIREBALL);
Expand All @@ -607,7 +611,7 @@ public void fireFireball(Location target) {
public void fireSkull(Location target) {
swingWeapon();
stats_skullsThrown++;
npc.faceLocation(target);
faceLocation(target);
Vector forward = getLivingEntity().getEyeLocation().getDirection();
Location spawnAt = getLivingEntity().getEyeLocation().clone().add(forward.clone().multiply(firingMinimumRange()));
Entity ent = spawnAt.getWorld().spawnEntity(spawnAt, EntityType.WITHER_SKULL);
Expand Down Expand Up @@ -737,7 +741,7 @@ public double getArmor(LivingEntity ent) {
}

public void punch(LivingEntity entity) {
npc.faceLocation(entity.getLocation());
faceLocation(entity.getLocation());
swingWeapon();
stats_punches++;
if (SentinelPlugin.instance.getConfig().getBoolean("random.workaround damage", false)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public boolean tryAttack(SentinelTrait st, LivingEntity ent) {
if (node == null) {
return false;
}
st.getNPC().faceLocation(ent.getEyeLocation());
st.faceLocation(ent.getEyeLocation());
direc.csminion.weaponInteraction((Player) st.getLivingEntity(), node, false);
return true;
}
Expand Down

0 comments on commit a357ab8

Please sign in to comment.