• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Touch of Lightnings 1.01[GUI]

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Heals a few allied units or damage enemy with help of lightnings. Total of 5 lightnings.
Level 1: Each lightning heals on 40 or damages on 60.
Level 2: Each lightning heals on 75 or damages on 80.
Level 3: Each lightning heals on 110 or damages on 100.

Cooldown:2
Manacost:25/50/75


Here GUI triggers:

  • ini tol GUI
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- dummy unit --------
      • Set Tol_dummy_unit_type = Dummy
      • -------- main ability --------
      • Set Tol_ability[1] = Touch of lightning[Q]
      • -------- dummy abilitys --------
      • Set Tol_ability[2] = healing wave
      • Set Tol_ability[3] = Chain lightning
      • -------- distance between target and cast a lightnings --------
      • Set Data_Array[1] = 125.00
      • -------- Flying Height --------
      • Set Data_Array[2] = 100.00
      • -------- Degrees data = angle of creation lightnings --------
      • Set Degrees_Data[1] = 0.00
      • Set Degrees_Data[2] = 90.00
      • Set Degrees_Data[3] = 180.00
      • Set Degrees_Data[4] = 270.00
"]

  • GUI version tol
  • Events
    • Unit - A unit Starts effect of an ability
  • Conditions
    • (Ability being cast) equal to (==) Tol_ability[1]
  • Actions
    • Set Tol_Point_array[0] = (Position of (Target unit of ability being cast))
      • Do Multiple ActionsFor each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set Tol_Point_array[(Integer A)] = (Tol_Point_array[0] offset by Data_Array[1] towards Degrees_Data[(Integer A)] degrees)
      • Do Multiple ActionsFor each (Integer A) from 0 to 4, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Tol_dummy_unit_type for (Triggering player) at Tol_Point_array[(Integer A)] facing Pi (3.14159) degrees
          • Set Tol_Units[(Integer A)] = (Last created unit)
          • Animation - Change Tol_Units[(Integer A)] flying height to Data_Array[2] at 0.00
          • Unit - Add a 2.00 second Generic expiration timer to Tol_Units[(Integer A)]
          • Unit - Add Tol_ability[2] to Tol_Units[(Integer A)]
          • Unit- Add Tol_ability[3] to Tol_Units[(Integer A)]
          • Unit - Set level of Tol_ability[2] for Tol_Units[(Integer A)] to (Level of Tol_ability[1] for (Triggering unit))
          • Unit - Set level of Tol_ability[3] for Tol_Units[(Integer A)] to (Level of Tol_ability[1] for (Triggering unit))
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Target unit of ability being cast) belongs to an enemy of (Triggering player)) equal to (==) true
              • Then - Actions
                • Unit - Order Tol_Units[(Integer A)] to chainlightning (Target unit of ability being cast)
              • Else - Actions
                • Unit - Order Tol_Units[(Integer A)] to healingwave (Target unit of ability being cast)
          • Set Tol_Units[(Integer A)] = No Unit
          • Custom script: call RemoveLocation(udg_Tol_Point_array[GetForLoopIndexA()])
"]

Keywords:
touch,spell,lightning,hill,damage,chain,GUI
Contents

Touch of lightning (Map)

Reviews
12th Dec 2015 IcemanBo: For too long time as NeedsFix. Rejected. GetForLoopIndexA() -> bj_forLoopAInded Combine the loops. You leak points. Only add the ability you need, not both.

Moderator

M

Moderator

12th Dec 2015
IcemanBo: For too long time as NeedsFix. Rejected.

Maker, 2nd Aug, Touch of Lightnings 1.01

GetForLoopIndexA() -> bj_forLoopAInded
Combine the loops.
You leak points.
Only add the ability you need, not both.
 
Looks like GUI converted to Jass, the coding is very bad...
- Never use locations, use coordinates instead
- Never use functions like "Trig_some_on_jass_Func026C" and a-like, that is very bad
- Never use BJ's when coding, well except for a few good BJ's
- Use loops when creating units
- Null unit variables
- You must make an expiring timer for your dummy

and a lot more...

EDIT: Maker did some pointers...

EDIT2: And since you are using vJASS...

Here is the improved spell of yours to get some pointers...
JASS:
scope TouchOfLightning initializer init

globals
    // ----
    //  SETUP PART
    // ----
    private constant integer SpellID = 'A003' //ordercode of your main ability
    private constant real zLoc=250.0   //z coordinate of chains
    private constant real offset=200   //distance beetween target loc and 4 other locations
    private constant integer dummyorder='h000' //ordercode of your dummy guy
    private constant integer dummyorderspell='A000' //ordercode of your dummy spell - chainlightning[enemy]
    private constant string orderenemystring="chainlightning" //order of enemy ability(chain lightning)
    private constant integer dummyorderspell2='A002' //ordercode of your dummy spell - healingwave[aliied]
    private constant string orderalliedstring="healingwave" //order of heal ability(ALLID)
    // ----
    //  END OF CONFIGURATIONS
    // ----
endglobals

private function CAST takes nothing returns boolean
    local unit u
    local unit target
    local unit dummy
    local integer i
    local real x
    local real y
    local integer level
    if GetSpellAbilityId()==SpellID then
        set u=GetTriggerUnit()
        set target=GetSpellTargetUnit()
        set x = GetUnitX(target)
        set y = GetUnitY(target)
        set level = GetUnitAbilityLevel(u, SpellID)
        set i = 0
        loop
            set dummy = CreateUnit(GetTriggerPlayer(), dummyorder, x, y, 0) 
            call SetUnitFlyHeight(dummy, zLoc, 0.00)
            call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
            if IsUnitEnemy(target, GetTriggerPlayer()) then
                call UnitAddAbility(dummy, dummyorderspell)
                call SetUnitAbilityLevel(dummy, dummyorderspell, level)
                call IssueTargetOrder(dummy, orderenemystring, target)               
            else
                call UnitAddAbility(dummy, dummyorderspell2)
                call SetUnitAbilityLevel(dummy, dummyorderspell2, level)
                call IssueTargetOrder(dummy, orderalliedstring, target)                
            endif
            set i = i+1
            exitwhen i > 4        
        endloop
    endif
    set u = null
    set target = null
    set dummy = null
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t, Condition(function CAST))
    set t = null
endfunction

endscope
 
Or, you could do this:

JASS:
library SpellToL
    globals
        // Ability Code
        private constant integer    ABIL_CODE           = 'A003'
        // Maximum Distance between lightnings
        private constant real       MAX_DISTANCE        = 200
        // The Spell Dummy
        private constant integer    DUMMY_CODE          = 'h000'
        // The Damaging Lightning Ability ID
        private constant integer    DUMMY_CAST1         = 'A000'
        // The Healing Lightning Ability ID
        private constant integer    DUMMY_CAST2         = 'A002'
        // The Healing Lightning
        private constant string     LIGHTNING_HEAL      = "healingwave"
        // The Damaging Lightning
        private constant string     LIGHTNING_CHAIN     = "chainlightning"
    endglobals

    private module Init
        private static method onInit takes nothing returns nothing
            local trigger t = CreateTrigger()
            call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
            call TriggerAddCondition(t,Condition(function thistype.cast))
            set t = null
        endmethod
    endmodule
    
    private struct Spell extends array
        static method filter takes nothing returns boolean
            local unit u = GetFilterUnit()
            if GetWidgetLife(u)>0.405 and not IsUnitType(u,UNIT_TYPE_STRUCTURE) then
                set u=null
                return true
            endif
            set u=null
            return false
        endmethod
        static method cast takes nothing returns boolean
            local unit u
            local unit t
            local unit d
            local real x
            local real y
            local player p
            local integer l
            local integer i=0
            local group g = CreateGroup()
            if GetSpellAbilityId()==ABIL_CODE then
                set u = GetTriggerUnit()
                set p = GetTriggerPlayer()
                set t = GetSpellTargetUnit()
                set l = GetUnitAbilityLevel(u,ABIL_CODE)
                loop
                    set x = GetUnitX(t)
                    set y = GetUnitY(t)
                    set d = CreateUnit(p,DUMMY_CODE,x,y,0)
                    call UnitApplyTimedLife(d,'BTLF',1.0)
                    if IsUnitEnemy(t,p) then
                        call UnitAddAbility(d,DUMMY_CAST1)
                        call SetUnitAbilityLevel(d,DUMMY_CAST1,l)
                        call IssueTargetOrder(d,LIGHTNING_CHAIN,t)               
                    else
                        call UnitAddAbility(d,DUMMY_CAST2)
                        call SetUnitAbilityLevel(d,DUMMY_CAST2,l)
                        call IssueTargetOrder(d,LIGHTNING_HEAL,t)                
                    endif
                    call GroupEnumUnitsInRange(g,x,y,MAX_DISTANCE,function thistype.filter)
                    set t=FirstOfGroup(g)
                    call GroupClear(g)
                    set i=i+1
                    exitwhen i>4
                endloop
            endif
            call DestroyGroup(g)
            set u = null
            set t = null
            set d = null
            set p = null
            set g = null
            return false
        endmethod
        implement Init
    endstruct
endlibrary

:3

edit
Fixed a bug and a compile error xD
 
Last edited:
Level 8
Joined
May 9, 2010
Messages
266
Thanks guys for Improving my code, I`l update it soon.

It is very important for me, because I`m learning jass.
Tell me please, why I should not use this points? It leaks?
In advance, thanks.

Looks like GUI converted to Jass, the coding is very bad...
- Never use locations, use coordinates instead
- Never use functions like "Trig_some_on_jass_Func026C" and a-like, that is very bad
- Never use BJ's when coding, well except for a few good BJ's
- Use loops when creating units
- Null unit variables
- You must make an expiring timer for your dummy

and a lot more...

EDIT: Maker did some pointers...

EDIT2: And since you are using vJASS...

Here is the improved spell of yours to get some pointers...
JASS:
scope TouchOfLightning initializer init

globals
    // ----
    //  SETUP PART
    // ----
    private constant integer SpellID = 'A003' //ordercode of your main ability
    private constant real zLoc=250.0   //z coordinate of chains
    private constant real offset=200   //distance beetween target loc and 4 other locations
    private constant integer dummyorder='h000' //ordercode of your dummy guy
    private constant integer dummyorderspell='A000' //ordercode of your dummy spell - chainlightning[enemy]
    private constant string orderenemystring="chainlightning" //order of enemy ability(chain lightning)
    private constant integer dummyorderspell2='A002' //ordercode of your dummy spell - healingwave[aliied]
    private constant string orderalliedstring="healingwave" //order of heal ability(ALLID)
    // ----
    //  END OF CONFIGURATIONS
    // ----
endglobals

private function CAST takes nothing returns boolean
    local unit u
    local unit target
    local unit dummy
    local integer i
    local real x
    local real y
    local integer level
    if GetSpellAbilityId()==SpellID then
        set u=GetTriggerUnit()
        set target=GetSpellTargetUnit()
        set x = GetUnitX(target)
        set y = GetUnitY(target)
        set level = GetUnitAbilityLevel(u, SpellID)
        set i = 0
        loop
            set dummy = CreateUnit(GetTriggerPlayer(), dummyorder, x, y, 0) 
            call SetUnitFlyHeight(dummy, zLoc, 0.00)
            call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
            if IsUnitEnemy(target, GetTriggerPlayer()) then
                call UnitAddAbility(dummy, dummyorderspell)
                call SetUnitAbilityLevel(dummy, dummyorderspell, level)
                call IssueTargetOrder(dummy, orderenemystring, target)               
            else
                call UnitAddAbility(dummy, dummyorderspell2)
                call SetUnitAbilityLevel(dummy, dummyorderspell2, level)
                call IssueTargetOrder(dummy, orderalliedstring, target)                
            endif
            set i = i+1
            exitwhen i > 4        
        endloop
    endif
    set u = null
    set target = null
    set dummy = null
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t, Condition(function CAST))
    set t = null
endfunction

endscope

Or, you could do this:

JASS:
library SpellToL
    globals
        // Ability Code
        private constant integer    ABIL_CODE           = 'A003'
        // Lightning Height
        private constant real       ZL                  = 250.0
        // Maximum Distance between lightnings
        private constant real       MAX_DISTANCE        = 200
        // The Spell Dummy
        private constant integer    DUMMY_CODE          = 'h000'
        // The Damaging Lightning Ability ID
        private constant integer    DUMMY_CAST1         = 'A000'
        // The Healing Lightning Ability ID
        private constant integer    DUMMY_CAST2         = 'A002'
        // The Healing Lightning
        private constant string     LIGHTNING_HEAL      = "healingwave"
        // The Damaging Lightning
        private constant string     LIGHTNING_CHAIN     = "chainlightning"
    endglobals

    private module Init
        private static method onInit takes nothing returns nothing
            local trigger t = CreateTrigger()
            call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
            call TriggerAddCondition(t,Condition(function thistype.cast))
            set t = null
        endmethod
    endmodule
    
    private struct Spell extends array
        static method cast takes nothing returns boolean
            local unit u
            local unit t
            local unit d
            local real x
            local real y
            local player p
            local integer l
            local integer i
            if GetSpellAbilityId()==ABIL_CODE then
                set u = GetTriggerUnit()
                set p = GetTriggerPlayer()
                set t = GetSpellTargetUnit()
                set x = GetUnitX(t)
                set y = GetUnitY(t)
                set l = GetUnitAbilityLevel(u,ABIL_CODE)
                set i = 0
                loop
                    set d = CreateUnit(p,DUMMY_CODE,x,y,0)
                    call UnitAddAbility(d,'Arav')
                    call UnitRemoveAbility(d,'Arav')
                    call SetUnitFlyHeight(d,ZL,0.00)
                    call UnitApplyTimedLife(d,'BTLF',1.0)
                    if IsUnitEnemy(t,p) then
                        call UnitAddAbility(d,DUMMY_CAST1)
                        call SetUnitAbilityLevel(d,DUMMY_CAST1,l)
                        call IssueTargetOrder(d,LIGHTNING_CHAIN,t)               
                    else
                        call UnitAddAbility(d,DUMMY_CAST2)
                        call SetUnitAbilityLevel(d,DUMMY_CAST2,l)
                        call IssueTargetOrder(d,LIGHTNING_HEAL,t)                
                    endif
                    set i=i+1
                    exitwhen i>4
                endloop
            endif
            set u = null
            set t = null
            set d = null
            set p = null
            return false
        endmethod
        implement Init
    endstruct
endlibrary

:3

edit
Fixed a bug and a compile error xD

Oo there is no any red strings. Red strings - are bad?:В

Looks like GUI converted to Jass.

Yes, Some things I converted, however, not all.




And one other thing:You posting the codes and when i copy it in my test map, it creates only one lightnning, insteed of 5.
 
Last edited:
Top