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. Choose your ride to damnation in the 5th Special Effect Contest Poll.
    Dismiss Notice
  6. The winners of the 13th Techtree Contest have been announced!
    Dismiss Notice
  7. The 13th Music Contest Poll is up! Vote for the best tracks in this symphony of frost and flame.
    Dismiss Notice
  8. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  9. 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 Tendrils v1.1

Submitted by xD.Schurke
This bundle is marked as approved. It works and satisfies the submission rules.
So here is another spell made in vJass

Requires:
* JNGP (JassHelper 0.9.G.0)
* xDModules
* BoolexprUtils

Thanks to Vexorian for JassHelper and BoolexprUtils


The hero soars up and creates tendriles consisting of pure energy. If a tendril
hits an enemy the unit will be damaged.



Changelog
----------

v.1.1
* Implemented ForGroup loop instead of group loop
* Added Sounds
* The caster now can fly through units etc.

Spell Script
Code (vJASS):
//********************************************************************************************
//* Lightning Tendrils v1.1 by xD.Schurke  
//* -------------------------------------
//*
//* Requires:
//*           * JNGP (JassHelper 0.9.G.0)
//*           * xDModules
//*           * BoolexprUtils
//*
//* Thanks to Vexorian for JassHelper and BoolexprUtils
//*
//* The hero soars up and creates tendriles consisting of pure energy. If a tendril
//* hits an enemy the unit will be damaged.
//*
//*
//* Changelog
//* ----------
//*
//* v.1.1
//*      * Implemented ForGroup loop instead of group loop
//*      * Added Sounds
//*      * The caster now can fly through units etc.
//*
//*
//********************************************************************************************
library LightningTendrils initializer init requires xDModules,BoolexprUtils
globals
    //Constants adjust to your map specific data/values
    private constant integer      spellID          = 'A000'                                                            //The spell raw-code
    private constant integer      flyID            = 'Amrf'                                                            //The fly raw-code DO NOT CHANGE THIS ONE
                                                               
    private constant real         interval         = 0.03125                                                           //The updating interval
    private constant real         tendrilInterval  = 0.1                                                               //The interval which moves the tendrils
    private constant real         heightDecStart   = 13.75                                                             //after this time the unit starts to move to the ground
    private constant real         range            = 350.                                                              //The range where the tendrils will move in
    private constant real         damageRange      = 50.                                                               //The range of the tendril impact damage
    private constant real         damage           = 3.                                                                
    private constant real         damageInc        = 2.
    private constant real         flyHeight        = 500.                                                              //The height where the hero will be
    private constant real         flyHeightInc     = 12.5
    private constant real         flyHeightDec     = -12.5
    private constant real         duration         = 15.                                                               //Duration of the spell
   
    private constant integer      tendrils         = 8                                                                 //Number of tendrils + increasement per level
    private constant integer      tendrilsInc      = 3
   
    //Following vars are for the effects
    private constant string       tendrilEffect    = "CLPB"
    private constant string       hitEffect        = "Abilities\\Spells\\Orc\\Purge\\PurgeBuffTarget.mdl"
    private constant string       endEffect        = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
    private constant string       attach           = "chest"
   
    //Sound effects
    private constant string       sfxString        = "Abilities\\Spells\\Orc\\LightningBolt\\LightningBolt.wav"
   
    //DO NOT CHANGE THOSE VARIABLES DUE OF IMPORTANT USAGE
    private          group        tmpG             = CreateGroup()
    private          unit         tmpU
    private          player       tmpP
    private          boolexpr     filter
endglobals

//*************************************Formulas***********************************************
private function tendrilCount takes integer lvl returns integer
    return tendrils+((lvl-1)*tendrilsInc)
endfunction

private function tendrilDamage takes integer lvl returns real
    return damage+((lvl-1)*damageInc)
endfunction
//********************************************************************************************


//*************************************Some functions*****************************************
private function GroupFilter takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(),tmpP) and (GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0) and IsUnitType(GetFilterUnit(),UNIT_TYPE_GROUND)
endfunction

private function GetRandomXInRect takes rect r returns real
    return GetRandomReal(GetRectMinX(r),GetRectMaxX(r))
endfunction

private function GetRandomYInRect takes rect r returns real
    return GetRandomReal(GetRectMinY(r),GetRectMaxY(r))
endfunction
//********************************************************************************************

//****************************************Core Part*******************************************
private function callback takes nothing returns nothing
    local unit u = GetEnumUnit()
    call UnitDamageTarget(tmpU,u,tendrilDamage(GetUnitAbilityLevel(tmpU,spellID)),false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
    set u = null
endfunction

private struct tendrilStruct
    unit      caster
    lightning tendril
    real      time      = 0.    
    method actions takes nothing returns nothing
        //local variable initialization
        local real x1 = GetUnitX(.caster)
        local real y1 = GetUnitY(.caster)
        local real z1 = GetUnitFlyHeight(.caster)        
        local rect r  = Rect(x1 -range,y1 -range,x1+range,y1+range) //<== Creates a rect where the tendril will move in
        local real x2 = GetRandomXInRect(r)
        local real y2 = GetRandomYInRect(r)
        local real z2 = 0  
        local sound sfx = CreateSound(sfxString,false,true,true,0,0,"")
        //setting the sound
        call SetSoundPosition(sfx, x2, y2, 0)
        call SetSoundVolume(sfx, R2I(100 * I2R(127) * 0.01))
        call StartSound(sfx)    
        call KillSoundWhenDone(sfx)
        //end of initialization
        set .time = .time + tendrilInterval
        //Tendril movement
        call MoveLightningEx(.tendril,true,x1,y1,z1,x2,y2,z2)
        call DestroyEffect(AddSpecialEffect(hitEffect,x2,y2))
       
        //Tendril damage
        set tmpP = GetOwningPlayer(.caster)
        set tmpU = .caster
        call GroupEnumUnitsInRange(tmpG,x2,y1,damageRange,filter)
        call ForGroup(tmpG,function callback)
       
        //when should this end??
        if .time >= duration then
            call DestroyEffect(AddSpecialEffect(endEffect,x2,y2))
            call DestroyLightning(.tendril)
            set .tendril = null
            set .caster = null
            call .destroy()
        endif
        //clear all leaks!!
        call RemoveRect(r)
        set sfx = null
        set r = null
    endmethod
    // for this look into xDModules :)
    implement structStack
endstruct

private struct tendrilCaster
    unit      caster
    real      height = 0.
    real      heightInc = flyHeightInc
    real      time    = 0.
    method actions takes nothing returns nothing                
        //First setting the height and time for increasing flyHeight etc.
        set .time = .time + interval
        set .height = .height + .heightInc  
        call SetUnitFlyHeight(.caster,.height,0)        
        if .height >= flyHeight then
            set .heightInc = 0
        endif
        if .time >= heightDecStart then
            set .heightInc = flyHeightDec
        endif
        //everything ends!!
        if .time >= duration then
            call SetUnitPathing(.caster,true)
            set .caster = null
            call .destroy()
        endif
    endmethod
    // for this look into xDModules :)
    implement structStack
endstruct
//Just another stupid condition function... realy blablabla
private function cond takes nothing returns boolean
    return GetSpellAbilityId() == spellID
endfunction

//action function takes care of initializate the structs and is the main protagonist in this little story XD
private function action takes nothing returns nothing
    local tendrilStruct dat
    local tendrilCaster data = tendrilCaster.create(interval)
    local unit caster = GetTriggerUnit()
    local integer i = 0
    set data.caster = caster
    call UnitAddAbility(caster,flyID)
    call UnitRemoveAbility(caster,flyID)
    call SetUnitPathing(caster,false)
    loop
        exitwhen i >= tendrilCount(GetUnitAbilityLevel(caster,spellID))
        set dat = tendrilStruct.create(tendrilInterval)
        set dat.tendril = AddLightningEx(tendrilEffect,true,GetUnitX(caster),GetUnitY(caster),GetUnitFlyHeight(caster),GetUnitX(caster),GetUnitY(caster),GetUnitFlyHeight(caster))
        set dat.caster= caster
        set i = i + 1
    endloop
    set caster = null
endfunction

//usual init stuff like preloading or setting filter
private function init takes nothing returns nothing
    local trigger int = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent(int,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,BOOLEXPR_TRUE)
        set i = i + 1
        exitwhen i >= bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition(int,Condition(function cond))
    call TriggerAddAction(int,function action)
    set int = null
    set filter = Condition(function GroupFilter)
    call Preload(hitEffect)
    call Preload(endEffect)
endfunction
endlibrary
 



xDModules
Code (vJASS):
//**********************************************************************************
//* xDModules v1.1 by xD.Schurke  -  16.04.2009
//* --------------------------------------------
//*      
//* Requires:
//*     * JNGP (JassHelper v0.9.G.0)
//*    
//*
//*     * Implement the module in your structs, which need timers.
//*     * The struct needs a method called actions
//*
//* Example:
//*
//* struct Data
//*     integer count = 0
//*     method actions takes nothing returns nothing
//*         call BJDebugMsg("Hello World")
//*         if count == 5 then
//*             set .active = false
//*         endif
//*     endmethod
//*     implement structStack
//* endstruct
//*
//* If you want to destroy the struct just the this.active = false (.active = false).
//* But don't forget to clear all leaks before
//*
//* Changelog:
//*     * Now the timer interval are commited by the create parameters
//*
//*
//**********************************************************************************
library xDModules
    module structStack
        boolean active = true
       
        private integer i    
        private static integer Total = 0
        private static thistype array Data
        private static timer Tim = CreateTimer()
        private static method callback takes nothing returns nothing
            local thistype dat
            local integer i = 0
            loop
                exitwhen i >= thistype.Total
                set dat = thistype.Data[i]
                if dat.active == true then
                    call dat.actions()
                else                
                    call thistype.destroy(dat)
                    set i = i - 1
                endif
                set i = i + 1
            endloop
            if thistype.Total == 0 then
                call PauseTimer(thistype.Tim)
            endif
        endmethod
   
        static method create takes real interval returns thistype
            local thistype dat = thistype.allocate()
            if thistype.Total == 0 then
                call TimerStart(thistype.Tim,interval,true,function thistype.callback)
            endif
            set thistype.Data[thistype.Total] = dat
            set dat.i = thistype.Total
            set thistype.Total = thistype.Total + 1
            return dat
        endmethod
       
        private method onDestroy takes nothing returns nothing
            set thistype.Total=thistype.Total-1
            set thistype.Data[.i]=thistype.Data[thistype.Total]
            set thistype.Data[.i].i=.i    
        endmethod
    endmodule
endlibrary


Keywords:
vJass,JESP,Schurke,Lightning,light,tendril,tendrils,energy,jass,good
Contents

Lightning Tendrils v1.1 (Map)

Reviews
Moderator
10:32, 19th Oct 2009 TriggerHappy187: Decent enough to be approved. Whats the point of using a local here, you save no function calls. private function callback takes nothing returns nothing local unit u = GetEnumUnit() call...
  1. 10:32, 19th Oct 2009
    TriggerHappy187:

    Decent enough to be approved.

    • Whats the point of using a local here, you save no function calls.
      Code (vJASS):

      private function callback takes nothing returns nothing
          local unit u = GetEnumUnit()
          call UnitDamageTarget(tmpU,u,tendrilDamage(GetUnitAbilityLevel(tmpU,spellID)),false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
          set u = null
      endfunction
       
    • You should be using GetWidgetLife instead of GetUnitState.
    • BOOLEXPR_TRUE
      is completely unneded in your event. You also don't need to set int to null.
     
  2. Yearight

    Yearight

    Joined:
    Dec 11, 2006
    Messages:
    343
    Resources:
    3
    Icons:
    1
    Maps:
    2
    Resources:
    3
    Add a spell description instead of "So here is another spell made in vJass". And The idea is nice. But no sounds at all and the lightnings moves to fast for my taste.
     
  3. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    look into the spell script there is allready a spelldiscription, why should I write it 2 times? so u just have to read the script header ...
     
  4. xxdingo93xx

    xxdingo93xx

    Joined:
    Sep 8, 2007
    Messages:
    746
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    what da hell is module ... :D
     
  5. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    ... dingo I lost all hope in you :p, when i uploaded my last spell you also asked this. I hoped you would inform yourself :D
     
  6. Yearight

    Yearight

    Joined:
    Dec 11, 2006
    Messages:
    343
    Resources:
    3
    Icons:
    1
    Maps:
    2
    Resources:
    3
    Else you could give a pointer that it is in spell script.
     
  7. xxdingo93xx

    xxdingo93xx

    Joined:
    Sep 8, 2007
    Messages:
    746
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    Nevaaa!!! I will ask you soooo long until yo u tell it to me!! :D
     
  8. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5

    noo wai!! :D
     
  9. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    600
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    yo mate xD.Schurke xD!

    well nice spell very nice its coded great in performances and is leakless + MUI. well there is again that loop which loops through the group just note that ForGroup is at least 6 times faster then loop in jass (6 times is minumum even more maybe) but still i dont think it will lag when casted multiple times.

    there is currently one thing which i would really like you to add and that is ofc sound. plz add some lightning sound for example from chain lightning or lightning bolt... any would be good just add it xD

    it will be 5/5 from me nothing more to say i like your module and boolexpr utils! great work once more! +rep

    off topic:
    well from time i first checked dingos pack and give a few tips he understanded them well so ill try to explain him this time too!

    modules are parts of code which can be added in structure of data and must follow other methodes in that struct like one from xD.Schurke which requires actions method.

    modules are using thistype which points to type in which struct they are implemented and all code in module now is accessible in that struct. however private members of module are not accessible in that struct nor in any other function / method. public members are accessible everywhere.

    so simple to say module is group of data which is used to perform single action type for each struct. in his module he is using it for looping (with timer).

    modules can as well be optional implemeted:
    Code (vJASS):

    struct xxx
    implement optional myMod
    endstruct
     


    which means that module will be added if by any chance possible while implement forces to add given module optional mode checks does it exist.

    if you still do not understand you can pm me to explain in more detail!

    Greets all!
    ~Dark Dragon
     
  10. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    Yeah will update both parts (ForGroup and sounds :D)
    btw. I'm working on a jass editor XD

    ...and +rep for explaining modules for dingo :)
     
  11. Guishiu

    Guishiu

    Joined:
    Apr 7, 2008
    Messages:
    160
    Resources:
    3
    Spells:
    3
    Resources:
    3
    The lightning moves too fast.... way too fast
    And my hero died and didnt come back. :(

    But other than that nice spell. Exactly like the guy in Ulduar.
    Fix the tendril speed, and make a Hero revive trigger. And the Test Map will be alot more fun. Maybe add a unit revive trigger aswell.
     
  12. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    600
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    :O xD i am glade you will update it ill check it out and rate 5/5 ofc :)

    EDIT: Great spell nice sounds and forgroup thats much faster now! 5/5
     
    Last edited: May 19, 2009
  13. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    Hmm, maybe smooth lightning moving would suit this better?
    Anyway nice idea, good coding, vJass ftw and so on...
    I don't have time to check the code whole but i think you did a good job so i would say 4/5, if you add smooth lightning moving it will be 5/5.
     
  14. Thanathos

    Thanathos

    Joined:
    Aug 2, 2008
    Messages:
    202
    Resources:
    5
    Spells:
    5
    Resources:
    5
    diden´t check this but if it´s true what everyone says it´s sad this got not reviewed by a mod.
     
  15. Majin

    Majin

    Joined:
    Mar 24, 2008
    Messages:
    181
    Resources:
    2
    Spells:
    2
    Resources:
    2
    Nice spell, just one thing

    Even though i know it has no Cooldown for testing reasons, you should make something to avoid this spell being spammed, weird things happens if i cast it too many times (like all unit models disappear and get merged in a polygons
    mess at the center of the map :eek: )
     
  16. Thanathos

    Thanathos

    Joined:
    Aug 2, 2008
    Messages:
    202
    Resources:
    5
    Spells:
    5
    Resources:
    5
    majin i know this phenomean...it also apperas if there are thousands of unit´s or what so ever on the map. Your graphic card runs out of memory, so very weird things happen. I think this is hardware dependend.
     
  17. Majin

    Majin

    Joined:
    Mar 24, 2008
    Messages:
    181
    Resources:
    2
    Spells:
    2
    Resources:
    2
    Yes, that's true, but it's the first time i have that by spamming a spell (usually it just starts lagging). I'd put some limit on the number of active spells possible or something if i made a spell that could cause this problem
     
  18. D4RK_G4ND4LF

    D4RK_G4ND4LF

    Joined:
    Feb 4, 2009
    Messages:
    1,196
    Resources:
    20
    Models:
    3
    Spells:
    15
    Tutorials:
    2
    Resources:
    20
    the sound is too loud imho but it's easy to adjust it so screw it
    you could make some effect blasting the unit into the air and one for the unit falling down (the random mass thunder clap is a nice try but a single one under the aster would fit better I think)
    you should also think about making the lightning effects spawn directly out of the caster and not under it

    and this would make it more realistic:
    • StopAttackFlying
      • Events
        • Unit - A unit Is attacked
      • Conditions
        • ((Attacked unit) is in LightningTendrilsCasterGroup) Equal to True
        • ((Triggering unit) is Able to attack flying units) Equal to False
      • Actions
        • Unit - Order (Triggering unit) to Stop
     
  19. Bel

    Bel

    Joined:
    Oct 6, 2009
    Messages:
    18
    Resources:
    0
    Resources:
    0
    Excellent spell.. to bad it's JASS.