Elites will move elsewhere when players die to them.
This commit is contained in:
parent
37c1b6fe6a
commit
05475b66fb
Binary file not shown.
@ -45,6 +45,7 @@ public class EliteMonster {
|
|||||||
static int ENRAGE_COOLDOWN = 20*60;
|
static int ENRAGE_COOLDOWN = 20*60;
|
||||||
static int STORINGENERGY_COOLDOWN = 20*50;
|
static int STORINGENERGY_COOLDOWN = 20*50;
|
||||||
static int GLOW_TIME = 20*1;
|
static int GLOW_TIME = 20*1;
|
||||||
|
static int WAIT_TIME = 20*10;
|
||||||
|
|
||||||
Monster m;
|
Monster m;
|
||||||
long last_rebuff_time=0;
|
long last_rebuff_time=0;
|
||||||
@ -76,10 +77,10 @@ public class EliteMonster {
|
|||||||
public void runTick() {
|
public void runTick() {
|
||||||
//This monster constantly gives itself its buffs as it may lose some (Debilitation mode).
|
//This monster constantly gives itself its buffs as it may lose some (Debilitation mode).
|
||||||
dontDrown();
|
dontDrown();
|
||||||
|
rebuff();
|
||||||
|
regenerateHealth();
|
||||||
|
moveFasterToTarget();
|
||||||
if (m.isValid() && targetlist.size()>0) {
|
if (m.isValid() && targetlist.size()>0) {
|
||||||
rebuff();
|
|
||||||
regenerateHealth();
|
|
||||||
moveFasterToTarget();
|
|
||||||
weakenTeam();
|
weakenTeam();
|
||||||
retargetInAir();
|
retargetInAir();
|
||||||
destroyLiquids(2);
|
destroyLiquids(2);
|
||||||
@ -203,6 +204,8 @@ public class EliteMonster {
|
|||||||
//Jump up to compensate. Move towards the player too.
|
//Jump up to compensate. Move towards the player too.
|
||||||
m.setVelocity((m.getLocation().getDirection()).add(new Vector(0,0.2*(l.getLocation().getY()-m.getLocation().getY()),0)));
|
m.setVelocity((m.getLocation().getDirection()).add(new Vector(0,0.2*(l.getLocation().getY()-m.getLocation().getY()),0)));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
m.setTarget(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,10 +383,15 @@ public class EliteMonster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Location getNearbyFreeLocation(Location l) {
|
private Location getNearbyFreeLocation(Location l) {
|
||||||
|
return getNearbyFreeLocation(l,3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Location getNearbyFreeLocation(Location l, int range) {
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
while (tries<10) {
|
while (tries<50) {
|
||||||
Location testloc = l.add((Math.random()*3)-(Math.random()*6),Math.random()*5,Math.random()*3-(Math.random()*6));
|
Location testloc = l.add((Math.random()*(range*2))-(range),Math.random()*range,(Math.random()*(range*2))-(range));
|
||||||
Block testblock = testloc.getBlock();
|
Block testblock = testloc.getBlock();
|
||||||
|
TwosideKeeper.log("Trying "+testloc, 2);
|
||||||
if (testblock.getType()==Material.AIR && testblock.getRelative(0, 1, 0).getType()==Material.AIR) {
|
if (testblock.getType()==Material.AIR && testblock.getRelative(0, 1, 0).getType()==Material.AIR) {
|
||||||
return testloc;
|
return testloc;
|
||||||
}
|
}
|
||||||
@ -423,4 +431,9 @@ public class EliteMonster {
|
|||||||
public List<Player> getTargetList() {
|
public List<Player> getTargetList() {
|
||||||
return targetlist;
|
return targetlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void randomlyTeleport() {
|
||||||
|
Location l = getNearbyFreeLocation(m.getLocation(),24);
|
||||||
|
m.teleport(l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class MonsterController {
|
|||||||
ms.SetLeader(true);
|
ms.SetLeader(true);
|
||||||
//Set the HP of the leader to a more proper amount.
|
//Set the HP of the leader to a more proper amount.
|
||||||
}
|
}
|
||||||
if (meetsConditionsToBeElite(ent)) {
|
if (meetsConditionsToBeElite(ent) && !minion) {
|
||||||
Monster m = (Monster)(ent);
|
Monster m = (Monster)(ent);
|
||||||
MonsterDifficulty md = MonsterDifficulty.ELITE;
|
MonsterDifficulty md = MonsterDifficulty.ELITE;
|
||||||
TwosideKeeper.log(ChatColor.DARK_PURPLE+"Converting to Elite.", 2);
|
TwosideKeeper.log(ChatColor.DARK_PURPLE+"Converting to Elite.", 2);
|
||||||
@ -143,10 +143,11 @@ public class MonsterController {
|
|||||||
|
|
||||||
private static boolean meetsConditionsToBeElite(LivingEntity ent) {
|
private static boolean meetsConditionsToBeElite(LivingEntity ent) {
|
||||||
if (Math.random()<=TwosideKeeper.ELITE_MONSTER_CHANCE && TwosideKeeper.LAST_ELITE_SPAWN+72000<TwosideKeeper.getServerTickTime() &&
|
if (Math.random()<=TwosideKeeper.ELITE_MONSTER_CHANCE && TwosideKeeper.LAST_ELITE_SPAWN+72000<TwosideKeeper.getServerTickTime() &&
|
||||||
((ent instanceof Zombie) || ((ent instanceof Skeleton) && ((Skeleton)ent).getSkeletonType()==SkeletonType.WITHER))) {
|
((ent instanceof Zombie) || ((ent instanceof Skeleton) && ((Skeleton)ent).getSkeletonType()==SkeletonType.WITHER))
|
||||||
|
&& ent.getWorld().equals(Bukkit.getWorld("world"))) {
|
||||||
TwosideKeeper.log("Trying for an elite monster.", 4);
|
TwosideKeeper.log("Trying for an elite monster.", 4);
|
||||||
if (GenericFunctions.PercentBlocksAroundArea(ent.getLocation().getBlock(),Material.AIR,16,8,16)>=75 &&
|
if (GenericFunctions.PercentBlocksAroundArea(ent.getLocation().getBlock(),Material.AIR,16,8,16)>=75 &&
|
||||||
ent.getNearbyEntities(64, 16, 64).size()<=2) {
|
ent.getNearbyEntities(128, 32, 128).size()<=2) {
|
||||||
TwosideKeeper.LAST_ELITE_SPAWN=TwosideKeeper.getServerTickTime();
|
TwosideKeeper.LAST_ELITE_SPAWN=TwosideKeeper.getServerTickTime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,7 @@ public class PlayerStructure {
|
|||||||
public List<ItemStack> deathloot = new ArrayList<ItemStack>();
|
public List<ItemStack> deathloot = new ArrayList<ItemStack>();
|
||||||
public double vendetta_amt = 0.0;
|
public double vendetta_amt = 0.0;
|
||||||
public HashMap<UUID,Long> hitlist = new HashMap<UUID,Long>();
|
public HashMap<UUID,Long> hitlist = new HashMap<UUID,Long>();
|
||||||
|
public long lastdeath = 0;
|
||||||
|
|
||||||
public double prev_weapondmg=0.0;
|
public double prev_weapondmg=0.0;
|
||||||
public double prev_buffdmg=0.0;
|
public double prev_buffdmg=0.0;
|
||||||
|
@ -2706,6 +2706,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
pd.vendetta_amt=0.0;
|
pd.vendetta_amt=0.0;
|
||||||
p.getInventory().clear();
|
p.getInventory().clear();
|
||||||
}
|
}
|
||||||
|
for (int i=0;i<elitemonsters.size();i++) {
|
||||||
|
EliteMonster em = elitemonsters.get(i);
|
||||||
|
em.getMonster().setTarget(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
@ -4156,9 +4160,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
public void entityTargetEvent(EntityTargetLivingEntityEvent ev) {
|
public void entityTargetEvent(EntityTargetLivingEntityEvent ev) {
|
||||||
if ((ev.getEntity() instanceof Monster)) {
|
if ((ev.getEntity() instanceof Monster)) {
|
||||||
|
log("In here",2);
|
||||||
Monster m = (Monster)ev.getEntity();
|
Monster m = (Monster)ev.getEntity();
|
||||||
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
|
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
|
||||||
if (ms.getElite()) {
|
if (ms.getElite()) {
|
||||||
|
log("In here",2);
|
||||||
EliteMonster em = null;
|
EliteMonster em = null;
|
||||||
for (int i=0;i<elitemonsters.size();i++) {
|
for (int i=0;i<elitemonsters.size();i++) {
|
||||||
if (elitemonsters.get(i).m.equals(ev.getEntity())) {
|
if (elitemonsters.get(i).m.equals(ev.getEntity())) {
|
||||||
@ -4167,10 +4173,36 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (em!=null && (ev.getTarget() instanceof Player) && !em.targetlist.contains((Player)ev.getTarget())) {
|
if (em!=null && (ev.getTarget() instanceof Player) && !em.targetlist.contains((Player)ev.getTarget())) {
|
||||||
em.targetlist.add((Player)ev.getTarget());
|
Player p = (Player)ev.getTarget();
|
||||||
|
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
|
if (pd.lastdeath+em.WAIT_TIME<=TwosideKeeper.getServerTickTime()) {
|
||||||
|
em.targetlist.add((Player)ev.getTarget());
|
||||||
|
} else {
|
||||||
|
log("This should trigger",2);
|
||||||
|
em.randomlyTeleport();
|
||||||
|
em.randomlyTeleport();
|
||||||
|
em.randomlyTeleport();
|
||||||
|
m.setTarget(null);
|
||||||
|
em.targetlist.remove((Player)ev.getTarget());
|
||||||
|
ev.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m.setTarget(ev.getTarget());
|
m.setTarget(ev.getTarget());
|
||||||
ev.setCancelled(true);
|
ev.setCancelled(true);
|
||||||
|
} else {
|
||||||
|
log("This monster is "+MonsterController.getMonsterDifficulty(m).name(),2);
|
||||||
|
if (MonsterController.getMonsterDifficulty(m)==MonsterDifficulty.ELITE) {
|
||||||
|
EliteMonster em = new EliteMonster(m);
|
||||||
|
if (em!=null && (ev.getTarget() instanceof Player) && !em.targetlist.contains((Player)ev.getTarget())) {
|
||||||
|
Player p = (Player)ev.getTarget();
|
||||||
|
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
|
if (pd.lastdeath+em.WAIT_TIME<=TwosideKeeper.getServerTickTime()) {
|
||||||
|
em.randomlyTeleport();
|
||||||
|
}
|
||||||
|
ev.setCancelled(true);
|
||||||
|
}
|
||||||
|
elitemonsters.add(em);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.getEntity() instanceof LivingEntity &&
|
if (ev.getEntity() instanceof LivingEntity &&
|
||||||
@ -4640,11 +4672,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,1,0),true);
|
p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,1,0),true);
|
||||||
p.removePotionEffect(PotionEffectType.ABSORPTION);
|
p.removePotionEffect(PotionEffectType.ABSORPTION);
|
||||||
|
GenericFunctions.addIFrame(p, 20*10);
|
||||||
|
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
|
pd.lastdeath=getServerTickTime();
|
||||||
|
log("Last death: "+pd.lastdeath, 2);
|
||||||
}
|
}
|
||||||
},1);
|
},1);
|
||||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
|
pd.lastdeath=getServerTickTime();
|
||||||
pd.hasDied=false;
|
pd.hasDied=false;
|
||||||
GenericFunctions.addIFrame(p, 20*10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user