• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[JASS] Need help doing a spell in JASS

Not open for further replies.
Level 6
Mar 27, 2009
hey dudes,

i tried to do a spell in jass, but failed. could anyone do it for me? (+rep of course)

  • PB
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) equal to PB
    • Actions
      • Set PB_loc = (Position of (Casting unit))
      • Set PB_caster = (Casting unit)
      • Unitgroup - Pick every unit in (Units within 600.00 of PB_loc matching (((Matching unit) belongs to an enemy of (Owner of PB_caster)) Gleich True)) and do (Actions)
        • Loop - Actions
          • Set PB_targetloc = (Position of (Picked unit))
          • Lightning - Create a XY lightning effect from source PB_loc to target PB_targetloc
          • Custom script: call RemoveLocation(udg_PB_targetloc)
          • Set num2 = (num2 + 1)
          • Set spez2[num2] = (Last created lightning effect)
      • Wait 2.00 seconds
      • Unitgroup - Pick every unit in (Units within 600.00 of PB_loc matching (((Matching unit) belongs to an enemy of (Owner of PB_caster)) Gleich True)) and do (Actions)
        • Loop - Actions
          • Unit - Cause PB_caster to damage (Picked unit), dealing ((Real((Level of PB for PB_caster))) x 80.00) damage of attack type Chaos and damage type Normal
      • Custom script: call RemoveLocation(udg_PB_loc)
      • For each (Integer A) from 1 to num2, do (Actions)
        • Schleifen - Aktionen
          • Lightning - Destroy spez2[(Integer A)]
      • Set num2 = 0
Last edited:
Level 11
Apr 6, 2008
Whiped something together fast for you :)

scope Spell

// By Ciebron
// Requiers Jass Newgen Pack and TimerUtlis by Vextorian ([url]http://www.wc3c.net/showthread.php?t=101322[/url])

    // Rawcode of the spell
    private constant integer SPELL_ID = 'A003'
    //Maximum number of targets (duh)
    private constant integer Max_Targets = 50
    //How long time it will take before the units get damaged
    private constant real Delay_Time = 2.
    //How often it will move the lightning
    private constant real Interval = 0.05
    //Aoe of the spell
    private constant real Aoe = 600.
    //How high the lightning will be in the air (UnitFlyHeight+this)
    private constant real Lightning_Z = 50.
    // Which lightning effect
    private constant string Lightning_Type = "CLPB"
    //Which special effect that will be created on the unit when it take damage
    private constant string SFX = "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl"
    //Where on the unit the special effect will be created on the unit
    private constant string ATTACH_POINT = "origin"
private function Damage takes integer lvl returns real
    return lvl*80.

//Setup Ends

    private integer Struct
    private filterfunc FilterFunc

private struct Data

unit Caster
unit array Victims [Max_Targets]

lightning array Lightning [Max_Targets]

real Damage
real ElapsedTime

integer Count

player Play

timer Time

    static unit TempU
    static group TempG = CreateGroup()
    static real TempX
    static real TempY

    static method onInit takes nothing returns nothing
        local trigger Trig = CreateTrigger()
        local integer index = 0
            call TriggerRegisterPlayerUnitEvent(Trig,Player(index),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        call TriggerAddCondition(Trig,Condition(function thistype.OnCast))
        set FilterFunc = Filter(function thistype.Filt)
        set Trig = null
    static method OnCast takes nothing returns boolean
        local unit u
        if GetSpellAbilityId()==SPELL_ID then
            set u = GetTriggerUnit()
            call thistype.create(u)
            set u = null
        return false
    static method create takes unit u returns thistype
        local thistype Dat = thistype.allocate()
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        set Dat.Caster = u
        set Dat.Damage = Damage(GetUnitAbilityLevel(Dat.Caster,SPELL_ID))
        set Dat.Count = 0
        set Dat.Play = GetOwningPlayer(Dat.Caster)
        set Dat.ElapsedTime = 0.
        set Dat.Time = NewTimer()
        set Struct = Dat
        call GroupEnumUnitsInRange(Dat.TempG,x,y,Aoe,FilterFunc)
            set Dat.TempU = FirstOfGroup(Dat.TempG)
            exitwhen Dat.Count >= Max_Targets or Dat.TempU == null
            call GroupRemoveUnit(Dat.TempG,Dat.TempU)
            set Dat.Lightning[Dat.Count] = AddLightningEx(Lightning_Type,true,x,y,GetUnitFlyHeight(Dat.Caster)+Lightning_Z,GetUnitX(Dat.TempU),GetUnitY(Dat.TempU),GetUnitFlyHeight(Dat.TempU)+Lightning_Z)
            set Dat.Victims[Dat.Count] = Dat.TempU
            set Dat.Count = Dat.Count + 1
        call SetTimerData(Dat.Time,Dat)
        call TimerStart(Dat.Time,Interval,true,function thistype.Callback)
        return Dat
    static method Callback takes nothing returns nothing
        local timer Timer = GetExpiredTimer()
        local thistype Dat = GetTimerData(Timer)
        local integer index = 0
        set Dat.ElapsedTime = Dat.ElapsedTime + Interval
        if Dat.ElapsedTime >= Delay_Time then            
                exitwhen index >= Dat.Count
                if SFX != "" then
                    call DestroyEffect(AddSpecialEffectTarget(SFX,Dat.Victims[index],ATTACH_POINT))
                call DestroyLightning(Dat.Lightning[index])
                call UnitDamageTarget(Dat.Caster,Dat.Victims[index],Dat.Damage,false,false,null,null,null)
                set Dat.Victims[index] = null
                set Dat.Lightning[index] = null
                set index = index + 1
            call ReleaseTimer(Dat.Time)
            call Dat.destroy()
            set Timer = null
            set Dat.TempX = GetUnitX(Dat.Caster)
            set Dat.TempY = GetUnitY(Dat.Caster)
                exitwhen index >= Dat.Count
                call MoveLightningEx(Dat.Lightning[index],true,Dat.TempX,Dat.TempY,GetUnitFlyHeight(Dat.Caster)+Lightning_Z,GetUnitX(Dat.Victims[index]),GetUnitY(Dat.Victims[index]),GetUnitFlyHeight(Dat.Caster)+Lightning_Z)
                set index = index + 1
    static method Filt takes nothing returns boolean
        local thistype Dat = Struct
        local unit f = GetFilterUnit()
        local boolean ok = GetWidgetLife(f) > 0.305 and IsUnitEnemy(f,Dat.Play)
        set f = null
        return ok
    method onDestroy takes nothing returns nothing
        set .Caster = null

Level 8
Feb 15, 2009
he made the spell in vJass just to let u know if u want to use it you need JNGP also i think his solution is to complex for such a simple spell but also very performant so if you have JNGP go for that nice script else w8 for someone that makes a normal Jass trigger ( i have no time sry =D)

I would highly recommend JNGP u learn Jass much faster ,coz of the easier to read colored code
Level 8
Feb 15, 2009
nobody uses handle vars anymore but u dont need them here neither structs u need he just makes 2 group picks and damages them with some lightnings so why structs or handlevars should be used in this trigger? for that simple thing your trigger creates much to much handles and useless things
Not open for further replies.