From fbcbc2606528b9e1bdf82233686ef7f005179de3 Mon Sep 17 00:00:00 2001 From: Light2 Date: Mon, 23 Sep 2013 18:02:31 +0200 Subject: [PATCH] Added some medic specials, minor combat fixes --- scripts/buffs/me_stasis_1.py | 11 ++++ scripts/buffs/me_stasis_self_1.py | 11 ++++ scripts/commands/combat/me_stasis_1.py | 11 ++++ scripts/commands/me_drag_1.py | 18 ++++++ scripts/commands/me_reckless_stimulation_1.py | 25 ++++++++ scripts/commands/me_reckless_stimulation_2.py | 25 ++++++++ scripts/commands/me_reckless_stimulation_3.py | 25 ++++++++ scripts/commands/me_reckless_stimulation_4.py | 25 ++++++++ scripts/commands/me_reckless_stimulation_5.py | 25 ++++++++ scripts/commands/me_reckless_stimulation_6.py | 25 ++++++++ scripts/commands/me_stasis_self_1.py | 24 +++++++ .../swg/PlayClientEffectObjectMessage.java | 64 +++++++++++++++++++ .../objects/creature/CreatureObject.java | 29 +++------ src/services/PlayerService.java | 17 +++-- src/services/SimulationService.java | 16 +++-- src/services/combat/CombatCommands.java | 9 +++ src/services/combat/CombatService.java | 10 +-- src/services/command/CombatCommand.java | 10 +++ src/services/command/CommandService.java | 12 ++++ 19 files changed, 355 insertions(+), 37 deletions(-) create mode 100644 scripts/buffs/me_stasis_1.py create mode 100644 scripts/buffs/me_stasis_self_1.py create mode 100644 scripts/commands/combat/me_stasis_1.py create mode 100644 scripts/commands/me_drag_1.py create mode 100644 scripts/commands/me_reckless_stimulation_1.py create mode 100644 scripts/commands/me_reckless_stimulation_2.py create mode 100644 scripts/commands/me_reckless_stimulation_3.py create mode 100644 scripts/commands/me_reckless_stimulation_4.py create mode 100644 scripts/commands/me_reckless_stimulation_5.py create mode 100644 scripts/commands/me_reckless_stimulation_6.py create mode 100644 scripts/commands/me_stasis_self_1.py create mode 100644 src/protocol/swg/PlayClientEffectObjectMessage.java diff --git a/scripts/buffs/me_stasis_1.py b/scripts/buffs/me_stasis_1.py new file mode 100644 index 00000000..1539e280 --- /dev/null +++ b/scripts/buffs/me_stasis_1.py @@ -0,0 +1,11 @@ +import sys + +def setup(core, actor, buff): + actor.playEffectObject('clienteffect/medic_stasis.cef', 'me_stasis_1') + actor.setSpeedMultiplierBase(0.2) + return + +def removeBuff(core, actor, buff): + actor.setSpeedMultiplierBase(1) + return + \ No newline at end of file diff --git a/scripts/buffs/me_stasis_self_1.py b/scripts/buffs/me_stasis_self_1.py new file mode 100644 index 00000000..6341cb4c --- /dev/null +++ b/scripts/buffs/me_stasis_self_1.py @@ -0,0 +1,11 @@ +import sys + +def setup(core, actor, buff): + actor.playEffectObject('clienteffect/medic_stasis.cef', 'me_stasis_self_1') + actor.setSpeedMultiplierBase(0.2) + return + +def removeBuff(core, actor, buff): + actor.setSpeedMultiplierBase(1) + return + \ No newline at end of file diff --git a/scripts/commands/combat/me_stasis_1.py b/scripts/commands/combat/me_stasis_1.py new file mode 100644 index 00000000..35ffc3d7 --- /dev/null +++ b/scripts/commands/combat/me_stasis_1.py @@ -0,0 +1,11 @@ +import sys + +def setup(core, actor, target, command): + command.setBuffNameTarget('me_stasis_1') + return + +def preRun(core, actor, target, command): + return + +def run(core, actor, target, commandString): + return diff --git a/scripts/commands/me_drag_1.py b/scripts/commands/me_drag_1.py new file mode 100644 index 00000000..d7a0a46a --- /dev/null +++ b/scripts/commands/me_drag_1.py @@ -0,0 +1,18 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + if actor.getGroupId() == 0: + return + + group = core.objectService.getObject(actor.getGroupId()) + + for creature in group.getMemberList(): + if creature.getPosture() == 14: + core.simulationService.teleport(creature, actor.getPosition(), actor.getOrientation(), actor.getParentId()) + + return + \ No newline at end of file diff --git a/scripts/commands/me_reckless_stimulation_1.py b/scripts/commands/me_reckless_stimulation_1.py new file mode 100644 index 00000000..9949b2e5 --- /dev/null +++ b/scripts/commands/me_reckless_stimulation_1.py @@ -0,0 +1,25 @@ +import sys +from services.command import CombatCommand + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + weapon = core.objectService.getObject(actor.getWeaponId()) + + if not weapon: + weapon = actor.getSlottedObject('default_weapon') + + command = core.commandService.getCommandByName('me_reckless_stimulation_1') + + if not combatSvc.applySpecialCost(actor, weapon, CombatCommand('me_reckless_stimulation_1')): + return + + actor.playEffectObject('clienteffect/medic_reckless_stimulation.cef', 'root') + actor.setAction(actor.getAction() + 1000) + + return + \ No newline at end of file diff --git a/scripts/commands/me_reckless_stimulation_2.py b/scripts/commands/me_reckless_stimulation_2.py new file mode 100644 index 00000000..d5ddeef2 --- /dev/null +++ b/scripts/commands/me_reckless_stimulation_2.py @@ -0,0 +1,25 @@ +import sys +from services.command import CombatCommand + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + weapon = core.objectService.getObject(actor.getWeaponId()) + + if not weapon: + weapon = actor.getSlottedObject('default_weapon') + + command = core.commandService.getCommandByName('me_reckless_stimulation_2') + + if not combatSvc.applySpecialCost(actor, weapon, CombatCommand('me_reckless_stimulation_2')): + return + + actor.playEffectObject('clienteffect/medic_reckless_stimulation.cef', 'root') + actor.setAction(actor.getAction() + 1500) + + return + \ No newline at end of file diff --git a/scripts/commands/me_reckless_stimulation_3.py b/scripts/commands/me_reckless_stimulation_3.py new file mode 100644 index 00000000..9d3820f4 --- /dev/null +++ b/scripts/commands/me_reckless_stimulation_3.py @@ -0,0 +1,25 @@ +import sys +from services.command import CombatCommand + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + weapon = core.objectService.getObject(actor.getWeaponId()) + + if not weapon: + weapon = actor.getSlottedObject('default_weapon') + + command = core.commandService.getCommandByName('me_reckless_stimulation_3') + + if not combatSvc.applySpecialCost(actor, weapon, CombatCommand('me_reckless_stimulation_3')): + return + + actor.playEffectObject('clienteffect/medic_reckless_stimulation.cef', 'root') + actor.setAction(actor.getAction() + 2000) + + return + \ No newline at end of file diff --git a/scripts/commands/me_reckless_stimulation_4.py b/scripts/commands/me_reckless_stimulation_4.py new file mode 100644 index 00000000..1121b29e --- /dev/null +++ b/scripts/commands/me_reckless_stimulation_4.py @@ -0,0 +1,25 @@ +import sys +from services.command import CombatCommand + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + weapon = core.objectService.getObject(actor.getWeaponId()) + + if not weapon: + weapon = actor.getSlottedObject('default_weapon') + + command = core.commandService.getCommandByName('me_reckless_stimulation_4') + + if not combatSvc.applySpecialCost(actor, weapon, CombatCommand('me_reckless_stimulation_4')): + return + + actor.playEffectObject('clienteffect/medic_reckless_stimulation.cef', 'root') + actor.setAction(actor.getAction() + 2500) + + return + \ No newline at end of file diff --git a/scripts/commands/me_reckless_stimulation_5.py b/scripts/commands/me_reckless_stimulation_5.py new file mode 100644 index 00000000..6978b27e --- /dev/null +++ b/scripts/commands/me_reckless_stimulation_5.py @@ -0,0 +1,25 @@ +import sys +from services.command import CombatCommand + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + weapon = core.objectService.getObject(actor.getWeaponId()) + + if not weapon: + weapon = actor.getSlottedObject('default_weapon') + + command = core.commandService.getCommandByName('me_reckless_stimulation_5') + + if not combatSvc.applySpecialCost(actor, weapon, CombatCommand('me_reckless_stimulation_5')): + return + + actor.playEffectObject('clienteffect/medic_reckless_stimulation.cef', 'root') + actor.setAction(actor.getAction() + 3000) + + return + \ No newline at end of file diff --git a/scripts/commands/me_reckless_stimulation_6.py b/scripts/commands/me_reckless_stimulation_6.py new file mode 100644 index 00000000..fc220b9f --- /dev/null +++ b/scripts/commands/me_reckless_stimulation_6.py @@ -0,0 +1,25 @@ +import sys +from services.command import CombatCommand + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + weapon = core.objectService.getObject(actor.getWeaponId()) + + if not weapon: + weapon = actor.getSlottedObject('default_weapon') + + command = core.commandService.getCommandByName('me_reckless_stimulation_6') + + if not combatSvc.applySpecialCost(actor, weapon, CombatCommand('me_reckless_stimulation_6')): + return + + actor.playEffectObject('clienteffect/medic_reckless_stimulation.cef', 'root') + actor.setAction(actor.getAction() + 3500) + + return + \ No newline at end of file diff --git a/scripts/commands/me_stasis_self_1.py b/scripts/commands/me_stasis_self_1.py new file mode 100644 index 00000000..fc808c70 --- /dev/null +++ b/scripts/commands/me_stasis_self_1.py @@ -0,0 +1,24 @@ +import sys +from services.command import CombatCommand + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + weapon = core.objectService.getObject(actor.getWeaponId()) + + if not weapon: + weapon = actor.getSlottedObject('default_weapon') + + command = core.commandService.getCommandByName('me_stasis_self_1') + + if not combatSvc.applySpecialCost(actor, weapon, CombatCommand('me_stasis_self_1')): + return + + core.buffService.addBuffToCreature(actor, 'me_stasis_self_1') + + return + \ No newline at end of file diff --git a/src/protocol/swg/PlayClientEffectObjectMessage.java b/src/protocol/swg/PlayClientEffectObjectMessage.java new file mode 100644 index 00000000..5e9dead4 --- /dev/null +++ b/src/protocol/swg/PlayClientEffectObjectMessage.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +public class PlayClientEffectObjectMessage extends SWGMessage { + + private long objectId; + private String effectFile; + private String commandString; + + public PlayClientEffectObjectMessage(String effectFile, long objectId, String commandString) { + + this.effectFile = effectFile; + this.objectId = objectId; + this.commandString = commandString; + + } + + @Override + public IoBuffer serialize() { + + IoBuffer result = IoBuffer.allocate(20 + effectFile.length() + commandString.length()).order(ByteOrder.LITTLE_ENDIAN); + + result.putShort((short) 5); + result.putInt(0x8855434A); + result.put(getAsciiString(effectFile)); + result.putShort((short) 0); + result.putLong(objectId); + result.put(getAsciiString(commandString)); + + return result.flip(); + + } + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 13695e7f..6f89cdfd 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -29,6 +29,7 @@ import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ChatSystemMessage; import protocol.swg.ObjControllerMessage; +import protocol.swg.PlayClientEffectObjectMessage; import protocol.swg.UpdatePVPStatusMessage; import protocol.swg.UpdatePostureMessage; import protocol.swg.objectControllerObjects.Posture; @@ -927,27 +928,15 @@ public class CreatureObject extends TangibleObject implements IPersistent { } IoBuffer delta; - // IoBuffer delta2; - int counter; synchronized(objectMutex) { if(health > maxHealth) health = maxHealth; - this.health = health; - counter = getHamListCounter() + 1; setHamListCounter(getHamListCounter() + 1); - delta = messageBuilder.buildUpdateHAMListDelta(); - /*if(health == 1) - delta2 = messageBuilder.buildHealthDelta(0); - else - delta2 = delta;*/ + delta = messageBuilder.buildHealthDelta(health); notifyObservers(delta, true); - - /*if(getClient() != null) - getClient().getSession().write(delta2);*/ + this.health = health; } - if(counter != getHamListCounter()) - System.out.println("test"); } @@ -959,18 +948,14 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void setAction(int action) { IoBuffer delta; - int counter; synchronized(objectMutex) { if(action > maxAction) action = maxAction; - this.action = action; - counter = getHamListCounter() + 1; setHamListCounter(getHamListCounter() + 1); - delta = messageBuilder.buildUpdateHAMListDelta(); + delta = messageBuilder.buildActionDelta(action); notifyObservers(delta, true); + this.action = action; } - if(counter != getHamListCounter()) - System.out.println("test"); } public int getHamListCounter() { @@ -1096,6 +1081,10 @@ public class CreatureObject extends TangibleObject implements IPersistent { notifyObservers(messageBuilder.buildResetHAMListDelta(), true); } } + + public void playEffectObject(String effectFile, String commandString) { + notifyObservers(new PlayClientEffectObjectMessage(effectFile, getObjectID(), commandString), true); + } } diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 6dfc165b..6f2d3beb 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -64,7 +64,7 @@ import engine.resources.service.INetworkRemoteEvent; public class PlayerService implements INetworkDispatch { private NGECore core; - private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2); + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); public PlayerService(final NGECore core) { this.core = core; @@ -106,9 +106,10 @@ public class PlayerService implements INetworkDispatch { @Override public void run() { - if(creature.getAction() < creature.getMaxAction() && creature.getPosture() != 14) - creature.setAction(creature.getAction() + 200); - + synchronized(creature.getMutex()) { + if(creature.getAction() < creature.getMaxAction() && creature.getPosture() != 14) + creature.setAction(creature.getAction() + 200); + } } }, 0, 1000, TimeUnit.MILLISECONDS); @@ -118,12 +119,14 @@ public class PlayerService implements INetworkDispatch { @Override public void run() { - if(creature.getHealth() < creature.getMaxHealth() && creature.getCombatFlag() == 0 && creature.getPosture() != 13 && creature.getPosture() != 14) - creature.setHealth(creature.getHealth() + 300); + synchronized(creature.getMutex()) { + if(creature.getHealth() < creature.getMaxHealth() && creature.getCombatFlag() == 0 && creature.getPosture() != 13 && creature.getPosture() != 14) + creature.setHealth(creature.getHealth() + 300); + } } - }, 0, 1100, TimeUnit.MILLISECONDS); + }, 0, 1000, TimeUnit.MILLISECONDS); /*scheduler.scheduleAtFixedRate(new Runnable() { diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 1eee2b75..83b80a8a 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -616,14 +616,20 @@ public class SimulationService implements INetworkDispatch { } - public void teleport(SWGObject obj, Point3D position, Quaternion orientation) { + public void teleport(SWGObject obj, Point3D position, Quaternion orientation, long cellId) { - if(position.x >= -8192 && position.x <= 8192 && position.z >= -8192 && position.z <= 8192) { - - DataTransform dataTransform = new DataTransform(new Point3D(position.x, position.y, position.z), orientation, 1, obj.getObjectID()); + if(cellId == 0) { + if(position.x >= -8192 && position.x <= 8192 && position.z >= -8192 && position.z <= 8192) { + obj.setMovementCounter(obj.getMovementCounter() + 1); + DataTransform dataTransform = new DataTransform(new Point3D(position.x, position.y, position.z), orientation, obj.getMovementCounter(), obj.getObjectID()); + ObjControllerMessage objController = new ObjControllerMessage(0x1B, dataTransform); + obj.notifyObservers(objController, true); + } + } else { + obj.setMovementCounter(obj.getMovementCounter() + 1); + DataTransformWithParent dataTransform = new DataTransformWithParent(new Point3D(position.x, position.y, position.z), orientation, obj.getMovementCounter(), obj.getObjectID(), cellId); ObjControllerMessage objController = new ObjControllerMessage(0x1B, dataTransform); obj.notifyObservers(objController, true); - } } diff --git a/src/services/combat/CombatCommands.java b/src/services/combat/CombatCommands.java index 1a30be6a..d1935736 100644 --- a/src/services/combat/CombatCommands.java +++ b/src/services/combat/CombatCommands.java @@ -417,6 +417,15 @@ public class CombatCommands { core.commandService.registerCombatCommand("me_traumatize_3"); core.commandService.registerCombatCommand("me_traumatize_4"); core.commandService.registerCombatCommand("me_traumatize_5"); + core.commandService.registerCombatCommand("me_stasis_1"); + core.commandService.registerCommand("me_stasis_self_1"); + core.commandService.registerCommand("me_drag_1"); + core.commandService.registerCommand("me_reckless_stimulation_1"); + core.commandService.registerCommand("me_reckless_stimulation_2"); + core.commandService.registerCommand("me_reckless_stimulation_3"); + core.commandService.registerCommand("me_reckless_stimulation_4"); + core.commandService.registerCommand("me_reckless_stimulation_5"); + core.commandService.registerCommand("me_reckless_stimulation_6"); // Officer diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 4d46a2aa..8f67abfe 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -79,10 +79,10 @@ public class CombatService implements INetworkDispatch { boolean success = true; - if(!applySpecialCost(attacker, weapon, command)) + if((command.getAttackType() == 0 || command.getAttackType() == 1 || command.getAttackType() == 3) && !attemptCombat(attacker, target)) success = false; - if((command.getAttackType() == 0 || command.getAttackType() == 1 || command.getAttackType() == 3) && !attemptCombat(attacker, target)) + if(!applySpecialCost(attacker, weapon, command)) success = false; if(!success) { @@ -328,7 +328,7 @@ public class CombatService implements INetworkDispatch { sendCombatPackets(attacker, target, weapon, command, actionCounter, damage, armorAbsorbed, hitType); - if(hitType != HitType.MISS && hitType != HitType.DODGE && hitType != HitType.PARRY) + if((hitType != HitType.MISS && hitType != HitType.DODGE && hitType != HitType.PARRY) || (command.getAddedDamage() == 0 && command.getPercentFromWeapon() == 0)) core.buffService.addBuffToCreature(target, command.getBuffNameTarget()); if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) @@ -456,7 +456,7 @@ public class CombatService implements INetworkDispatch { } - private boolean applySpecialCost(CreatureObject attacker, WeaponObject weapon, CombatCommand command) { + public boolean applySpecialCost(CreatureObject attacker, WeaponObject weapon, CombatCommand command) { float actionCost = command.getActionCost(); float healthCost = command.getHealthCost(); @@ -765,7 +765,7 @@ public class CombatService implements INetworkDispatch { success = false; if((command.getAttackType() == 0 || command.getAttackType() == 1 || command.getAttackType() == 3) && !attemptHeal(healer, target)) - success = false; + target = healer; if(!success) { IoSession session = healer.getClient().getSession(); diff --git a/src/services/command/CombatCommand.java b/src/services/command/CombatCommand.java index 011db4d3..444d0895 100644 --- a/src/services/command/CombatCommand.java +++ b/src/services/command/CombatCommand.java @@ -77,6 +77,7 @@ public class CombatCommand extends BaseSWGCommand { private String cooldownGroup; private float executeTime; private float warmupTime; + private float vigorCost; // for commando kill meter and bm specials public CombatCommand(String commandName) { super(commandName); @@ -135,6 +136,7 @@ public class CombatCommand extends BaseSWGCommand { bypassArmor = (Float) visitor.getObject(i, 48); healthCost = (Float) visitor.getObject(i, 54); actionCost = (Float) visitor.getObject(i, 55); + setVigorCost((Float) visitor.getObject(i, 56)); dotType = (String) visitor.getObject(i, 60); dotIntensity = (Integer) visitor.getObject(i, 61); dotDuration = (Integer) visitor.getObject(i, 62); @@ -695,6 +697,14 @@ public class CombatCommand extends BaseSWGCommand { public void setWarmupTime(float warmupTime) { this.warmupTime = warmupTime; } + + public float getVigorCost() { + return vigorCost; + } + + public void setVigorCost(float vigorCost) { + this.vigorCost = vigorCost; + } diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index e9fe85c1..e6c9293b 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -140,6 +140,18 @@ public class CommandService implements INetworkDispatch { } + public BaseSWGCommand getCommandByName(String name) { + + Vector commands = new Vector(commandLookup); // copy for thread safety + + for(BaseSWGCommand command : commands) { + if(command.getCommandName().equalsIgnoreCase(name)) + return command; + } + return null; + + } + private void processCombatCommand(CreatureObject attacker, SWGObject target, CombatCommand command, int actionCounter, String commandArgs) { boolean success = true;