• 🏆 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] Crash?

Status
Not open for further replies.
Level 12
Joined
Dec 10, 2008
Messages
850
Ok, so today I download JassCraft, and made a trigger in it, and it clears with WE, but every time I cast the spell BOOM, crash. I get no real clue what happened, since I just started JASS.
JASS:
function Trig_LightningCross_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_LightningCross_Copy_Actions takes nothing returns nothing
    local unit udg_LightningCrossCast
    local real udg_LightningCrossReal1
    local real udg_LightningCrossReal2
    local real udg_LightningCrossReal3
    local real udg_LightningCrossReal4
    local location udg_LightningCrossLoc1
    local location udg_LightningCrossLoc2
    local location udg_LightningCrossLoc3
    local location udg_LightningCrossLoc4
    set udg_LightningCrossCast = GetSpellAbilityUnit()
    set udg_LightningCrossReal1 = 0.00
    set udg_LightningCrossReal2 = 0.00
    set udg_LightningCrossReal3 = 0.00
    set udg_LightningCrossReal4 = 0.00
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 20
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd  
        set udg_LightningCrossLoc1 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal1, 90.00)
        set udg_LightningCrossLoc2 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal2, 0.00)
        set udg_LightningCrossLoc3 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal3, 180.00)
        set udg_LightningCrossLoc4 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal4, 270.00)
        call AddSpecialEffectLocBJ( udg_LightningCrossLoc1, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        call AddSpecialEffectLocBJ( udg_LightningCrossLoc2, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        call AddSpecialEffectLocBJ( udg_LightningCrossLoc3, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        call AddSpecialEffectLocBJ( udg_LightningCrossLoc4, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        set udg_LightningCrossReal1 = ( udg_LightningCrossReal1 + 50.00 )
        set udg_LightningCrossReal2 = ( udg_LightningCrossReal2 + 50.00 )
        set udg_LightningCrossReal3 = ( udg_LightningCrossReal3 + 50.00 )
        set udg_LightningCrossReal4 = ( udg_LightningCrossReal4 + 50.00 )
        call RemoveLocation(udg_LightningCrossLoc1)
        call RemoveLocation(udg_LightningCrossLoc2)
        call RemoveLocation(udg_LightningCrossLoc3)
        call RemoveLocation(udg_LightningCrossLoc4)
        call TriggerSleepAction( 0.01 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 20
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_LightningCrossLoc1 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal1, 90.00)
        set udg_LightningCrossLoc2 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal2, 0.00)
        set udg_LightningCrossLoc3 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal3, 180.00)
        set udg_LightningCrossLoc4 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal4, 270.00)
        call AddSpecialEffectLocBJ( udg_LightningCrossLoc1, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        call AddSpecialEffectLocBJ( udg_LightningCrossLoc2, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        call AddSpecialEffectLocBJ( udg_LightningCrossLoc3, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        call AddSpecialEffectLocBJ( udg_LightningCrossLoc4, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        set udg_LightningCrossReal1 = ( udg_LightningCrossReal1 - 50.00 )
        set udg_LightningCrossReal2 = ( udg_LightningCrossReal2 - 50.00 )
        set udg_LightningCrossReal3 = ( udg_LightningCrossReal3 - 50.00 )
        set udg_LightningCrossReal4 = ( udg_LightningCrossReal4 - 50.00 )
        call RemoveLocation(udg_LightningCrossLoc1)
        call RemoveLocation(udg_LightningCrossLoc2)
        call RemoveLocation(udg_LightningCrossLoc3)
        call RemoveLocation(udg_LightningCrossLoc4)
        call TriggerSleepAction( 0.01 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set udg_LightningCrossCast = null
endfunction

//===========================================================================
function InitTrig_LightningCross_Copy takes nothing returns nothing
    local trigger gg_trg_LightningCross_Copy
    set gg_trg_LightningCross_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_LightningCross_Copy, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_LightningCross_Copy, Condition( function Trig_LightningCross_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_LightningCross_Copy, function Trig_LightningCross_Copy_Actions )
endfunction
I know its full of BJs and probably tins of other evil things, but my native list disapeared to I dont no were it is....
Please help.

(and I'll +rep you if you do!)
 
Level 7
Joined
Jul 20, 2008
Messages
377
First, most JASS coders use local variables for loop index values. Second, you're calling TriggerSleepAction() in loops. You should never sleep in loops (besides, what's the point in sleeping in loops anyway?). Instead of sleep, you should be using timers.

Also, you're creating and then immediately destroying special effects. Why? In the end, the players will never see that special effect.

And this, along with the others like it:

JASS:
set udg_LightningCrossLoc1 = PolarProjectionBJ(GetUnitLoc(udg_LightningCrossCast), udg_LightningCrossReal1, 90.00)

leaks. GetUnitLoc creates a location, but there is no variable for it. Also, you should prefer X and Y coordinates over locations.

As for your native list, maybe you mis-typed something into the native list search box?

Also, your condition function should be simplified to this:

JASS:
function Trig_LightningCross_Copy_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

The way the editor converts conditions from GUI to JASS is just plain freaking stupid. Not only is it doing an "if then else," it's also doing "not," another unnecessary step.
 
Level 4
Joined
May 4, 2008
Messages
113
Also, you're creating and then immediately destroying special effects. Why? In the end, the players will never see that special effect.

This is incorrect, certain special effects can be deleted immediately and they will still show up, such as thunder clap.
Although with local variables you can easily keep a trigger MUI and leave them alive for a little longer, anyways. Just wanted to clarify that they do indeed work.
 
Level 12
Joined
Dec 10, 2008
Messages
850
Also, please start learning JASS by our Tutorials in the TUTORIALS SECTION!

Do you think I would know what a native is if I didnt read the tutorials? And I did say that I just started to learn JASS, so I'm not gunna really know what does what yet.

Anybody who thinks that this is converted GUI. most of it is, I I'm just trying this right now, so I'm not gunna really try a full scratch trigger until I understand it better. Thanks for everybody helping thou =)
 
Level 7
Joined
Jul 20, 2008
Messages
377
This is incorrect, certain special effects can be deleted immediately and they will still show up, such as thunder clap.

True, the ones that generate particles will continue running their particle effects (but no longer generate particles). Non-particle special effects will just disappear.
 
Status
Not open for further replies.
Top