Spell Holy Light

D.V.D

Make a wish
Reaction score
73
Holy Light
By: D.V.D
Spell Type: No Target
Code Type: Jass
Levels: 10
Description: The Caster brings down the lights fromk the heaven dealing making many shines hit the ground. Each shine heals all allies in 250 range of it and damages all enemies in 250 range.

The spell is almost MUI and MPI. Some waits will be cut off when 2 units cast the ability at the same time but the difference is unotisable.

Level 1: 8 shines, 30 damage/heal
Level 2: 10 shines, 60 damage/heal
Level 3: 12 shines, 130 damage/heal
Level 4: 13 shines, 200 damage/heal
Level 5: 15 shines, 375 damage/heal
Level 6: 17 shines, 560 damage/heal
Level 7: 18 shines, 1250 damage/heal
Level 8: 20 shines, 4675 damage/heal
Level 9: 24 shines, 6780 damage/heal
Level 10: 30 shines, 8000 damage/heal

Screenshot:
holylight.jpg

Code:
JASS:

function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Check1 takes nothing returns boolean
    return GetOwningPlayer(GetEnumUnit()) == GetOwningPlayer(GetTriggerUnit())
endfunction

function Check2 takes nothing returns boolean
    return GetOwningPlayer(GetEnumUnit()) != GetOwningPlayer(GetTriggerUnit())
endfunction

function UnitGroupActions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local integer array dh
    set dh[1] = 30
    set dh[2] = 60
    set dh[3] = 130
    set dh[4] = 200
    set dh[5] = 375
    set dh[6] = 560
    set dh[7] = 1250
    set dh[8] = 4675
    set dh[9] = 6780
    set dh[10] = 8000
    if ( Check1() ) then
        call SetWidgetLife(GetEnumUnit(), GetWidgetLife(GetEnumUnit()) + I2R(dh[GetUnitAbilityLevel(Caster, 'A001')]))
    else
    endif
    if ( Check2() ) then
        call UnitDamageTargetBJ( Caster, GetEnumUnit(), I2R(dh[GetUnitAbilityLevel(Caster, 'A001')]), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    else
    endif
endfunction

function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local unit dummy
    local location p0 = GetUnitLoc(Caster)
    local location p1
    local location p2
    local integer array i
    local integer t = 0
    local group unitgroup
    set i[1] = 8
    set i[2] = 10
    set i[3] = 12
    set i[4] = 13
    set i[5] = 15
    set i[6] = 17
    set i[7] = 18
    set i[8] = 20
    set i[9] = 24
    set i[10] = 30
    call TriggerSleepAction( 0.40 )
    loop
        exitwhen t > i[GetUnitAbilityLevel(Caster, 'A001')]
        set p1 = PolarProjectionBJ(p0, GetRandomReal(250.00, 550.00), GetRandomDirectionDeg())
        call CreateNUnitsAtLocFacingLocBJ( 1, 'h001', GetOwningPlayer(Caster), p1, p1 )
        set dummy = GetLastCreatedUnit()
        call PauseUnitBJ( true, dummy )
        set p2 = GetUnitLoc(dummy)
        set unitgroup = GetUnitsInRangeOfLocAll(( I2R(GetUnitAbilityLevel(Caster, 'A001')) * 100.00 ), p2)
        call UnitApplyTimedLifeBJ( 1.00, 'BTLF', dummy )
        call TriggerSleepAction( 0.20 )
        call ForGroup( unitgroup, function UnitGroupActions )
        set t = t + 1
    endloop
    call RemoveLocation( p0 )
    call RemoveLocation( p1 )
    call RemoveLocation( p2 )
    call DestroyGroup( unitgroup )
    set Caster = null
    set dummy = null
endfunction

//===========================================================================
function InitTrig_Holy_Light takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction


Idea from Hero Line Wars RoC v5.0
http://gamezonezelda.blogspot.com/
 

Attachments

  • Holy Light.w3x
    25.9 KB · Views: 225

DBZ-123

TH.net Regular
Reaction score
19
function Trig_Holy_Light_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A001' ) ) then
return false
endif
return true
endfunction

do

function Trig_Holy_Light_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A001'
endfunction

use returns

screenshot?
 

D.V.D

Make a wish
Reaction score
73
Screenshots I can't make because I have a laptop and the lap top key board is really wierd. Doesn't have all the keys so it changes some. Sometimes I can't make a question mark.
 

DBZ-123

TH.net Regular
Reaction score
19
theres a Prt Scr key. Copy it to paint save upload to tinypic, photobucket, imageshack. Then get link and use image tags.

set dh[1] = 30
set dh[2] = 60
set dh[3] = 130
set dh[4] = 200
set dh[5] = 375
set dh[6] = 560
set dh[7] = 1250
set dh[8] = 4675
set dh[9] = 6780
set dh[10] = 8000

your not even using this
 

Romek

Super Moderator
Reaction score
963
Converted GUI is so ugly, it's an eyesore to read through. :p

Could you submit the GUI version of this, as MPI please?
And resubmit it in Jass once you've learned how to code a bit more.
 

D.V.D

Make a wish
Reaction score
73
I don't have a GUI version of this. I just used GUI functions beccause there aren't any good tutorials. Prt Screen Key doesn't always work on a laptop keyboard. The keys switch. Read my post. And making a MPi version of this would be a pain. Yes im using Dh for the damage calculation. I set it to the level of the ability instead of 1 or 5 in the array box.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Converted GUI is so ugly, it's an eyesore to read through. :p

Could you submit the GUI version of this, as MPI please?
And resubmit it in Jass once you've learned how to code a bit more.
Since you can't use several local variables and an array local variable in gui without many customs scripts, he can't, or the result will be as ugly imho.

@D.V.D : But plz do what DBZ-123 suggest.
 

Romek

Super Moderator
Reaction score
963
> you forgot the udg_ before the variables
Why would he want a udg_ prefix?
These are locals anyway, and those are the names of the locals.
 
Reaction score
341
ugh....this looks like your added a few locals to a gui converted spell.

First off inline your conditions..

JASS:
function Trig_Holy_Light_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Trig_Holy_Light_Func004Func009Func001C takes nothing returns boolean
    return GetOwningPlayer(GetEnumUnit()) == GetOwningPlayer(GetTriggerUnit())
endfunction

function Trig_Holy_Light_Func004Func009Func002C takes nothing returns boolean
    return GetOwningPlayer(GetEnumUnit()) != GetOwningPlayer(GetTriggerUnit())
endfunction



SetUnitLifeBJ...use SetWidgetLife.

JASS:
        //call SetUnitLifeBJ( GetEnumUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit()) + I2R(dh[GetUnitAbilityLevelSwapped('A001', Caster)]) ) )
        call SetWidgetLife(GetEnumUnit(), GetWidgetLife(GetEnumUnit()) + I2R(dh[GetUnitAbilityLevelSwapped('A001', Caster)]))


GetUnitAbilityLevelSwapped, are you kidding?

JASS:
call SetWidgetLife(GetEnumUnit(), GetWidgetLife(GetEnumUnit()) + I2R(dh[GetUnitAbilityLevel(Caster, 'A001')]))


again with the BJ's...

JASS:
        //call UnitDamageTargetBJ( Caster, GetEnumUnit(), I2R(dh[GetUnitAbilityLevelSwapped('A001', Caster)]), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
        call UnitDamageTarget(Caster, GetEnumUnit(), I2R(dh[GetUnitAbilityLevel(Caster, 'A001')]), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)


bj_forLoopAIndex.... use a real loop with a local variable. I'm too lazy to go over the rest of your code, because theres to much to fix.
 

D.V.D

Make a wish
Reaction score
73
Thanks.

UPDATE:
Changed the code making it have less BJ's and ore efficient. Thanks to TriggerHappy +rep.
 

D.V.D

Make a wish
Reaction score
73
=========================
== Update ==
=========================

Changed all Ability Swapped to a more a more efficient call. Took of some memory off the map too.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Just from looking through quickly:
  • Inline the conditions, like TriggerHappy said
  • Change the locations to X/Y
  • Instead of "CreateNUnits..." use "CreateUnit()"
  • Set the dummy right into the dummy variable
  • "call UnitDamageTargetBJ", c'mon now...
  • TriggerSleepAction for that small of a time will almost always be off
  • PolarProjectionBJ, PauseUnitBJ, ForGroupBJ
  • "call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)", look below.
JASS:
local integer i = 0
loop
    call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
    set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
 

D.V.D

Make a wish
Reaction score
73
Just from looking through quickly:
  • Inline the conditions, like TriggerHappy said
  • Change the locations to X/Y
  • Instead of "CreateNUnits..." use "CreateUnit()"
  • Set the dummy right into the dummy variable
  • "call UnitDamageTargetBJ", c'mon now...
  • TriggerSleepAction for that small of a time will almost always be off
  • PolarProjectionBJ, PauseUnitBJ, ForGroupBJ
  • "call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)", look below.
JASS:
local integer i = 0
loop
    call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
    set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop

Removing DamageBJ and PauseBJ didn't work out. Whats set the dummy right into the variable? Whats change locations to X/Y? Whats inline the conditions? Everything else is changed. I don't get why make the spell MPi when its MUI already. It won't change it will it?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Give me a few minutes.
I'll fix it up with comments so you know what was wrong etc.


Try this:
JASS:
    function HLConditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A001'
    endfunction
    
    //=====These two conditions are now inlined
    //function Trig_Holy_Light_Func004Func009Func001C takes nothing returns boolean
        //return GetOwningPlayer(GetEnumUnit()) == GetOwningPlayer(GetTriggerUnit())
    //endfunction
    
    //function Trig_Holy_Light_Func004Func009Func002C takes nothing returns boolean
        //return GetOwningPlayer(GetEnumUnit()) != GetOwningPlayer(GetTriggerUnit())
    //endfunction
    
    function HLGroup takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        //=====Set GetEnumUnit() into a variable too
        local unit Enum = GetEnumUnit()
        local integer array dh
        //=====A few extra variables
        local player ENUM = GetOwningPlayer(Enum)
        local player TRIG = GetOwningPlayer(Caster)
        local integer QTT = GetUnitAbilityLevel(Caster, 'A001')
        set dh[1] = 30
        set dh[2] = 60
        set dh[3] = 130
        set dh[4] = 200
        set dh[5] = 375
        set dh[6] = 560
        set dh[7] = 1250
        set dh[8] = 4675
        set dh[9] = 6780
        set dh[10] = 8000
        //=====Inline the conditions
        //if ( Trig_Holy_Light_Func004Func009Func001C() ) then
        if(ENUM == TRIG) then
            call SetWidgetLife(Enum, GetWidgetLife(Enum) + I2R(dh[QTT]))
        elseif(ENUM != TRIG) then
        //=====What&#039;s up with the endif <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" /> ?
        //endif
        //if ( Trig_Holy_Light_Func004Func009Func002C() ) then
            //=====Replace UnitDamageTargetBJ() with it&#039;s native
            //call UnitDamageTargetBJ(Caster, GetEnumUnit(), I2R(dh[GetUnitAbilityLevel(Caster, &#039;A001&#039;)]), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
            call UnitDamageTarget(Caster, Enum, I2R(dh[QTT]), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        //=====else??? Not needed
        //else
        endif
        //=====Don&#039;t forget to null everything
        set Enum = null
        set Caster = null
    endfunction
    
    function HLActions takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        local unit dummy
        //=====Use X/Y instead of location
        //local location p0 = GetUnitLoc(Caster)
        local real CX = GetUnitX(Caster)
        local real CY = GetUnitY(Caster)
        //=====Use X/Y instead of location
        //local location p1
        local location p2
        local integer array i
        local integer t = 0
        local group unitgroup
        //=====A couple more locals
        local real RR1 = GetRandomReal(250.00, 550.00)
        local real RR2 = GetRandomReal(0.00, 360.00)
        local integer QT = GetUnitAbilityLevel(Caster, &#039;A001&#039;)
        
        set i[1] = 8
        set i[2] = 10
        set i[3] = 12
        set i[4] = 13
        set i[5] = 15
        set i[6] = 17
        set i[7] = 18
        set i[8] = 20
        set i[9] = 24
        set i[10] = 30
        call TriggerSleepAction(0.40)
        loop
        exitwhen t &gt; i[QT]
            //=====Use X/Y instead of location
            //set p1 = PolarProjectionBJ(Location(CX, CY), GetRandomReal(250.00, 550.00), GetRandomReal(0, 360))
            set CX = CX + RR1 * Cos(RR2 * bj_DEGTORAD)
            set CY = CY + RR1 * Sin(RR2 * bj_DEGTORAD)
            //=====Got rid of CreateNUnitsAtLocFacingLocBJ() BJ
            //call CreateNUnitsAtLocFacingLocBJ( 1, &#039;h001&#039;, GetOwningPlayer(Caster), p1, p1 )
            //=====Set &quot;dummy&quot; directly into &quot;CreateUnit()&quot;
            set dummy = CreateUnit(GetOwningPlayer(Caster), &#039;h001&#039;, CX, CY, bj_UNIT_FACING)
            //set dummy = GetLastCreatedUnit()
            //=====Replace PauseUnitBJ() with it&#039;s native
            //call PauseUnitBJ( true, dummy )
            call PauseUnit(dummy, true)
            set p2 = GetUnitLoc(dummy)
            //=====I leave this BJ/location alone
            set unitgroup = GetUnitsInRangeOfLocAll((I2R(QT) * 100.00), p2)
            //=====Reaplce UnitApplyTimedLifeBJ() with it&#039;s native
            //call UnitApplyTimedLifeBJ( 1.00, &#039;BTLF&#039;, dummy )
            call UnitApplyTimedLife(dummy, &#039;BTLF&#039;, 1.00)
            call TriggerSleepAction(0.20)
            //=====Replace ForGroupBJ() with it&#039;s native, and give the function a better name
            //call ForGroupBJ( unitgroup, function Trig_Holy_Light_Func004Func009A )
            call ForGroup(unitgroup, function HLGroup)
            set t = t + 1
        endloop
        //=====These two locations aren&#039;t used anymore
        //call RemoveLocation(p0)
        //call RemoveLocation(p1)
        call RemoveLocation(p2)
        call DestroyGroup(unitgroup)
        //=====You have to null groups also
        set unitgroup = null
        set Caster = null
        set dummy = null
    endfunction

//===========================================================================
    function InitTrig_Holy_Light takes nothing returns nothing
        local trigger t = CreateTrigger()
        //=====Run a loop so that spell works even with neutrals
        local integer i = 0
        loop
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
        endloop
        //call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        
        //=====Rename the functions to something that looks nicer
        call TriggerAddCondition(t, Condition(function HLConditions))
        call TriggerAddAction(t, function HLActions)
        //call TriggerAddCondition(t, Condition( function Trig_Holy_Light_Conditions ) )
        //call TriggerAddAction( t, function Trig_Holy_Light_Actions )
    endfunction
 

D.V.D

Make a wish
Reaction score
73
I don't get this part of the trigger that you added:
JASS:

set CX = CX + RR1 * Cos(RR2 * bj_DEGTORAD)
set CY = CY + RR1 * Sin(RR2 * bj_DEGTORAD)


Your code makes a line of holy light. Check what my spell actually does. It makes the light in a random point from the caster and won't go further than I think like 400.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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