• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Wurst] Execute, a high-level library for making flashy spells

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,522
link

Execute is a library for making flashy/cinematic style abilities, typically where a caster kills a target in some devastating/spectacular way.

Encoding such spells usually requires to manage a state machine, where each instance of the spell effect has a series of sub-effects that compose together. Along the way, the author must handling things like premature death of the target, or perhaps interruption is something encoded into the sequence itself, which is useful for boss fights.

Example code looks like the following:

Wurst:
constant seq = new LinkedList<ExecuteExecutable>()
   ..add(new ExecuteLockTarget())
   ..add(new ExecuteLockCaster())
   ..add(new ExecuteAnimate(UnitAnimations.HeroBloodElf.spellChannel.idx))
   ..add(new ExecuteLightning(3.5, "AFOD"))
   ..add(new ExecuteFxTarget(Abilities.soulBurnbuff))
   ..add(new ExecuteWait(.5))
   ..add(new ExecuteFxCaster(Abilities.obsidianRegenAura))
   ..add(new ExecuteKnockup(1500.))
   ..add(new ExecuteWait(.65))
   ..add(new ExecuteForgetTargetVelocity())
   ..add(new ExecuteWait(.1))
   ..add(new ExecuteFxTarget(Abilities.darkPortalTarget))
   ..add(new ExecuteKnockArcToCaster(1400.))
   ..add(new ExecuteAnimate(UnitAnimations.HeroBloodElf.spell.idx))
   ..add(new ExecuteWait(.1))
   ..add(new ExecuteUnlockCaster())
   ..add(new ExecuteFxTarget(Abilities.bloodImpact))
   ..add(new ExecuteWait(1.))
   ..add(new ExecuteFxTarget(Abilities.bloodImpact))
   ..add(new ExecuteWait(1.))
   ..add(new ExecuteFxTarget(Abilities.bloodImpact))

init
   EventListener.add(EVENT_PLAYER_UNIT_SPELL_EFFECT) ->
       let target = EventData.getSpellTargetUnit()
       EventData.getTriggerUnit().issueImmediateOrder("stop")

       if EventData.getSpellAbilityId() == 'AHbn' or EventData.getSpellAbilityId() == 'AHhx'
           new Execute(
               EventData.getTriggerUnit(),
               target,
               seq
           )

Demo:



To use this library, just add execute-wurst to your wurst.build:

Code:
$ cat MyProject/wurst.build
---
projectName: WurstProject
dependencies:
- https://github.com/wurstscript/wurstStdlib2
- https://github.com/Cokemonkey11/execute-wurst
 
Top