• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[jass] Help me clean up my noob spell

Status
Not open for further replies.
Level 1
Joined
May 19, 2009
Messages
1
My first attempt at converting my gui spell to jass.

I tried my best to clean it up.

But i am sure its still far from clean, still looks very messy to me.

So would anyone help me clean it up. And explain it to me if its advanced stuffs.

The spells creates 6 tornados in the area of the point of the ability casted.

The middle tornado is created outside of the loop, then it is given a dummy monsoon ability and it is ordered to cast it.

5 tornados are created from a loop, using integers to determine the location whereby the tornados are created.

All tornados expires after 15 seconds.


Code:
scope ThunderArea initializer Init

private function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A003' ) ) then
        return false
    endif
    return true
endfunction

private function Actions takes nothing returns nothing
    local location loc = GetSpellTargetLoc()
    local integer int = -72
   
    call CreateNUnitsAtLoc( 1, 'n001', GetOwningPlayer(GetSpellAbilityUnit()), loc, bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'A005', GetLastCreatedUnit() )
    call SetUnitAbilityLevelSwapped( 'A005', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A003', GetSpellAbilityUnit()) )
    call UnitAddAbilityBJ( 'A006', GetLastCreatedUnit() )
    call SetUnitAbilityLevelSwapped( 'A006', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A003', GetSpellAbilityUnit()) )
    call IssuePointOrderLocBJ( GetLastCreatedUnit(), "monsoon", loc )
    call UnitApplyTimedLifeBJ( 15.00, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLoc( 1, 'n002', GetOwningPlayer(GetSpellAbilityUnit()), loc, bj_UNIT_FACING )
    call UnitApplyTimedLifeBJ( 15.00, 'BTLF', GetLastCreatedUnit() )
   
    loop
        exitwhen int >= 360
        set int = ( int + 72 )
        set loc = PolarProjectionBJ(GetSpellTargetLoc(), 400.00, I2R(int))
        call CreateNUnitsAtLoc( 1, 'n001', GetOwningPlayer(GetSpellAbilityUnit()), loc, bj_UNIT_FACING )
        call UnitApplyTimedLifeBJ( 15.00, 'BTLF', GetLastCreatedUnit() )
    endloop
    
    call PlaySoundAtPointBJ( gg_snd_RollingThunder1, 100, loc, 0 )
    call PlaySoundAtPointBJ( gg_snd_LightningBolt1, 100, loc, 0 )
    
    call RemoveLocation(loc)
    
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger ThunderArea = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( ThunderArea, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( ThunderArea, Condition( function Conditions ) )
    call TriggerAddAction( ThunderArea, function Actions )
endfunction

endscope
 
Status
Not open for further replies.
Top