Results 1 to 9 of 9
http://idgs.in/222954
  1. #1
    ranzi's Avatar
    Join Date
    Apr 2007
    Location
    Japanz (Juakarta Puanaazz)
    Posts
    625
    Points
    821.01
    Thanks: 2 / 8 / 6

    Default [vJASS Spell] Lightning Invocation

    Calls forth lightning from the abyss, targets enemy units within 600 AoE to follow under the caster command as long as the spell channeled. Also healing friendly allied hero units for 10 hit points per second.
    Requires:
    TimerUtils - Vexorian
    PUI - Cohadar

    Spoiler untuk Screenshots :


    Spoiler untuk Code :

    Code:
    //******************************************************************************
    //*                                                                            *
    //*                          Lightning Invocation                              *
    //*                                  v1.00                                     *
    //*                                                                            *
    //*                  By: scorpion182 aka ranzi aka ada_aja                     *
    //*                         http://www.jade-wars.com                           *
    //*                                                                            *
    //******************************************************************************
    library LightningInvocation initializer init requires TimerUtils, PolarProjection
    //*************************************************************
    //* Configuration Constants
        globals
        
            private constant integer DUMMY_ID='e000' //Dummy Caster Unit Rawcode
            private constant integer SPELL_ID='A000' //Spell Rawcode
            private constant integer LIGHTNING_NUM=6 //Number of Lightning
            private constant real LIGHTNING_HEIGHT=500. //Lightning Height
            private constant string LIGHTNING_ID="AFOD" //Lighting Rawcode
            private constant string GROUND_FX="Abilities\\Weapons\\VengeanceMissile\\VengeanceMissile.mdl" //Effect attach to lightning
            private constant string HEAL_FX="Abilities\\Weapons\\VengeanceMissile\\VengeanceMissile.mdl" //Effect attach to target heal unit
            private constant string CASTER_FX="Abilities\\Spells\\Orc\\Voodoo\\VoodooAura.mdl" //Effect attach to caster
            private constant string CASTER_ATTCH="origin" //caster attachment point
            private constant string TARGT_H_ATTCH="origin" //target heal attachment point 
            private constant string ORDER_ID="starfall" //spell order id
            private constant real INTERVAL=0.1 //timer interval
            private constant boolean CLOCKWISE=false //rotate clockwise?
            private constant real ANGLE_INCREMENT=.15 //angle movement
        endglobals
        
    //*****************************************************************
    //* Configuration Functions
    
    //* Spell Damage
        private constant function HEAL_AMOUNT takes integer lvl returns real
            return lvl*10.0*INTERVAL
        endfunction
    //* Spell Area of Effect Radius
        private constant function RADIUS takes integer lvl returns real
            return lvl*600.
        endfunction
    
    //* Configuration End
    //*****************************************************************
        globals
            private integer array UnitData
            private boolexpr b
        endglobals
        //set unit's integer
        private function AttachIntegerToUnit takes unit u, integer i returns nothing
            set UnitData[GetUnitIndex(u)] = i
        endfunction
        //get unit's integer 
        private function GetIntegerFromUnit takes unit u returns integer
            return UnitData[GetUnitIndex(u)]
        endfunction
        //spell filter function
        private function Spell_Filter takes nothing returns boolean
            return (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE)==false) and (GetWidgetLife(GetFilterUnit()) > 0.405)
        endfunction
        //spell struct
        private struct data
            unit caster
            unit dum
            unit array missile[LIGHTNING_NUM]
            lightning array lg[LIGHTNING_NUM]
            real array angle[LIGHTNING_NUM] 
            effect fx
            timer t
            group g=CreateGroup()
            
            static method create takes unit c, timer t returns data
                local data d=data.allocate()
                
                set d.caster=c
                set d.t=t
                
                set d.fx=AddSpecialEffectTarget(CASTER_FX, d.caster,CASTER_ATTCH)
                set d.dum=CreateUnit(GetOwningPlayer(d.caster),DUMMY_ID,GetUnitX(d.caster),GetUnitY(d.caster),0)
        
                return d
            endmethod
            //update victim group
            method Update_Group takes nothing returns nothing
                local unit s
                local group temp=CreateGroup()
                local integer lvl=GetUnitAbilityLevel(.caster,SPELL_ID)
                
                call GroupEnumUnitsInRange(temp,GetUnitX(.caster),GetUnitY(.caster),RADIUS(lvl),b)
                
                loop
                    set s=FirstOfGroup(temp)
                exitwhen s==null
                    //convert owner
                    if (IsUnitEnemy(s,GetOwningPlayer(.caster))==true and IsUnitInGroup(s,.g)==false and IsUnitType(s,UNIT_TYPE_HERO)==false) then
                        call AttachIntegerToUnit(s,GetPlayerId(GetOwningPlayer(s)))
                        call SetUnitOwner(s,GetOwningPlayer(.caster),true)
                        call GroupAddUnit(.g,s)
                    //heal friendly unit
                    elseif (IsUnitAlly(s,GetOwningPlayer(.caster))==true and s!=.caster and IsUnitType(s,UNIT_TYPE_HERO)==true) then
                        call SetUnitState(s,UNIT_STATE_LIFE,GetUnitState(s,UNIT_STATE_LIFE)+HEAL_AMOUNT(lvl))
                        call DestroyEffect(AddSpecialEffectTarget(HEAL_FX, s,TARGT_H_ATTCH))
                    endif
                    call GroupRemoveUnit(temp,s)
                endloop
                
                call DestroyGroup(temp)
                
                set temp=null
                set s=null
            endmethod
            
            private method onDestroy takes nothing returns nothing
                local integer i=0
                local unit s
                local integer idx
                
                call ReleaseTimer(.t)
                call DestroyEffect(.fx)
                call KillUnit(.dum)
                
                //revert creeps to original owner
                loop
                    set s=FirstOfGroup(.g)
                exitwhen s==null
                    set idx=GetIntegerFromUnit(s)
                    call SetUnitOwner(s,Player(idx),true)
                    call GroupRemoveUnit(.g,s)
                endloop
                
                call DestroyGroup(.g)
                //destroy lightning
                loop
                exitwhen i>LIGHTNING_NUM
                    call DestroyLightning(.lg[i])
                    call KillUnit(.missile[i])
                    set i=i+1
                endloop
                
                set s=null
            endmethod
            
        endstruct
    
        //spell trigger condition
        private function Conditions takes nothing returns boolean
            return GetSpellAbilityId() == SPELL_ID
        endfunction
        //rotate the lightning
        private function Clock takes nothing returns nothing
            local timer t = GetExpiredTimer()
            local data d=data(GetTimerData(t))
            local integer i=0
            local real x1 
            local real y1 
            local real x2 = GetUnitX(d.dum)
            local real y2 = GetUnitY(d.dum)
            local real angle
            local location l1=GetUnitLoc(d.dum)
            local location l2
            local integer lvl=GetUnitAbilityLevel(d.caster,SPELL_ID)
            
            if (GetUnitCurrentOrder(d.caster)==OrderId(ORDER_ID)) then
            
                call d.Update_Group()
                call TimerStart(t,INTERVAL,false,function Clock)
                
                loop
                exitwhen i>LIGHTNING_NUM
                    set x1 = GetUnitX(d.missile[i])
                    set y1 = GetUnitY(d.missile[i])
                    //rotate counter clockwise
                    if CLOCKWISE==false then
                        set angle=d.angle[i]+ANGLE_INCREMENT
                    //rotate clockwise
                    else
                        set angle=d.angle[i]-ANGLE_INCREMENT
                    endif
                    //move lightning
                    call SetUnitPosition(d.missile[i], x2+RADIUS(lvl)*Cos(angle), y2+RADIUS(lvl)*Sin(angle))
                    set l2=GetUnitLoc(d.missile[i])
                    call MoveLightningEx(d.lg[i],true,GetUnitX(d.dum),GetUnitY(d.dum),GetLocationZ(l1)+LIGHTNING_HEIGHT,GetUnitX(d.missile[i]),GetUnitY(d.missile[i]),GetLocationZ(l2))
                    call DestroyEffect(AddSpecialEffectTarget(GROUND_FX, d.missile[i],"origin"))
                    set d.angle[i]=angle
                    call RemoveLocation(l2)
                    set i=i+1
                endloop
            else
                call d.destroy()
            endif
            
            call RemoveLocation(l1)
            
            set l1=null
            set l2=null
            set t=null
        endfunction
        //spell trigger actions
        private function Actions takes nothing returns nothing
            local timer t=NewTimer()
            local data d=data.create(GetSpellAbilityUnit(),t)
            local integer i=0
            local location l1
            local location l2
            local integer lvl=GetUnitAbilityLevel(d.caster,SPELL_ID)
            
            call SetTimerData(t,integer(d))
            //create lightning
            set l1=GetUnitLoc(d.dum)
            
            loop
            exitwhen i>LIGHTNING_NUM
                set d.missile[i]=CreateUnit(GetOwningPlayer(d.caster),DUMMY_ID, PolarProjectionX(GetUnitX(d.caster),RADIUS(lvl), 360/LIGHTNING_NUM*i), PolarProjectionY(GetUnitY(d.caster), RADIUS(lvl), 360/LIGHTNING_NUM*i), 0.00)
                set l2=GetUnitLoc(d.missile[i])
                set d.lg[i]=AddLightningEx(LIGHTNING_ID,true,GetUnitX(d.dum),GetUnitY(d.dum),GetLocationZ(l1)+LIGHTNING_HEIGHT,GetUnitX(d.missile[i]),GetUnitY(d.missile[i]),GetLocationZ(l2))
                set d.angle[i]=bj_DEGTORAD*360/LIGHTNING_NUM*i
                call RemoveLocation(l2)
                set i=i+1
            endloop
            
            call TimerStart(t,INTERVAL,false,function Clock)
            call RemoveLocation(l1)
            
            set l1=null
            set l2=null
            set t=null
        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 Conditions))
            call TriggerAddAction(t,function Actions)
            
            set b=Condition(function Spell_Filter)
            
            //Preload FX
            call Preload(GROUND_FX)
            call Preload(CASTER_FX)
            call Preload(HEAL_FX)
            
            set t=null
        
        endfunction
        
    endlibrary


    Last edited by ranzi; 31-07-09 at 16:40.

  2. Hot Ad
  3. #2

    Join Date
    May 2009
    Location
    Indonesia
    Posts
    193
    Points
    317.90
    Thanks: 23 / 4 / 4

    Default

    yang kek gw bilang d hive, itu biar bagus d bkin klo unit keluar dari lingkaran ga bisa d control lagi trus liat ni bug yang gw temuin



    betulin tuh hahahaha

  4. #3
    ranzi's Avatar
    Join Date
    Apr 2007
    Location
    Japanz (Juakarta Puanaazz)
    Posts
    625
    Points
    821.01
    Thanks: 2 / 8 / 6

    Default

    Quote Originally Posted by GulaHula View Post
    yang kek gw bilang d hive, itu biar bagus d bkin klo unit keluar dari lingkaran ga bisa d control lagi trus liat ni bug yang gw temuin

    betulin tuh hahahaha
    ok..thanks..eh kok bisa produce bug gitu, gmn kondisinya?? gw lancar2 aj soalnya

    EDIT:
    oh gw tau lw casting dua kali lol XD XD...cooldownnya di lamain donk haha
    Last edited by ranzi; 31-07-09 at 14:38.

  5. #4
    SrZ]Xevirath's Avatar
    Join Date
    Feb 2007
    Location
    Dragon Palace
    Posts
    3,427
    Points
    5,090.80
    Thanks: 0 / 20 / 16

    Default

    Dibikin biar cancel aja klo double cast

    btw kodenya.. anu.. >_>

    Kamu ngebikin rumit sesuatu yg seharusnya nga -_-;

    Keren tapi ~

    EDIT: oh ternyata nga panjang.. cuma scrollnya di sini rusak jadi kliatan panjang - -
    Last edited by SrZ]Xevirath; 31-07-09 at 16:15.

  6. #5
    ranzi's Avatar
    Join Date
    Apr 2007
    Location
    Japanz (Juakarta Puanaazz)
    Posts
    625
    Points
    821.01
    Thanks: 2 / 8 / 6

    Default

    Quote Originally Posted by --Thanatos-- View Post
    Dibikin biar cancel aja klo double cast

    btw kodenya.. anu.. >_>

    Kamu ngebikin rumit sesuatu yg seharusnya nga -_-;

    Keren tapi ~

    EDIT: oh ternyata nga panjang.. cuma scrollnya di sini rusak jadi kliatan panjang - -
    ....cara ngedetect double cast kek mana ..uda coba pake lastordernya rising_dusk gag bisa --a??

  7. #6
    DoOs_101's Avatar
    Join Date
    Oct 2006
    Location
    Jakarta
    Posts
    2,371
    Points
    3,181.21
    Thanks: 0 / 9 / 8

    Default

    Quote Originally Posted by ranzi View Post
    ....cara ngedetect double cast kek mana ..uda coba pake lastordernya rising_dusk gag bisa --a??
    Wkwkwkw nice one Mr. Spell Maker . Sebentar lg gw post informasi mengenai project kt yg baru.
    Quotes of the week:
    "He vanishes only to return as a tyrant."


  8. #7
    ranzi's Avatar
    Join Date
    Apr 2007
    Location
    Japanz (Juakarta Puanaazz)
    Posts
    625
    Points
    821.01
    Thanks: 2 / 8 / 6

    Default

    Quote Originally Posted by DoOs_101 View Post
    Wkwkwkw nice one Mr. Spell Maker . Sebentar lg gw post informasi mengenai project kt yg baru.
    klo project yg baru jadi, gw minta terrain VoA doos

  9. #8
    DoOs_101's Avatar
    Join Date
    Oct 2006
    Location
    Jakarta
    Posts
    2,371
    Points
    3,181.21
    Thanks: 0 / 9 / 8

    Default

    Quote Originally Posted by ranzi View Post
    klo project yg baru jadi, gw minta terrain VoA doos
    Boleh :P
    Quotes of the week:
    "He vanishes only to return as a tyrant."


  10. #9
    SrZ]Xevirath's Avatar
    Join Date
    Feb 2007
    Location
    Dragon Palace
    Posts
    3,427
    Points
    5,090.80
    Thanks: 0 / 20 / 16

    Default

    Eh... tapi jangan deh... harus Create2 Trigger baru yang bisa menyebabkan kekacauan -_-;

    Tapi tetep keren spellnya =P
    Last edited by SrZ]Xevirath; 31-07-09 at 18:15.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •