mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-17 07:02:53 -04:00
Fixed animation & buff window shows for recipient
This commit is contained in:
@@ -7,7 +7,7 @@ def setup():
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
print ('Buffing Player: ' + str(target.getObjectId()))
|
||||
openBuffWindow = BuffBuilderStartMessage(actor.getObjectId(), target.getObjectId())
|
||||
openBuffWindow = BuffBuilderStartMessage(actor.getObjectId(), actor.getObjectId(), target.getObjectId())
|
||||
objController = ObjControllerMessage(11, openBuffWindow)
|
||||
actor.getClient().getSession().write(objController.serialize())
|
||||
return
|
||||
@@ -2,5 +2,5 @@ import sys
|
||||
|
||||
def setup(core, object):
|
||||
object.setCustomName('Suan Dann')
|
||||
object.setCurrentAnimation('appearance/animation/all_b_dnc_bowie_loop.ans')
|
||||
#object.setCurrentAnimation('appearance/animation/all_b_dnc_bowie_loop.ans')
|
||||
return
|
||||
@@ -1,66 +1,99 @@
|
||||
package protocol.swg.objectControllerObjects;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import resources.objects.BuffItem;
|
||||
|
||||
public class BuffBuilderChange extends ObjControllerObject {
|
||||
|
||||
private long bufferId;
|
||||
private long recipientId;
|
||||
private int buffCost;
|
||||
private int accepted;
|
||||
private int startTime;
|
||||
|
||||
private long unk1;
|
||||
private long unk2;
|
||||
private long unk3;
|
||||
|
||||
private int unkI1;
|
||||
private int unkI2;
|
||||
private long objectId;
|
||||
private long bufferId;
|
||||
private long recipientId;
|
||||
|
||||
private byte unkByte;
|
||||
|
||||
private Vector<BuffItem> buffs;
|
||||
|
||||
public BuffBuilderChange() {
|
||||
|
||||
}
|
||||
|
||||
public BuffBuilderChange(long bufferId, long recipientId, int accepted, int cost) {
|
||||
public BuffBuilderChange(long objectId, long bufferId, long recipientId, int accepted, int cost) {
|
||||
this.objectId = objectId;
|
||||
this.bufferId = bufferId;
|
||||
this.recipientId = recipientId;
|
||||
this.accepted = accepted;
|
||||
this.buffCost = cost;
|
||||
//this.unkByte = (byte) 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(IoBuffer data) {
|
||||
unk1 = data.getLong();
|
||||
unkI1 = data.getInt();
|
||||
unk2 = data.getLong();
|
||||
unk3 = data.getLong();
|
||||
unkI2 = data.getInt();
|
||||
objectId = data.getLong(); // acting players id
|
||||
data.getInt(); // tick count
|
||||
bufferId = data.getLong(); // objId
|
||||
recipientId = data.getLong();
|
||||
startTime = data.getInt();
|
||||
buffCost = data.getInt();
|
||||
accepted = data.getInt();
|
||||
unkByte = data.get();
|
||||
|
||||
int size = data.getInt(); // list size
|
||||
for(int i = 0; i < size; i++) {
|
||||
BuffItem buff = new BuffItem();
|
||||
int stringSize;
|
||||
try {
|
||||
stringSize = data.getShort();
|
||||
String buffName = new String(ByteBuffer.allocate(stringSize).put(data.array(), data.position(), size).array(), "US-ASCII");
|
||||
buff.setSkillName(buffName);
|
||||
data.position(data.position() + size);
|
||||
buff.setUnknown(data.getInt());
|
||||
buff.setAmount(data.getInt());
|
||||
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IoBuffer serialize() {
|
||||
IoBuffer result = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
|
||||
result.putInt(ObjControllerMessage.BUFF_BUILDER_CHANGE);
|
||||
result.putLong(unk1);
|
||||
result.putLong(objectId);
|
||||
|
||||
result.putInt(unkI1); // tickCount
|
||||
result.putLong(unk2);
|
||||
result.putLong(unk3);
|
||||
result.putInt(unkI2); // starting time
|
||||
result.putInt(0); // tickCount
|
||||
result.putLong(bufferId);
|
||||
result.putLong(recipientId);
|
||||
result.putInt(startTime); // starting time
|
||||
result.putInt(buffCost);
|
||||
result.putInt(accepted);
|
||||
result.put(unkByte); // unk
|
||||
result.put((byte) 0); // default 0
|
||||
|
||||
//return result.flip();
|
||||
if (buffs == null || buffs.isEmpty()){
|
||||
result.putInt(0);
|
||||
} else {
|
||||
result.putInt(buffs.size());
|
||||
for (BuffItem buff : buffs) {
|
||||
result.put(getAsciiString(buff.getSkillName()));
|
||||
result.putInt(buff.getUnknown());
|
||||
result.putInt(buff.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
return result.flip();
|
||||
}
|
||||
|
||||
@@ -72,14 +105,6 @@ public class BuffBuilderChange extends ObjControllerObject {
|
||||
this.bufferId = bufferId;
|
||||
}
|
||||
|
||||
public long getRecipientId() {
|
||||
return recipientId;
|
||||
}
|
||||
|
||||
public void setRecipientId(long recipientId) {
|
||||
this.recipientId = recipientId;
|
||||
}
|
||||
|
||||
public int getBuffCost() {
|
||||
return buffCost;
|
||||
}
|
||||
@@ -96,46 +121,14 @@ public class BuffBuilderChange extends ObjControllerObject {
|
||||
this.accepted = accepted;
|
||||
}
|
||||
|
||||
public long getUnk1() {
|
||||
return unk1;
|
||||
public long getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
public void setUnk1(long unk1) {
|
||||
this.unk1 = unk1;
|
||||
public void setObjectId(long objId) {
|
||||
this.objectId = objId;
|
||||
}
|
||||
|
||||
public long getUnk2() {
|
||||
return unk2;
|
||||
}
|
||||
|
||||
public void setUnk2(long unk2) {
|
||||
this.unk2 = unk2;
|
||||
}
|
||||
|
||||
public long getUnk3() {
|
||||
return unk3;
|
||||
}
|
||||
|
||||
public void setUnk3(long unk3) {
|
||||
this.unk3 = unk3;
|
||||
}
|
||||
|
||||
public int getUnkI1() {
|
||||
return unkI1;
|
||||
}
|
||||
|
||||
public void setUnkI1(int unkI1) {
|
||||
this.unkI1 = unkI1;
|
||||
}
|
||||
|
||||
public int getUnkI2() {
|
||||
return unkI2;
|
||||
}
|
||||
|
||||
public void setUnkI2(int unkI2) {
|
||||
this.unkI2 = unkI2;
|
||||
}
|
||||
|
||||
public byte getUnkByte() {
|
||||
return this.unkByte;
|
||||
}
|
||||
@@ -144,4 +137,27 @@ public class BuffBuilderChange extends ObjControllerObject {
|
||||
this.unkByte = unkByte;
|
||||
}
|
||||
|
||||
public int getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(int startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public long getRecipientId() {
|
||||
return recipientId;
|
||||
}
|
||||
|
||||
public void setRecipientId(long recipientId) {
|
||||
this.recipientId = recipientId;
|
||||
}
|
||||
|
||||
public void setBuffs(Vector<BuffItem> buffVector) {
|
||||
this.buffs = buffVector;
|
||||
}
|
||||
|
||||
public Vector<BuffItem> getBuffVector() {
|
||||
return this.buffs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@ public class BuffBuilderStartMessage extends ObjControllerObject {
|
||||
|
||||
private long objectId;
|
||||
private long recieverId;
|
||||
private long bufferId;
|
||||
|
||||
public BuffBuilderStartMessage(long objectId, long recieverId) {
|
||||
public BuffBuilderStartMessage(long objectId, long bufferId, long recieverId) {
|
||||
this.objectId = objectId;
|
||||
this.bufferId = bufferId;
|
||||
this.recieverId = recieverId;
|
||||
}
|
||||
|
||||
@@ -30,7 +32,7 @@ public class BuffBuilderStartMessage extends ObjControllerObject {
|
||||
|
||||
result.putLong(objectId);
|
||||
result.putInt(0); // tick count
|
||||
result.putLong(objectId);
|
||||
result.putLong(bufferId);
|
||||
result.putLong(recieverId);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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 resources.objects;
|
||||
|
||||
public class BuffItem {
|
||||
private String skillName;
|
||||
private int unknown;
|
||||
private int amount;
|
||||
|
||||
public BuffItem() {
|
||||
|
||||
}
|
||||
|
||||
public BuffItem(String skillName, int unknown, int amount) {
|
||||
this.skillName = skillName;
|
||||
this.unknown = unknown;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getSkillName() {
|
||||
return skillName;
|
||||
}
|
||||
|
||||
public void setSkillName(String skillName) {
|
||||
this.skillName = skillName;
|
||||
}
|
||||
|
||||
public int getUnknown() {
|
||||
return unknown;
|
||||
}
|
||||
|
||||
public void setUnknown(int unknown) {
|
||||
this.unknown = unknown;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
@@ -713,10 +713,10 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
synchronized(objectMutex) {
|
||||
this.currentAnimation = currentAnimation;
|
||||
}
|
||||
//Animation animation = new Animation(getObjectId(), currentAnimation);
|
||||
//ObjControllerMessage objController = new ObjControllerMessage(0x1B, animation);
|
||||
Animation animation = new Animation(getObjectId(), currentAnimation);
|
||||
ObjControllerMessage objController = new ObjControllerMessage(0x1B, animation);
|
||||
|
||||
//notifyObservers(objController, true);
|
||||
notifyObservers(objController, true);
|
||||
|
||||
notifyObservers(messageBuilder.buildCurrentAnimationDelta(currentAnimation), true);
|
||||
|
||||
|
||||
@@ -35,9 +35,13 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.objectControllerObjects.BuffBuilderChange;
|
||||
import protocol.swg.objectControllerObjects.BuffBuilderStartMessage;
|
||||
import resources.common.Console;
|
||||
@@ -48,6 +52,8 @@ import resources.objects.DamageOverTime;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import main.NGECore;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
@@ -70,25 +76,64 @@ public class BuffService implements INetworkDispatch {
|
||||
Console.println("BUFF_BUILDER_CHANGE RECIEVED");
|
||||
data.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
Client client = core.getClient((Integer) session.getAttribute("connectionId"));
|
||||
|
||||
if(client == null)
|
||||
return;
|
||||
|
||||
SWGObject sender = client.getParent();
|
||||
|
||||
if(sender == null)
|
||||
return;
|
||||
|
||||
BuffBuilderChange changeMessage = new BuffBuilderChange();
|
||||
changeMessage.deserialize(data);
|
||||
|
||||
//Console.println("Unknown Long 1 (objId?): " + changeMessage.getUnk1());
|
||||
//Console.println("Unknown Int 1 (tickCount?): " + changeMessage.getUnkI1());
|
||||
//Console.println("Unknown Long 2 (objId?): " + changeMessage.getUnk2());
|
||||
//Console.println("Unknown Long 3 (buff or buffer?): " + changeMessage.getUnk3());
|
||||
//Console.println("Unknown Int 2 (???): " + changeMessage.getUnkI2());
|
||||
//Console.println("Unknown Int 3 (buffCost?): " + changeMessage.getBuffCost());
|
||||
//Console.println("Unknown Int 4 (accepted?): " + changeMessage.getAccepted());
|
||||
//Console.println("Unknown Byte: " + changeMessage.getUnkByte());
|
||||
//CreatureObject player = (CreatureObject) core.objectService.getObject(changeMessage.getUnk1());
|
||||
SWGObject recipient = core.objectService.getObject(changeMessage.getRecipientId());
|
||||
|
||||
//if (player == null)
|
||||
//return;
|
||||
|
||||
//BuffBuilderStartMessage startMsg = new BuffBuilderStartMessage(changeMessage.getBufferId(), changeMessage.getUnknown());
|
||||
//player.getClient().getSession().write(startMsg.serialize());
|
||||
if (recipient == null || recipient.getClient() == null)
|
||||
return;
|
||||
|
||||
if (sender.getClient().getSession().containsAttribute("buffWorkshop")) {
|
||||
|
||||
long attribute = (long) sender.getClient().getSession().getAttribute("buffWorkshop");
|
||||
Console.println("Sender Attribute = " + attribute);
|
||||
Console.println("Recipient ID (Packet) = " + changeMessage.getRecipientId());
|
||||
|
||||
if (attribute == changeMessage.getObjectId()) {
|
||||
// TODO: accepted checked? give buff
|
||||
Console.println("Buffer buffing themselves!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (attribute == changeMessage.getRecipientId() && attribute != changeMessage.getObjectId()) {
|
||||
Console.println("Attribute check passed!");
|
||||
BuffBuilderChange recievingMsg = new BuffBuilderChange(recipient.getObjectId(), changeMessage.getBufferId(), recipient.getObjectId(), 0, changeMessage.getBuffCost());
|
||||
recievingMsg.setStartTime(changeMessage.getStartTime());
|
||||
|
||||
ObjControllerMessage objController = new ObjControllerMessage(0x23, recievingMsg);
|
||||
recipient.getClient().getSession().write(objController.serialize());
|
||||
Console.println("Msg sent to: " + recipient.getCustomName());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Don't need a Buff Recipient Window for buffing themselves..
|
||||
if (changeMessage.getObjectId() == changeMessage.getRecipientId()) {
|
||||
sender.getClient().getSession().setAttribute("buffWorkshop", recipient.getObjectId());
|
||||
Console.println("Sender attribute set to: " + sender.getClient().getSession().getAttribute("buffWorkshop").toString());
|
||||
return;
|
||||
}
|
||||
|
||||
BuffBuilderStartMessage startMsg = new BuffBuilderStartMessage(recipient.getObjectId(), sender.getObjectId(), recipient.getObjectId());
|
||||
ObjControllerMessage objController = new ObjControllerMessage(11, startMsg);
|
||||
recipient.getClient().getSession().write(objController.serialize());
|
||||
|
||||
recipient.getClient().getSession().setAttribute("buffWorkshop", changeMessage.getObjectId());
|
||||
Console.println("Recipient attribute set to: " + recipient.getClient().getSession().getAttribute("buffWorkshop").toString());
|
||||
sender.getClient().getSession().setAttribute("buffWorkshop", recipient.getObjectId());
|
||||
Console.println("Sender attribute set to: " + sender.getClient().getSession().getAttribute("buffWorkshop").toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user