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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -408,6 +413,10 @@ public enum MovementManager {
|
||||
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();
|
||||
|
||||
@@ -596,6 +599,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
|
||||
// if flying, make sure spell valid for flying.
|
||||
// if (pc.getAltitude() > 0)
|
||||
@@ -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) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import engine.Enum.GuildState;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.GuildManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
@@ -27,6 +26,8 @@ import engine.objects.Guild;
|
||||
import engine.objects.GuildStatusController;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AcceptSubInviteHandler() {
|
||||
@@ -37,74 +38,69 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
||||
PlayerCharacter playerCharacter;
|
||||
Guild protectorate;
|
||||
Guild nation;
|
||||
PlayerCharacter sourcePlayer;
|
||||
Guild sourceGuild;
|
||||
Guild targetGuild;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get PlayerCharacter of person sending sub invite
|
||||
|
||||
playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||
sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (playerCharacter == null)
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
|
||||
protectorate = playerCharacter.getGuild();
|
||||
nation = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||
|
||||
//must be source guild to sub to
|
||||
|
||||
if (nation == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||
if (targetGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
if (protectorate == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||
if (sourceGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
|
||||
if (protectorate.equals(nation))
|
||||
if (sourceGuild.equals(targetGuild))
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Only a guild leader can accept fealty!");
|
||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only a guild leader can accept fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
//source guild is limited to 7 subs
|
||||
//TODO this should be based on TOL rank
|
||||
|
||||
if (!nation.canSubAGuild(protectorate)) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||
if (!targetGuild.canSubAGuild(sourceGuild)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
|
||||
//all tests passed, let's Handle code
|
||||
//Update Target Guild State.
|
||||
|
||||
// Update database
|
||||
sourceGuild.upgradeGuildState(false);
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(protectorate.getObjectUUID(), nation.getObjectUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
//Add sub so GuildMaster can Swear in.
|
||||
|
||||
//update Guild states.
|
||||
ArrayList<Guild> subs = targetGuild.getSubGuildList();
|
||||
subs.add(sourceGuild);
|
||||
|
||||
protectorate.setNation(nation);
|
||||
GuildManager.updateAllGuildTags(protectorate);
|
||||
protectorate.upgradeGuildState(false);
|
||||
targetGuild.setGuildState(GuildState.Nation);
|
||||
|
||||
if (nation.getGuildState() == GuildState.Sovereign)
|
||||
nation.upgradeGuildState(true);
|
||||
|
||||
//Let's send the message back.
|
||||
|
||||
msg.setUnknown02(1);
|
||||
msg.setResponse("Your guild is now a " + protectorate.getGuildState().name() + '.');
|
||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
ChatManager.chatSystemInfo(playerCharacter, "Your guild is now a " + protectorate.getGuildState().name() + '.');
|
||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1249,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());
|
||||
|
||||
@@ -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;
|
||||
@@ -4437,6 +4441,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(sourceType.name());
|
||||
float amount;
|
||||
@@ -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