Problem with a spell..

Rushhour

New Member
Reaction score
46
I made this "spell" at the start of my map and that's the reason why it looks so nooby. Then I decided to update it to make it more efficient, but now only the old version works and I don't find any mistake:

I didn't build up a struct because there will never be more than 2 instances running at the same time, one from each of two towers, so having two triggers is easier :D
The dummy casts a swarm of chainbolts at all units in a rect. The first bolt does 1% damage, the second one 2%, ... . This damage is multiplicated with the level. Also the maximum amount of targets is calculated with the level, but that's not the point.

Old version that works:
JASS:
scope Chainbolt initializer InitTrig_Chainbolt1_Kopieren
globals
    private group unitgroup=CreateGroup()
    private unit dummy
    private real maxtargets
    private real counter
endglobals

private function Trig_Chainbolt_Conditions1 takes nothing returns boolean
    return GetSpellAbilityId() == 'A00X' and  GetSpellAbilityUnit() == gg_unit_e004_0227
endfunction

private function Filter1 takes nothing returns boolean
    if IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.405 and GetOwningPlayer(GetFilterUnit()) == Player(6) and maxtargets >0 then
        call IssueTargetOrder(dummy,"thunderbolt",GetFilterUnit())
        set maxtargets=maxtargets-1
        call SetWidgetLife(GetFilterUnit(),GetWidgetLife(GetFilterUnit())- ((udg_Chainboltlevel/100)*counter) * GetUnitState(GetFilterUnit(),UNIT_STATE_MAX_LIFE) )
        set counter=counter+1
    endif
    return false
endfunction

private function Trig_Chainbolt_Actions1 takes nothing returns nothing
    set counter=1
    set maxtargets=21-udg_Chainboltlevel
    set dummy=CreateUnit(Player(0),'h00E',GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),bj_UNIT_FACING)
    call GroupEnumUnitsInRect(unitgroup,gg_rct_See1,Condition(function Filter1))
    call RemoveUnit(dummy)
endfunction

private function InitTrig_Chainbolt1_Kopieren takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t, Condition( function Trig_Chainbolt_Conditions1 ) )
    call TriggerAddAction( t, function Trig_Chainbolt_Actions1 )
endfunction
endscope

There was another trigger that ordered a unit to fire an ability every 15. seconds and this activated the old skill (yea I know, nonsense :D)
"new" version that only fires one stormbolt. Structure condition removed.
JASS:
scope Chainbolt initializer Chainbolt1
globals
    private group unitgroup=CreateGroup()
    private unit dummy
    private real maxtargets
    private real counter
endglobals

private function Castanddamage takes nothing returns boolean
local unit u=GetFilterUnit()
    if GetUnitState(u, UNIT_STATE_LIFE) > 0.405 and GetOwningPlayer(u) == Player(6) and maxtargets >0 then
        call IssueTargetOrder(dummy,"thunderbolt",u)
//casts only one time (mana costs, cd etc is 0 ..)
        set maxtargets=maxtargets-1
      //  call PingMinimap(GetUnitX(u),GetUnitY(u),2.) this pings the right enemies
        call SetWidgetLife(u,GetWidgetLife(u)- ((udg_Chainboltlevel/100)*counter) * GetUnitState(u,UNIT_STATE_MAX_LIFE) )
        set counter=counter+1
    endif
    set u=null
    return false
endfunction

private function ChainboltBase takes nothing returns boolean
    set counter=1
    set maxtargets=21-udg_Chainboltlevel //level one hits 20 targets, level 10 hits 11 targets (--> 2 full hits)
    set dummy=CreateUnit(Player(0),'h00E',GetUnitX(gg_unit_e004_0227),GetUnitY(gg_unit_e004_0227),bj_UNIT_FACING)
    call GroupEnumUnitsInRect(unitgroup,gg_rct_See1,Condition(function Castanddamage))
    call UnitApplyTimedLife(dummy, 'BTLF', 10.00)
    return false
endfunction

private function Chainbolt1 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterTimerEvent(t,15.,true)
    call TriggerAddCondition( t,Condition( function ChainboltBase ))
endfunction
endscope
 
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