From 4d99a8493593a5ea219541b55a8e99dbe185f76f Mon Sep 17 00:00:00 2001 From: voronius Date: Tue, 5 Aug 2014 04:14:13 +0300 Subject: [PATCH] Fix for inspiration buff Buff is now properly applied, stat mods are properly computed and changes to stats are clearly visible . Sample test at https://www.youtube.com/watch?v=KOV2C4z5VAw --- scripts/buffs/buildabuff_inspiration.py | 4 -- scripts/skillMods/elemental_resistance.py | 16 +++++ .../expertise_innate_protection_acid.py | 10 +++ .../expertise_innate_protection_cold.py | 10 +++ ...expertise_innate_protection_electricity.py | 10 +++ .../expertise_innate_protection_heat.py | 10 +++ src/resources/common/BuffBuilder.java | 30 ++++++++- src/services/BuffService.java | 25 +++++++- src/services/EntertainmentService.java | 63 ++++++++++++++++--- 9 files changed, 162 insertions(+), 16 deletions(-) create mode 100644 scripts/skillMods/elemental_resistance.py create mode 100644 scripts/skillMods/expertise_innate_protection_acid.py create mode 100644 scripts/skillMods/expertise_innate_protection_cold.py create mode 100644 scripts/skillMods/expertise_innate_protection_electricity.py create mode 100644 scripts/skillMods/expertise_innate_protection_heat.py diff --git a/scripts/buffs/buildabuff_inspiration.py b/scripts/buffs/buildabuff_inspiration.py index 35a49556..0474b1d9 100644 --- a/scripts/buffs/buildabuff_inspiration.py +++ b/scripts/buffs/buildabuff_inspiration.py @@ -5,19 +5,15 @@ def setup(core, actor, buff): return def add(core, actor, buff): - buffWorkshop = actor.getAttachment('buffWorkshop') - if buffWorkshop is None: return - attached = actor.getAttachment('inspireDuration') buff.setDuration(float(actor.getAttachment('inspireDuration') * 60)) for BuffItem in buffWorkshop: core.skillModService.addSkillMod(actor, BuffItem.getSkillName(), BuffItem.getAffectAmount()) - return def remove(core, actor, buff): diff --git a/scripts/skillMods/elemental_resistance.py b/scripts/skillMods/elemental_resistance.py new file mode 100644 index 00000000..5a327427 --- /dev/null +++ b/scripts/skillMods/elemental_resistance.py @@ -0,0 +1,16 @@ +import sys + +def add(core, actor, skillMod, divisor): + core.skillModService.addSkillMod(actor, 'acid', skillMod) + core.skillModService.addSkillMod(actor, 'heat', skillMod) + core.skillModService.addSkillMod(actor, 'cold', skillMod) + core.skillModService.addSkillMod(actor, 'electricity', skillMod) + return + +def deduct(core, actor, skillMod, divisor): + core.skillModService.deductSkillMod(actor, 'acid', skillMod) + core.skillModService.deductSkillMod(actor, 'heat', skillMod) + core.skillModService.deductSkillMod(actor, 'cold', skillMod) + core.skillModService.deductSkillMod(actor, 'electricity', skillMod) + return + \ No newline at end of file diff --git a/scripts/skillMods/expertise_innate_protection_acid.py b/scripts/skillMods/expertise_innate_protection_acid.py new file mode 100644 index 00000000..f3597431 --- /dev/null +++ b/scripts/skillMods/expertise_innate_protection_acid.py @@ -0,0 +1,10 @@ +import sys + +def add(core, actor, skillMod, divisor): + core.skillModService.addSkillMod(actor, 'acid', skillMod) + return + +def deduct(core, actor, skillMod, divisor): + core.skillModService.deductSkillMod(actor, 'acid', skillMod) + return + \ No newline at end of file diff --git a/scripts/skillMods/expertise_innate_protection_cold.py b/scripts/skillMods/expertise_innate_protection_cold.py new file mode 100644 index 00000000..8581c26d --- /dev/null +++ b/scripts/skillMods/expertise_innate_protection_cold.py @@ -0,0 +1,10 @@ +import sys + +def add(core, actor, skillMod, divisor): + core.skillModService.addSkillMod(actor, 'cold', skillMod) + return + +def deduct(core, actor, skillMod, divisor): + core.skillModService.deductSkillMod(actor, 'cold', skillMod) + return + \ No newline at end of file diff --git a/scripts/skillMods/expertise_innate_protection_electricity.py b/scripts/skillMods/expertise_innate_protection_electricity.py new file mode 100644 index 00000000..6174b979 --- /dev/null +++ b/scripts/skillMods/expertise_innate_protection_electricity.py @@ -0,0 +1,10 @@ +import sys + +def add(core, actor, skillMod, divisor): + core.skillModService.addSkillMod(actor, 'electricity', skillMod) + return + +def deduct(core, actor, skillMod, divisor): + core.skillModService.deductSkillMod(actor, 'electricity', skillMod) + return + \ No newline at end of file diff --git a/scripts/skillMods/expertise_innate_protection_heat.py b/scripts/skillMods/expertise_innate_protection_heat.py new file mode 100644 index 00000000..19188fc7 --- /dev/null +++ b/scripts/skillMods/expertise_innate_protection_heat.py @@ -0,0 +1,10 @@ +import sys + +def add(core, actor, skillMod, divisor): + core.skillModService.addSkillMod(actor, 'heat', skillMod) + return + +def deduct(core, actor, skillMod, divisor): + core.skillModService.deductSkillMod(actor, 'heat', skillMod) + return + \ No newline at end of file diff --git a/src/resources/common/BuffBuilder.java b/src/resources/common/BuffBuilder.java index 83b2d9fb..cd3c48a4 100644 --- a/src/resources/common/BuffBuilder.java +++ b/src/resources/common/BuffBuilder.java @@ -30,6 +30,11 @@ public class BuffBuilder { private String statAffects; private String statName; + + public enum BuffCategory {ATTRIBUTES,RESISTANCES,TRADE,COMBAT,MISC}; + private BuffCategory catId; + + public BuffBuilder() { } @@ -42,6 +47,10 @@ public class BuffBuilder { return category; } + public BuffCategory getCategoryId() { + return catId; + } + public int getCost() { return this.cost; } @@ -66,7 +75,26 @@ public class BuffBuilder { this.affectAmount = affectAmount; } - public void setCategory(String category) { + public void setCategory(String category) + { + this.catId=BuffCategory.MISC; + if(category.equals("attributes")) + { + this.catId=BuffCategory.ATTRIBUTES; + } + else if(category.equals("trade")) + { + this.catId=BuffCategory.TRADE; + } + else if(category.equals("resistances")) + { + this.catId=BuffCategory.RESISTANCES; + } + else if(category.equals("combat")) + { + this.catId=BuffCategory.COMBAT; + } + this.category = category; } diff --git a/src/services/BuffService.java b/src/services/BuffService.java index 993c25bb..4b7c533c 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -89,7 +89,10 @@ public class BuffService implements INetworkDispatch { Buff buff = buffMap.get(buffName); - if(buff == null) return false; + if(buff == null) + { + return false; + } // Here the necessary checks must be placed to prevent buffs from the same buff group (e.g. Buff D) being stacked! @@ -105,6 +108,10 @@ public class BuffService implements INetworkDispatch { public Buff doAddBuff(final CreatureObject target, String buffName, final CreatureObject buffer) { + //BUG HERE !! watch it + //TODO fix this -- !! this is wrong - I can buff from 5,5 in cantina someone sitting at 20,20 in the universe/planet !!! - accross the galaxy/planet + //cause get position is relative to creature system of coordinates - when one's outside and other inside + //if you must use getPosition() check for isInCell first for both or something like that if (target.getPosition().getDistance(buffer.getPosition()) > 20) { return null; } @@ -119,7 +126,21 @@ public class BuffService implements INetworkDispatch { else buff.setTotalPlayTime(0); - if(FileUtilities.doesFileExist("scripts/buffs/" + buffName + ".py")) core.scriptService.callScript("scripts/buffs/", buffName, "setup", core, buffer, buff); + + if(FileUtilities.doesFileExist("scripts/buffs/" + buffName + ".py")) + { + if(!buffName.equals("buildabuff_inspiration")) + { + core.scriptService.callScript("scripts/buffs/", buffName, "setup", core, buffer, buff); + } + else + { + //!!! for special case inspiration , workshop is attached to target + core.scriptService.callScript("scripts/buffs/", buffName, "add", core, target, buff); + } + } + + for (final Buff otherBuff : target.getBuffList()) { if (buff.getGroup1().equals(otherBuff.getGroup1())) diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 78c04f0d..ab1b03e3 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -62,6 +62,8 @@ public class EntertainmentService implements INetworkDispatch { private Map performanceEffects = new ConcurrentHashMap(); + + public EntertainmentService(NGECore core) { this.core = core; populateSkillCaps(); @@ -282,7 +284,8 @@ public class EntertainmentService implements INetworkDispatch { buffRecipient.getClient().getSession().write(closeMessage.serialize()); } - if (sender.getObjectId() == buffRecipient.getObjectId()) { + if (sender.getObjectId() == buffRecipient.getObjectId()) + { // send close packet to buffer BuffBuilderEndMessage end = new BuffBuilderEndMessage(sentPacket); end.setObjectId(buffer.getObjectId()); @@ -294,6 +297,8 @@ public class EntertainmentService implements INetworkDispatch { buffer.getClient().getSession().write(closeMessage.serialize()); CreatureObject cre = (CreatureObject) buffer; cre.sendSystemMessage("The buff recipient cancelled the buff builder session.", (byte) 0); + + } } } @@ -537,21 +542,61 @@ public class EntertainmentService implements INetworkDispatch { Vector availableStats = buffBuilderSkills; Vector stats = new Vector(); - for (BuffItem item : buffVector) { - for(BuffBuilder builder : availableStats) { - if(builder.getStatName().equalsIgnoreCase(item.getSkillName())) { + for (BuffItem item : buffVector) + { + for(BuffBuilder builder : availableStats) + { + + if(builder.getStatName().equalsIgnoreCase(item.getSkillName())) + { + + if(builder.getMaxTimesApplied() < item.getInvested()) return; + + int affectTotal=0; + + - // Ent. Expertise Percent + (invested points * affect amount) = stat - int bonusPoints = (int) (builder.getAffectAmount() *((float) item.getEntertainerBonus()/100f)); - int affectTotal = bonusPoints + (item.getInvested() * builder.getAffectAmount()); - BuffItem stat = new BuffItem(builder.getStatAffects(), item.getInvested(), item.getEntertainerBonus()); - stat.setAffectAmount(affectTotal); + + switch(builder.getCategoryId()) + { + + case TRADE: + case RESISTANCES: + case ATTRIBUTES: + { + affectTotal=(int)( ( (1+(float) item.getEntertainerBonus()/100f)*builder.getAffectAmount()) * item.getInvested()); + break; + + } + case COMBAT: + { + affectTotal=(int) (( builder.getAffectAmount()+item.getEntertainerBonus()) * item.getInvested()); + break; + + } + case MISC: + { + affectTotal=(int) (( builder.getAffectAmount()) * item.getInvested()); + break; + + } + default: + { + System.out.println("unhandled builder catId of "+builder.getCategoryId()); + } + + } + + stat.setAffectAmount(affectTotal); stats.add(stat); + + break; } + } }