Proper random walking override.

This commit is contained in:
MobiusDevelopment 2021-10-26 23:50:42 +00:00
parent 55c18870df
commit 4e9f507f33
28 changed files with 134 additions and 56 deletions

View File

@ -539,7 +539,7 @@ public class AttackableAI extends CreatureAI
}
}
// Order to the MonsterInstance to random walk (1/100)
else if (npc.hasRandomAnimation() && (npc.getSpawn() != null) && (Rnd.get(RANDOM_WALK_RATE) == 0))
else if (npc.isRandomWalkingEnabled() && (npc.getSpawn() != null) && (Rnd.get(RANDOM_WALK_RATE) == 0))
{
int x1;
int y1;

View File

@ -2736,16 +2736,6 @@ public class Attackable extends NpcInstance
return getTemplate().getAbsorbLevel();
}
/**
* Check if the server allows Random Animation.<br>
* This is located here because Monster and FriendlyMob both extend this class. The other non-pc instances extend either NpcInstance or MonsterInstance.
*/
@Override
public boolean hasRandomAnimation()
{
return (Config.MAX_MONSTER_ANIMATION > 0) && isMonster() && !(this instanceof GrandBossInstance);
}
protected void setCommandChannelTimer(CommandChannelTimer commandChannelTimer)
{
_commandChannelTimer = commandChannelTimer;

View File

@ -230,7 +230,13 @@ public class ChestInstance extends MonsterInstance
}
@Override
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return false;
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}

View File

@ -52,6 +52,12 @@ public class ControllableMobInstance extends MonsterInstance
return 500;
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
public ControllableMobInstance(int objectId, NpcTemplate template)
{
super(objectId, template);

View File

@ -27,4 +27,10 @@ public class FeedableBeastInstance extends MonsterInstance
{
super(objectId, template);
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
}

View File

@ -78,10 +78,10 @@ public class FestivalMonsterInstance extends MonsterInstance
/**
* All mobs in the festival really don't need random animation.
* @return true, if successful
* @return false
*/
@Override
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return false;
}

View File

@ -94,7 +94,7 @@ public class FortSiegeGuardInstance extends Attackable
}
@Override
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return false;
}

View File

@ -83,4 +83,10 @@ public class GourdInstance extends MonsterInstance
}
super.reduceCurrentHp(damage, attacker, awake);
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
}

View File

@ -111,15 +111,27 @@ public class GrandBossInstance extends MonsterInstance
}, 60000, 20000);
}
@Override
public boolean isRaid()
{
return true;
}
public void healFull()
{
super.setCurrentHp(super.getMaxHp());
super.setCurrentMp(super.getMaxMp());
}
@Override
public boolean isRandomAnimationEnabled()
{
return false;
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
@Override
public boolean isRaid()
{
return true;
}
}

View File

@ -291,6 +291,12 @@ public class MonsterInstance extends Attackable
_minionList.clearRespawnList();
}
@Override
public boolean isRandomWalkingEnabled()
{
return Config.MAX_DRIFT_RANGE > 0;
}
@Override
public boolean isMonster()
{

View File

@ -151,15 +151,16 @@ public class NpcInstance extends Creature
}
}
/**
* Check if the server allows Random Animation.
* @return true, if successful
*/
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return Config.MAX_NPC_ANIMATION > 0;
}
public boolean isRandomWalkingEnabled()
{
return false;
}
public class destroyTemporalNPC implements Runnable
{
private final Spawn _oldSpawn;

View File

@ -80,4 +80,10 @@ public class PenaltyMonsterInstance extends MonsterInstance
}
return true;
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
}

View File

@ -83,7 +83,7 @@ public class SiegeGuardInstance extends Attackable
}
@Override
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return false;
}

View File

@ -67,7 +67,7 @@ public class RandomAnimationTaskManager implements Runnable
public void add(NpcInstance npc)
{
if (npc.hasRandomAnimation())
if (npc.isRandomAnimationEnabled())
{
PENDING_ANIMATIONS.putIfAbsent(npc, Chronos.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
}

View File

@ -539,7 +539,7 @@ public class AttackableAI extends CreatureAI
}
}
// Order to the MonsterInstance to random walk (1/100)
else if (npc.hasRandomAnimation() && (npc.getSpawn() != null) && (Rnd.get(RANDOM_WALK_RATE) == 0))
else if (npc.isRandomWalkingEnabled() && (npc.getSpawn() != null) && (Rnd.get(RANDOM_WALK_RATE) == 0))
{
int x1;
int y1;

View File

@ -3088,16 +3088,6 @@ public class Attackable extends NpcInstance
return getTemplate().getAbsorbLevel();
}
/**
* Check if the server allows Random Animation.<br>
* This is located here because Monster and FriendlyMob both extend this class. The other non-pc instances extend either NpcInstance or MonsterInstance.
*/
@Override
public boolean hasRandomAnimation()
{
return (Config.MAX_MONSTER_ANIMATION > 0) && isMonster() && !(this instanceof GrandBossInstance);
}
protected void setCommandChannelTimer(CommandChannelTimer commandChannelTimer)
{
_commandChannelTimer = commandChannelTimer;

View File

@ -230,7 +230,13 @@ public class ChestInstance extends MonsterInstance
}
@Override
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return false;
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}

View File

@ -52,6 +52,12 @@ public class ControllableMobInstance extends MonsterInstance
return 500;
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
public ControllableMobInstance(int objectId, NpcTemplate template)
{
super(objectId, template);

View File

@ -27,4 +27,10 @@ public class FeedableBeastInstance extends MonsterInstance
{
super(objectId, template);
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
}

View File

@ -78,10 +78,10 @@ public class FestivalMonsterInstance extends MonsterInstance
/**
* All mobs in the festival really don't need random animation.
* @return true, if successful
* @return false
*/
@Override
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return false;
}

View File

@ -94,7 +94,7 @@ public class FortSiegeGuardInstance extends Attackable
}
@Override
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return false;
}

View File

@ -83,4 +83,10 @@ public class GourdInstance extends MonsterInstance
}
super.reduceCurrentHp(damage, attacker, awake);
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
}

View File

@ -111,15 +111,27 @@ public class GrandBossInstance extends MonsterInstance
}, 60000, 20000);
}
@Override
public boolean isRaid()
{
return true;
}
public void healFull()
{
super.setCurrentHp(super.getMaxHp());
super.setCurrentMp(super.getMaxMp());
}
@Override
public boolean isRandomAnimationEnabled()
{
return false;
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
@Override
public boolean isRaid()
{
return true;
}
}

View File

@ -291,6 +291,12 @@ public class MonsterInstance extends Attackable
_minionList.clearRespawnList();
}
@Override
public boolean isRandomWalkingEnabled()
{
return Config.MAX_DRIFT_RANGE > 0;
}
@Override
public boolean isMonster()
{

View File

@ -153,15 +153,16 @@ public class NpcInstance extends Creature
}
}
/**
* Check if the server allows Random Animation.
* @return true, if successful
*/
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return Config.MAX_NPC_ANIMATION > 0;
}
public boolean isRandomWalkingEnabled()
{
return false;
}
public class destroyTemporalNPC implements Runnable
{
private final Spawn _oldSpawn;

View File

@ -80,4 +80,10 @@ public class PenaltyMonsterInstance extends MonsterInstance
}
return true;
}
@Override
public boolean isRandomWalkingEnabled()
{
return false;
}
}

View File

@ -83,7 +83,7 @@ public class SiegeGuardInstance extends Attackable
}
@Override
public boolean hasRandomAnimation()
public boolean isRandomAnimationEnabled()
{
return false;
}

View File

@ -67,7 +67,7 @@ public class RandomAnimationTaskManager implements Runnable
public void add(NpcInstance npc)
{
if (npc.hasRandomAnimation())
if (npc.isRandomAnimationEnabled())
{
PENDING_ANIMATIONS.putIfAbsent(npc, Chronos.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
}