• 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.

[vJASS] Lightning Strike

Status
Not open for further replies.
Level 6
Joined
Apr 16, 2011
Messages
158
Well that magic should be "Lightning Strike" I (zeus Dota) am trying to do her only for code, I have the following problems:
1-I get to create a the light put is so fast that nor of the to see.
2-to light it should come from top but does she come from the right side, as I know?I didn't remove the light to see the effect
what do I need?
that the effect has a time to be visualized and that the light comes from top.
suggestions? :vw_wtf:

JASS:
library LightningStrike requires SpellEffectEvent
   
   private function TargetDamage takes integer i returns real
        return 100. + 75.*i
   endfunction
    
   struct LightningStrike extends array
        
        // The Id of the ability
        private static constant integer ABIL_CODE       = 'A002'
        
        // The code of dummy
        private static constant integer DUMMY           = 'n001'
        
        // The Id of the ability of dummy
        private static constant integer ABIL_CODE_DUMMY = 'A003'
        
        // The Id of the fly ability
        private static constant integer ABIL_FLY        = 'Amrf'
        
        // The type of created light
        private static constant string LIGHT_EFFECT     = "CLPB"
        
        // The Height of fly dummy
        private static constant real HEIGHT             = 1000

        private static method onCast takes nothing returns nothing
        local player p = GetTriggerPlayer()
        
        local unit t = GetSpellTargetUnit()
        local unit u = GetTriggerUnit()
        
        local real ux = GetUnitX(t)
        local real uy = GetUnitY(t)
        
        local unit d = CreateUnit(p, DUMMY, ux, uy, 0)
        
        local real dx = GetUnitX(d)
        local real dy = GetUnitY(d)
        
        local integer i = GetUnitAbilityLevel(u, ABIL_CODE)
        
        local lightning l = AddLightningEx(LIGHT_EFFECT,true,ux,dy,32,uy,dy,32)
        
        call UnitAddAbility(d, ABIL_FLY)
        
        call SetUnitFlyHeight(d, HEIGHT, 0)
        
        call UnitDamageTarget(u,t,TargetDamage(i),false,false,null,null,null)
        
        call UnitApplyTimedLife(d, 'BTLF', 1)
        
        call DestroyLightning(l)
        set p = null
        set t = null
        set u = null
        set d = null
        set l = null
        
        endmethod

        private static method onInit takes nothing returns nothing
            call RegisterSpellEffectEvent(ABIL_CODE, function thistype.onCast)
        endmethod
    endstruct
endlibrary
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
You need to delay the destruction of the lightning with a timer. You can use a timer system like TimerUtils to attach the lightning to the timer so you can destroy it a fixed interval later.

I think the other problem you were having lies in the line:
JASS:
local lightning l = AddLightningEx(LIGHT_EFFECT,true,ux,dy,32,uy,dy,32)

Your parameters don't make sense. You want the lightning to be created from the sky to the ground yet you state both z values as 32. One should be a large integer, I would say 1000 would suffice. The other value should be 0, or I suppose the height of the terrain at that point.

You also use the values ux, dy which corresponds to the coordinates of two different units, and the input uy, dy is the y-coordinate of two different units.

It should look like this, I think:
JASS:
local lightning l = AddLightningEx(LIGHT_EFFECT,true,dx,dy,1000,dx,dy,0)
 
Status
Not open for further replies.
Top