mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-28 13:12:54 -04:00
Merge branch 'master' of https://github.com/ProjectSWGCore/NGECore2
This commit is contained in:
@@ -38,6 +38,8 @@ public class Buff implements IListObject {
|
||||
|
||||
@NotPersistent
|
||||
private SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
private String group1;
|
||||
private int priority;
|
||||
private float duration;
|
||||
private String buffName;
|
||||
private long ownerId;
|
||||
@@ -70,6 +72,8 @@ public class Buff implements IListObject {
|
||||
if(visitor.getObject(i, 0) != null)
|
||||
if(((String) visitor.getObject(i, 0)).equalsIgnoreCase(buffName)) {
|
||||
|
||||
group1 = (String) visitor.getObject(i, 1);
|
||||
priority = (int) visitor.getObject(i, 4);
|
||||
duration = (Float) visitor.getObject(i, 6);
|
||||
effect1Name = (String) visitor.getObject(i, 7);
|
||||
effect1Value = (Float) visitor.getObject(i, 8);
|
||||
@@ -112,14 +116,19 @@ public class Buff implements IListObject {
|
||||
IoBuffer buffer = bufferPool.allocate(28, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(CRC.StringtoCRC(buffName.toLowerCase()));
|
||||
if(duration < 1) {
|
||||
if(duration > 0) {
|
||||
buffer.putInt((int) (totalPlayTime + getRemainingDuration()));
|
||||
buffer.putInt(0);
|
||||
buffer.putInt((int) duration);
|
||||
} else {
|
||||
buffer.putInt(-1);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
} else {
|
||||
buffer.putInt((int) (totalPlayTime + getRemainingDuration()));
|
||||
buffer.putInt(0);
|
||||
buffer.putInt((int) duration);
|
||||
}
|
||||
buffer.putLong(ownerId);
|
||||
buffer.putInt(1); // unk
|
||||
@@ -130,6 +139,22 @@ public class Buff implements IListObject {
|
||||
|
||||
}
|
||||
|
||||
public String getGroup1() {
|
||||
return group1;
|
||||
}
|
||||
|
||||
public void setGroup1(String group1) {
|
||||
this.group1 = group1;
|
||||
}
|
||||
|
||||
public float getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public float getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import resources.objects.player.PlayerObject;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
@@ -65,17 +66,27 @@ public class BuffService implements INetworkDispatch {
|
||||
|
||||
final Buff buff = new Buff(buffName, creature.getObjectID());
|
||||
buff.setTotalPlayTime(((PlayerObject) creature.getSlottedObject("ghost")).getTotalPlayTime());
|
||||
if(creature.getBuffByName(buffName) != null) {
|
||||
|
||||
|
||||
for (Buff otherBuff : creature.getBuffList()) {
|
||||
if (buff.getGroup1().equals(otherBuff.getGroup1()))
|
||||
if (buff.getPriority() >= otherBuff.getPriority()) {
|
||||
if (buff.getBuffName().equals(otherBuff.getBuffName())) {
|
||||
if (otherBuff.getRemainingDuration() > buff.getDuration()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
removeBuffFromCreature(creature, otherBuff); System.out.println("buff removed " + buffName);
|
||||
break;
|
||||
}else{
|
||||
System.out.println("buff not added:" + buffName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Buff otherBuff = creature.getBuffByName(buffName);
|
||||
if(otherBuff.getRemainingDuration() > buff.getDuration()) {
|
||||
return;
|
||||
} else {
|
||||
removeBuffFromCreature(creature, otherBuff);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (FileUtilities.doesFileExist("scripts/commands/" + buffName + ".py")) buffName = "buff_" + buffName;
|
||||
core.scriptService.callScript("scripts/buffs", "setup", buffName, core, creature, buff);
|
||||
|
||||
creature.addBuff(buff);
|
||||
@@ -88,20 +99,23 @@ public class BuffService implements INetworkDispatch {
|
||||
|
||||
removeBuffFromCreature(creature, buff);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}, (long) buff.getDuration(), TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
} }
|
||||
|
||||
public void removeBuffFromCreature(CreatureObject creature, Buff buff) {
|
||||
|
||||
if(!creature.getBuffList().contains(buff))
|
||||
return;
|
||||
|
||||
core.scriptService.callScript("scripts/buffs", "removeBuff", buff.getBuffName(), core, creature, buff);
|
||||
creature.removeBuff(buff);
|
||||
if(!creature.getBuffList().contains(buff))
|
||||
return;
|
||||
|
||||
String buffName = buff.getBuffName();
|
||||
if (FileUtilities.doesFileExist("scripts/commands/" + buffName + ".py")) buffName = "buff_" + buffName;
|
||||
core.scriptService.callScript("scripts/buffs", "removeBuff", buffName, core, creature, buff);
|
||||
creature.removeBuff(buff);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user