diff --git a/scripts/commands/covercharge.py b/scripts/commands/covercharge.py index 82ca56af..d0eae641 100644 --- a/scripts/commands/covercharge.py +++ b/scripts/commands/covercharge.py @@ -39,7 +39,7 @@ def handleCoverCharge(actor, window, eventType, returnList): actor.sendSystemMessage('@performance:cc_stop_charge', 0) return else: - actor.setCoverCharge(int(returnList.get(0))) + actor.setCoverCharge(charge) actor.sendSystemMessage('You are now charging a cover of ' + returnList.get(0) + ' credits(s).', 0) return return diff --git a/scripts/expertise/expertise_en_holographic_mastery_1.py b/scripts/expertise/expertise_en_holographic_mastery_1.py index 59a4c40a..e705762e 100644 --- a/scripts/expertise/expertise_en_holographic_mastery_1.py +++ b/scripts/expertise/expertise_en_holographic_mastery_1.py @@ -10,7 +10,7 @@ def addExpertisePoint(core, actor): if not player.getProfession() == 'entertainer_1a': return - actor.addSkill('expertise_en_holographic_mastery_1') + core.services.skillModService.addSkillMod(actor, 'expertise_en_holographic_additional_backup', 1) addAbilities(core, actor, player) return @@ -25,7 +25,7 @@ def removeExpertisePoint(core, actor): if not player.getProfession() == 'entertainer_1a': return - actor.removeSkill('expertise_en_holographic_mastery_1') + core.services.skillModService.deductSkillMod(actor, 'expertise_en_holographic_additional_backup', 1) removeAbilities(core, actor, player) diff --git a/scripts/expertise/expertise_en_holographic_mastery_2.py b/scripts/expertise/expertise_en_holographic_mastery_2.py index 72a8e391..e705762e 100644 --- a/scripts/expertise/expertise_en_holographic_mastery_2.py +++ b/scripts/expertise/expertise_en_holographic_mastery_2.py @@ -10,7 +10,7 @@ def addExpertisePoint(core, actor): if not player.getProfession() == 'entertainer_1a': return - actor.addSkill('expertise_en_holographic_mastery_2') + core.services.skillModService.addSkillMod(actor, 'expertise_en_holographic_additional_backup', 1) addAbilities(core, actor, player) return @@ -25,7 +25,7 @@ def removeExpertisePoint(core, actor): if not player.getProfession() == 'entertainer_1a': return - actor.removeSkill('expertise_en_holographic_mastery_2') + core.services.skillModService.deductSkillMod(actor, 'expertise_en_holographic_additional_backup', 1) removeAbilities(core, actor, player) diff --git a/src/resources/objects/SkillMod.java b/src/resources/objects/SkillMod.java new file mode 100644 index 00000000..0af11b6b --- /dev/null +++ b/src/resources/objects/SkillMod.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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 resources.objects; + +import org.apache.mina.core.buffer.IoBuffer; + +import com.sleepycat.persist.model.Persistent; + +@Persistent +public class SkillMod extends Delta { + + private int base; + private int modifier; + private String name; + + public SkillMod() { + } + + public SkillMod(String name, int base, int modifier) { + this.name = name; + this.base = base; + this.modifier = modifier; + } + + public int getBase() { + return base; + } + + public void setBase(int base) { + this.base = base; + } + + public int getModifier() { + return modifier; + } + + public void setModifier(int modifier) { + this.modifier = modifier; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public byte[] getBytes() { + IoBuffer buffer = createBuffer(name.length() + 10); + + buffer.put(getAsciiString(name)); + buffer.putInt(base); + buffer.putInt(modifier); + + return buffer.array(); + } + +} diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 08f33a9b..03236871 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -31,9 +31,8 @@ import com.sleepycat.persist.model.Persistent; import engine.resources.common.CRC; import resources.objects.Buff; import resources.objects.ObjectMessageBuilder; +import resources.objects.SkillMod; import engine.resources.objects.SWGObject; -import engine.resources.objects.SkillMod; - import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; @@ -158,18 +157,22 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(0); } else { buffer.putInt(creature.getSkillMods().size()); - buffer.putInt(creature.getSkillModsUpdateCounter()); + buffer.putInt(creature.getSkillMods().getUpdateCounter()); - for(SkillMod skillMod : creature.getSkillMods().get()) { + for(SkillMod skillMod : creature.getSkillMods()) { buffer.put((byte) 0); - buffer.put(getAsciiString(skillMod.getSkillModString())); + buffer.put(getAsciiString(skillMod.getName())); buffer.putInt(skillMod.getBase()); buffer.putInt(skillMod.getModifier()); } } buffer.putFloat(creature.getSpeedMultiplierBase()); buffer.putFloat(creature.getSpeedMultiplierMod()); - buffer.putLong(creature.getListenToId()); + + if(creature.getPerformanceListenee() != null) + buffer.putLong(creature.getPerformanceListenee().getObjectId()); + else + buffer.putLong(0); buffer.putFloat(creature.getRunSpeed()); @@ -833,7 +836,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } - public IoBuffer buildAddSkillModDelta(String name, int base) { + /*public IoBuffer buildAddSkillModDelta(String name, int base) { CreatureObject creature = (CreatureObject) object; @@ -851,9 +854,9 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { return buffer; - } + }*/ - public IoBuffer buildRemoveSkillModDelta(String name, int base) { + /*public IoBuffer buildRemoveSkillModDelta(String name, int base) { CreatureObject creature = (CreatureObject) object; @@ -871,7 +874,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { return buffer; - } + }*/ public IoBuffer buildAddSkillDelta(String name) { @@ -1060,23 +1063,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1C, buffer, size + 4); return buffer; } - - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - switch (viewType) { - case 3: - case 6: - { - object.notifyObservers(buffer.flip(), true); - } - default: - { - if (object.getClient() != null && object.getClient().getSession() != null) { - object.getClient().getSession().write(buffer.flip()); - } - } - } - } - + public IoBuffer buildAddEquipmentDelta(TangibleObject item) { CreatureObject creature = (CreatureObject) object; @@ -1178,11 +1165,36 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + switch (viewType) { + case 1: + case 3: + case 4: { + switch(updateType) { + case 3: { + buffer = createDelta("CREO", (byte) 4, (short) 1, (byte) 3, buffer.flip(), buffer.array().length + 4); + + if (object.getClient() != null && object.getClient().getSession() != null) { + //object.getClient().getSession().write(buffer); + } + break; + } + + } + } + case 6: + case 8: + case 9: + default: + { + return; + } + } + } + @Override public void sendBaselines() { } - - } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index efb52cb8..0d847cb0 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -47,10 +47,10 @@ import engine.clients.Client; import resources.objects.Buff; import resources.objects.DamageOverTime; import resources.objects.SWGList; +import resources.objects.SkillMod; import engine.resources.objects.IPersistent; import engine.resources.objects.MissionCriticalObject; import engine.resources.objects.SWGObject; -import engine.resources.objects.SkillMod; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -86,7 +86,6 @@ public class CreatureObject extends TangibleObject implements IPersistent { private int skillModsUpdateCounter = 0; private float speedMultiplierBase = 1; private float speedMultiplierMod = 1; - private long listenToId = 0; private float runSpeed = (float) 7.3; private float slopeModAngle = 1; private float slopeModPercent = 1; @@ -558,7 +557,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { public SkillMod getSkillMod(String name) { synchronized(skillMods.getMutex()) { for(SkillMod skillMod : skillMods.get()) { - if(skillMod.getSkillModString().equals(name)) + if(skillMod.getName().equals(name)) return skillMod; } } @@ -573,19 +572,21 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void addSkillMod(String name, int base) { if(getSkillMod(name) == null) { - // TODO: This will need to be fixed as it doesn't update in the character sheet properly (wrong delta) + // TODO: Send skill mods delta in sendListDelta SkillMod skillMod = new SkillMod(); skillMod.setBase(base); - skillMod.setSkillModString(name); + skillMod.setName(name); skillMod.setModifier(0); skillMods.add(skillMod); } else { + SkillMod mod = getSkillMod(name); mod.setBase(mod.getBase() + base); - if(getClient() != null) { + + /*if(getClient() != null) { setSkillModsUpdateCounter((short) (getSkillModsUpdateCounter() + 1)); getClient().getSession().write(messageBuilder.buildAddSkillModDelta(name, mod.getBase())); - } + }*/ } } @@ -601,24 +602,23 @@ public class CreatureObject extends TangibleObject implements IPersistent { if(mod.getBase() <= 0) { removeSkillMod(mod); } else { - if(getClient() != null) { + skillMods.set(skillMods.indexOf(mod), mod); + System.out.println("Deducted mod!"); + /*if(getClient() != null) { setSkillModsUpdateCounter((short) (getSkillModsUpdateCounter() + 1)); getClient().getSession().write(messageBuilder.buildAddSkillModDelta(name, mod.getBase())); - } + }*/ } } public void removeSkillMod(SkillMod mod) { - skillMods.remove(mod); - if(getClient() != null) { + /*if(getClient() != null) { setSkillModsUpdateCounter((short) (getSkillModsUpdateCounter() + 1)); - getClient().getSession().write(messageBuilder.buildRemoveSkillModDelta(mod.getSkillModString(), mod.getBase())); - } - - + getClient().getSession().write(messageBuilder.buildRemoveSkillModDelta(mod.getName(), mod.getBase())); + }*/ } public short getSkillModsUpdateCounter() { @@ -665,18 +665,6 @@ public class CreatureObject extends TangibleObject implements IPersistent { notifyObservers(speedDelta, true); } - public long getListenToId() { - synchronized(objectMutex) { - return listenToId; - } - } - - public void setListenToId(long listenToId) { - synchronized(objectMutex) { - this.listenToId = listenToId; - } - } - public float getRunSpeed() { synchronized(objectMutex) { return runSpeed; @@ -1181,7 +1169,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { */ destination.getSession().write(upvpm.serialize()); - UpdatePostureMessage upm = new UpdatePostureMessage(getObjectID(), (byte) 0); + UpdatePostureMessage upm = new UpdatePostureMessage(getObjectID(), getPosture()); destination.getSession().write(upm.serialize()); } } @@ -1554,9 +1542,9 @@ public class CreatureObject extends TangibleObject implements IPersistent { synchronized(objectMutex) { this.performanceWatchee = performanceWatchee; } - // not sure at this point if it makes a difference really. - // on Live, an empty CREO4 was sent, at least when listenToId was empty. - //getClient().getSession().write(messageBuilder.buildListenToId(0)); + + //if(this.performanceListenee == null) + //getClient().getSession().write(messageBuilder.buildListenToId(0)); } public CreatureObject getPerformanceListenee() { @@ -1568,10 +1556,8 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void setPerformanceListenee(CreatureObject performanceListenee) { synchronized(objectMutex) { this.performanceListenee = performanceListenee; - //possibly redundant, need to research this further. - this.listenToId = performanceListenee.getObjectId(); } - getClient().getSession().write(messageBuilder.buildListenToId(this.listenToId)); + getClient().getSession().write(messageBuilder.buildListenToId(performanceListenee.getObjectId())); } diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index d3375af1..885d4999 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -35,6 +35,7 @@ import resources.datatables.Posture; import resources.objects.Buff; import resources.objects.BuffItem; import resources.objects.SWGList; +import resources.objects.SkillMod; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; @@ -46,7 +47,6 @@ import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; import engine.resources.objects.SWGObject; -import engine.resources.objects.SkillMod; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -348,7 +348,8 @@ public class EntertainmentService implements INetworkDispatch { //core.commandService.registerCommand("stopwatching"); // SWGList error //core.commandService.registerCommand("holoEmote"); core.commandService.registerCommand("covercharge"); - + //core.commandService.registerCommand("en_holographic_recall"); + //core.commandService.registerCommand("en_holographic_image"); // TODO: Add /bandsolo, /bandpause, /changeBandMusic, /changeDance, /changeGroupDance, /changeMusic // Entertainer Effects @@ -392,11 +393,14 @@ public class EntertainmentService implements INetworkDispatch { reciever.setAttachment("buffWorkshop", stats); - PlayerObject rPlayer = (PlayerObject) reciever.getSlottedObject("ghost"); + if (buffer == reciever) + reciever.setAttachment("inspireDuration", 215); + + //PlayerObject rPlayer = (PlayerObject) reciever.getSlottedObject("ghost"); - long timeStamp = 0; - if (reciever.getAttachment("buffWorkshopTimestamp") != null) - timeStamp = (long) reciever.getAttachment("buffWorkshopTimestamp"); + //long timeStamp = 0; + //if (reciever.getAttachment("buffWorkshopTimestamp") != null) + //timeStamp = (long) reciever.getAttachment("buffWorkshopTimestamp"); core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration", buffer); /*if (core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration", buffer) && !rPlayer.getProfession().equals("entertainer_1a")) {