Browse Source

added power casting for pets who have DB entires

pull/13/head
FatBoy-DOTC 3 years ago
parent
commit
69c78fa5a6
  1. 3
      src/engine/ai/MobileFSM.java
  2. 38
      src/engine/ai/utilities/CombatUtilities.java
  3. 4
      src/engine/objects/Mob.java

3
src/engine/ai/MobileFSM.java

@ -1126,8 +1126,7 @@ public class MobileFSM {
return; return;
} }
//HashMap<Integer, Integer> staticPowers = aiAgent.getMobBase().getStaticPowers(); HashMap<Integer, Integer> staticPowers = aiAgent.getMobBase().getStaticPowers();
HashMap<Integer,Integer> staticPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(aiAgent.getMobBaseID());
if (staticPowers != null && !staticPowers.isEmpty()) { if (staticPowers != null && !staticPowers.isEmpty()) {
int chance = ThreadLocalRandom.current().nextInt(100); int chance = ThreadLocalRandom.current().nextInt(100);

38
src/engine/ai/utilities/CombatUtilities.java

@ -15,13 +15,17 @@ import engine.Enum.*;
import engine.ai.MobileFSM.STATE; import engine.ai.MobileFSM.STATE;
import engine.gameManager.ChatManager; import engine.gameManager.ChatManager;
import engine.gameManager.CombatManager; import engine.gameManager.CombatManager;
import engine.gameManager.PowersManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.msg.TargetedActionMsg; import engine.net.client.msg.TargetedActionMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -381,10 +385,42 @@ public class CombatUtilities {
float min = (mainHand) ? agent.getMinDamageHandOne() : agent.getMinDamageHandTwo(); float min = (mainHand) ? agent.getMinDamageHandOne() : agent.getMinDamageHandTwo();
float max = (mainHand) ? agent.getMaxDamageHandOne() : agent.getMaxDamageHandTwo();; float max = (mainHand) ? agent.getMaxDamageHandOne() : agent.getMaxDamageHandTwo();;
if(agent.isSummonedPet() == true)
{
//check if we have powers to cast
if(agent.mobPowers.isEmpty() == false) {
//check for power usage
Random random = new Random();
int value = random.nextInt(0 + (agent.mobPowers.size() + (agent.mobPowers.size() * 5))) + 0;
if (value <= agent.mobPowers.size())
{
//do power
int powerId = agent.mobPowers.get(value);
PowersManager.runPowerAction(agent,target,target.getLoc(),new ActionsBase(),40, PowersManager.getPowerByToken(powerId));
}
else
{
//do mele damage
float range = max - min; float range = max - min;
float damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; float damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
if (AbstractWorldObject.IsAbstractCharacter(target))
if (((AbstractCharacter) target).isSit())
damage *= 2.5f; //increase damage if sitting
if (AbstractWorldObject.IsAbstractCharacter(target))
return ((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, damage, 0);
if (target.getObjectType() == GameObjectType.Building) {
Building building = (Building) target;
Resists resists = building.getResists();
return damage * (1 - (resists.getResist(dt, 0) / 100));
}
}
}
}
float range = max - min;
float damage = min + ((ThreadLocalRandom.current().nextFloat()*range)+(ThreadLocalRandom.current().nextFloat()*range))/2;
//DAMAGE FORMULA FOR PET
if (AbstractWorldObject.IsAbstractCharacter(target)) if (AbstractWorldObject.IsAbstractCharacter(target))
if (((AbstractCharacter)target).isSit()) if (((AbstractCharacter)target).isSit())
damage *= 2.5f; //increase damage if sitting damage *= 2.5f; //increase damage if sitting

4
src/engine/objects/Mob.java

@ -32,6 +32,7 @@ import engine.net.client.msg.ManageCityAssetsMsg;
import engine.net.client.msg.PetMsg; import engine.net.client.msg.PetMsg;
import engine.net.client.msg.PlaceAssetMsg; import engine.net.client.msg.PlaceAssetMsg;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import engine.server.world.WorldServer; import engine.server.world.WorldServer;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -111,7 +112,7 @@ public class Mob extends AbstractIntelligenceAgent {
public boolean despawned = false; public boolean despawned = false;
public Vector3fImmutable destination = Vector3fImmutable.ZERO; public Vector3fImmutable destination = Vector3fImmutable.ZERO;
public Vector3fImmutable localLoc = Vector3fImmutable.ZERO; public Vector3fImmutable localLoc = Vector3fImmutable.ZERO;
public HashMap<Integer,Integer> mobPowers;
/** /**
* No Id Constructor * No Id Constructor
*/ */
@ -365,6 +366,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.setObjectTypeMask(MBServerStatics.MASK_PET | this.getTypeMasks()); this.setObjectTypeMask(MBServerStatics.MASK_PET | this.getTypeMasks());
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
this.setLoc(this.getLoc()); this.setLoc(this.getLoc());
mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getMobBaseID());
} }
if (!isPet && this.contract == null) { if (!isPet && this.contract == null) {
this.level = (short) this.mobBase.getLevel(); this.level = (short) this.mobBase.getLevel();

Loading…
Cancel
Save