mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-12 22:45:31 -04:00
Added duels, added incap and deathblow, fixed some buff issues
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import sys
|
||||
|
||||
def setup(core, actor, buff):
|
||||
return
|
||||
|
||||
def removeBuff(core, actor, buff):
|
||||
return
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import sys
|
||||
|
||||
def setup(core, actor, buff):
|
||||
return
|
||||
|
||||
def removeBuff(core, actor, buff):
|
||||
return
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
combatSvc = core.combatService
|
||||
|
||||
if not target:
|
||||
return
|
||||
|
||||
if actor.getPosture() == 13 or actor.getPosture() == 14:
|
||||
return
|
||||
|
||||
if not target.getPosture() == 13:
|
||||
return
|
||||
|
||||
if not target.isAttackableBy(actor):
|
||||
return
|
||||
|
||||
if not target.inRange(actor.getPosition(), 5):
|
||||
return
|
||||
|
||||
combatSvc.deathblowPlayer(actor, target)
|
||||
|
||||
return
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
combatSvc = core.combatService
|
||||
|
||||
if not target:
|
||||
return
|
||||
|
||||
if not target.getClient():
|
||||
return
|
||||
|
||||
if actor == target:
|
||||
actor.sendSystemMessage('You cannot challenge yourself.', 0)
|
||||
return
|
||||
|
||||
if combatSvc.areInDuel(actor, target):
|
||||
return
|
||||
|
||||
if actor.getDuelList().contains(target):
|
||||
actor.sendSystemMessage('You already challenged ' + target.getCustomName() + ' to a duel.', 0)
|
||||
|
||||
combatSvc.handleDuel(actor, target)
|
||||
|
||||
return
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
combatSvc = core.combatService
|
||||
|
||||
if not target:
|
||||
return
|
||||
|
||||
if not target.getClient():
|
||||
return
|
||||
|
||||
if actor == target:
|
||||
return
|
||||
|
||||
if not combatSvc.areInDuel(actor, target):
|
||||
return
|
||||
|
||||
combatSvc.handleEndDuel(actor, target)
|
||||
|
||||
return
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import sys
|
||||
|
||||
def setup(core, actor, buff):
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
core.buffService.addBuffToCreature(actor, 'fs_buff_def_1_1')
|
||||
return
|
||||
|
||||
@@ -4,6 +4,10 @@ def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
if actor.getPosture() == 13 or actor.getPosture() == 14:
|
||||
return
|
||||
|
||||
actor.setPosture(1)
|
||||
actor.setSpeedMultiplierBase(0)
|
||||
actor.setTurnRadius(0)
|
||||
|
||||
@@ -4,6 +4,10 @@ def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
if actor.getPosture() == 13 or actor.getPosture() == 14:
|
||||
return
|
||||
|
||||
actor.setPosture(2)
|
||||
actor.setSpeedMultiplierBase(0.25)
|
||||
actor.setTurnRadius(1)
|
||||
|
||||
@@ -5,5 +5,6 @@ def setup():
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
actor.setSpeedMultiplierBase(float(commandString))
|
||||
core.buffService.addBuffToCreature(actor, 'bh_prescience')
|
||||
return
|
||||
|
||||
@@ -7,6 +7,9 @@ def setup():
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
if actor.getPosture() == 13 or actor.getPosture() == 14:
|
||||
return
|
||||
|
||||
if len(commandString) > 0:
|
||||
parsedMsg = commandString.split(',', 4)
|
||||
x = float(parsedMsg[0])
|
||||
|
||||
@@ -5,6 +5,9 @@ def setup():
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
if actor.getPosture() == 13 or actor.getPosture() == 14:
|
||||
return
|
||||
|
||||
if actor.getStateBitmask() == 32768:
|
||||
actor.setStateBitmask(0)
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ def addProfessionAbilities(core, object, profession):
|
||||
object.addAbility('fs_sh_3')
|
||||
object.addAbility('fs_dm_cc_6')
|
||||
object.addAbility('fs_dm_7')
|
||||
object.addAbility('fs_buff_def_1_1')
|
||||
elif profession == 'medic_1a':
|
||||
object.addAbility('me_bacta_bomb_5')
|
||||
object.addAbility('me_bacta_grenade_5')
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import engine.resources.common.CRC;
|
||||
|
||||
import protocol.swg.SWGMessage;
|
||||
|
||||
public class UpdatePVPStatusMessage extends SWGMessage {
|
||||
@@ -37,6 +39,13 @@ public class UpdatePVPStatusMessage extends SWGMessage {
|
||||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
public UpdatePVPStatusMessage(long objectId, int pvpStatus, String faction) {
|
||||
this.objectId = objectId;
|
||||
this.pvpStatus = pvpStatus;
|
||||
this.faction = CRC.StringtoCRC(faction);
|
||||
}
|
||||
|
||||
|
||||
public void deserialize(IoBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
@@ -101,7 +101,8 @@ public class CombatSpam extends ObjControllerObject{
|
||||
result.putInt(0x20); // unk
|
||||
result.putInt(0); // unk
|
||||
result.putInt(0); // unk
|
||||
result.putInt(armorAbsorbed); // damage absorbed by armor
|
||||
//result.putInt(armorAbsorbed); // damage absorbed by armor
|
||||
result.putInt(damage);
|
||||
result.putInt(damage); // total damage done after armor without elemental
|
||||
result.putInt(0); // punishing blow for all values
|
||||
result.putInt(0); // unk
|
||||
|
||||
@@ -111,7 +111,7 @@ public class Buff implements IListObject {
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(28, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(CRC.StringtoCRC(buffName));
|
||||
buffer.putInt(CRC.StringtoCRC(buffName.toLowerCase()));
|
||||
if(duration > 0) {
|
||||
buffer.putInt((int) (totalPlayTime + getRemainingDuration()));
|
||||
buffer.putInt(0);
|
||||
@@ -119,7 +119,7 @@ public class Buff implements IListObject {
|
||||
} else {
|
||||
buffer.putInt(-1);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(-1);
|
||||
buffer.putInt(0);
|
||||
}
|
||||
buffer.putLong(ownerId);
|
||||
buffer.putInt(1); // unk
|
||||
|
||||
@@ -23,9 +23,14 @@ package resources.objects.building;
|
||||
|
||||
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import resources.objects.cell.CellObject;
|
||||
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -47,6 +52,26 @@ public class BuildingObject extends SWGObject {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public CellObject getCellByCellNumber(final int cellNumber) {
|
||||
|
||||
final AtomicReference<CellObject> ref = new AtomicReference<CellObject>();
|
||||
|
||||
this.viewChildren(this, true, false, new Traverser() {
|
||||
|
||||
@Override
|
||||
public void process(SWGObject obj) {
|
||||
|
||||
if(obj instanceof CellObject && ((CellObject) obj).getCellNumber() == cellNumber)
|
||||
ref.set((CellObject) obj);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return ref.get();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -269,9 +269,9 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putInt(6); // Max HAM
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(20000);
|
||||
buffer.putInt(creature.getMaxHealth());
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(12500);
|
||||
buffer.putInt(creature.getMaxAction());
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0x2C01);
|
||||
buffer.putInt(0);
|
||||
@@ -637,6 +637,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
System.out.println("HAM list counter: " + creature.getHamListCounter());
|
||||
buffer.put((byte) 2);
|
||||
buffer.putShort((short) 0);
|
||||
buffer.putInt(health);
|
||||
@@ -655,6 +656,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
System.out.println("HAM list counter: " + creature.getHamListCounter());
|
||||
buffer.put((byte) 2);
|
||||
buffer.putShort((short) 2);
|
||||
buffer.putInt(action);
|
||||
@@ -868,6 +870,54 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildResetHAMListDelta() {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(35, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
buffer.put((byte) 3);
|
||||
buffer.putShort((short) 6);
|
||||
buffer.putInt(creature.getHealth());
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(creature.getAction());
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0x2C01);
|
||||
buffer.putInt(0);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x15, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildUpdateHAMListDelta() {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(22, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(2);
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
buffer.put((byte) 2);
|
||||
buffer.putShort((short) 0);
|
||||
buffer.putInt(creature.getHealth());
|
||||
buffer.put((byte) 2);
|
||||
buffer.putShort((short) 2);
|
||||
buffer.putInt(creature.getAction());
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x15, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -134,7 +134,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
|
||||
// non-baseline vars
|
||||
@NotPersistent
|
||||
private List<Long> duelList = Collections.synchronizedList(new ArrayList<Long>());
|
||||
private List<CreatureObject> duelList = Collections.synchronizedList(new ArrayList<CreatureObject>());
|
||||
@NotPersistent
|
||||
private CreatureMessageBuilder messageBuilder;
|
||||
|
||||
@@ -820,7 +820,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
return appearanceEquipmentList;
|
||||
}
|
||||
|
||||
public List<Long> getDuelList() {
|
||||
public List<CreatureObject> getDuelList() {
|
||||
return duelList;
|
||||
}
|
||||
|
||||
@@ -912,15 +912,43 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
}
|
||||
|
||||
public void setHealth(int health) {
|
||||
|
||||
synchronized(objectMutex) {
|
||||
if(getPosture() == 13) {
|
||||
if(health > maxHealth)
|
||||
health = maxHealth;
|
||||
this.health = health;
|
||||
notifyObservers(messageBuilder.buildUpdateHAMListDelta(), true);
|
||||
setPosture((byte) 0);
|
||||
setTurnRadius(1);
|
||||
setSpeedMultiplierBase(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IoBuffer delta;
|
||||
// IoBuffer delta2;
|
||||
int counter;
|
||||
synchronized(objectMutex) {
|
||||
if(health > maxHealth)
|
||||
health = maxHealth;
|
||||
this.health = health;
|
||||
counter = getHamListCounter() + 1;
|
||||
setHamListCounter(getHamListCounter() + 1);
|
||||
delta = messageBuilder.buildHealthDelta(health);
|
||||
delta = messageBuilder.buildUpdateHAMListDelta();
|
||||
/*if(health == 1)
|
||||
delta2 = messageBuilder.buildHealthDelta(0);
|
||||
else
|
||||
delta2 = delta;*/
|
||||
|
||||
notifyObservers(delta, true);
|
||||
|
||||
/*if(getClient() != null)
|
||||
getClient().getSession().write(delta2);*/
|
||||
}
|
||||
notifyObservers(delta, true);
|
||||
if(counter != getHamListCounter())
|
||||
System.out.println("test");
|
||||
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
@@ -931,14 +959,18 @@ 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.buildActionDelta(action);
|
||||
delta = messageBuilder.buildUpdateHAMListDelta();
|
||||
notifyObservers(delta, true);
|
||||
}
|
||||
notifyObservers(delta, true);
|
||||
if(counter != getHamListCounter())
|
||||
System.out.println("test");
|
||||
}
|
||||
|
||||
public int getHamListCounter() {
|
||||
@@ -1041,6 +1073,13 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
getClient().getSession().write(messageBuilder.buildGroupInviteDelta(getInviteSenderId(), getInviteCounter(), getInviteSenderName()));
|
||||
|
||||
}
|
||||
|
||||
public void resetHAMList() {
|
||||
synchronized(objectMutex) {
|
||||
setHamListCounter(getHamListCounter() + 1);
|
||||
notifyObservers(messageBuilder.buildResetHAMListDelta(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -79,16 +79,19 @@ public class BuffService implements INetworkDispatch {
|
||||
core.scriptService.callScript("scripts/buffs", "setup", buffName, core, creature, buff);
|
||||
|
||||
creature.addBuff(buff);
|
||||
scheduler.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if(buff.getDuration() > 0) {
|
||||
scheduler.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
removeBuffFromCreature(creature, buff);
|
||||
|
||||
}
|
||||
|
||||
removeBuffFromCreature(creature, buff);
|
||||
|
||||
}
|
||||
|
||||
}, (long) buff.getDuration(), TimeUnit.SECONDS);
|
||||
}, (long) buff.getDuration(), TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -91,24 +91,37 @@ public class PlayerService implements INetworkDispatch {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if(creature.getAction() < creature.getMaxAction())
|
||||
if(creature.getAction() < creature.getMaxAction() && creature.getPosture() != 14)
|
||||
creature.setAction(creature.getAction() + 200);
|
||||
|
||||
}
|
||||
|
||||
}, 0, 1, TimeUnit.SECONDS);
|
||||
}, 0, 1000, TimeUnit.MILLISECONDS);
|
||||
|
||||
scheduler.scheduleAtFixedRate(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if(creature.getHealth() < creature.getMaxHealth() && creature.getCombatFlag() == 0)
|
||||
if(creature.getHealth() < creature.getMaxHealth() && creature.getCombatFlag() == 0 && creature.getPosture() != 13 && creature.getPosture() != 14)
|
||||
creature.setHealth(creature.getHealth() + 300);
|
||||
|
||||
}
|
||||
|
||||
}, 0, 1, TimeUnit.SECONDS);
|
||||
}, 0, 1100, TimeUnit.MILLISECONDS);
|
||||
|
||||
/*scheduler.scheduleAtFixedRate(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if(creature.getCombatFlag() == 1)
|
||||
creature.resetHAMList();
|
||||
|
||||
}
|
||||
|
||||
}, 0, 10, TimeUnit.SECONDS);*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -40,49 +40,49 @@ public class ScriptService {
|
||||
|
||||
public void callScript(String path, String module, String method) {
|
||||
PythonInterpreter interpreter = new PythonInterpreter();
|
||||
interpreter.cleanup();
|
||||
interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method);
|
||||
PyObject func = interpreter.get(method);
|
||||
func.__call__(Py.java2py(core));
|
||||
interpreter.cleanup();
|
||||
}
|
||||
|
||||
public void callScript(String path, String module, String method, Object arg1) {
|
||||
PythonInterpreter interpreter = new PythonInterpreter();
|
||||
interpreter.cleanup();
|
||||
interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method);
|
||||
PyObject func = interpreter.get(method);
|
||||
func.__call__(Py.java2py(core), Py.java2py(arg1));
|
||||
interpreter.cleanup();
|
||||
}
|
||||
|
||||
public void callScript(String path, String method, String module, Object arg1, Object arg2) {
|
||||
PythonInterpreter interpreter = new PythonInterpreter();
|
||||
interpreter.cleanup();
|
||||
interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method);
|
||||
PyObject func = interpreter.get(method);
|
||||
func.__call__(Py.java2py(arg1), Py.java2py(arg2));
|
||||
interpreter.cleanup();
|
||||
}
|
||||
|
||||
public void callScript(String path, String method, String module, Object arg1, Object arg2, Object arg3) {
|
||||
PythonInterpreter interpreter = new PythonInterpreter();
|
||||
interpreter.cleanup();
|
||||
interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method);
|
||||
PyObject func = interpreter.get(method);
|
||||
func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3));
|
||||
interpreter.cleanup();
|
||||
}
|
||||
|
||||
public void callScript(String path, String module, String method, Object arg1, Object arg2, Object arg3, Object arg4) {
|
||||
PythonInterpreter interpreter = new PythonInterpreter();
|
||||
interpreter.cleanup();
|
||||
interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method);
|
||||
PyObject func = interpreter.get(method);
|
||||
func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3), Py.java2py(arg4));
|
||||
interpreter.cleanup();
|
||||
}
|
||||
|
||||
public PyObject getMethod(String path, String module, String method) {
|
||||
PythonInterpreter interpreter = new PythonInterpreter();
|
||||
interpreter.cleanup();
|
||||
interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method);
|
||||
PyObject func = interpreter.get(method);
|
||||
interpreter.cleanup();
|
||||
return func;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,10 @@ public class SimulationService implements INetworkDispatch {
|
||||
core.commandService.registerCommand("addfriend");
|
||||
core.commandService.registerCommand("removefriend");
|
||||
core.commandService.registerCommand("getfriendlist");
|
||||
core.commandService.registerCommand("deathblow");
|
||||
core.commandService.registerCommand("endduel");
|
||||
core.commandService.registerCommand("duel");
|
||||
|
||||
}
|
||||
|
||||
public void add(SWGObject object, int x, int y) {
|
||||
@@ -663,7 +667,7 @@ public class SimulationService implements INetworkDispatch {
|
||||
if(object == obj1 || object == obj2)
|
||||
continue;
|
||||
|
||||
if(object.getTemplateData().getAttribute("collisionActionBlockFlags") != null) {
|
||||
if(object.getTemplateData() != null && object.getTemplateData().getAttribute("collisionActionBlockFlags") != null) {
|
||||
int bit = (Integer) object.getTemplateData().getAttribute("collisionActionBlockFlags") & 255;
|
||||
if(bit == (Integer) object.getTemplateData().getAttribute("collisionActionBlockFlags"))
|
||||
continue;
|
||||
|
||||
@@ -187,6 +187,7 @@ public class CombatCommands {
|
||||
core.commandService.registerCombatCommand("fs_sh_1");
|
||||
core.commandService.registerCombatCommand("fs_sh_2");
|
||||
core.commandService.registerCombatCommand("fs_sh_3");
|
||||
core.commandService.registerCommand("fs_buff_def_1_1");
|
||||
|
||||
|
||||
// Commando
|
||||
|
||||
@@ -24,10 +24,14 @@ package services.combat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.UpdatePVPStatusMessage;
|
||||
import protocol.swg.objectControllerObjects.CombatAction;
|
||||
import protocol.swg.objectControllerObjects.CombatSpam;
|
||||
import protocol.swg.objectControllerObjects.CommandEnqueueRemove;
|
||||
@@ -46,6 +50,7 @@ import engine.resources.service.INetworkRemoteEvent;
|
||||
public class CombatService implements INetworkDispatch {
|
||||
|
||||
private NGECore core;
|
||||
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
|
||||
public CombatService(NGECore core) {
|
||||
this.core = core;
|
||||
@@ -281,7 +286,7 @@ public class CombatService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
private boolean attemptCombat(CreatureObject attacker, TangibleObject target) {
|
||||
|
||||
|
||||
if(target.getDefendersList().contains(attacker) && attacker.getDefendersList().contains(target))
|
||||
return true;
|
||||
|
||||
@@ -422,7 +427,6 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
public byte getHitType(CreatureObject attacker, CreatureObject target, WeaponObject weapon, CombatCommand command) {
|
||||
|
||||
Random rand = new Random();
|
||||
float r;
|
||||
|
||||
// negation rolls(parry, miss and dodge) can only roll on single target attacks, strikethrough also only rolls on single target attacks
|
||||
@@ -436,13 +440,13 @@ public class CombatService implements INetworkDispatch {
|
||||
missNegation = 0.4f;
|
||||
missChance -= missNegation;
|
||||
}
|
||||
r = rand.nextFloat();
|
||||
r = new Random().nextFloat();
|
||||
if(r <= missChance)
|
||||
return HitType.MISS;
|
||||
}
|
||||
float dodgeChance = target.getSkillMod("display_only_dodge").getBase() / 10000;
|
||||
|
||||
r = rand.nextFloat();
|
||||
r = new Random().nextFloat();
|
||||
if(r <= dodgeChance)
|
||||
return HitType.DODGE;
|
||||
|
||||
@@ -452,7 +456,7 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
float parryChance = target.getSkillMod("display_only_parry").getBase() / 10000;
|
||||
|
||||
r = rand.nextFloat();
|
||||
r = new Random().nextFloat();
|
||||
if(r <= parryChance)
|
||||
return HitType.PARRY;
|
||||
|
||||
@@ -460,7 +464,7 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
float stChance = attacker.getSkillMod("display_only_strikethrough").getBase() / 10000;
|
||||
|
||||
r = rand.nextFloat();
|
||||
r = new Random().nextFloat();
|
||||
if(r <= stChance)
|
||||
return HitType.STRIKETHROUGH;
|
||||
|
||||
@@ -468,7 +472,7 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
float critChance = attacker.getSkillMod("display_only_critical").getBase() / 10000;
|
||||
|
||||
r = rand.nextFloat();
|
||||
r = new Random().nextFloat();
|
||||
if(r <= critChance)
|
||||
return HitType.CRITICAL;
|
||||
|
||||
@@ -480,12 +484,11 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
public byte doMitigationRolls(CreatureObject attacker, CreatureObject target, WeaponObject weapon, CombatCommand command, byte hitType) {
|
||||
|
||||
Random rand = new Random();
|
||||
float r;
|
||||
|
||||
float blockChance = target.getSkillMod("display_only_block").getBase() / 10000;
|
||||
|
||||
r = rand.nextFloat();
|
||||
r = new Random().nextFloat();
|
||||
if(r <= blockChance)
|
||||
return HitType.BLOCK;
|
||||
|
||||
@@ -493,7 +496,7 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
float evasionChance = target.getSkillMod("display_only_evasion").getBase() / 10000;
|
||||
|
||||
r = rand.nextFloat();
|
||||
r = new Random().nextFloat();
|
||||
if(r <= evasionChance)
|
||||
return HitType.EVASION;
|
||||
|
||||
@@ -503,7 +506,7 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
float glanceChance = target.getSkillMod("display_only_glancing_blow").getBase() / 10000;
|
||||
|
||||
r = rand.nextFloat();
|
||||
r = new Random().nextFloat();
|
||||
if(r <= glanceChance)
|
||||
return HitType.GLANCE;
|
||||
|
||||
@@ -514,16 +517,45 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
public void applyDamage(CreatureObject attacker, CreatureObject target, int damage) {
|
||||
public void applyDamage(CreatureObject attacker, final CreatureObject target, int damage) {
|
||||
|
||||
if(target.getHealth() - damage <= 0) {
|
||||
target.setHealth(1);
|
||||
target.setPosture((byte) 13);
|
||||
synchronized(target.getMutex()) {
|
||||
target.setHealth(1);
|
||||
target.setPosture((byte) 13);
|
||||
target.setTurnRadius(0);
|
||||
target.setSpeedMultiplierBase(0);
|
||||
target.resetHAMList();
|
||||
}
|
||||
attacker.resetHAMList();
|
||||
scheduler.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
synchronized(target.getMutex()) {
|
||||
|
||||
if(target.getPosture() != 13)
|
||||
return;
|
||||
|
||||
//target.resetHAMList();
|
||||
target.setPosture((byte) 0);
|
||||
target.setTurnRadius(1);
|
||||
target.setSpeedMultiplierBase(1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}, target.getIncapTimer(), TimeUnit.SECONDS);
|
||||
core.buffService.addBuffToCreature(target, "incapWeaken");
|
||||
if(target.getSlottedObject("ghost") != null)
|
||||
attacker.sendSystemMessage("You incapacitate " + target.getCustomName() + ".", (byte) 0);
|
||||
return;
|
||||
}
|
||||
target.setHealth(target.getHealth() - damage);
|
||||
synchronized(target.getMutex()) {
|
||||
target.setHealth(target.getHealth() - damage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -602,7 +634,9 @@ public class CombatService implements INetworkDispatch {
|
||||
healAmount += (healAmount * (healPotency / 100));
|
||||
}
|
||||
|
||||
target.setHealth(target.getHealth() + healAmount);
|
||||
synchronized(target.getMutex()) {
|
||||
target.setHealth(target.getHealth() + healAmount);
|
||||
}
|
||||
|
||||
if(FileUtilities.doesFileExist("scripts/commands/combat" + command.getCommandName() + ".py"))
|
||||
core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "run", core, healer, target, null);
|
||||
@@ -633,9 +667,65 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void deathblowPlayer(CreatureObject attacker, CreatureObject target) {
|
||||
|
||||
target.setPosture((byte) 14);
|
||||
attacker.sendSystemMessage("You have killed " + target.getCustomName() + ".", (byte) 0);
|
||||
attacker.removeDefender(target);
|
||||
target.removeDefender(attacker);
|
||||
|
||||
// TODO: Create Clone SUI Window
|
||||
|
||||
}
|
||||
|
||||
public boolean areInDuel(CreatureObject creature1, CreatureObject creature2) {
|
||||
|
||||
if(creature1.getDuelList().contains(creature2) && creature2.getDuelList().contains(creature1))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void handleDuel(CreatureObject requester, CreatureObject target) {
|
||||
|
||||
if(!target.getDuelList().contains(requester)) {
|
||||
|
||||
requester.getDuelList().add(target);
|
||||
requester.sendSystemMessage("You challenge " + target.getCustomName() + " to a duel.", (byte) 0);
|
||||
target.sendSystemMessage(requester.getCustomName() + " challenges you to a duel.", (byte) 0);
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
requester.getDuelList().add(target);
|
||||
requester.sendSystemMessage("You accept " + target.getCustomName() + "'s challenge.", (byte) 0);
|
||||
target.sendSystemMessage(requester.getCustomName() + " accepts your challenge.", (byte) 0);
|
||||
target.getClient().getSession().write(new UpdatePVPStatusMessage(requester.getObjectID(), 55, requester.getFaction()).serialize());
|
||||
requester.getClient().getSession().write(new UpdatePVPStatusMessage(target.getObjectID(), 55, target.getFaction()).serialize());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void handleEndDuel(CreatureObject requester, CreatureObject target) {
|
||||
|
||||
requester.getDuelList().remove(target);
|
||||
target.getDuelList().remove(requester);
|
||||
|
||||
target.removeDefender(requester);
|
||||
requester.removeDefender(target);
|
||||
|
||||
target.getClient().getSession().write(new UpdatePVPStatusMessage(requester.getObjectID(), 0x16, requester.getFaction()).serialize());
|
||||
requester.getClient().getSession().write(new UpdatePVPStatusMessage(target.getObjectID(), 0x16, target.getFaction()).serialize());
|
||||
|
||||
requester.sendSystemMessage("You end your duel with " + target.getCustomName() + ".", (byte) 0);
|
||||
target.sendSystemMessage(requester.getCustomName() + " ends your duel.", (byte) 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public enum HitType{;
|
||||
|
||||
@@ -95,7 +95,8 @@ public class CommandService implements INetworkDispatch {
|
||||
|
||||
if(command instanceof CombatCommand) {
|
||||
CombatCommand command2 = (CombatCommand) command.clone();
|
||||
core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "setup", core, actor, target, command2);
|
||||
if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py"))
|
||||
core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "setup", core, actor, target, command2);
|
||||
processCombatCommand(actor, target, command2, commandEnqueue.getActionCounter(), commandEnqueue.getCommandArguments());
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user