need help optimizing this

Hellohihi

New Member
Reaction score
42
How do i not use the bjs. I cant find natives to do them...? Or how to do i make a more efficient code of it.

JASS:
scope regrowtrees initializer Init

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

private function regrow takes nothing returns nothing
    call DestructableRestoreLife( GetEnumDestructable(), GetDestructableMaxLife(GetEnumDestructable()), true ))
endfunction

private function Actions takes nothing returns nothing
    local location loc = GetSpellTargetLoc()
    call EnumDestructablesInCircleBJ( 300.00, loc, function regrow )
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIvi\\AIviTarget.mdl", GetLocationX(loc) , GetLocationY(loc))
    call RemoveLocation(loc)
    set loc = null
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger regrowtrees = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( regrowtrees, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( regrowtrees, Condition( function Conditions ) )
    call TriggerAddAction( regrowtrees, function Actions )
    set regrowtrees = null
endfunction
endscope
 

Silvenon

New Member
Reaction score
19
I suggest replacing EnumDestructablesInCircleBJ.

JASS:
scope regrowtrees initializer Init

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

private function regrow takes nothing returns nothing
    call DestructableRestoreLife( GetEnumDestructable(), GetDestructableMaxLife(GetEnumDestructable()), true ))
endfunction

private function True takes nothing returns boolean
    return true
endfunction

private function Actions takes nothing returns nothing
    local location loc = GetSpellTargetLoc()
    local real x = GetLocationX(loc)
    local real y = GetLocationY(loc)
    local rect r = Rect(x - 300, y - 300, x + 300, y + 300)
    call EnumDestructablesInRect(r, Condition(function True), function regrow)
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIvi\\AIviTarget.mdl", x , y)
    call RemoveLocation(loc)
    call RemoveRect(r)
    set loc = null
    set r = null
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger regrowtrees = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( regrowtrees, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( regrowtrees, Condition( function Conditions ) )
    call TriggerAddAction( regrowtrees, function Actions )
    set regrowtrees = null
endfunction
endscope
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top