From e5ecd36cc938e105198b3734e4d74a0647a0b496 Mon Sep 17 00:00:00 2001 From: NeumimTo Date: Sat, 27 Nov 2021 10:58:14 +0100 Subject: [PATCH] scripting cont --- .../cz/neumimto/rpg/SpigotRpgBootstrap.java | 2 +- Common/lib-cp/NT-Script-0.1.9.jar | Bin 111149 -> 111186 bytes .../damage/IEntityWeaponDamageEarlyEvent.java | 4 + .../rpg/common/scripting/NTScriptEngine.java | 27 +--- .../common/scripting/SkillScriptHandlers.java | 2 +- .../scripting/mechanics/SkillCommons.java | 7 ++ .../rpg/common/skills/SkillService.java | 24 +++- .../scripting/EffectScriptGenerator.java | 3 +- .../scripting/ListenerScriptGenerator.java | 4 +- .../skills/scripting/ScriptSkillModel.java | 4 + .../rpg/common/skills/tree/SkillType.java | 9 ++ .../skills/types/PassiveScriptSkill.java | 8 -- .../rpg/common/skills/types/PassiveSkill.java | 18 ++- .../neumimto/rpg/common/utils/MathUtils.java | 5 + .../assets/nt-rpg/defaults/skills.conf | 87 +++++++++++-- .../cz/neumimto/rpg/TestSkillService.java | 2 +- .../effects/common/ArrowblastEffect.java | 58 +++++++++ .../SpigotEntityWeaponDamageEarlyEvent.java | 12 ++ .../listeners/SpigotDamageListener.java | 1 + .../rpg/spigot/skills/SpigotSkillService.java | 117 +++++++++++------- 20 files changed, 296 insertions(+), 98 deletions(-) create mode 100644 Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/effects/common/ArrowblastEffect.java diff --git a/Bootstrap/Spigot/src/main/java/cz/neumimto/rpg/SpigotRpgBootstrap.java b/Bootstrap/Spigot/src/main/java/cz/neumimto/rpg/SpigotRpgBootstrap.java index e50d630b3..b033a63b0 100644 --- a/Bootstrap/Spigot/src/main/java/cz/neumimto/rpg/SpigotRpgBootstrap.java +++ b/Bootstrap/Spigot/src/main/java/cz/neumimto/rpg/SpigotRpgBootstrap.java @@ -19,7 +19,7 @@ @Author("NeumimTo") @Website("https://github.com/Sponge-RPG-dev/NT-RPG") @LogPrefix("NTRPG") -@ApiVersion(ApiVersion.Target.v1_14) +@ApiVersion(ApiVersion.Target.v1_17) @SoftDependsOn( value = { @SoftDependency("PlaceholderAPI"), diff --git a/Common/lib-cp/NT-Script-0.1.9.jar b/Common/lib-cp/NT-Script-0.1.9.jar index 9ca841eefe5db0125cb0d72aa2c56ca24c1eaeb7..43acfc57864bdafdb7d16f45041e0194936f1ff3 100644 GIT binary patch delta 7913 zcmX|`byQT}_xBk(WJrmjK^hb!grTIRK{_ReP8kNNkuDj~0fz2Iq`N^nl$P$80g*;U z^g%!0-*f&r_q|{HefGNNoORc_YwfBX{OKKhQe6!kTw*LNLP9KzVc=WRK8m}CKGxm9 z{yW_bawI^As`fnLHSlld6!l2S2nP#miwMaQ$AW?v0|@FHLalLd?vnMikw0<&3F^31 zynmu9@gd>Aiiypt$ZZBJta&voEN0}}PzEGH8XcU?wkPRzc$on*CPIsyjg^(oJJa5( zug9KiQj=WwFzRM)prGkt*@hV^BZ7Rv3|3`S+1PY!K4-MNWaMht^>QsUeH=vjF>&4V z@%1X~xOG40b|o;nw0re8>ud0(4ryEsYMrp%Y(6?6^;9$Xvn5ts1 z2q~=WU#0-I{Mt;abY7gE&ud0T?=~@na2x;`n6br%TiBTfcx)n=j_0jem3Z7l9S?~E zgFi$bPnrQh`Gxm5Ue$@iDL+2va8r0QzX|`ytXa`qIOFI`_q%3cy~{1QRG!C!krm$b ziHSHJ=W4c=c97BsyjtbD@)aK^^&{XRDFJ;bk?99J&rkuElwPf4pk1vLqj*@ztJXvW zalXLV2@D!hMwA4F?;{`h*;x~0n?2gX!`r~I41~2nQ%){k zkNR&``4FH$+)(=8Mup-b*)#=_^Lb_jh&~@ueqTnxc&&6V8|v21iNkBc3%D@YXv-w5 zP=@XRlf`s!W^Um`UVvEe#@4nk01GN0=_&NgOg-ZfMy8&?YFO*?f`gL~<-Nr)XivBw zQ{~1kZ@5b7r&X8Po1lnre*M#utD^Ldi0p9?ldSJafYgfXJ)?Fbn1AGx4s~jwBS`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hOjjQb!QjRIBTxb^*&^I$7bZ_hulf()^ zL|_lNGvpQ$bv@UN9W62hD9RDNhfMB6XPU2;`~7>?%YPVMZ+6Jd7^v6YXBEtsnF%*Z z-nObEiI$@!*r`x_3KzIn2kBW}SQcum?`pco&sO}1r}yfMo=^ir%Fa^t+YyC(zyo<`I&1%gU@YsOX`6_|tcVwTb{jyR`|9fiDj&M={qo z#ivJV12=D>b_j*V8A~npB&3sUymQEN?`C1o&##&?e~cGc9iiTEi~fl>n6TbA7b*v< zY$M+AkL(D9J`q@Sx@b+Lo}28?qYFFdKQ{QrZFKg*O!oFIT5iz5SzQyIu=7+x;0=># z=fK3(?3>x+u$@xAS%V|;0OM|t_K}VK;=5VonG6pOQSi_N!~j+tw)Lm)La@yu2S$Ap z{)nFb2f6N|PGukAC3J*HKml8jr%V7&6IVKb7xkZf5aL(>Q1}a4{{v78|DVw=1gK&D zlSTeFI)v000*v5C>Jo4-2_Otb03P_up?`3K%rF)Ny#RodpfHYu@o$_72bUj6JpR%p zgZwB0h{DrP|Ha>m0q6;_(}a+XA^;9Vw-^9~*P8!NM;2am`5&B+zDx$`tbEaHUH@Ob zu=T%_`XvAb_?_*)xVHo#3tzVX7c-Uuq~N(v{^H0|fE@hf#S7;7*NU|4#Y*Jng&IZJ0YHQ^#DD4W za)1oN5$eB%3>p9zl3o2GsaXL40>&XO6##wse0+#&1%MoKQ1S8rBEEUj-0H;AZ$AX1od@ zf*{HAUxpAOTK%G^#{ORh5fWAXa;+V%f0=`7fE+>r-#-NqqFe)Dhu?9Ae69f~BB*-+ gAXJ|K_>k=y02jiB-`|P`B3ui=LBfIpUjFz000k@$U;qFB diff --git a/Common/src/main/java/cz/neumimto/rpg/common/events/damage/IEntityWeaponDamageEarlyEvent.java b/Common/src/main/java/cz/neumimto/rpg/common/events/damage/IEntityWeaponDamageEarlyEvent.java index 6e43a18f3..bc1f39e90 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/events/damage/IEntityWeaponDamageEarlyEvent.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/events/damage/IEntityWeaponDamageEarlyEvent.java @@ -1,5 +1,6 @@ package cz.neumimto.rpg.common.events.damage; +import cz.neumimto.rpg.common.entity.IEntity; import cz.neumimto.rpg.common.items.RpgItemStack; import java.util.Optional; @@ -10,4 +11,7 @@ public interface IEntityWeaponDamageEarlyEvent extends DamageIEntityEarlyEvent { void setWeapon(RpgItemStack weapon); + void setDamager(IEntity attacker); + + IEntity getDamager(); } diff --git a/Common/src/main/java/cz/neumimto/rpg/common/scripting/NTScriptEngine.java b/Common/src/main/java/cz/neumimto/rpg/common/scripting/NTScriptEngine.java index 71c87d7f3..233c7864b 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/scripting/NTScriptEngine.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/scripting/NTScriptEngine.java @@ -4,6 +4,7 @@ import com.google.inject.Key; import cz.neumimto.nts.NTScript; import cz.neumimto.nts.annotations.ScriptMeta; +import cz.neumimto.rpg.common.Rpg; import cz.neumimto.rpg.common.assets.AssetService; import cz.neumimto.rpg.common.effects.IEffect; import cz.neumimto.rpg.common.logging.Log; @@ -14,6 +15,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.StringReader; import java.util.*; @@ -55,18 +57,18 @@ public NTScript scriptContextForSkills(Consumer builder, Class } NTScript.Builder n = NTScript.builder() - .implementingType(ScriptSkill.class) + .implementingType(type) .classAnnotations(new Class[]{Singleton.class}) .fieldAnnotation(new Class[]{Inject.class}) .macro(macrosMap) .withEnum(SkillResult.class) - .implementingType(type) + .debugOutput(Rpg.get().getWorkingDirectory() + File.separator + "/compiled-scripts") .add(getStl()) - .debugOutput("/tmp") .logging(Log::warn) .package_("cz.neumimto.rpg.script.skills") .setClassNamePattern(type.getSimpleName()); + n.add(STL); builder.accept(n); return n.build(); @@ -87,25 +89,6 @@ public List getStl() { .forEach(list::add); } catch (Throwable t) { - Log.info("Java service provider bug still present, doing it the stupid way"); - - try { - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.BleedingEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.FeatherFall")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.Maim")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.ManaShieldEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.NoAutohealEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.PiggifyEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.SlowEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.StunEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.UnhealEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.UnlimtedFoodLevelEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.WebEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.FlickerEffect")); - list.add(Class.forName("cz.neumimto.rpg.spigot.effects.common.InvisibilityEffect")); - } catch (Exception e) { - - } } list.addAll(STL); diff --git a/Common/src/main/java/cz/neumimto/rpg/common/scripting/SkillScriptHandlers.java b/Common/src/main/java/cz/neumimto/rpg/common/scripting/SkillScriptHandlers.java index 4ba74c3c5..6c5cb09ab 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/scripting/SkillScriptHandlers.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/scripting/SkillScriptHandlers.java @@ -27,7 +27,7 @@ SkillResult castOnTarget(@NamedParam("caster") IActiveCharacter caster, interface Passive extends SkillScriptHandlers { @ScriptTarget - SkillResult init(@NamedParam("caster") IActiveCharacter caster, + void init(@NamedParam("caster") IActiveCharacter caster, @NamedParam("context") PlayerSkillContext context, @NamedParam("this_skill")ISkill iSkill); } diff --git a/Common/src/main/java/cz/neumimto/rpg/common/scripting/mechanics/SkillCommons.java b/Common/src/main/java/cz/neumimto/rpg/common/scripting/mechanics/SkillCommons.java index 66a4706ad..2b44dd153 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/scripting/mechanics/SkillCommons.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/scripting/mechanics/SkillCommons.java @@ -10,6 +10,7 @@ import cz.neumimto.rpg.common.skills.PlayerSkillContext; import jdk.jfr.Name; +import java.util.concurrent.ThreadLocalRandom; import java.util.logging.Logger; @AutoService(NTScriptProxy.class) @@ -32,6 +33,12 @@ public boolean exists(@NamedParam("o|obj|var") Object o) { return o != null; } + @Handler + @Function("roll") + public boolean roll(@NamedParam("pass") double min, @NamedParam("maxVal|max") double max) { + return ThreadLocalRandom.current().nextDouble(max) <= min; + } + @Handler @Function("print") public void print(@NamedParam("o|obj|var") Object o) { diff --git a/Common/src/main/java/cz/neumimto/rpg/common/skills/SkillService.java b/Common/src/main/java/cz/neumimto/rpg/common/skills/SkillService.java index e33ac34ff..9954a2369 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/skills/SkillService.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/skills/SkillService.java @@ -38,6 +38,7 @@ import java.nio.file.Paths; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Consumer; import java.util.stream.Stream; import static cz.neumimto.rpg.common.logging.Log.*; @@ -70,6 +71,8 @@ public SkillService() { Stream.of(SkillType.values()).forEach(this::registerSkillType); } + public abstract Consumer getNTSBuilderContext(); + public void load() { skillTrees.clear(); reloadSkills(); @@ -170,9 +173,6 @@ public void registerSkillAlternateName(String name, ISkill skill) { skillByNames.put(name, skill); } - - public abstract NTScript getNtScriptCompilerFor(Class c); - public ISkill skillDefinitionToSkill(ScriptSkillModel scriptSkillModel, ClassLoader classLoader) { if (scriptSkillModel.handlerId.equalsIgnoreCase("nts")) { @@ -190,7 +190,8 @@ public ISkill skillDefinitionToSkill(ScriptSkillModel scriptSkillModel, ClassLoa Log.info("Compiling nts script " + scriptSkillModel.id + " as " + c.getSimpleName()); - Class generate = getNtScriptCompilerFor(c).compile(scriptSkillModel.script); + Class generate = ntScriptEngine.prepareCompiler(getNTSBuilderContext(),c) + .compile(scriptSkillModel.script); if (generate == null) { Log.error("Unable to generate script " + scriptSkillModel.id); } @@ -198,6 +199,21 @@ public ISkill skillDefinitionToSkill(ScriptSkillModel scriptSkillModel, ClassLoa ScriptSkill ss = getSkillByHandlerType(instance); ss.setModel(scriptSkillModel); ss.setHandler(instance); + if (ss instanceof PassiveScriptSkill p) { + p.setRelevantEffectName(scriptSkillModel.relevantEffectName); + } + + if (scriptSkillModel.skillTypes != null) { + for (String skillType : scriptSkillModel.skillTypes) { + SkillType st = SkillType.byId(skillType); + if (st == null) { + Log.warn("Unknown skill type " + st); + } else { + ss.addSkillType(st); + } + } + } + injector.injectMembers(ss); injectCatalogId((ISkill) ss, scriptSkillModel.id); return (ISkill) ss; diff --git a/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/EffectScriptGenerator.java b/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/EffectScriptGenerator.java index 7034346bb..ceaef8b07 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/EffectScriptGenerator.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/EffectScriptGenerator.java @@ -166,7 +166,6 @@ public ClassVisitor wrap(TypeDescription instrumentedType, ClassVisitor classVis } - // bb.make().saveIn(new File("/tmp")); Class loaded = bb.make() .load(classLoader, INJECTION) .getLoaded(); @@ -202,7 +201,7 @@ private static ScriptEffectBase.Handler generateHandler(String script, ClassLoad .getLoaded(); Class compile = Rpg.get().getScriptEngine() - .prepareCompiler(builder -> {}, loaded1) + .prepareCompiler(Rpg.get().getSkillService().getNTSBuilderContext(), loaded1) .compile(script); try { Object o = compile.newInstance(); diff --git a/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/ListenerScriptGenerator.java b/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/ListenerScriptGenerator.java index b6b80a899..10f6d6496 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/ListenerScriptGenerator.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/ListenerScriptGenerator.java @@ -32,8 +32,8 @@ public static Class from(ScriptListenerModel model, ClassLoader classLoader) { .make() .load(classLoader, ClassLoadingStrategy.Default.INJECTION) .getLoaded(); - Class compile = Rpg.get().getScriptEngine().prepareCompiler(builder -> { - }, bb).compile(model.script); + + Class compile = Rpg.get().getScriptEngine().prepareCompiler(Rpg.get().getSkillService().getNTSBuilderContext(), bb).compile(model.script); return compile; } catch (Throwable t) { t.printStackTrace(); diff --git a/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/ScriptSkillModel.java b/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/ScriptSkillModel.java index 921ed374c..cfd5ec7df 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/ScriptSkillModel.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/skills/scripting/ScriptSkillModel.java @@ -24,6 +24,10 @@ public class ScriptSkillModel { @Path("Script") public String script; + @Optional + @Path("RelevantEffectName") + public String relevantEffectName; + @Optional @Path("SuperType") public String superType; diff --git a/Common/src/main/java/cz/neumimto/rpg/common/skills/tree/SkillType.java b/Common/src/main/java/cz/neumimto/rpg/common/skills/tree/SkillType.java index 97bb6cfea..e3ccde1b0 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/skills/tree/SkillType.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/skills/tree/SkillType.java @@ -69,4 +69,13 @@ public String getId() { public String getTranslationKey() { return name; } + + public static SkillType byId(String id) { + for (SkillType value : values()) { + if (value.id.equalsIgnoreCase(id)) { + return value; + } + } + return null; + } } diff --git a/Common/src/main/java/cz/neumimto/rpg/common/skills/types/PassiveScriptSkill.java b/Common/src/main/java/cz/neumimto/rpg/common/skills/types/PassiveScriptSkill.java index 11c2bda94..0e2e70325 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/skills/types/PassiveScriptSkill.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/skills/types/PassiveScriptSkill.java @@ -1,18 +1,10 @@ package cz.neumimto.rpg.common.skills.types; -import cz.neumimto.rpg.common.Rpg; import cz.neumimto.rpg.common.entity.players.IActiveCharacter; -import cz.neumimto.rpg.common.logging.Log; import cz.neumimto.rpg.common.scripting.SkillScriptHandlers; -import cz.neumimto.rpg.common.skills.ISkillType; import cz.neumimto.rpg.common.skills.PlayerSkillContext; import cz.neumimto.rpg.common.skills.scripting.ScriptSkillModel; -import javax.script.Bindings; -import javax.script.SimpleBindings; -import java.util.List; -import java.util.Optional; - /** * Created by NeumimTo on 7.10.2018. */ diff --git a/Common/src/main/java/cz/neumimto/rpg/common/skills/types/PassiveSkill.java b/Common/src/main/java/cz/neumimto/rpg/common/skills/types/PassiveSkill.java index d3462499f..d62a8ceb0 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/skills/types/PassiveSkill.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/skills/types/PassiveSkill.java @@ -2,6 +2,8 @@ package cz.neumimto.rpg.common.skills.types; +import cz.neumimto.nts.annotations.ScriptMeta.NamedParam; +import cz.neumimto.nts.annotations.ScriptMeta.ScriptTarget; import cz.neumimto.rpg.common.effects.EffectService; import cz.neumimto.rpg.common.entity.players.IActiveCharacter; import cz.neumimto.rpg.common.inventory.InventoryService; @@ -10,14 +12,13 @@ import cz.neumimto.rpg.common.skills.PlayerSkillContext; import cz.neumimto.rpg.common.skills.SkillExecutionType; import cz.neumimto.rpg.common.skills.SkillResult; -import cz.neumimto.rpg.common.skills.scripting.JsBinding; import javax.inject.Inject; /** * Created by NeumimTo on 6.8.2015. */ -@JsBinding(JsBinding.Type.CLASS) + public abstract class PassiveSkill extends AbstractSkill { public static enum Type { @@ -53,6 +54,7 @@ public SkillResult onPreUse(IActiveCharacter character, PlayerSkillContext esi) protected void update(IActiveCharacter IActiveCharacter) { inventoryService.initializeCharacterInventory(IActiveCharacter); PlayerSkillContext skill = IActiveCharacter.getSkill(getId()); + effectService.removeEffect(relevantEffectName, IActiveCharacter, this); applyEffect(skill, IActiveCharacter); } @@ -79,10 +81,20 @@ public void skillRefund(IActiveCharacter IActiveCharacter, PlayerSkillContext co } } - public abstract void applyEffect(PlayerSkillContext info, IActiveCharacter character); + @ScriptTarget + public abstract void applyEffect(@NamedParam("c|context") PlayerSkillContext info, + @NamedParam("caster") IActiveCharacter character); @Override public SkillExecutionType getSkillExecutionType() { return SkillExecutionType.PASSIVE; } + + public String getRelevantEffectName() { + return relevantEffectName; + } + + public void setRelevantEffectName(String relevantEffectName) { + this.relevantEffectName = relevantEffectName; + } } diff --git a/Common/src/main/java/cz/neumimto/rpg/common/utils/MathUtils.java b/Common/src/main/java/cz/neumimto/rpg/common/utils/MathUtils.java index ee878ca5d..70ff78890 100644 --- a/Common/src/main/java/cz/neumimto/rpg/common/utils/MathUtils.java +++ b/Common/src/main/java/cz/neumimto/rpg/common/utils/MathUtils.java @@ -1,5 +1,6 @@ package cz.neumimto.rpg.common.utils; +import java.util.concurrent.ThreadLocalRandom; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,6 +28,10 @@ public static double round(float value, int precision) { return Math.round(value * scale) / scale; } + public static double randomInRange(double min, double max) { + return min + (max - min) * ThreadLocalRandom.current().nextDouble(); + } + public static boolean isNumeric(String str) { return str.matches("-?\\d+(\\.\\d+)?"); } diff --git a/Common/src/main/resources/assets/nt-rpg/defaults/skills.conf b/Common/src/main/resources/assets/nt-rpg/defaults/skills.conf index b129954ed..fa60b3522 100644 --- a/Common/src/main/resources/assets/nt-rpg/defaults/skills.conf +++ b/Common/src/main/resources/assets/nt-rpg/defaults/skills.conf @@ -114,9 +114,9 @@ Skills: [ # With SuperType Targeted we can use reference @caster and @target in our script IF damage{damager=@caster, target=@target, damage=@damage, k=0, s=@this_skill} - @x = random{} * 0.4 - 0.2 - @z = random{} * 0.4 - 0.2 - @vector = vector{x=@x, y=0.8, z=@z} + @x = random{} * 0.4 + @z = random{} * 0.4 + @vector = Vector{x=@x, y=0.8, z=@z} set_velocity{v=@vector, e=@target} particle{e=@target, a=2, p=Particle.EXPLOSION_NORMAL} @@ -172,8 +172,8 @@ Skills: [ Handler: nts SuperType: Active Skill-Types: [ - "ILLUSION" - "STEALTH" + "ntrpg:ILLUSION" + "ntrpg:STEALTH" ] Script: """ @duration = $settings.duration @@ -192,8 +192,8 @@ Skills: [ Handler: nts SuperType: Active Skill-Types: [ - "ILLUSION" - "STEALTH" + "ntrpg:ILLUSION" + "ntrpg:STEALTH" ] Script: """ @duration = $settings.duration @@ -244,6 +244,44 @@ Skills: [ return SkillResult.OK """ } + { + Id: "ntrpg:arrowblast" + Handler: nts + SuperType: Active + Script: """ + @arrows = $settings.arrows + @dmin = $settings.damageMin + @dmax = $settings.damageMax + @p = $settings.period + @v = $settings.velocity + + @effect = ArrowBlastEffect{c=@caster, a=@arrows, dmin=@dmin, dmax=@dmax, period=@p, velocity=@v} + add_effect{effect=@effect, es=@caster, source=@this_skill} + + return SkillResult.OK + """ + } + { + Id: "ntrpg:basher" + Handler: nts + SuperType: Passive + RelevantEffectId: BasherEffect + Script: """ + @chance = $settings.change + @exDamage = $settings.extraDamage + @stunDuration = $settings.stunDuration + + @effect = BasherEffect{} + @effect.stunDuration = @stunDuration + @effect.chance = @chance + @effect.extraDamage = @exDamage + @effect.consumer = @caster + + add_effect{effect=@effect, es=@caster, source=@this_skill} + + RETURN + """ + } { Id: "ntrpg:devourMagic" Handler: nts @@ -271,11 +309,15 @@ Effects: [ Fields { multiplier: numeric } - OnTick: """ - @consumer = @effect.consumer - - RETURN - """ + } + { + Id: BasherEffect + SuperType: UnstackableEffect + Fields { + chance: numeric + extraDamage: numeric + stunDuration: numeric + } } ] Listeners: [ @@ -292,6 +334,27 @@ Listeners: [ regain_mana{e=@target, a=@mana, s=@effect} END + RETURN + """ + } + { + Id: InternalSkillListener2 + Event: IEntityWeaponDamageEarlyEvent + Script: """ + @target = @event.target + @damager = @event.damager + @effect = get_effect{e=@damager, en="BasherEffect"} as BasherEffect + + IF exists{var=@effect} + IF roll{pass=@effect.chance, maxVal=100} + @damage = @event.damage + @effect.extraDamage + @event.damage = @damage + @stunDuration = @effect.stunDuration + @stunEffect = StunEffect{target=@target, duration=@stunDuration} + add_effect{effect=@stunEffect, es=@damager, source=@effect} + END + END + RETURN """ } diff --git a/Common/src/test/java/cz/neumimto/rpg/TestSkillService.java b/Common/src/test/java/cz/neumimto/rpg/TestSkillService.java index 109b1d11f..7eb70d176 100644 --- a/Common/src/test/java/cz/neumimto/rpg/TestSkillService.java +++ b/Common/src/test/java/cz/neumimto/rpg/TestSkillService.java @@ -16,7 +16,7 @@ public class TestSkillService extends SkillService { @Override - public NTScript getNtScriptCompilerFor(Class c) { + public NTScript getNtScriptCompilerFor(Class c) { return ntScriptEngine.prepareCompiler(builder -> { try { builder diff --git a/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/effects/common/ArrowblastEffect.java b/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/effects/common/ArrowblastEffect.java new file mode 100644 index 000000000..9a282cf6e --- /dev/null +++ b/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/effects/common/ArrowblastEffect.java @@ -0,0 +1,58 @@ +package cz.neumimto.rpg.spigot.effects.common; + +import com.google.auto.service.AutoService; +import cz.neumimto.nts.annotations.ScriptMeta; +import cz.neumimto.nts.annotations.ScriptMeta.NamedParam; +import cz.neumimto.rpg.common.effects.EffectBase; +import cz.neumimto.rpg.common.effects.IEffect; +import cz.neumimto.rpg.common.entity.IEffectConsumer; +import cz.neumimto.rpg.common.utils.MathUtils; +import cz.neumimto.rpg.spigot.entities.ISpigotEntity; +import cz.neumimto.rpg.spigot.entities.ProjectileCache; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; + +@AutoService(IEffect.class) +@ScriptMeta.Function("ArrowblastEffect") +public class ArrowblastEffect extends EffectBase { + + public static String name = "Arrowblast"; + private final int arrows; + private final double damage; + private final double damageMax; + private final long velocity; + + @ScriptMeta.Handler + public ArrowblastEffect(@NamedParam("c|consumer") IEffectConsumer consumer, + @NamedParam("a|arrows") int arrows, + @NamedParam("dmin|damage-min") double damage, + @NamedParam("dmax|damage-max") double damageMax, + @NamedParam("p|period") long period, + @NamedParam("v|velocity") long velocity) { + super(name, consumer); + this.arrows = arrows; + this.damage = damage; + this.damageMax = damageMax; + this.velocity = velocity; + setPeriod(period); + setDuration(period * arrows + 1); + } + + @Override + public void onTick(IEffect self) { + LivingEntity livingEntity = (LivingEntity) getConsumer().getEntity(); + + World world = livingEntity.getWorld(); + Location location = livingEntity.getLocation(); + Arrow arrow = (Arrow) world.spawnEntity(location.clone().add(0, 1, 0).add(location.getDirection()), EntityType.ARROW); + arrow.setVelocity(livingEntity.getLocation().getDirection().multiply(velocity)); + arrow.setShooter(livingEntity); + + + ProjectileCache projectileProperties = ProjectileCache.putAndGet(arrow, (ISpigotEntity) getConsumer()); + projectileProperties.onHit((event, attacker, target) -> event.setDamage(MathUtils.randomInRange(damage, damageMax))); + } +} diff --git a/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/events/damage/SpigotEntityWeaponDamageEarlyEvent.java b/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/events/damage/SpigotEntityWeaponDamageEarlyEvent.java index 181b80207..3cebcd6d7 100644 --- a/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/events/damage/SpigotEntityWeaponDamageEarlyEvent.java +++ b/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/events/damage/SpigotEntityWeaponDamageEarlyEvent.java @@ -1,5 +1,6 @@ package cz.neumimto.rpg.spigot.events.damage; +import cz.neumimto.rpg.common.entity.IEntity; import cz.neumimto.rpg.common.events.damage.IEntityWeaponDamageEarlyEvent; import cz.neumimto.rpg.common.items.RpgItemStack; import org.bukkit.event.HandlerList; @@ -10,6 +11,7 @@ public class SpigotEntityWeaponDamageEarlyEvent extends SpigotAbstractDamageEvent implements IEntityWeaponDamageEarlyEvent { private RpgItemStack weapon; + private IEntity damager; @Override public Optional getWeapon() { @@ -21,6 +23,16 @@ public void setWeapon(RpgItemStack weapon) { this.weapon = weapon; } + @Override + public void setDamager(IEntity attacker) { + this.damager = attacker; + } + + @Override + public IEntity getDamager() { + return damager; + } + private static final HandlerList HANDLERS_LIST = new HandlerList(); @Override diff --git a/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/listeners/SpigotDamageListener.java b/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/listeners/SpigotDamageListener.java index efac9a8a5..80a66f04c 100644 --- a/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/listeners/SpigotDamageListener.java +++ b/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/listeners/SpigotDamageListener.java @@ -177,6 +177,7 @@ private void processWeaponDamageEarly(EntityDamageByEntityEvent event, EntityDam e.setTarget(target); e.setDamage(newdamage); e.setWeapon(rpgItemStack); + e.setDamager(attacker); if (Rpg.get().postEvent(e)) { event.setCancelled(true); diff --git a/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/skills/SpigotSkillService.java b/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/skills/SpigotSkillService.java index 0f5fcf486..514993b8d 100644 --- a/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/skills/SpigotSkillService.java +++ b/Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/skills/SpigotSkillService.java @@ -3,10 +3,13 @@ import cz.neumimto.nts.NTScript; import cz.neumimto.rpg.common.Rpg; import cz.neumimto.rpg.common.gui.ISkillTreeInterfaceModel; +import cz.neumimto.rpg.common.scripting.NTScriptEngine; import cz.neumimto.rpg.common.scripting.SkillScriptHandlers; +import cz.neumimto.rpg.common.skills.SkillResult; import cz.neumimto.rpg.common.skills.types.ScriptSkill; import cz.neumimto.rpg.common.skills.SkillService; import cz.neumimto.rpg.spigot.SpigotRpgPlugin; +import cz.neumimto.rpg.spigot.effects.common.*; import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.Sound; @@ -15,9 +18,11 @@ import javax.inject.Singleton; import java.io.File; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Consumer; @Singleton public class SpigotSkillService extends SkillService { @@ -26,11 +31,62 @@ public class SpigotSkillService extends SkillService { private Map guiModelById; + public static Consumer SPIGOT_SCRIPT_SCOPE; + + static { + SPIGOT_SCRIPT_SCOPE = builder -> { + try { + builder + .withEnum(Particle.class) + .withEnum(Sound.class) + .withEnum(BlockFace.class) + .withEnum(SkillResult.class) + .add(Vector.class.getConstructor(double.class, double.class, double.class), "vector", List.of("x","y","z")) + + .add(Math.class.getDeclaredMethod("max", double.class, double.class), List.of("a","b")) + .add(Math.class.getDeclaredMethod("min", double.class, double.class), List.of("a","b")) + .add(Math.class.getDeclaredMethod("pow", double.class, double.class), List.of("a","b")) + .add(Math.class.getDeclaredMethod("abs", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("sqrt", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("ceil", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("floor", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("log", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("toDegrees", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("toRadians", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("random"), List.of("a")) + + .add(Math.class.getDeclaredMethod("sin", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("sinh", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("asin", double.class), List.of("a")) + + .add(Math.class.getDeclaredMethod("tan", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("tanh", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("atan", double.class), List.of("a")) + + .add(Math.class.getDeclaredMethod("cos", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("cosh", double.class), List.of("a")) + .add(Math.class.getDeclaredMethod("acos", double.class), List.of("a")) + .add(Rpg.get().getScriptEngine().STL) + .debugOutput(Rpg.get().getWorkingDirectory() + File.separator + "/compiled-scripts"); + + ; + } catch (Throwable t) { + t.printStackTrace(); + } + }; + } + + public SpigotSkillService() { guiModelByCharacter = new HashMap<>(); guiModelById = new HashMap<>(); } + @Override + public Consumer getNTSBuilderContext() { + return SPIGOT_SCRIPT_SCOPE; + } + @Override public void load() { int i = 0; @@ -50,7 +106,25 @@ public void load() { i++; } } - //scriptSkillsParents.put("targeted", TargetedScriptSkill.class); + + //java service provider bug + ntScriptEngine.STL.addAll(Arrays.asList( + BleedingEffect.class, + FeatherFall.class, + Maim.class, + ManaShieldEffect.class, + NoAutohealEffect.class, + PiggifyEffect.class, + SlowEffect.class, + StunEffect.class, + UnhealEffect.class, + UnlimtedFoodLevelEffect.class, + WebEffect.class, + FlickerEffect.class, + InvisibilityEffect.class, + ArrowblastEffect.class + )); + super.load(); } @@ -62,47 +136,6 @@ protected Class getScriptTargetType(Class c, String s) { return super.getScriptTargetType(c, s); } - @Override - public NTScript getNtScriptCompilerFor(Class c) { - return ntScriptEngine.prepareCompiler(builder -> { - try { - builder - .withEnum(Particle.class) - .withEnum(Sound.class) - .withEnum(BlockFace.class) - - .add(Vector.class.getConstructor(double.class, double.class, double.class), "vector", List.of("x","y","z")) - - .add(Math.class.getDeclaredMethod("max", double.class, double.class), List.of("a","b")) - .add(Math.class.getDeclaredMethod("min", double.class, double.class), List.of("a","b")) - .add(Math.class.getDeclaredMethod("pow", double.class, double.class), List.of("a","b")) - .add(Math.class.getDeclaredMethod("abs", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("sqrt", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("ceil", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("floor", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("log", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("toDegrees", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("toRadians", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("random"), List.of("a")) - - .add(Math.class.getDeclaredMethod("sin", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("sinh", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("asin", double.class), List.of("a")) - - .add(Math.class.getDeclaredMethod("tan", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("tanh", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("atan", double.class), List.of("a")) - - .add(Math.class.getDeclaredMethod("cos", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("cosh", double.class), List.of("a")) - .add(Math.class.getDeclaredMethod("acos", double.class), List.of("a")) - .debugOutput(Rpg.get().getWorkingDirectory() + File.separator + "/compiled-scripts") - ; - } catch (Throwable t) { - t.printStackTrace(); - } - }, c); - } @Override public ISkillTreeInterfaceModel getGuiModelByCharacter(char c) {