Added serverside cooldown control

This commit is contained in:
Light2
2013-09-22 18:24:48 +02:00
parent 7a4b985bc2
commit 5ff085adcc
5 changed files with 58 additions and 6 deletions
Binary file not shown.
@@ -25,6 +25,8 @@ import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import engine.resources.common.CRC;
import protocol.swg.ObjControllerMessage;
public class StartTask extends ObjControllerObject {
@@ -32,11 +34,15 @@ public class StartTask extends ObjControllerObject {
private int actionCounter;
private long objectId;
private int commandCRC;
private int cooldownGroupCRC;
private float cooldown;
public StartTask(int actionCounter, long objectId, int commandCRC) {
public StartTask(int actionCounter, long objectId, int commandCRC, int cooldownGroupCRC, float cooldown) {
this.actionCounter = actionCounter;
this.objectId = objectId;
this.commandCRC = commandCRC;
this.cooldownGroupCRC = cooldownGroupCRC;
this.cooldown = cooldown;
}
@Override
@@ -58,9 +64,9 @@ public class StartTask extends ObjControllerObject {
result.putInt(0);
result.putInt(0);
result.putInt(commandCRC);
result.putInt(0); // second unknown crc
result.putInt(cooldownGroupCRC); // second unknown crc
result.putInt(0); // unk
result.putFloat(0); // cooldown
result.putFloat(cooldown); // cooldown
return result.flip();
+2 -2
View File
@@ -334,7 +334,7 @@ public class CombatService implements INetworkDispatch {
ObjControllerMessage objController = new ObjControllerMessage(0x1B, combatAction);
attacker.notifyObserversInRange(objController, true, 125);
StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC());
StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), command.getCooldown());
ObjControllerMessage objController2 = new ObjControllerMessage(0x0B, startTask);
attacker.getClient().getSession().write(objController2.serialize());
@@ -359,7 +359,7 @@ public class CombatService implements INetworkDispatch {
ObjControllerMessage objController = new ObjControllerMessage(0x1B, combatAction);
attacker.notifyObserversInRange(objController, true, 125);
StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC());
StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), command.getCooldown());
ObjControllerMessage objController2 = new ObjControllerMessage(0x0B, startTask);
attacker.getClient().getSession().write(objController2.serialize());
+42 -1
View File
@@ -74,7 +74,9 @@ public class CombatCommand extends BaseSWGCommand {
private float delayAttackInterval;
private int delayAttackLoops;
private int delayAttackEggPosition;
private String cooldownGroup;
private float executeTime;
private float warmupTime;
public CombatCommand(String commandName) {
super(commandName);
@@ -156,6 +158,21 @@ public class CombatCommand extends BaseSWGCommand {
}
}
DatatableVisitor visitor2 = ClientFileManager.loadFile("datatables/command/command_table.iff", DatatableVisitor.class);
for(int i = 0; i < visitor2.getRowCount(); i++) {
if(visitor2.getObject(i, 0) != null) {
if(((String) visitor2.getObject(i, 0)).equalsIgnoreCase(commandName)) {
cooldownGroup = (String) visitor2.getObject(i, 85);
warmupTime = (Float) visitor2.getObject(i, 86);
executeTime = (Float) visitor2.getObject(i, 87);
cooldown = (Float) visitor2.getObject(i, 88);
}
}
}
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
@@ -654,6 +671,30 @@ public class CombatCommand extends BaseSWGCommand {
public void setDelayAttackLoops(int delayAttackLoops) {
this.delayAttackLoops = delayAttackLoops;
}
public String getCooldownGroup() {
return cooldownGroup;
}
public void setCooldownGroup(String cooldownGroup) {
this.cooldownGroup = cooldownGroup;
}
public float getExecuteTime() {
return executeTime;
}
public void setExecuteTime(float executeTime) {
this.executeTime = executeTime;
}
public float getWarmupTime() {
return warmupTime;
}
public void setWarmupTime(float warmupTime) {
this.warmupTime = warmupTime;
}
+5
View File
@@ -30,6 +30,7 @@ import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import engine.clients.Client;
import engine.resources.common.CRC;
import engine.resources.objects.SWGObject;
import engine.resources.scene.Point3D;
import engine.resources.service.INetworkDispatch;
@@ -40,6 +41,7 @@ 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;
@@ -206,6 +208,9 @@ public class CommandService implements INetworkDispatch {
CommandEnqueueRemove commandRemove = new CommandEnqueueRemove(attacker.getObjectId(), actionCounter);
ObjControllerMessage objController = new ObjControllerMessage(0x0B, commandRemove);
attacker.getClient().getSession().write(objController.serialize());
StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), -1);
ObjControllerMessage objController2 = new ObjControllerMessage(0x0B, startTask);
attacker.getClient().getSession().write(objController2.serialize());
} else {
if(command.getHitType() == 5) {