Spell Lightning Anger

Kazuga

Let the game begin...
Reaction score
110
Kazuga proudly presents!

Lightning Anger

Requires:
HAIL
TT
TimedLightning by Flare
Newgen

GUI/JASS? vJass
Laggless? Haven't felt any lagg at all and my computer sucks^^
Leakless? Hope so..

Description:
Channels up elektricity to then send it out in form of a giant electricity ball towards your enemy. The electricity ball will follow the target untill it reaches it's goal. When hit the electricity ball will shock all enemies within range of the target dealing damage.

Screen shots:
lightningangercastea4.png

lightningangerhitbb7.png

They aren't the best so you better check it out ingame^^

Code:
JASS:
//************************************************************************
//*                  Lightning Anger by Kazuga                           *
//************************************************************************



scope Lightnings initializer Lightning
    //! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")
    globals
        private constant integer dummyID = 'h001'            //Dummy id
        private constant integer raw     = 'A001'           //Ability id
        private constant integer aoe     = 500             //AoE of the damage
        private constant integer movement   = 20          //Range of the movement of the lightning ball
        private constant integer damage  = 200           //Amount of damage dealt, damage is multiplied with level of ability
        private constant string lightnings = "CLPB"     //Chain lightning type
        private constant real speed = 0.05             //Speed of the lightning ball
        
        //********************************************************************************************
        //Hearby follows the special effects. To change the effect you must write the path within the*
        //speech signs ("), and don't forget to add a backslash sign (\) to each backslash sign.     *
        //********************************************************************************************
        
        private constant string lightningeffect = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl"                   //Lightning effect type
        private constant string skylightning = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl"     //The lightning coming from the sky
        private constant string starfalleffect = "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl" //The starfall effect when casting the ability
        private constant string warstompeffect = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"     // The warstomp effect wich apears on the targeted unit when hit
        
        //*******************************************************************************
        //*        WARNING!                WARNING!                    WARNING!         *
        //* Spell starts here! Do not change anything below unless you know what you do!*
        //*******************************************************************************
        
        group z
        unit unitx  = null
        unit dummyx = null
    endglobals
    private struct TestStruct
        unit dummy
        unit target
        real tx
        real ty
        timer SlideTimer
        unit caster
    endstruct
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == raw
    endfunction
    function Trig_LightningAnger_FilterCondition takes nothing returns boolean
        return GetWidgetLife( GetFilterUnit() ) > 0.405 and IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( unitx ) ) == true    
    endfunction

    function Damage takes nothing returns nothing
        local unit affected = GetEnumUnit ()
        call UnitDamageTarget(unitx,affected,(damage*I2R(GetUnitAbilityLevel(unitx,'A001'))),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
        call DestroyEffect (AddSpecialEffectTarget(lightningeffect,affected,"origin"))
        call TimedLightning (lightnings,GetUnitX(affected),GetUnitY(affected),0,GetUnitX(dummyx),GetUnitY(dummyx),0,1.,true,1,0)
        set affected = null
    endfunction

    private function Effect takes real myX, real myY, unit Target returns nothing
        local real x = GetUnitX(Target)
        local real y = GetUnitY(Target)
        set z = CreateGroup()
        call GroupEnumUnitsInRange(z,x,y,aoe,Condition(function Trig_LightningAnger_FilterCondition))
        call ForGroup(z,function Damage)
        call DestroyEffect(AddSpecialEffect(skylightning,myX,myY))
        call DestroyEffect(AddSpecialEffect(warstompeffect,myX,myY))
        call DestroyGroup(z)
    endfunction
    
    private function Slide takes nothing returns nothing
        local TestStruct data = GetData (GetExpiredTimer ())
        local real x = GetUnitX(data.dummy)
        local real y = GetUnitY(data.dummy)
        local real newX
        local real newY
        local real angle
        local real distance
        local real real1=45
                            
        set data.tx    = GetUnitX(data.target)
        set data.ty    = GetUnitY(data.target)
        set angle = Atan2(data.ty-y,data.tx-x)
        set newX  = x + movement *Cos(angle)
        set newY  = y + movement *Sin(angle)

        call SetUnitPosition(data.dummy,newX,newY)
        set distance=SquareRoot( (x-data.tx)*(x-data.tx) + (y-data.ty)*(y-data.ty) )
        if distance < 20 then
            call PauseTimer (data.SlideTimer)
            call ResetData (data.SlideTimer)
            call DestroyTimer (data.SlideTimer)
            call RemoveUnit(data.dummy)
            set unitx = data.caster
            set dummyx= data.dummy
            call Effect( data.tx, data.ty, data.target)
            call data.destroy ()
        endif
    endfunction     

    private function Actions takes nothing returns nothing
        local TestStruct data = TestStruct.create ()
        local unit Unit   = GetTriggerUnit()
        local real real1 = GetUnitFacing(GetTriggerUnit())*bj_DEGTORAD

        local real x = GetUnitX(GetTriggerUnit())
        local real y = GetUnitY(GetTriggerUnit())

        local real x2 = x + 300 * Cos((real1+2.531))
        local real y2 = y + 300 * Sin((real1+2.531))

        local real x3 = x + 300 * Cos((real1+3.142))
        local real y3 = y + 300 * Sin((real1+3.142))

        local real x4 = x + 300 * Cos((real1+3.752))
        local real y4 = y + 300 * Sin((real1+3.752))
        local effect special1

        set data.caster = GetTriggerUnit()
        set data.SlideTimer = CreateTimer()
        set data.target = (GetSpellTargetUnit())
        set special1 = AddSpecialEffect(starfalleffect,x,y)
        call TriggerSleepAction (0.1)
        call DestroyEffect (AddSpecialEffect(lightningeffect,x2,y2))
        call DestroyEffect (AddSpecialEffect(lightningeffect,x3,y3))
        call DestroyEffect (AddSpecialEffect(lightningeffect,x4,y4))
        call DestroyEffect (AddSpecialEffect(skylightning,x,y))
        call PauseUnit (Unit, true)

        call TimedLightning (lightnings, x, y, 0, x2, y2, 0, 1., true, 1, 0)
        call TimedLightning (lightnings, x, y, 0, x3, y3, 0, 1., true, 1, 0)
        call TimedLightning (lightnings, x, y, 0, x4, y4, 0, 1., true, 1, 0)
    

        call TriggerSleepAction (1)
        call DestroyEffect(special1)
        set data.dummy = CreateUnit (GetOwningPlayer(Unit),dummyID,x,y,0)
        call SetUnitPathing(data.dummy, false )
        call PauseUnit (Unit, false)
        call TimerStart (data.SlideTimer,speed,true, function Slide)
        call SetData (data.SlideTimer, data)
        set Unit = null
        set special1 = null
    endfunction


    //=========================================================================== 
    private function SafeFilt takes nothing returns boolean
        return true
    endfunction
    private function Lightning takes nothing returns nothing
        local trigger trig = CreateTrigger()
        local integer i = 0
        loop
            exitwhen i > 15
            call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
            set i = i + 1
        endloop
        call TriggerAddCondition (trig, Condition (function Conditions ) )
        call TriggerAddAction (trig, function Actions )
        set trig = null
    endfunction
endscope

Please report possible leaks or issues, and feedback on the terrain would be nice to^^
Thanks to all who helped me with making this spell^^

And finally the map itself:rolleyes:

Edit: Updated code
Edit: Changed some eyecandy
Edit: It's now easier to modify the spell
Edit: Updated code
Edit: Updated code
 

Attachments

  • Lightning anger.w3x
    50.2 KB · Views: 494

Flare

Stops copies me!
Reaction score
662
You didn't null alot of your locals (these are the ones I've seen so far)

*effect1 in your Actions function
*dummy in Effect function
*temp in Effect function

If you have JASScraft, you can search for the variable type, and see if it extends handle e.g.
JASS:
type ability            extends     handle

Anything that extends handle must be nulled if it's local

Make the damage variable a private member so it won't conflict with other variables of the same name.

You really need to add a config header. It's nearly impossible for GUI/newbie JASS users to customize your spell (what if I want the lightning ball to travel faster? What if I want to change the AoE of the end effect? I would have to dig through the code :\

For your first spell, the code looks decent (apart from the above stuff), I'll give it a go now


EDIT: Wow, that was pretty fun. Only one problem I saw though... the initial lightning lasts a small bit too long, I think it could be lowered by 0.5 sec, possibly even 1 sec, but that's just because I think that normal lightning (i.e. chain lightning, forked lightning, finger of death, but not drain) doesn't really look good unless it appears and disappears quickly :)
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
There are a few issues with the coding...

Well, first off, why do you even have the local variable "Unit". You don't need it, you can just set the data.caster = GetTriggerUnit() rather than setting it to a local variable.

Next, those ability strings should be configurable strings, otherwise it will be harder to edit, or at least just take longer.

Some stuff that can help it do less multiplication:
JASS:
local real real1                   = GetUnitFacing(GetTriggerUnit())*bj_DEGTORAD

local real x2 = x + 300 * Cos(real1 + 2.531)
local real y2 = y + 300 * Sin(real1 + 2.531)

local real x3 = x + 300 * Cos(real1 + 3.142)
local real y3 = y + 300 * Sin(real1 + 3.142)

local real x4 = x + 300 * Cos(real1 + 3.752)
local real y4 = y + 300 * Sin(real1 + 3.752)


Because it is doing the radians of the facing + the radians of the numbers you have. A little less math for the machine. :p

I might of miscalculated though because I did this real fast.

On the callback, where do you use these reals? :p
JASS:
local real x2 
local real y2


I don't see them being used. xD

In the "effect" function you can just do the math optimizing like I said before, you can just use some calculator.

Over here:
JASS:
    set z = GetUnitsInRangeOfLocMatching(500, temp, Condition (function Trig_LightningAnger_FilterCondition))


You should create a group, then use GroupEnumUnitsInRange and use coordinates rather than a location. That function doesn't have "BJ" on it but it is still a BJ found in the blizzard.j

In this:
JASS:
(GetUnitAbilityLevelSwapped('A001', unitx)


Use GetUnitAbilityLevel(unitx,'A001') instead because the other is a BJ function.

I think that is all... Not sure though. ^^ Good job on the spell!

Oh yeah, and the terrain is nice but the weather effects lagged my comp a bit. :p
 

Kazuga

Let the game begin...
Reaction score
110
Edited the code, it's now easier to modify the values for more less experienced in jass:)

Purge you calculated correct in the math things however I have no idea how you calculated it =/.

Flare, I nulled the locals you took up, hope I didn't miss anything...
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Good, now it is getting much better, Kazuga. :D

To figure out calculations, you can use:
JASS:
    constant real      bj_DEGTORAD                      = bj_PI/180.0


So, you would do 3.1415926/180.0 (lol, you don't need that much accuracy in this case though :p) which is 0.017453292 or something like that.

Then you would multiply the number together (eg: 145)... So 145*0.017453292... = ~2.53072 xD

Alternatively, just use "call BJDebugMsg(R2S(real) + " = " + R2S(real*bj_DEGTORAD))"

If real was like 5, it would show 5 = whatever the conversion leads to. :p

Just replace the real numbers, test it, and it will give you the value.
 

Kazuga

Let the game begin...
Reaction score
110
Ah thanks^^ I will see if I can get that to work in a sec, but right now I edited the eye candy when the lightning ball hits the enemy. Instead of that X lightning there will now be a lightning to all affected units from the position of the targeted unit. I think it looks better but it could still be aproved...

Need feedback on that part^^
 

Kazuga

Let the game begin...
Reaction score
110
Ye, thanks to all who helped me^^ However how do you submit a screenshot so that it's seen here? I have uploaded it at ImageShack but it doesn't work with it's URL with
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Right click the image, then click "Copy Image Location". Then just paste it in the image tags. Otherwise, you can right click it and click "View Image" then post that link in img tags.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
JASS:
    local real x
    local real y
    local real x2
    local real y2
    local real real1 = 0
    local unit dummy


1) I don't see you use any of those variables in your Effect function, so declaring them seems rather useless.

2) You never destroy z in your Effect function.

3) Anything to make the spell more configurable should go into the global section. This should include the rawcode of the lightnings, the sources of the special effects and maybe even the timer period of the periodic timer.



You could also change this:

JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "")
endlibrary


To this:

JASS:
scope Lightnings initializer Lightning

//! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")


Remove that library, put the textmacro inside the scope and add "private" in the last argument, this since you use the name "Data" for your property.
 

Kazuga

Let the game begin...
Reaction score
110
Ok I have fixed most of the things you told me to, there is just one thing left. The modification of the timer.

When I take integer it complains, but with real I can start the game but the dummy isn't moved...
JASS:
private constant real speed        = 0.05

JASS:
call TimerStart (data.SlideTimer,speed,true, function Slide)

Whole code:
JASS:
//************************************************************************
//*                  Lightning Anger by Kazuga                           *
//************************************************************************



scope Lightnings initializer Lightning
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")
globals
private constant integer dummyID   = 'h001'            //Dummy id
private constant integer raw       = 'A001'           //Ability id
private constant integer aoe       = 500             //AoE of the damage
private constant real speed        = 0.05           //Speed of the lightning ball
private constant integer damage    = 200           //Amount of damage dealt, damage is multiplied with level of ability
private constant string lightnings = "CLPB"       //Chain lightning type

//********************************************************************************************
//Hearby follows the special effects. To change the effect you must write the path within the*
//speech signs ("), and don't forget to add a backslash sign (\) to each backslash sign.     *
//********************************************************************************************

private constant string lightningeffect = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl"                   //Lightning effect type
private constant string skylightning    = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl"     //The lightning coming from the sky
private constant string starfalleffect  = "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl" //The starfall effect when casting the ability
private constant string warstompeffect  = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"     // The warstomp effect wich apears on the targeted unit when hit

//*******************************************************************************
//*        WARNING!                WARNING!                    WARNING!         *
//* Spell starts here! Do not change anything below unless you know what you do!*
//*******************************************************************************

group z
unit unitx  = null
unit dummyx = null
endglobals
private struct TestStruct
unit dummy
unit target
real tx
real ty
timer SlideTimer
unit caster
endstruct

private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == raw
endfunction
function Trig_LightningAnger_FilterCondition takes nothing returns boolean
    return GetWidgetLife( GetFilterUnit() ) > 0.405 and IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( unitx ) ) == true
    
endfunction
function Trig_LightningAnger_Func001A takes nothing returns nothing
local real xx = GetUnitX(GetEnumUnit())
local real yy = GetUnitY(GetEnumUnit())
local real x = GetUnitX(dummyx)
local real y = GetUnitY(dummyx)
    call UnitDamageTarget(unitx, GetEnumUnit(), ( damage * I2R(GetUnitAbilityLevel(unitx,'A001')) ),true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
    call DestroyEffect (AddSpecialEffect(lightningeffect,xx,yy))
    call TimedLightning (lightnings, xx, yy, 0, x, y, 0, 1., true, 1, 0)

 endfunction

private function Effect takes real myX, real myY, unit Target returns nothing

    local location temp = GetUnitLoc(Target)

    set z = GetUnitsInRangeOfLocMatching(aoe, temp, Condition (function Trig_LightningAnger_FilterCondition))
    call ForGroup( z, (function Trig_LightningAnger_Func001A ))
    call RemoveLocation (temp)
  call DestroyEffect (AddSpecialEffect(skylightning,myX,myY))  
  call DestroyEffect (AddSpecialEffect(warstompeffect,myX,myY))  
  call DestroyGroup(z)
   set temp = null
  endfunction



private function Slide takes nothing returns nothing
local TestStruct data = GetData (GetExpiredTimer ())
local real x = GetUnitX(data.dummy)
local real y = GetUnitY(data.dummy)
local real newX
local real newY
local real angle
local real distance
local real real1=45



set data.tx    = GetUnitX(data.target)
set data.ty    = GetUnitY(data.target)
set angle = Atan2(data.ty-y,data.tx-x)
set newX  = x + speed *Cos(angle)
set newY  = y + speed *Sin(angle)

call SetUnitPosition(data.dummy,newX,newY)
set distance=SquareRoot( (x-data.tx)*(x-data.tx) + (y-data.ty)*(y-data.ty) )
if distance < 20 then
    call PauseTimer (data.SlideTimer)
    call ResetData (data.SlideTimer)
    call DestroyTimer (data.SlideTimer)
    call RemoveUnit(data.dummy)
    set unitx = data.caster
    set dummyx= data.dummy
    call Effect( data.tx, data.ty, data.target)
    call data.destroy ()
endif
endfunction


private function Actions takes nothing returns nothing
local TestStruct data = TestStruct.create ()
local unit Unit                    = GetTriggerUnit()
local real real1                   = GetUnitFacing(GetTriggerUnit())*bj_DEGTORAD

local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())

local real x2 = x + 300 * Cos((real1+2.531))
local real y2 = y + 300 * Sin((real1+2.531))

local real x3 = x + 300 * Cos((real1+3.142))
local real y3 = y + 300 * Sin((real1+3.142))

local real x4 = x + 300 * Cos((real1+3.752))
local real y4 = y + 300 * Sin((real1+3.752))
local effect special1

set data.caster = GetTriggerUnit()
set data.SlideTimer = CreateTimer()
set data.target = (GetSpellTargetUnit())
set special1 = AddSpecialEffect(starfalleffect,x,y)
call TriggerSleepAction (0.1)
call DestroyEffect (AddSpecialEffect(lightningeffect,x2,y2))
call DestroyEffect (AddSpecialEffect(lightningeffect,x3,y3))
call DestroyEffect (AddSpecialEffect(lightningeffect,x4,y4))
call DestroyEffect (AddSpecialEffect(skylightning,x,y))
call PauseUnit (Unit, true)

call TimedLightning (lightnings, x, y, 0, x2, y2, 0, 1., true, 1, 0)
call TimedLightning (lightnings, x, y, 0, x3, y3, 0, 1., true, 1, 0)
call TimedLightning (lightnings, x, y, 0, x4, y4, 0, 1., true, 1, 0)


call TriggerSleepAction (1)
call DestroyEffect(special1)
set data.dummy = CreateUnit (GetOwningPlayer(Unit),dummyID,x,y,0)
call SetUnitPathing(data.dummy, false )
call PauseUnit (Unit, false)
call TimerStart (data.SlideTimer,speed,true, function Slide)
call SetData (data.SlideTimer, data)
set Unit = null
set special1 = null
endfunction


//===========================================================================

private function SafeFilt takes nothing returns boolean
return true
endfunction
private function Lightning takes nothing returns nothing
 local trigger trig = CreateTrigger()
local integer i = 0
loop
    exitwhen i > 15
    call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
    set i = i + 1
endloop
 call TriggerAddCondition (trig, Condition (function Conditions ) )
 call TriggerAddAction (trig, function Actions )
 set trig = null
 endfunction

endscope

How does the other modifications look?^^ Hope this is somewhat what you ment :p
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
JASS:
    private constant real speed


This was your movement variable, set it back to 20. You're currently moving the dummy 0.05 units forwards each time the timer expires instead of 20.

Make a new variable:

JASS:
    private constant real TimerPeriod = 0.05


And use that one for the timer.



Other than that it looks nice, great work.
 

Kazuga

Let the game begin...
Reaction score
110
This was your movement variable, set it back to 20. You're currently moving the dummy 0.05 units forwards each time the timer expires instead of 20.

Aha forgot to change the movement variable^^ Ok added a new one for the time so you can now change both of them.:)

Other than that it looks nice, great work.
Thanks^^


Edit: Code and map updated.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Hm.. I think it is rather useless declaring the variables on this:
JASS:
function Trig_LightningAnger_Func001A takes nothing returns nothing
local real xx = GetUnitX(GetEnumUnit())
local real yy = GetUnitY(GetEnumUnit())
local real x = GetUnitX(dummyx)
local real y = GetUnitY(dummyx)
    call UnitDamageTarget(unitx, GetEnumUnit(), ( damage * I2R(GetUnitAbilityLevel(unitx,'A001')) ),true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
    call DestroyEffect (AddSpecialEffect(lightningeffect,xx,yy))
    call TimedLightning (lightnings, xx, yy, 0, x, y, 0, 1., true, 1, 0)

 endfunction


Can be this:
JASS:
function Trig_LightningAnger_Func001A takes nothing returns nothing
    call UnitDamageTarget(unitx,GetEnumUnit(),(damage*I2R(GetUnitAbilityLevel(unitx,'A001'))),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
    call DestroyEffect(AddSpecialEffect(lightningeffect,GetUnitX(GetEnumUnit()),GetUnitY(GetEnumUnit())))
    call TimedLightning (lightnings,GetUnitX(GetEnumUnit()),GetUnitY(GetEnumUnit()),0,GetUnitX(dummyx),GetUnitY(dummyx),0,1.,true,1,0)
endfunction


And please change the function name, it is obvious that that is GUI converted. :p

This part now:
JASS:
    set z = GetUnitsInRangeOfLocMatching(aoe, temp, Condition (function Trig_LightningAnger_FilterCondition


Is a BJ and requires a location which sucks because locations need to be removed, they need to be nulled, and reals are more accurate. Here you go:
JASS:
private function Effect takes real myX, real myY, unit Target returns nothing
    local real x = GetUnitX(Target)
    local real y = GetUnitY(target)
    set z = CreateGroup()
    call GroupEnumUnitsInRange(z,x,y,aoe,Condition(function Trig_LightningAnger_FilterCondition))
    call ForGroup(z,function Trig_LightningAnger_Func001A)
    call DestroyEffect(AddSpecialEffect(skylightning,myX,myY))  
    call DestroyEffect(AddSpecialEffect(warstompeffect,myX,myY))  
    call DestroyGroup(z)
endfunction


Really, you could just loop instead because you aren't really executing much functions.
 

Kazuga

Let the game begin...
Reaction score
110
A thanks^^

Ye I must admit it was GUI converted, I had no idea what it looked like so I copy pasted it :p

Is a loop faster? And also will it be able to affect all units with the chain lightning effect?

Updated code:
JASS:
//************************************************************************
//*                  Lightning Anger by Kazuga                           *
//************************************************************************



scope Lightnings initializer Lightning
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")
globals
private constant integer dummyID = 'h001'            //Dummy id
private constant integer raw     = 'A001'           //Ability id
private constant integer aoe     = 500             //AoE of the damage
private constant integer movement   = 20          //Range of the movement of the lightning ball
private constant integer damage  = 200           //Amount of damage dealt, damage is multiplied with level of ability
private constant string lightnings = "CLPB"     //Chain lightning type
private constant real speed = 0.05             //Speed of the lightning ball

//********************************************************************************************
//Hearby follows the special effects. To change the effect you must write the path within the*
//speech signs ("), and don't forget to add a backslash sign (\) to each backslash sign.     *
//********************************************************************************************

private constant string lightningeffect = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl"                   //Lightning effect type
private constant string skylightning = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl"     //The lightning coming from the sky
private constant string starfalleffect = "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl" //The starfall effect when casting the ability
private constant string warstompeffect = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"     // The warstomp effect wich apears on the targeted unit when hit

//*******************************************************************************
//*        WARNING!                WARNING!                    WARNING!         *
//* Spell starts here! Do not change anything below unless you know what you do!*
//*******************************************************************************

group z
unit unitx  = null
unit dummyx = null
endglobals
private struct TestStruct
unit dummy
unit target
real tx
real ty
timer SlideTimer
unit caster
endstruct

private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == raw
endfunction
function Trig_LightningAnger_FilterCondition takes nothing returns boolean
    return GetWidgetLife( GetFilterUnit() ) > 0.405 and IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( unitx ) ) == true
    
endfunction

function Damage takes nothing returns nothing
    call UnitDamageTarget(unitx,GetEnumUnit(),(damage*I2R(GetUnitAbilityLevel(unitx,'A001'))),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
    call DestroyEffect(AddSpecialEffect(lightningeffect,GetUnitX(GetEnumUnit()),GetUnitY(GetEnumUnit())))
    call TimedLightning (lightnings,GetUnitX(GetEnumUnit()),GetUnitY(GetEnumUnit()),0,GetUnitX(dummyx),GetUnitY(dummyx),0,1.,true,1,0)
endfunction



private function Effect takes real myX, real myY, unit Target returns nothing
    local real x = GetUnitX(Target)
    local real y = GetUnitY(Target)
    set z = CreateGroup()
    call GroupEnumUnitsInRange(z,x,y,aoe,Condition(function Trig_LightningAnger_FilterCondition))
    call ForGroup(z,function Damage)
    call DestroyEffect(AddSpecialEffect(skylightning,myX,myY))  
    call DestroyEffect(AddSpecialEffect(warstompeffect,myX,myY))  
    call DestroyGroup(z)
endfunction





private function Slide takes nothing returns nothing
local TestStruct data = GetData (GetExpiredTimer ())
local real x = GetUnitX(data.dummy)
local real y = GetUnitY(data.dummy)
local real newX
local real newY
local real angle
local real distance
local real real1=45



set data.tx    = GetUnitX(data.target)
set data.ty    = GetUnitY(data.target)
set angle = Atan2(data.ty-y,data.tx-x)
set newX  = x + movement *Cos(angle)
set newY  = y + movement *Sin(angle)

call SetUnitPosition(data.dummy,newX,newY)
set distance=SquareRoot( (x-data.tx)*(x-data.tx) + (y-data.ty)*(y-data.ty) )
if distance < 20 then
    call PauseTimer (data.SlideTimer)
    call ResetData (data.SlideTimer)
    call DestroyTimer (data.SlideTimer)
    call RemoveUnit(data.dummy)
    set unitx = data.caster
    set dummyx= data.dummy
    call Effect( data.tx, data.ty, data.target)
    call data.destroy ()
endif
endfunction


private function Actions takes nothing returns nothing
local TestStruct data = TestStruct.create ()
local unit Unit                    = GetTriggerUnit()
local real real1                   = GetUnitFacing(GetTriggerUnit())*bj_DEGTORAD

local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())

local real x2 = x + 300 * Cos((real1+2.531))
local real y2 = y + 300 * Sin((real1+2.531))

local real x3 = x + 300 * Cos((real1+3.142))
local real y3 = y + 300 * Sin((real1+3.142))

local real x4 = x + 300 * Cos((real1+3.752))
local real y4 = y + 300 * Sin((real1+3.752))
local effect special1

set data.caster = GetTriggerUnit()
set data.SlideTimer = CreateTimer()
set data.target = (GetSpellTargetUnit())
set special1 = AddSpecialEffect(starfalleffect,x,y)
call TriggerSleepAction (0.1)
call DestroyEffect (AddSpecialEffect(lightningeffect,x2,y2))
call DestroyEffect (AddSpecialEffect(lightningeffect,x3,y3))
call DestroyEffect (AddSpecialEffect(lightningeffect,x4,y4))
call DestroyEffect (AddSpecialEffect(skylightning,x,y))
call PauseUnit (Unit, true)

call TimedLightning (lightnings, x, y, 0, x2, y2, 0, 1., true, 1, 0)
call TimedLightning (lightnings, x, y, 0, x3, y3, 0, 1., true, 1, 0)
call TimedLightning (lightnings, x, y, 0, x4, y4, 0, 1., true, 1, 0)


call TriggerSleepAction (1)
call DestroyEffect(special1)
set data.dummy = CreateUnit (GetOwningPlayer(Unit),dummyID,x,y,0)
call SetUnitPathing(data.dummy, false )
call PauseUnit (Unit, false)
call TimerStart (data.SlideTimer,speed,true, function Slide)
call SetData (data.SlideTimer, data)
set Unit = null
set special1 = null
endfunction


//===========================================================================

private function SafeFilt takes nothing returns boolean
return true
endfunction
private function Lightning takes nothing returns nothing
 local trigger trig = CreateTrigger()
local integer i = 0
loop
    exitwhen i > 15
    call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
    set i = i + 1
endloop
 call TriggerAddCondition (trig, Condition (function Conditions ) )
 call TriggerAddAction (trig, function Actions )
 set trig = null
 endfunction

endscope
 

Flare

Stops copies me!
Reaction score
662
JASS:
function Trig_LightningAnger_Func001A takes nothing returns nothing
    call UnitDamageTarget(unitx,GetEnumUnit(),(damage*I2R(GetUnitAbilityLevel(unitx,'A001'))),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
    call DestroyEffect(AddSpecialEffect(lightningeffect,GetUnitX(GetEnumUnit()),GetUnitY(GetEnumUnit())))
    call TimedLightning (lightnings,GetUnitX(GetEnumUnit()),GetUnitY(GetEnumUnit()),0,GetUnitX(dummyx),GetUnitY(dummyx),0,1.,true,1,0)
endfunction


Wouldn't it be better to do
JASS:
function Trig_LightningAnger_Func001A takes nothing returns nothing
local unit u = GetEnumUnit ()
    call UnitDamageTarget(unitx,u,(damage*I2R(GetUnitAbilityLevel(unitx,'A001'))),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
    call DestroyEffect(AddSpecialEffect(lightningeffect,GetUnitX(u),GetUnitY(u)))
//Or use AddSpecialEffectTarget i.e.
call DestroyEffect (AddSpecialEffectTarget (u, lightningeffect, "origin"))
    call TimedLightning (lightnings,GetUnitX(u),GetUnitY(u),0,GetUnitX(dummyx),GetUnitY(dummyx),0,1.,true,1,0)
set u = null
endfunction


since variables are faster than function calls aren't they?
 

Kazuga

Let the game begin...
Reaction score
110
Hm nice, it looks better now when the effect is clinged to the unit if it moves from it's current location.:rolleyes:

Just a pointout, the effect should be before the affected unit:)
JASS:
    call DestroyEffect (AddSpecialEffectTarget(lightningeffect,u,"origin"))


Thanks^^ Code and map updated.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top