Browse Source

Merge remote-tracking branch 'origin/debug-pet-stats'

master
MagicBot 1 year ago
parent
commit
e15075f57f
  1. 39
      src/engine/ai/MobileFSM.java
  2. 3
      src/engine/loot/LootManager.java
  3. 3
      src/engine/objects/Mob.java
  4. 8
      src/engine/powers/poweractions/ApplyEffectPowerAction.java
  5. 3
      src/engine/powers/poweractions/CreateMobPowerAction.java

39
src/engine/ai/MobileFSM.java

@ -105,6 +105,11 @@ public class MobileFSM { @@ -105,6 +105,11 @@ public class MobileFSM {
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
}
}
if(target.getPet() != null){
if(target.getPet().getCombatTarget() == null && target.getPet().assist() == true){
target.getPet().setCombatTarget(mob);
}
}
}
public static void AttackBuilding(Mob mob, Building target) {
@ -172,6 +177,9 @@ public class MobileFSM { @@ -172,6 +177,9 @@ public class MobileFSM {
attackDelay = 11000;
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
if(target.combatTarget == null){
target.combatTarget = mob;
}
}
}
@ -432,6 +440,18 @@ public class MobileFSM { @@ -432,6 +440,18 @@ public class MobileFSM {
return;
}
}
if(aiAgent.combatTarget == null) {
//look for pets to aggro if no players found to aggro
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(aiAgent, MobileFSMManager.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PET);
for (AbstractWorldObject awoMob : awoList) {
//dont scan self.
if (aiAgent.equals(awoMob))
continue;
Mob aggroMob = (Mob) awoMob;
aiAgent.setCombatTarget(aggroMob);
return;
}
}
}
private static void CheckMobMovement(Mob mob) {
@ -658,11 +678,26 @@ public class MobileFSM { @@ -658,11 +678,26 @@ public class MobileFSM {
mob.killCharacter("no owner");
}
}
if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive())
mob.setCombatTarget(null);
if (mob.getCombatTarget() != null)
if(!mob.getCombatTarget().isAlive() || mob.getCombatTarget().getLoc().distanceSquared(mob.getOwner().getLoc()) > 75)
mob.setCombatTarget(null);
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)
CheckMobMovement(mob);
CheckForAttack(mob);
//recover health
if(mob.getTimestamps().containsKey("HEALTHRECOVERED") == false){
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
}
if(mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000){
if(mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None))* 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED",System.currentTimeMillis());
if(mob.getHealth() > mob.getHealthMax()){
mob.setHealth(mob.getHealthMax());
}
}
}
}
private static void HamletGuardLogic(Mob mob) {

3
src/engine/loot/LootManager.java

@ -225,9 +225,6 @@ public class LootManager { @@ -225,9 +225,6 @@ public class LootManager {
}
int min = (int)(mobLevel * 2.5f);
int roll = ThreadLocalRandom.current().nextInt(max-min) + min;
if(roll >= 191){
int poo = 0;
}
return roll;
}
public static void AddGenTableRow(int tableID, GenTableRow row) {

3
src/engine/objects/Mob.java

@ -1490,6 +1490,9 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1490,6 +1490,9 @@ public class Mob extends AbstractIntelligenceAgent {
float s;
h = this.mobBase.getHealthMax();
if(this.isPet()){
h = this.level * 0.5f * 120;
}
m = this.statSpiCurrent;
s = this.statConCurrent;

8
src/engine/powers/poweractions/ApplyEffectPowerAction.java

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
package engine.powers.poweractions;
import com.sun.prism.impl.ps.BaseShaderContext;
import engine.Enum.GameObjectType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
@ -140,10 +141,17 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { @@ -140,10 +141,17 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
((Mob) awo).setCombatTarget(source);
ChatSystemMsg msg = ChatManager.CombatInfo(source, awo);
DispatchMessage.sendToAllInRange(source, msg);
((Mob)awo).refresh();
}
}
if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
if(((Mob)awo).isPet()) {
((Mob) awo).recalculateStats();
}
}
this.effect.startEffect(source, awo, trains, eff);
}
}
protected void _applyEffectForItem(Item item, int trains) {

3
src/engine/powers/poweractions/CreateMobPowerAction.java

@ -158,6 +158,9 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -158,6 +158,9 @@ public class CreateMobPowerAction extends AbstractPowerAction {
if(pet.isSiege() == false) {
MovementManager.translocate(pet, owner.getLoc(), owner.region);
}
pet.recalculateStats();
pet.healthMax = pet.level * 0.5f * 120;
pet.setHealth(pet.healthMax);
PetMsg pm = new PetMsg(5, pet);
Dispatch dispatch = Dispatch.borrow(owner, pm);
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);

Loading…
Cancel
Save