1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  5. Dismiss Notice
  6. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Lightning Ward (GUI/JASS/VJASS)

Submitted by Septimus
This bundle is marked as approved. It works and satisfies the submission rules.
Detail
Status

Forum: http://septimus.invisionplus.net
Coding: GUI/JASS/VJASS
Current Version: 1.08

Ability Description

Unleash a ward around the targeted unit that would attack it, the ward would also release a energy bolt that destroy the hp of nearby enemy unit. Targeted unit get stun for 5 seconds by this ability.

Level 1 - Lasts 10 seconds.
Level 2 - Lasts 15 seconds.
Level 3 - Lasts 20 seconds.

Changelog
Version 1.08 Update

Fix documentation.

Version 1.07

Create a VJASS version of it (Full credit for VJASS version goes to Dark Dragon).

Version 1.06

Add additional code in order to remove 16 memory leaks of type boolexpr cause by TriggerRegisterAnyUnitEventBJ

Version 1.05

Create a JASS version of it.

Version 1.04

Further optimize the maths to enable beginner to modify this spell easier.

Version 1.03

Fix minor flaw.

Version 1.02

Improve coding.

Version 1.01

Disable documentation sample.



Credit
Dark_Dragon - For hinting a tiny flaw in the coding and fix JASS. He is also responsible for making VJASS version of it.
-BerZeKeR- - Showing a efficient maths coding.
GhostWolf - For pointing a silly mistake I made in JASS version and help me optimize the JASS version.
hvo-busterkomo - Helping me fix loop issue at JASS version.
Purplepoot - For guiding me in loop issue at JASS version.
Ralle - For guiding me in loop issue at JASS version.

GUI Scripting
  • Lightning Ward GUI
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lightning Ward (GUI)
    • Actions
      • Set LW_Target_Unit = (Target unit of ability being cast)
      • Set LW_Target_Point = (Target point of ability being cast)
      • Set LW_Target_Position = (Position of LW_Target_Unit)
      • Set LW_Level = (Level of Lightning Ward (GUI) for (Triggering unit))
      • Set LW_Duration = (5.00 + (5.00 x (Real(LW_Level))))
      • Set LW_Loop_Number = 5
      • For each (Integer LW_Integer) from 1 to LW_Loop_Number, do (Actions)
        • Loop - Actions
          • Set LW_Spawn_Point = (LW_Target_Position offset by 500.00 towards (360.00 x ((Real(LW_Integer)) / (Real(LW_Loop_Number)))) degrees)
          • Unit - Create 1 Lightning Ward for (Owner of (Triggering unit)) at LW_Spawn_Point facing LW_Target_Point
          • Unit - Add a LW_Duration second Generic expiration timer to (Last created unit)
          • Unit - Add Lightning Bolt to (Last created unit)
          • Unit - Order (Last created unit) to Undead Crypt Lord - Locust Swarm
          • Unit - Order (Last created unit) to Attack LW_Target_Unit
          • Custom script: call RemoveLocation(udg_LW_Spawn_Point)
      • Custom script: call RemoveLocation(udg_LW_Target_Point)
      • Custom script: call RemoveLocation(udg_LW_Target_Position)


JASS Scripting
Code (vJASS):
function Trig_Lightning_Ward_JASS_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Lightning_Ward_JASS_Actions takes nothing returns nothing
    local unit LTR = GetTriggerUnit()
    local unit LV = GetSpellTargetUnit()
    local location LP = GetSpellTargetLoc()
    local location LT = GetUnitLoc(LV)
    local location LSP
    local integer LL = GetUnitAbilityLevel(LTR, 'A003')
    local real LD = 5.00 + 5.00 * LL
    local integer LI = 1
    local unit LU
    local real FA = AngleBetweenPoints(LT, LP)
    local integer DU = 5
    local real Deg = 360/DU
    loop
        exitwhen LI > DU
        set LSP = PolarProjectionBJ(LT, 500.00, LI * Deg)
        set LU = CreateUnitAtLoc(GetOwningPlayer(LTR), 'o000', LSP, FA)
        call UnitApplyTimedLife(LU, 'BTLF', LD)
        call UnitAddAbility(LU, 'A002')
        call IssueImmediateOrder(LU, "locustswarm" )
        call IssueTargetOrder(LU, "attack", LV )
        call RemoveLocation(LSP)
        set LU = null
        set LI = (LI+1)
    endloop
    call RemoveLocation(LP)
    call RemoveLocation(LT)
    set LP = null
    set LT = null
    set LTR = null
    set LV = null
    set LSP = null
endfunction

constant function DummyFilter takes nothing returns boolean
    return true
endfunction

function Lightning_Ward_JASS takes nothing returns nothing
    local trigger T = CreateTrigger()
    local integer TI = 0
    local filterfunc FF = Filter(function DummyFilter)
    loop
    exitwhen (TI >= bj_MAX_PLAYER_SLOTS)
    call TriggerRegisterPlayerUnitEvent(T, Player(TI), EVENT_PLAYER_UNIT_SPELL_EFFECT, FF)
    set TI = TI + 1
    endloop
    call DestroyFilter(FF)
    set FF = null
    set T = null
endfunction

//===========================================================================
function InitTrig_Lightning_Ward_JASS takes nothing returns nothing
    set gg_trg_Lightning_Ward_JASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Ward_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Lightning_Ward_JASS, Condition( function Trig_Lightning_Ward_JASS_Conditions ) )
    call TriggerAddAction( gg_trg_Lightning_Ward_JASS, function Trig_Lightning_Ward_JASS_Actions )
endfunction


VJASS Scripting
Code (vJASS):
library_once LightningWard initializer Init

globals
    private constant integer LIGHTNING_WARD = 'A004'
    private constant integer DUMMY_RAWCODE  = 'o000'
    private constant integer SWARM_RAWCODE  = 'A002'
    private constant real    OFFSET_DISTANCE = 500.
    private constant integer MAX_WARDS = 5
endglobals

private function LightningWard takes nothing returns boolean
    local unit LTU
    local unit LV
    local player P
    local real X
    local real Y
    local real LD
    local integer LI
    local unit LU
    local real RAD
    if (GetSpellAbilityId() == LIGHTNING_WARD) then
    set LTU = GetTriggerUnit()
    set LV = GetSpellTargetUnit()
    set X = GetUnitX(LV)
    set Y = GetUnitY(LV)
    set LD = (GetUnitAbilityLevel(LTU, LIGHTNING_WARD)*5)+5.
    set RAD = (2.*bj_PI)/MAX_WARDS
    set P = GetOwningPlayer(LTU)
    set LI = 0
    loop
    exitwhen (LI >= MAX_WARDS)
        set LU = CreateUnit(P, DUMMY_RAWCODE, X+OFFSET_DISTANCE*Cos(RAD*LI), Y+OFFSET_DISTANCE*Sin(RAD*LI), 0.)
        call UnitApplyTimedLife(LU, 'BTLF', LD)
        call UnitAddAbility(LU, SWARM_RAWCODE)
        call IssueImmediateOrder(LU, "locustswarm" )
        call IssueTargetOrder(LU, "attack", LV)
        set LI = LI + 1
    endloop
    set LU = null
    set P = null
    set LTU = null
    set LV = null
    endif
    return (FALSE)
endfunction

// ===========================================================================
private constant function DummyFilter takes nothing returns boolean
    return true
endfunction

private function Init takes nothing returns nothing
    local trigger T = CreateTrigger()
    local integer I = 0
    local filterfunc FF = Filter(function DummyFilter)
    loop
    exitwhen (I >= bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T, Player(I), EVENT_PLAYER_UNIT_SPELL_EFFECT, FF)
        set I = I + 1
    endloop
    call TriggerAddCondition(T, Condition(function LightningWard))
    call DestroyFilter(FF)
    set FF = null
    set T = null
endfunction

endlibrary


Keywords:
Wards, Lightning, Electricity, Multi Effect, Impressive
Contents

Lightning Ward Spell (Map)

Reviews
Moderator
19:50, 7th May 2009 Dr Super Good: Highly Recommended Very impressive spells. I feared that they might lag on my PC looking at the screenshot but was suprized to see that even with multile casts of multiple version, no lag occured. It...
Thread Status:
Not open for further replies.
  1. 19:50, 7th May 2009
    Dr Super Good:
    Evaluation

    Rating

    Highly Recommended

    Rating Comment

    Very impressive spells. I feared that they might lag on my PC looking at the screenshot but was suprized to see that even with multile casts of multiple version, no lag occured. It seems completly leakless and obviously is fully MUI, as the test proves. It also looks cool, which is important and I can see many maps using this spell with no problems. It also seems to be easilly balencable as quite a few of its effects are object editor related, but there is also some customizability in the actual spell itself. Testing this spell was not that good, as the test conditions are poor as multiple versions are cast with the same button.

    Suggestions . . .
    - Improve test map, fixing it so that you can choose which version is cast properly and that it is easier to test (better creep arangement).


    Advice: If you do not understand why this spell was given the rating it received or if you would like to ask questions about how to improve this spell. Feel free to send a private message to spell moderator Dr Super Good.
     
  2. -Berz-

    -Berz-

    Joined:
    Mar 5, 2008
    Messages:
    3,203
    Resources:
    123
    Icons:
    111
    Packs:
    1
    Skins:
    1
    Spells:
    10
    Resources:
    123
    Haha, simple and really useful ;D

    Could use some more eye candy, but its ok as it is.

    Good Job =)
     
  3. Septimus

    Septimus

    Joined:
    May 3, 2008
    Messages:
    4,174
    Resources:
    49
    Packs:
    1
    Maps:
    35
    Spells:
    8
    Tutorials:
    5
    Resources:
    49
    This is my first spell and I still trying to figure out a even more effective coding, right now I try to figure out how to set the If/Then/Else of the level and duration in much appropriate way so it would not restrain the level into max 3 (Maybe you won't understand what I trying to say at here :p).

    Creating spell really tough, it need a good creativity to make even 1 spell. Do not worry about this spell, it was leak free unless I forgot about something.

    I think my spell description need to be change, any idea how to make it sound better?
     
  4. -Berz-

    -Berz-

    Joined:
    Mar 5, 2008
    Messages:
    3,203
    Resources:
    123
    Icons:
    111
    Packs:
    1
    Skins:
    1
    Spells:
    10
    Resources:
    123
    It is leak free and MUI, so don't worry ;D You have problems with ideas/creativity too? Join the club :<
     
  5. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    omg the insane map maker is making insane spells ;)

    will check it when I comes home from school
     
  6. xxdingo93xx

    xxdingo93xx

    Joined:
    Sep 8, 2007
    Messages:
    746
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    Well, this is a very simple spell ... :p
    Not the best, but judging about this is your first spell - compliment, I don't have to mention about location leaks etc. ;)
     
  7. Rmx

    Rmx

    Joined:
    Aug 27, 2007
    Messages:
    1,088
    Resources:
    18
    Icons:
    3
    Spells:
    15
    Resources:
    18
    Nice spell for a beginner But needs alot of work to make Better spells ...

    Keep up the GJ .. + REP :)
     
  8. Septimus

    Septimus

    Joined:
    May 3, 2008
    Messages:
    4,174
    Resources:
    49
    Packs:
    1
    Maps:
    35
    Spells:
    8
    Tutorials:
    5
    Resources:
    49
    If I have a good idea and my maths was any better, I could create a better spell... :=/
     
  9. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    600
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    very good for beginner spell!

    things i would suggest are as following:

    1. --------------------------------------
    Change your spell event to:

    • Unit - A unit Starts the effect of an ability


    2. --------------------------------------
    Change your if then else [(if then else) if then else] with following line:

    • Set LW_Duration = (5.00 + (5.00 x (Real(LW_Level))))


    3. --------------------------------------
    In your variable LW_Target_Unit store Target unit of ability being cast and create new variable LW_Target_Pos and store target's position. Then instead of whole the time calling Target Unit of ab... use LW_Target_Unit

    its not coz of speed its coz when calling that function multiple times in same trigger might bug. Its blizzard bug, so that is why i suggest you to use variable coz 1. when called it will work 100%.

    4. --------------------------------------
    I would add few comments but since code is simple it does not need to have any comments. Well for other beginners it should but as said not needed.


    that would be all fix this and it will be 5/5 coz this is your first spell.
    +rep anyway
    ~Dark Dragon

    EDIT: :O you said if you where better at math? maybe i might help you...
     
  10. Septimus

    Septimus

    Joined:
    May 3, 2008
    Messages:
    4,174
    Resources:
    49
    Packs:
    1
    Maps:
    35
    Spells:
    8
    Tutorials:
    5
    Resources:
    49
    Ahh, yes. That is what I been thinking about it, I been trying to fix this. But, I don't know how cause my maths sucks... :p

    Thanks, +rep

    I don't know there is a existence of such a bug.
     
  11. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Although I don't like the special effects, it might come in handy for some people...
     
  12. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    600
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    no no no xD

    you got me wrong i mean you should store unit in LW_Target_Unit not point here is the code how it should look like:

    • Lightning Ward
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Lightning Ward
      • Actions
        • Set LW_Target_Unit = (Target unit of ability being cast)
        • Set LW_Target_Point = (Target point of ability being cast)
        • Set LW_Target_Pos = (Position of LW_Target_Unit)
        • Set LW_Level = (Level of Lightning Ward for (Triggering unit))
        • Set LW_Duration = (5.00 + (5.00 x (Real(LW_Level))))
        • For each (Integer LW_Integer) from 1 to 5, do (Actions)
          • Loop - Actions
            • Set LW_Spawn_Point = (LW_Target_Pos offset by 500.00 towards (LW_Real + 72.00) degrees)
            • Unit - Create 1 Lightning Ward for (Owner of (Triggering unit)) at LW_Spawn_Point facing LW_Target_Point
            • Unit - Add a LW_Duration second Generic expiration timer to (Last created unit)
            • Unit - Add Lightning Bolt to (Last created unit)
            • Unit - Order (Last created unit) to Undead Crypt Lord - Locust Swarm
            • Unit - Order (Last created unit) to Attack LW_Target_Unit
            • Set LW_Real = (LW_Real + 72.00)
            • Custom script: call RemoveLocation(udg_LW_Spawn_Point)
        • Custom script: call RemoveLocation(udg_LW_Target_Point)
        • Custom script: call RemoveLocation(udg_LW_Target_Pos)


    anyway its 5/5 now gj on ur first spell and if you need help with math or coding...
    feel free to ask me ill try to help!

    Greets!
    ~Dark Dragon
     
  13. Septimus

    Septimus

    Joined:
    May 3, 2008
    Messages:
    4,174
    Resources:
    49
    Packs:
    1
    Maps:
    35
    Spells:
    8
    Tutorials:
    5
    Resources:
    49
    Ooops.. my bad, I mistaken what you mean... Would fix it asap.
     
  14. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    Wow, you say this is your first spell?
    Gj, i mean it is refreshing to see someones first spell and that i don't have to implicate how to fix leaks and use variables...
    Well deserves 5/5 +rep^^
     
  15. Septimus

    Septimus

    Joined:
    May 3, 2008
    Messages:
    4,174
    Resources:
    49
    Packs:
    1
    Maps:
    35
    Spells:
    8
    Tutorials:
    5
    Resources:
    49
    I know how to fix leak and use variable/array. The only main problem with spell is, it require maths such as radian, offset, degree and etc etc. Which are my natural weak spot in spell making.. XD
     
  16. -Berz-

    -Berz-

    Joined:
    Mar 5, 2008
    Messages:
    3,203
    Resources:
    123
    Icons:
    111
    Packs:
    1
    Skins:
    1
    Spells:
    10
    Resources:
    123
    I'll check it when i get home 8)
     
  17. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    600
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    since its your first jass spell i think its really awesome. I can say only great job on it its well optimized and leakless. Well i am not sure do you know but actually that AnyUnitEventBJ cause 16 memory leaks of type boolexpr to fix that make function which returns true and takes nothing, the in init trigger:

    Code (vJASS):

    local filterfunc ff = Filter(function ThatTrueFunc)
    set i = 0
    loop
    exitwhen (i >= bj_MAX_PLAYER_SLOTS)
    call TriggerRegisterPlayerUnitEvent(trig, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, ff)
    set i = i + 1
    endloop

    call DestroyFilter(ff)
    set ff = null
     


    Greets!
    ~DD
     
  18. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    EDIT:
    Post was wrong, just do what dd said^^
     
    Last edited: May 4, 2009
  19. Rmx

    Rmx

    Joined:
    Aug 27, 2007
    Messages:
    1,088
    Resources:
    18
    Icons:
    3
    Spells:
    15
    Resources:
    18
    the spell is very efficient i like it :) and the visual effects are great 5/5 for me and +rep :)

    Edit : Fist i need to spread some rep :p
     
    Last edited: May 4, 2009
Thread Status:
Not open for further replies.