From 3b1568339d69dd5a6d3ae4003bc08c6994ce7a7d Mon Sep 17 00:00:00 2001 From: voronius Date: Wed, 6 Aug 2014 20:05:04 +0300 Subject: [PATCH 1/2] Fix for issue 136 Fix for issue 136. Inspiration buffs should no longer stack. --- scripts/commands/inspire.py | 3 +- src/services/BuffService.java | 74 ++++++++++++++++++++------ src/services/EntertainmentService.java | 9 +++- src/services/spawn/CreatureSkill.java | 65 ++++++++++++++++++++++ 4 files changed, 132 insertions(+), 19 deletions(-) create mode 100644 src/services/spawn/CreatureSkill.java diff --git a/scripts/commands/inspire.py b/scripts/commands/inspire.py index 282fe64a..15948e9e 100644 --- a/scripts/commands/inspire.py +++ b/scripts/commands/inspire.py @@ -10,13 +10,12 @@ def run(core, actor, target, commandString): if not playerObject or playerObject.getProfession() != "entertainer_1a": return - if target is None or actor.getObjectId() == target.getObjectId(): openBuffWindow = BuffBuilderStartMessage(actor.getObjectId(), actor.getObjectId(), actor.getObjectId()) objController = ObjControllerMessage(11, openBuffWindow) actor.getClient().getSession().write(objController.serialize()) return - + if target is None and commandString is not None: target = core.chatService.getObjectByFirstName(commandString) if target is None: diff --git a/src/services/BuffService.java b/src/services/BuffService.java index 4b7c533c..70a24957 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -143,7 +143,7 @@ public class BuffService implements INetworkDispatch { for (final Buff otherBuff : target.getBuffList()) { - if (buff.getGroup1().equals(otherBuff.getGroup1())) + if (buff.getGroup1().equals(otherBuff.getGroup1())) if (buff.getPriority() >= otherBuff.getPriority()) { if (buff.getBuffName().equals(otherBuff.getBuffName())) { @@ -164,11 +164,11 @@ public class BuffService implements INetworkDispatch { if (otherBuff.getRemainingDuration() > buff.getDuration() && otherBuff.getStacks() >= otherBuff.getMaxStacks()) return null; } - removeBuffFromCreature(target, otherBuff); break; - } else { - System.out.println("buff not added:" + buffName); + } else + { + return null; } } @@ -239,9 +239,12 @@ public class BuffService implements INetworkDispatch { } @SuppressWarnings("unused") - public void removeBuffFromCreature(CreatureObject creature, Buff buff) { + public void removeBuffFromCreature(CreatureObject creature, Buff buff) + { if(!creature.getBuffList().contains(buff)) - return; + { + return; + } DamageOverTime dot = creature.getDotByBuff(buff); if(dot != null) { dot.getTask().cancel(true); @@ -251,14 +254,40 @@ public class BuffService implements INetworkDispatch { /* if(FileUtilities.doesFileExist("scripts/buffs/" + buff.getBuffName() + ".py")) core.scriptService.callScript("scripts/buffs/", buff.getBuffName(), "remove", core, creature, buff); else {*/ - if(buff.getEffect1Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect1Name(), (int) buff.getEffect1Value()); - if(buff.getEffect2Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect2Name(), (int) buff.getEffect2Value()); - if(buff.getEffect1Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect3Name(), (int) buff.getEffect3Value()); - if(buff.getEffect1Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect4Name(), (int) buff.getEffect4Value()); - if(buff.getEffect1Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect5Name(), (int) buff.getEffect5Value()); -// } - if (!buff.getCallback().equals("none") && !buff.getCallback().equals("")) { + if(buff.getEffect1Name().length() > 0) + { + + core.skillModService.deductSkillMod(creature, buff.getEffect1Name(), (int) buff.getEffect1Value()); + + } + + if(buff.getEffect2Name().length() > 0) + { + core.skillModService.deductSkillMod(creature, buff.getEffect2Name(), (int) buff.getEffect2Value()); + } + + if(buff.getEffect3Name().length() > 0) + { + core.skillModService.deductSkillMod(creature, buff.getEffect3Name(), (int) buff.getEffect3Value()); + + } + + if(buff.getEffect4Name().length() > 0) + { + core.skillModService.deductSkillMod(creature, buff.getEffect4Name(), (int) buff.getEffect4Value()); + + } + + if(buff.getEffect5Name().length() > 0) + { + core.skillModService.deductSkillMod(creature, buff.getEffect5Name(), (int) buff.getEffect5Value()); + } +// } + + // ??? callback for what ? toggle buff ? + if (!buff.getCallback().equals("none") && !buff.getCallback().equals("")) + { if (FileUtilities.doesFileExist("scripts/buffs/" + buff.getBuffName() + ".py")) { PyObject method = core.scriptService.getMethod("scripts/buffs/", buff.getBuffName(), buff.getCallback()); @@ -267,6 +296,19 @@ public class BuffService implements INetworkDispatch { } } } + //remove method is more like it + else + { + if (FileUtilities.doesFileExist("scripts/buffs/" + buff.getBuffName() + ".py")) + { + PyObject method = core.scriptService.getMethod("scripts/buffs/", buff.getBuffName(), "remove"); + + if (method != null && method.isCallable()) + { + method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(buff)); + } + } + } creature.removeBuff(buff); for (String effect : buff.getParticleEffect().split(",")) { @@ -352,14 +394,16 @@ public class BuffService implements INetworkDispatch { public void addGroupBuff(CreatureObject target, String buffName, CreatureObject buffer) { - if(buffer.getGroupId() == 0) { + if(buffer.getGroupId() == 0) + { doAddBuff(target, buffName, buffer); return; } GroupObject group = (GroupObject) core.objectService.getObject(buffer.getGroupId()); - if(group == null) { + if(group == null) + { doAddBuff(target, buffName, buffer); return; } diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index ab1b03e3..645dcd8d 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -539,6 +539,12 @@ public class EntertainmentService implements INetworkDispatch { public void giveInspirationBuff(CreatureObject reciever, CreatureObject buffer, Vector buffVector) { + + if (reciever.hasBuff("buildabuff_inspiration")) + { + core.buffService.removeBuffFromCreature(reciever, reciever.getBuffByName("buildabuff_inspiration")); + } + Vector availableStats = buffBuilderSkills; Vector stats = new Vector(); @@ -611,8 +617,7 @@ public class EntertainmentService implements INetworkDispatch { //if (reciever.getAttachment("buffWorkshopTimestamp") != null) //timeStamp = (long) reciever.getAttachment("buffWorkshopTimestamp"); - if (reciever.hasBuff("buildabuff_inspiration")) - core.buffService.removeBuffFromCreature(reciever, reciever.getBuffByName("buildabuff_inspiration")); + core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration", buffer); /*if (core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration", buffer) && !rPlayer.getProfession().equals("entertainer_1a")) { diff --git a/src/services/spawn/CreatureSkill.java b/src/services/spawn/CreatureSkill.java new file mode 100644 index 00000000..0a647ac1 --- /dev/null +++ b/src/services/spawn/CreatureSkill.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * 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 services.spawn; + +public class CreatureSkill +{ + public String name; + public long cooldown; + public long usage; + public Integer mask; + public CreatureSkill(String name, long cooldown, Integer mask) + { + this.name=name; + this.cooldown=cooldown; + this.mask=mask; + } + public String getName() + { + return name; + } + public long getCooldown() + { + return cooldown; + } + public Integer getMask() + { + return mask; + } + public void setUsage(long usage) + { + this.usage=usage; + } + public long getUsage() + { + return usage; + } + public static final byte BUFF_SKILL=1; + public static final byte DAMAGE_SKILL=2; + public static final byte DEFENSE_SKILL=4; + public static final byte DRAIN_SKILL=8; + public static final byte HEAL_SKILL=16; + +} + + + From 76b552bc29748f879587bae73a65700f403d8d56 Mon Sep 17 00:00:00 2001 From: voronius Date: Wed, 6 Aug 2014 20:20:29 +0300 Subject: [PATCH 2/2] Fix for 139 part 2 Inspiration buffs should no longer stack - https://www.youtube.com/upload. Removed a new file I shouldn't have commited. --- src/services/spawn/CreatureSkill.java | 65 --------------------------- 1 file changed, 65 deletions(-) delete mode 100644 src/services/spawn/CreatureSkill.java diff --git a/src/services/spawn/CreatureSkill.java b/src/services/spawn/CreatureSkill.java deleted file mode 100644 index 0a647ac1..00000000 --- a/src/services/spawn/CreatureSkill.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * 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 services.spawn; - -public class CreatureSkill -{ - public String name; - public long cooldown; - public long usage; - public Integer mask; - public CreatureSkill(String name, long cooldown, Integer mask) - { - this.name=name; - this.cooldown=cooldown; - this.mask=mask; - } - public String getName() - { - return name; - } - public long getCooldown() - { - return cooldown; - } - public Integer getMask() - { - return mask; - } - public void setUsage(long usage) - { - this.usage=usage; - } - public long getUsage() - { - return usage; - } - public static final byte BUFF_SKILL=1; - public static final byte DAMAGE_SKILL=2; - public static final byte DEFENSE_SKILL=4; - public static final byte DRAIN_SKILL=8; - public static final byte HEAL_SKILL=16; - -} - - -