Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b944847b8a | |||
| cdf6465f60 |
@@ -24,3 +24,5 @@
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
*.code-workspace
|
||||
|
||||
|
||||
@@ -1196,6 +1196,7 @@ public class Enum {
|
||||
Durability,
|
||||
ExclusiveDamageCap,
|
||||
Fade,
|
||||
Fear,
|
||||
Fly,
|
||||
Health,
|
||||
HealthFull,
|
||||
|
||||
@@ -280,6 +280,9 @@ public class dbEffectsBaseHandler extends dbHandlerBase {
|
||||
case Stunned:
|
||||
abstractEffectModifier = new StunnedEffectModifier(rs);
|
||||
break;
|
||||
case Fear:
|
||||
abstractEffectModifier = new FearEffectModifier(rs);
|
||||
break;
|
||||
case Value:
|
||||
abstractEffectModifier = new ValueEffectModifier(rs);
|
||||
if (effectBase != null) {
|
||||
|
||||
@@ -243,12 +243,8 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
|
||||
public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) {
|
||||
|
||||
// Column name must match what NPC/Mob loaders read ("equipmentSet").
|
||||
// Using the wrong column here causes the update to fail silently and
|
||||
// dev command to report "Unable to find Equipset" despite a valid ID.
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipmentSet`=? WHERE `UID`=?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipsetID`=? WHERE `UID`=?")) {
|
||||
|
||||
preparedStatement.setInt(1, equipSetID);
|
||||
preparedStatement.setLong(2, npc.getObjectUUID());
|
||||
@@ -471,4 +467,4 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,6 +433,11 @@ public enum CombatManager {
|
||||
if (bonus != null && bonus.getBool(ModType.Stunned, SourceType.None))
|
||||
attackFailure = true;
|
||||
|
||||
//see if attacker is feared. If so, stop here
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Fear, SourceType.None))
|
||||
attackFailure = true;
|
||||
|
||||
//Get Range of weapon
|
||||
|
||||
float range;
|
||||
|
||||
@@ -79,6 +79,11 @@ public enum MovementManager {
|
||||
return;
|
||||
}
|
||||
|
||||
// Will this prevent movement at all or only player input for movement?
|
||||
if (toMove.getBonuses().getBool(ModType.Fear, SourceType.None)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.getEndLat() > MBServerStatics.MAX_WORLD_WIDTH)
|
||||
msg.setEndLat((float) MBServerStatics.MAX_WORLD_WIDTH);
|
||||
|
||||
@@ -407,6 +412,10 @@ public enum MovementManager {
|
||||
PlayerBonuses bonus = member.getBonuses();
|
||||
if (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotMove, SourceType.None))
|
||||
continue;
|
||||
|
||||
//don't move if player is feared
|
||||
if (bonus.getBool(ModType.Fear, SourceType.None))
|
||||
continue;
|
||||
|
||||
member.update();
|
||||
|
||||
|
||||
@@ -313,6 +313,9 @@ public enum PowersManager {
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotCast, SourceType.None) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
return true;
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Fear, SourceType.None))
|
||||
return true;
|
||||
|
||||
// if moving make sure spell valid for movement
|
||||
Vector3fImmutable endLoc = playerCharacter.getEndLoc();
|
||||
|
||||
@@ -595,6 +598,9 @@ public enum PowersManager {
|
||||
SourceType sourceType = SourceType.GetSourceType(pb.getCategory());
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotCast, SourceType.None) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
return true;
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Fear, SourceType.None))
|
||||
return true;
|
||||
|
||||
// if moving make sure spell valid for movement
|
||||
// if flying, make sure spell valid for flying.
|
||||
@@ -761,6 +767,11 @@ public enum PowersManager {
|
||||
finishRecycleTime(msg.getPowerUsedID(), playerCharacter, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bonus.getBool(ModType.Fear, SourceType.None)) {
|
||||
finishRecycleTime(msg.getPowerUsedID(), playerCharacter, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// get target loc
|
||||
@@ -1042,6 +1053,9 @@ public enum PowersManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Fear, SourceType.None))
|
||||
return;
|
||||
|
||||
msg.setNumTrains(9999);
|
||||
msg.setUnknown04(2);
|
||||
DispatchMessage.sendToAllInRange(caster, msg);
|
||||
@@ -2565,6 +2579,10 @@ public enum PowersManager {
|
||||
|
||||
}
|
||||
|
||||
public static void cancelOnFear(AbstractCharacter ac) {
|
||||
|
||||
}
|
||||
|
||||
private static PowersBase getLastPower(AbstractCharacter ac) {
|
||||
if (ac == null)
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package engine.jobs;
|
||||
|
||||
import engine.job.AbstractJob;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.server.MBServerStatics;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class FearWanderJob extends AbstractJob {
|
||||
private final AbstractCharacter target;
|
||||
private final Random rand = new Random();
|
||||
|
||||
public FearWanderJob(AbstractCharacter target) {
|
||||
super();
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
// Only wander if still feared
|
||||
if (target == null || !target.getBonuses().getBool(engine.Enum.ModType.Fear, engine.Enum.SourceType.None))
|
||||
return;
|
||||
|
||||
// Pick a random direction and distance
|
||||
float angle = rand.nextFloat() * (float)Math.PI * 2f;
|
||||
float distance = 5f + rand.nextFloat() * 10f; // 5-15 units
|
||||
|
||||
Vector3fImmutable current = target.getLoc();
|
||||
float newX = current.x + (float)Math.cos(angle) * distance;
|
||||
float newZ = current.z + (float)Math.sin(angle) * distance;
|
||||
|
||||
// Clamp to world bounds if needed
|
||||
newX = (float) Math.max(0, Math.min(newX, MBServerStatics.MAX_WORLD_WIDTH));
|
||||
newZ = (float) Math.max(0, Math.min(newZ, MBServerStatics.MAX_WORLD_HEIGHT));
|
||||
|
||||
Vector3fImmutable dest = new Vector3fImmutable(newX, current.y, newZ);
|
||||
|
||||
// Issue movement (implement setEndLoc or similar in your AbstractCharacter)
|
||||
target.setEndLoc(dest);
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class CombatUtilities {
|
||||
}
|
||||
|
||||
public static boolean canSwing(Mob agent) {
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None));
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.Fear, SourceType.None));
|
||||
}
|
||||
|
||||
public static void swingIsMiss(Mob agent, AbstractWorldObject target, int animation) {
|
||||
|
||||
@@ -169,7 +169,7 @@ public class MovementUtilities {
|
||||
if (agent.getMobBase() != null && Enum.MobFlagType.SENTINEL.elementOf(agent.getMobBase().getFlags()))
|
||||
return false;
|
||||
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.Fear, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
|
||||
}
|
||||
|
||||
public static Vector3fImmutable randomPatrolLocation(Mob agent, Vector3fImmutable center, float radius) {
|
||||
|
||||
@@ -1653,6 +1653,30 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
PowersManager.cancelOnStun(this);
|
||||
}
|
||||
|
||||
public final void cancelOnFear() {
|
||||
boolean changed = false;
|
||||
for (String s : this.effects.keySet()) {
|
||||
Effect eff = this.effects.get(s);
|
||||
if (eff == null)
|
||||
continue;
|
||||
if (eff.cancelOnFear() && eff.cancel()) {
|
||||
eff.cancelJob();
|
||||
this.effects.remove(s);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
JobContainer wanderJob = this.getTimers().get("FearWander");
|
||||
if (wanderJob != null) {
|
||||
wanderJob.cancelJob();
|
||||
this.getTimers().remove("FearWander");
|
||||
}
|
||||
if (changed) {
|
||||
applyBonuses();
|
||||
}
|
||||
PowersManager.cancelOnFear(this);
|
||||
}
|
||||
|
||||
//Call to apply any new effects to player
|
||||
public synchronized void applyBonuses() {
|
||||
PlayerCharacter player;
|
||||
|
||||
@@ -48,6 +48,7 @@ public class Effect {
|
||||
private boolean cancelOnTerritoryClaim;
|
||||
private boolean cancelOnUnEquip;
|
||||
private boolean cancelOnStun;
|
||||
private boolean cancelOnFear;
|
||||
private boolean bakedInStat = false;
|
||||
private boolean isStatic = false;
|
||||
private int effectSourceType = 0;
|
||||
@@ -80,6 +81,7 @@ public class Effect {
|
||||
this.cancelOnTerritoryClaim = false;
|
||||
this.cancelOnUnEquip = false;
|
||||
this.cancelOnStun = false;
|
||||
this.cancelOnFear = false;
|
||||
this.eb = eb;
|
||||
this.trains = trains;
|
||||
}
|
||||
@@ -99,6 +101,7 @@ public class Effect {
|
||||
this.cancelOnTerritoryClaim = false;
|
||||
this.cancelOnUnEquip = false;
|
||||
this.cancelOnStun = false;
|
||||
this.cancelOnFear = false;
|
||||
this.eb = eb;
|
||||
this.trains = trains;
|
||||
this.isStatic = isStatic;
|
||||
@@ -581,6 +584,12 @@ public class Effect {
|
||||
return this.cancelOnStun;
|
||||
}
|
||||
|
||||
public boolean cancelOnFear() {
|
||||
if (this.eb == null)
|
||||
return true;
|
||||
return this.cancelOnFear;
|
||||
}
|
||||
|
||||
public boolean cancelOnTakeDamage() {
|
||||
if (this.eb == null)
|
||||
return true;
|
||||
|
||||
@@ -541,18 +541,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
mobWithoutID.parentZone = parent;
|
||||
mobWithoutID.parentZoneID = parent.getObjectUUID();
|
||||
|
||||
// Ensure spawn coordinates are persisted for DB insert
|
||||
// statLat/statAlt/statLon represent local (zone-relative) spawn
|
||||
// coordinates used by the DB handler when creating the mob row.
|
||||
if (spawn != null && parent != null) {
|
||||
// Convert world coordinates to zone-local spawn coordinates
|
||||
Vector3fImmutable localSpawn = spawn.subtract(parent.getLoc());
|
||||
mobWithoutID.statLat = localSpawn.x;
|
||||
mobWithoutID.statAlt = localSpawn.y;
|
||||
mobWithoutID.statLon = localSpawn.z;
|
||||
}
|
||||
|
||||
// NPC in a Building derives position from slot
|
||||
|
||||
if (mobWithoutID.building != null)
|
||||
mobWithoutID.bindLoc = Vector3fImmutable.ZERO;
|
||||
|
||||
@@ -1259,7 +1249,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (!this.isMoving())
|
||||
return;
|
||||
|
||||
if (this.isAlive() == false || this.getBonuses().getBool(ModType.Stunned, SourceType.None) || this.getBonuses().getBool(ModType.CannotMove, SourceType.None)) {
|
||||
if (this.isAlive() == false || this.getBonuses().getBool(ModType.Stunned, SourceType.None) || this.getBonuses().getBool(ModType.Fear, SourceType.None) || this.getBonuses().getBool(ModType.CannotMove, SourceType.None)) {
|
||||
//Target is stunned or rooted. Don't move
|
||||
|
||||
this.stopMovement(this.getMovementLoc());
|
||||
|
||||
@@ -470,8 +470,7 @@ public class NPC extends AbstractCharacter {
|
||||
newNPC.bindLoc = Vector3fImmutable.ZERO;
|
||||
|
||||
newNPC.parentZoneUUID = parent.getObjectUUID();
|
||||
// guild may be null when spawning via ./npc; default to 0
|
||||
newNPC.guildUUID = (guild != null) ? guild.getObjectUUID() : 0;
|
||||
newNPC.guildUUID = guild.getObjectUUID();
|
||||
|
||||
if (building == null)
|
||||
newNPC.buildingUUID = 0;
|
||||
@@ -1348,4 +1347,4 @@ public class NPC extends AbstractCharacter {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4407,6 +4407,10 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
if (this.bonuses.getBool(ModType.Stunned, SourceType.None))
|
||||
return 0f;
|
||||
|
||||
if (this.bonuses.getBool(
|
||||
ModType.Fear, SourceType.None))
|
||||
return 0f;
|
||||
|
||||
// Get base skill amount
|
||||
CharacterSkill sk = this.skills.get(type);
|
||||
float amount;
|
||||
@@ -4436,6 +4440,10 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
// must not be stunned
|
||||
if (this.bonuses.getBool(ModType.Stunned, SourceType.None))
|
||||
return 0f;
|
||||
|
||||
if (this.bonuses.getBool(ModType.Fear, SourceType.None))
|
||||
return 0f;
|
||||
|
||||
|
||||
// Get base skill amount
|
||||
CharacterSkill sk = this.skills.get(sourceType.name());
|
||||
@@ -4897,6 +4905,12 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
this.region = AbstractWorldObject.GetRegionByWorldObject(this);
|
||||
return;
|
||||
}
|
||||
if (this.isAlive() == false || this.getBonuses().getBool(ModType.Fear, SourceType.None)) {
|
||||
//Target is feared. Don't move
|
||||
this.stopMovement(newLoc);
|
||||
this.region = AbstractWorldObject.GetRegionByWorldObject(this);
|
||||
return;
|
||||
}
|
||||
if (newLoc.equals(this.getEndLoc())) {
|
||||
this.stopMovement(newLoc);
|
||||
this.region = AbstractWorldObject.GetRegionByWorldObject(this);
|
||||
|
||||
@@ -247,6 +247,8 @@ public class ActionsBase {
|
||||
//TODO make this more efficient then testing strings
|
||||
if (this.stackType.equals("Stun") && bonus.getBool(ModType.ImmuneTo, SourceType.Stun))
|
||||
return true; //Currently stun immune. Skip stun
|
||||
else if (this.stackType.equals("Fear") && bonus.getBool(ModType.ImmuneTo, SourceType.Fear))
|
||||
return true; //Currently fear immune. Skip fear
|
||||
else if (this.stackType.equals("Snare") && bonus.getBool(ModType.ImmuneTo, SourceType.Snare))
|
||||
return true; //Currently snare immune. Skip snare
|
||||
else if (this.stackType.equals("Blindness") && bonus.getBool(ModType.ImmuneTo, SourceType.Blind))
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.powers.effectmodifiers;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.ModType;
|
||||
import engine.Enum.SourceType;
|
||||
import engine.jobs.FearWanderJob;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.AbstractEffectJob;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class FearEffectModifier extends AbstractEffectModifier {
|
||||
|
||||
public FearEffectModifier(ResultSet rs) throws SQLException {
|
||||
super(rs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _applyEffectModifier(AbstractCharacter source, AbstractWorldObject awo, int trains, AbstractEffectJob effect) {
|
||||
// Optional: custom logic when fear is applied
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyBonus(AbstractCharacter ac, int trains) {
|
||||
PlayerBonuses bonus = ac.getBonuses();
|
||||
|
||||
bonus.setBool(this.modType, this.sourceType, true);
|
||||
ac.cancelOnFear();
|
||||
ac.setIsCasting(false);
|
||||
ac.stopMovement(ac.getLoc());
|
||||
|
||||
// Schedule the wander job if not already scheduled
|
||||
if (ac.getTimers().get("FearWander") == null) {
|
||||
JobContainer wanderJob = JobScheduler.getInstance().scheduleJob(
|
||||
new FearWanderJob(ac), 2000
|
||||
);
|
||||
|
||||
ac.getTimers().put("FearWander", wanderJob);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyBonus(Item item, int trains) {}
|
||||
@Override
|
||||
public void applyBonus(Building building, int trains) {}
|
||||
}
|
||||
Reference in New Issue
Block a user