Browse Source

Merge remote-tracking branch 'origin/pet-guard-damage-fix' into release-1.3

master
MagicBot 2 years ago
parent
commit
0f5b0493b9
  1. 6
      src/engine/ai/MobileFSM.java
  2. 106
      src/engine/ai/utilities/CombatUtilities.java
  3. 6
      src/engine/objects/Mob.java

6
src/engine/ai/MobileFSM.java

@ -16,10 +16,7 @@ import engine.Enum.GameObjectType;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.ai.utilities.CombatUtilities; import engine.ai.utilities.CombatUtilities;
import engine.ai.utilities.MovementUtilities; import engine.ai.utilities.MovementUtilities;
import engine.gameManager.BuildingManager; import engine.gameManager.*;
import engine.gameManager.CombatManager;
import engine.gameManager.MovementManager;
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.PerformActionMsg; import engine.net.client.msg.PerformActionMsg;
@ -1130,7 +1127,6 @@ public class MobileFSM {
} }
HashMap<Integer, Integer> staticPowers = aiAgent.getMobBase().getStaticPowers(); HashMap<Integer, Integer> staticPowers = aiAgent.getMobBase().getStaticPowers();
if (staticPowers != null && !staticPowers.isEmpty()) { if (staticPowers != null && !staticPowers.isEmpty()) {
int chance = ThreadLocalRandom.current().nextInt(100); int chance = ThreadLocalRandom.current().nextInt(100);

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

@ -12,16 +12,26 @@ package engine.ai.utilities;
import engine.Enum; import engine.Enum;
import engine.Enum.*; import engine.Enum.*;
import engine.ai.MobileFSM;
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.DbManager;
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 sun.security.util.Debug;
import java.security.KeyStore;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -237,7 +247,6 @@ public class CombatUtilities {
speed = agent.getSpeedHandOne(); speed = agent.getSpeedHandOne();
else else
speed = agent.getSpeedHandTwo(); speed = agent.getSpeedHandTwo();
DamageType dt = DamageType.Crush; DamageType dt = DamageType.Crush;
if (agent.isSiege()) if (agent.isSiege())
dt = DamageType.Siege; dt = DamageType.Siege;
@ -280,6 +289,64 @@ public class CombatUtilities {
else if(triggerBlock(agent,target)) else if(triggerBlock(agent,target))
swingIsBlock(agent,target, passiveAnim); swingIsBlock(agent,target, passiveAnim);
else else
//check for a cast here?
//agent.mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(agent.getMobBaseID());
if(agent.mobPowers.size() > 0 && agent.mobPowers != null)
{
//get cast chance 33% cast 67% mele
int random = ThreadLocalRandom.current().nextInt(agent.mobPowers.size() * 3);
//allow casting of spell
if(random <= agent.mobPowers.size())
{
int powerToken;
int powerRank;
//cast a spell
Map<Integer,Integer> entries = agent.mobPowers;
int count = 0;
for(Map.Entry<Integer,Integer> entry : entries.entrySet())
{
count += 1;
if(count == random)
{
powerToken = entry.getKey();
//powerRank = entry.getValue();
switch(agent.getLevel())
{
default:
powerRank = 1;
break;
case 10:
powerRank = 5;
break;
case 20:
powerRank = 10;
break;
case 30:
powerRank = 15;
break;
case 40:
powerRank = 25;
break;
case 50:
powerRank = 30;
break;
case 60:
powerRank = 35;
break;
case 70:
powerRank = 40;
break;
}
System.out.println(agent.getMobBase().getFirstName() + " is casting: " + PowersManager.getPowerByToken(powerToken).skillName);
PowersManager.applyPower(agent,target,target.getLoc(),powerToken,powerRank, false);
}
}
return;
}
}
//finished with casting check
swingIsDamage(agent,target, determineDamage(agent,target, mainHand, speed, dt), anim); swingIsDamage(agent,target, determineDamage(agent,target, mainHand, speed, dt), anim);
if (agent.getWeaponPower() != null) if (agent.getWeaponPower() != null)
@ -381,10 +448,45 @@ 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)
{
min = 40 * (1 + (agent.getLevel()/10));
max = 60 * (1 + (agent.getLevel()/8));
//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

6
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();
@ -2201,7 +2203,7 @@ public class Mob extends AbstractIntelligenceAgent {
} catch(Exception e){ } catch(Exception e){
Logger.error( e.getMessage()); Logger.error( e.getMessage());
} }
mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getMobBaseID());
if (this.equip == null) { if (this.equip == null) {
Logger.error("Null equipset returned for uuid " + currentID); Logger.error("Null equipset returned for uuid " + currentID);
this.equip = new HashMap<>(0); this.equip = new HashMap<>(0);

Loading…
Cancel
Save