• 🏆 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!

[JASS] New to jass, please help finding mistakes

Status
Not open for further replies.
JASS:
    function func_s1_Func001002002 takes nothing returns boolean
    return ( IsUnitSelected(GetFilterUnit(), GetTriggerPlayer()) == true )
endfunction

function func_s1_Actions takes nothing returns nothing
    local effect array R_Release_Effect
    local group R_Release_Group = null
    local unit R_Release_Unit = null
    local real R_Release_Real1 = 0.00
    local real R_Release_Real2 = 0.00
    local location R_Release_Tmp_Loc = null
    local location R_Release_Tmp_Loc2 = null
    local integer R_Release_Tmp_Integer = 0
    set R_Release_Group = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function func_s1_Func001002002))
    set R_Release_Unit = GroupPickRandomUnit(R_Release_Group)
    set R_Release_Group = null
    set R_Release_Real1 = 0.00
    set R_Release_Real2 = 125.00
    set R_Release_Tmp_Loc = GetUnitLoc(R_Release_Unit)
    set R_Release_Tmp_Integer = 0
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 200
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set R_Release_Real1 = ( R_Release_Real1 + 3.60 )
        set R_Release_Real2 = ( R_Release_Real2 + 1.10 )
        set R_Release_Tmp_Loc2 = PolarProjectionBJ(R_Release_Tmp_Loc, R_Release_Real2, R_Release_Real1)
        call AddSpecialEffectLocBJ( R_Release_Tmp_Loc2, "Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl" )
        call RemoveLocation(R_Release_Tmp_Loc2)
        set R_Release_Tmp_Integer = ( R_Release_Tmp_Integer + 1 )
        set R_Release_Effect[R_Release_Tmp_Integer] = GetLastCreatedEffectBJ()
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call RemoveLocation(R_Release_Tmp_Loc)
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 200
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set R_Release_Tmp_Integer = GetForLoopIndexA()
        call TriggerSleepAction( ( 0.01 / 100.00 ) )
        call DestroyEffectBJ( R_Release_Effect[R_Release_Tmp_Integer] )
        set R_Release_Effect[R_Release_Tmp_Integer] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function Init_s1 takes nothing returns nothing
    local trigger func_s1
    set func_s1 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( func_s1, Player(0), "-r release", true )
    call TriggerAddAction( func_s1, function func_s1_Actions )
endfunction

What did I wrong? Nothing happens at all, and I don't see the spell, only the wc3 is crashing after some seconds after init.
 
Level 5
Joined
Oct 27, 2007
Messages
158
Check if Init_s1 is run in the map init triggers function. It would explain nothing happening when you type the trigger string.

The trigger doesn't crash on me and does what it should do. I think you have some faulty code somewhere else in your map.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
local group R_Release_Group = null should be local group R_Release_Group = CreateGroup().


Now since you are not Enuming it (GroupEnumUnits...), you can just set it to its value right at the start.
Also your other variables, why not just do it straight away like this

JASS:
local R_Release_Group = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function func_s1_Func001002002))
local R_Release_Unit = GroupPickRandomUnit(R_Release_Group)
local R_Release_Real2 = 125.00
local R_Release_Tmp_Loc = GetUnitLoc(R_Release_Unit)
local R_Release_Tmp_Integer = 0
call DestroyGroup(R_Release_Group) // don't forget to destroy groups !
set R_Release_Group = null


You didn't null the locations.


call TriggerSleepAction( ( 0.01 / 100.00 ) ) - You can't wait a value under ~0.27.
Even if you could, you could just type 0.0001.


Use DestroyEffect instead of DestroyEffectBJ



You can also give some nicer names to your functions and loop integers instead of the blizzard generated crappy names :S
 
Level 5
Joined
Oct 27, 2007
Messages
158
You need to lose the ugly bj loop globals and make local ones. That's causing your trigger to fail on multiple instances.
When you create a special effect it returns an effect for a reason.

JASS:
set R_Release_Tmp_Integer = R_Release_Tmp_Integer + 1
set R_Release_Effect[R_Release_Tmp_Integer] = AddSpecialEffectLoc("Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl", R_Release_Tmp_Loc2)
call RemoveLocation(R_Release_Tmp_Loc2)
 
Status
Not open for further replies.
Top