forked from MagicBane/Server
Compare commits
9 Commits
convex-data
...
subdate
| Author | SHA1 | Date | |
|---|---|---|---|
| c02564d7af | |||
| 945f85443d | |||
| 3649c629b7 | |||
| 1c31070fc8 | |||
| bff41967db | |||
| d3692d0fb7 | |||
| 074a799d01 | |||
| 36ffd08a72 | |||
| 58f828b3cd |
@@ -693,6 +693,8 @@ public class MobAI {
|
|||||||
DefaultLogic(mob);
|
DefaultLogic(mob);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(mob.isAlive())
|
||||||
|
RecoverHealth(mob);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -808,7 +810,7 @@ public class MobAI {
|
|||||||
chaseTarget(mob);
|
chaseTarget(mob);
|
||||||
break;
|
break;
|
||||||
case GuardMinion:
|
case GuardMinion:
|
||||||
if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned)
|
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null)
|
||||||
randomGuardPatrolPoint(mob);
|
randomGuardPatrolPoint(mob);
|
||||||
else {
|
else {
|
||||||
if (mob.getCombatTarget() != null) {
|
if (mob.getCombatTarget() != null) {
|
||||||
@@ -827,6 +829,7 @@ public class MobAI {
|
|||||||
chaseTarget(mob);
|
chaseTarget(mob);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
|
||||||
@@ -1043,7 +1046,6 @@ public class MobAI {
|
|||||||
mob.setCombatTarget(newTarget);
|
mob.setCombatTarget(newTarget);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckMobMovement(mob);
|
CheckMobMovement(mob);
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1054,24 +1056,9 @@ public class MobAI {
|
|||||||
public static void GuardMinionLogic(Mob mob) {
|
public static void GuardMinionLogic(Mob mob) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!mob.npcOwner.isAlive()) {
|
boolean isComanded = mob.npcOwner.isAlive();
|
||||||
|
if (!isComanded) {
|
||||||
if (mob.getCombatTarget() == null) {
|
GuardCaptainLogic(mob);
|
||||||
CheckForPlayerGuardAggro(mob);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
|
||||||
|
|
||||||
if (newTarget != null) {
|
|
||||||
|
|
||||||
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
|
||||||
if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
|
|
||||||
mob.setCombatTarget(newTarget);
|
|
||||||
} else
|
|
||||||
mob.setCombatTarget(newTarget);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else {
|
}else {
|
||||||
if (mob.npcOwner.getCombatTarget() != null)
|
if (mob.npcOwner.getCombatTarget() != null)
|
||||||
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
|
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
|
||||||
@@ -1110,22 +1097,6 @@ public class MobAI {
|
|||||||
CheckMobMovement(mob);
|
CheckMobMovement(mob);
|
||||||
|
|
||||||
CheckForAttack(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());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -1379,4 +1350,22 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RecoverHealth(Mob 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ import engine.Enum.GuildState;
|
|||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.gameManager.GuildManager;
|
||||||
import engine.gameManager.SessionManager;
|
import engine.gameManager.SessionManager;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
@@ -26,8 +27,6 @@ import engine.objects.Guild;
|
|||||||
import engine.objects.GuildStatusController;
|
import engine.objects.GuildStatusController;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
public AcceptSubInviteHandler() {
|
public AcceptSubInviteHandler() {
|
||||||
@@ -38,69 +37,74 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
|||||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
||||||
PlayerCharacter sourcePlayer;
|
PlayerCharacter playerCharacter;
|
||||||
Guild sourceGuild;
|
Guild protectorate;
|
||||||
Guild targetGuild;
|
Guild nation;
|
||||||
Dispatch dispatch;
|
Dispatch dispatch;
|
||||||
|
|
||||||
// get PlayerCharacter of person sending sub invite
|
// get PlayerCharacter of person sending sub invite
|
||||||
|
|
||||||
sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||||
|
|
||||||
if (sourcePlayer == null)
|
if (playerCharacter == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
sourceGuild = sourcePlayer.getGuild();
|
protectorate = playerCharacter.getGuild();
|
||||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
nation = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||||
|
|
||||||
//must be source guild to sub to
|
//must be source guild to sub to
|
||||||
|
|
||||||
if (targetGuild == null) {
|
if (nation == null) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sourceGuild == null) {
|
if (protectorate == null) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceGuild.equals(targetGuild))
|
if (protectorate.equals(nation))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus()) == false) {
|
||||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only a guild leader can accept fealty!");
|
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Only a guild leader can accept fealty!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//source guild is limited to 7 subs
|
//source guild is limited to 7 subs
|
||||||
//TODO this should be based on TOL rank
|
//TODO this should be based on TOL rank
|
||||||
|
|
||||||
if (!targetGuild.canSubAGuild(sourceGuild)) {
|
if (!nation.canSubAGuild(protectorate)) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//all tests passed, let's Handle code
|
//all tests passed, let's Handle code
|
||||||
//Update Target Guild State.
|
|
||||||
|
|
||||||
sourceGuild.upgradeGuildState(false);
|
// Update database
|
||||||
|
|
||||||
//Add sub so GuildMaster can Swear in.
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<Guild> subs = targetGuild.getSubGuildList();
|
//update Guild states.
|
||||||
subs.add(sourceGuild);
|
|
||||||
|
|
||||||
targetGuild.setGuildState(GuildState.Nation);
|
protectorate.setNation(nation);
|
||||||
|
GuildManager.updateAllGuildTags(protectorate);
|
||||||
|
protectorate.upgradeGuildState(false);
|
||||||
|
|
||||||
|
if (nation.getGuildState() == GuildState.Sovereign)
|
||||||
|
nation.upgradeGuildState(true);
|
||||||
|
|
||||||
//Let's send the message back.
|
//Let's send the message back.
|
||||||
|
|
||||||
msg.setUnknown02(1);
|
msg.setUnknown02(1);
|
||||||
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
msg.setResponse("Your guild is now a " + protectorate.getGuildState().name() + '.');
|
||||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
ChatManager.chatSystemInfo(playerCharacter, "Your guild is now a " + protectorate.getGuildState().name() + '.');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user