mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-12 22:45:31 -04:00
Command fixes, command removing
This commit is contained in:
@@ -39,6 +39,7 @@ import protocol.swg.UpdatePVPStatusMessage;
|
||||
import protocol.swg.chat.ChatSystemMessage;
|
||||
import protocol.swg.objectControllerObjects.Animation;
|
||||
import protocol.swg.objectControllerObjects.Posture;
|
||||
import protocol.swg.objectControllerObjects.StartTask;
|
||||
|
||||
import com.sleepycat.je.Environment;
|
||||
import com.sleepycat.je.Transaction;
|
||||
@@ -48,11 +49,13 @@ import com.sleepycat.persist.model.NotPersistent;
|
||||
import main.NGECore;
|
||||
import engine.clients.Client;
|
||||
import resources.common.Cooldown;
|
||||
import resources.common.OutOfBand;
|
||||
import resources.objects.Buff;
|
||||
import resources.objects.DamageOverTime;
|
||||
import resources.objects.SWGList;
|
||||
import resources.objects.SWGMap;
|
||||
import resources.objects.SkillMod;
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.objects.IPersistent;
|
||||
import engine.resources.objects.MissionCriticalObject;
|
||||
import engine.resources.objects.SWGObject;
|
||||
@@ -61,6 +64,7 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import services.command.BaseSWGCommand;
|
||||
|
||||
@Entity(version=6)
|
||||
public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
@@ -1113,18 +1117,17 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
}
|
||||
|
||||
public void sendSystemMessage(String message, byte displayType) {
|
||||
|
||||
if(getClient() != null && getClient().getSession() != null) {
|
||||
ChatSystemMessage systemMsg = new ChatSystemMessage(message, displayType);
|
||||
getClient().getSession().write(systemMsg.serialize());
|
||||
}
|
||||
|
||||
sendSystemMessage(message, new OutOfBand(), displayType);
|
||||
}
|
||||
|
||||
public void sendSystemMessage(String stfFilename, String stfName, int stat, int displayType) {
|
||||
public void sendSystemMessage(OutOfBand outOfBand, byte displayType) {
|
||||
sendSystemMessage("", outOfBand, displayType);
|
||||
}
|
||||
|
||||
public void sendSystemMessage(String message, OutOfBand outOfBand, byte displayType) {
|
||||
|
||||
if(getClient() != null && getClient().getSession() != null) {
|
||||
ChatSystemMessage systemMsg = new ChatSystemMessage(stfFilename, stfName, stat, (byte) displayType);
|
||||
ChatSystemMessage systemMsg = new ChatSystemMessage(message, outOfBand, displayType);
|
||||
getClient().getSession().write(systemMsg.serialize());
|
||||
}
|
||||
|
||||
@@ -1740,16 +1743,17 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
if (System.currentTimeMillis() < cooldowns.get(cooldownGroup)) {
|
||||
return true;
|
||||
} else {
|
||||
removeCooldown(cooldownGroup);
|
||||
cooldowns.remove(cooldownGroup);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeCooldown(String cooldownGroup) {
|
||||
if (cooldowns.containsKey(cooldownGroup)) {
|
||||
cooldowns.remove(cooldownGroup);
|
||||
public boolean removeCooldown(int actionCounter, BaseSWGCommand command) {
|
||||
if (cooldowns.containsKey(command.getCooldownGroup())) {
|
||||
cooldowns.remove(command.getCooldownGroup());
|
||||
getClient().getSession().write(new ObjControllerMessage(0x0B, new StartTask(actionCounter, getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), -1)).serialize());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1765,7 +1769,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
if (System.currentTimeMillis() < cooldowns.get(cooldownGroup)) {
|
||||
return (long) (cooldowns.get(cooldownGroup) - System.currentTimeMillis());
|
||||
} else {
|
||||
removeCooldown(cooldownGroup);
|
||||
cooldowns.remove(cooldownGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ import resources.common.*;
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.objectControllerObjects.CommandEnqueue;
|
||||
import protocol.swg.objectControllerObjects.CommandEnqueueRemove;
|
||||
import protocol.swg.objectControllerObjects.ShowFlyText;
|
||||
import protocol.swg.objectControllerObjects.StartTask;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
@@ -114,8 +113,18 @@ public class CommandService implements INetworkDispatch {
|
||||
switch (command.getTargetType()) {
|
||||
case 0: // Target Not Used For This Command
|
||||
break;
|
||||
case 1: // Other Only
|
||||
if (target == null || target == actor) {
|
||||
case 1: // Other Only (objectId/targetName)
|
||||
if (target == null) {
|
||||
if (commandArgs != null && !commandArgs.equals("")) {
|
||||
String name = commandArgs.split(" ")[0];
|
||||
|
||||
target = core.objectService.getObjectByFirstName(name);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (target == actor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -128,16 +137,32 @@ public class CommandService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
if (!core.simulationService.checkLineOfSight(actor, target)) {
|
||||
actor.showFlyText("@combat_effects:cant_see", 1.5f, new RGB(72, 209, 204), 1, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: // Self Only
|
||||
case 2: // Anyone (objectId/targetName)
|
||||
if (target == null) {
|
||||
target = actor;
|
||||
if (commandArgs != null && !commandArgs.equals("")) {
|
||||
String name = commandArgs.split(" ")[0];
|
||||
|
||||
target = core.objectService.getObjectByFirstName(name);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (target != actor) {
|
||||
if (target.getContainer() == actor || target.getGrandparent() == actor) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (command.getMaxRangeToTarget() != 0 && actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!core.simulationService.checkLineOfSight(actor, target)) {
|
||||
actor.showFlyText("@combat_effects:cant_see", 1.5f, new RGB(72, 209, 204), 1, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -145,13 +170,45 @@ public class CommandService implements INetworkDispatch {
|
||||
case 3: // Free Target Mode (rally points, group waypoints)
|
||||
target = null;
|
||||
|
||||
if (commandArgs == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
String[] args = commandArgs.split(" ");
|
||||
|
||||
float x = 0, y = 0, z = 0;
|
||||
|
||||
try {
|
||||
if (args.length == 2) {
|
||||
x = Integer.valueOf(args[0]);
|
||||
z = Integer.valueOf(args[1]);
|
||||
} else if (args.length > 2) {
|
||||
x = Integer.valueOf(args[0]);
|
||||
y = Integer.valueOf(args[1]);
|
||||
z = Integer.valueOf(args[2]);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Point3D position = new Point3D(x, y, z);
|
||||
|
||||
if (command.getMaxRangeToTarget() != 0 && actor.getPosition().getDistance(position) > command.getMaxRangeToTarget()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 4: // Anyone
|
||||
case 4: // Any object
|
||||
if (target == null) {
|
||||
target = actor;
|
||||
break;
|
||||
}
|
||||
|
||||
if (command.getMaxRangeToTarget() != 0 && actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!core.simulationService.checkLineOfSight(actor, target)) {
|
||||
actor.showFlyText("@combat_effects:cant_see", 1.5f, new RGB(72, 209, 204), 1, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -428,12 +485,8 @@ public class CommandService implements INetworkDispatch {
|
||||
|
||||
|
||||
if(target != attacker && success && !core.simulationService.checkLineOfSight(attacker, target)) {
|
||||
|
||||
ShowFlyText los = new ShowFlyText(attacker.getObjectID(), attacker.getObjectID(), "combat_effects", "cant_see", (float) 1.5, new RGB(72, 209, 204), 1);
|
||||
ObjControllerMessage objController = new ObjControllerMessage(0x1B, los);
|
||||
attacker.getClient().getSession().write(objController.serialize());
|
||||
attacker.showFlyText("@combat_effects:cant_see", 1.5f, new RGB(72, 209, 204), 1, true);
|
||||
success = false;
|
||||
|
||||
}
|
||||
|
||||
if(!success && attacker.getClient() != null) {
|
||||
@@ -466,6 +519,15 @@ public class CommandService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
public void removeCommand(CreatureObject actor, int actionCounter, BaseSWGCommand command) {
|
||||
if (actor == null || actor.getClient() == null || command == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
actor.getClient().getSession().write(new ObjControllerMessage(0x0B, new CommandEnqueueRemove(actor.getObjectId(), actionCounter)).serialize());
|
||||
actor.removeCooldown(actionCounter, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertOpcodes(Map<Integer, INetworkRemoteEvent> swgOpcodes, Map<Integer, INetworkRemoteEvent> objControllerOpcodes) {
|
||||
|
||||
@@ -508,6 +570,7 @@ public class CommandService implements INetworkDispatch {
|
||||
|
||||
if (!callCommand(actor, target, command, commandEnqueue.getActionCounter(), commandEnqueue.getCommandArguments())) {
|
||||
// Call failScriptHook
|
||||
removeCommand(actor, commandEnqueue.getActionCounter(), command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -72,6 +73,7 @@ import protocol.swg.chat.ChatOnConnectAvatar;
|
||||
import protocol.swg.chat.ChatOnGetFriendsList;
|
||||
import protocol.swg.chat.ChatRoomList;
|
||||
import protocol.swg.chat.ChatServerStatus;
|
||||
import protocol.swg.objectControllerObjects.ShowFlyText;
|
||||
import protocol.swg.objectControllerObjects.UiPlayEffect;
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.CrcStringTableVisitor;
|
||||
@@ -590,6 +592,32 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
public SWGObject getObjectByFirstName(String customName) {
|
||||
|
||||
synchronized(objectList) {
|
||||
|
||||
for(SWGObject obj : objectList.values()) {
|
||||
if(obj.getCustomName() == null)
|
||||
continue;
|
||||
if(obj.getCustomName().startsWith(customName))
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EntityCursor<CreatureObject> cursor = core.getCreatureODB().getCursor(Long.class, CreatureObject.class);
|
||||
|
||||
Iterator<CreatureObject> it = cursor.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
if(it.next().getCustomName().startsWith(customName))
|
||||
return it.next();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public CreatureObject getCreatureFromDB(long objectId) {
|
||||
return core.getCreatureODB().get(new Long(objectId), Long.class, CreatureObject.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user