HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell Not Working Need Help

11-16-2007, 04:28 AM#1
shadowange1
Okay i have a triggered spell that basically makes a bunch of effects that damage units around him for a certain amount of time.

Problem: For some reason this spell instantly kills units regardless of how much hp they have.

The spell starts off by removing leaks and then doing 7 random effects. It begins the effects in a for loop and make a random int to decide which it will do. it adds any dummy casters to a group which will later be killed at the end of the spell.

The first ttrigger initiates the second which will do the effects then goes back to the first to finish off the spell.

Sorry if im not too descriptive but ive made the trigger into jass so i can post it here. If anyone needs anything clarified i can do it. TY in advance
Hidden information:
Collapse JASS:
function Trig_Mega_Flare_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00J' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_Func009A takes nothing returns nothing
    call KillUnit( GetEnumUnit() )
endfunction

function Trig_Mega_Flare_Actions takes nothing returns nothing
    call RemoveLocation (udg_MF_Point[8])
    set udg_MF_Unit = GetSpellAbilityUnit()
    call UnitDamageTargetBJ( udg_MF_Unit, udg_MF_Unit, ( ( 2.00 * I2R(GetUnitAbilityLevelSwapped('A00J', udg_MF_Unit)) ) * I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_MF_Unit, true)) ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DIVINE )
    set udg_MF_Point[8] = GetUnitLoc(GetSpellAbilityUnit())
    call EnableTrigger( gg_trg_Mega_Flare_cont )
    call TriggerSleepAction( ( 3.00 * I2R(GetUnitAbilityLevelSwapped('A00J', udg_MF_Unit)) ) )
    call EnableTrigger( gg_trg_Mega_Flare_cont )
    call TriggerSleepAction( 3.00 )
    call ForGroupBJ( udg_MF_Kill, function Trig_Mega_Flare_Func009A )
endfunction

//===========================================================================
function InitTrig_Mega_Flare takes nothing returns nothing
    set gg_trg_Mega_Flare = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Mega_Flare, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Mega_Flare, Condition( function Trig_Mega_Flare_Conditions ) )
    call TriggerAddAction( gg_trg_Mega_Flare, function Trig_Mega_Flare_Actions )
endfunction


Hidden information:
Collapse JASS:
function Trig_Mega_Flare_cont_Conditions takes nothing returns boolean
    if ( not ( OrderId2StringBJ(GetUnitCurrentOrder(udg_MF_Unit)) == "starfall" ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func003C takes nothing returns boolean
    if ( not ( udg_MF_Chance < 6 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func004Func003Func001Func001C takes nothing returns boolean
    if ( ( IsUnitAliveBJ(GetEnumUnit()) == false ) ) then
        return true
    endif
    if ( ( IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) == false ) ) then
        return true
    endif
    if ( ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return true
    endif
    if ( ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) == true ) ) then
        return true
    endif
    if ( ( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Mega_Flare_cont_Func020Func004Func003Func001C takes nothing returns boolean
    if ( not Trig_Mega_Flare_cont_Func020Func004Func003Func001Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func004Func003A takes nothing returns nothing
    if ( Trig_Mega_Flare_cont_Func020Func004Func003Func001C() ) then
        call GroupRemoveUnitSimple( GetEnumUnit(), udg_MF_Group[GetForLoopIndexA()] )
    else
    endif
endfunction

function Trig_Mega_Flare_cont_Func020Func004Func006A takes nothing returns nothing
    call UnitDamageTargetBJ( udg_MF_Unit, GetEnumUnit(), udg_MF_Damage[GetForLoopIndexA()], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Mega_Flare_cont_Func020Func004C takes nothing returns boolean
    if ( not ( udg_MF_Chance < 14 ) ) then
        return false
    endif
    if ( not ( udg_MF_Chance >= 6 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func005Func003Func001Func001C takes nothing returns boolean
    if ( ( IsUnitAliveBJ(GetEnumUnit()) == false ) ) then
        return true
    endif
    if ( ( IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) == false ) ) then
        return true
    endif
    if ( ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return true
    endif
    if ( ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) == true ) ) then
        return true
    endif
    if ( ( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Mega_Flare_cont_Func020Func005Func003Func001C takes nothing returns boolean
    if ( not Trig_Mega_Flare_cont_Func020Func005Func003Func001Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func005Func003A takes nothing returns nothing
    if ( Trig_Mega_Flare_cont_Func020Func005Func003Func001C() ) then
        call GroupRemoveUnitSimple( GetEnumUnit(), udg_MF_Group[GetForLoopIndexA()] )
    else
    endif
endfunction

function Trig_Mega_Flare_cont_Func020Func005Func006A takes nothing returns nothing
    call UnitDamageTargetBJ( udg_MF_Unit, GetEnumUnit(), udg_MF_Damage[GetForLoopIndexA()], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Mega_Flare_cont_Func020Func005C takes nothing returns boolean
    if ( not ( udg_MF_Chance < 22 ) ) then
        return false
    endif
    if ( not ( udg_MF_Chance >= 14 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func006Func003Func001Func001C takes nothing returns boolean
    if ( ( IsUnitAliveBJ(GetEnumUnit()) == false ) ) then
        return true
    endif
    if ( ( IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) == false ) ) then
        return true
    endif
    if ( ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return true
    endif
    if ( ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) == true ) ) then
        return true
    endif
    if ( ( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Mega_Flare_cont_Func020Func006Func003Func001C takes nothing returns boolean
    if ( not Trig_Mega_Flare_cont_Func020Func006Func003Func001Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func006Func003A takes nothing returns nothing
    if ( Trig_Mega_Flare_cont_Func020Func006Func003Func001C() ) then
        call GroupRemoveUnitSimple( GetEnumUnit(), udg_MF_Group[GetForLoopIndexA()] )
    else
    endif
endfunction

function Trig_Mega_Flare_cont_Func020Func006Func007A takes nothing returns nothing
    call UnitDamageTargetBJ( udg_MF_Unit, GetEnumUnit(), udg_MF_Damage[GetForLoopIndexA()], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Mega_Flare_cont_Func020Func006C takes nothing returns boolean
    if ( not ( udg_MF_Chance < 42 ) ) then
        return false
    endif
    if ( not ( udg_MF_Chance >= 22 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func007Func002Func001Func001C takes nothing returns boolean
    if ( ( IsUnitAliveBJ(GetEnumUnit()) == false ) ) then
        return true
    endif
    if ( ( IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) == false ) ) then
        return true
    endif
    if ( ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return true
    endif
    if ( ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) == true ) ) then
        return true
    endif
    if ( ( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Mega_Flare_cont_Func020Func007Func002Func001C takes nothing returns boolean
    if ( not Trig_Mega_Flare_cont_Func020Func007Func002Func001Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func007Func002A takes nothing returns nothing
    if ( Trig_Mega_Flare_cont_Func020Func007Func002Func001C() ) then
        call GroupRemoveUnitSimple( GetEnumUnit(), udg_MF_Group[GetForLoopIndexA()] )
    else
    endif
endfunction

function Trig_Mega_Flare_cont_Func020Func007C takes nothing returns boolean
    if ( not ( udg_MF_Chance < 53 ) ) then
        return false
    endif
    if ( not ( udg_MF_Chance >= 42 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func008Func004C takes nothing returns boolean
    if ( not ( GetHeroStatBJ(bj_HEROSTAT_INT, udg_MF_Unit, true) <= 65 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Func020Func008C takes nothing returns boolean
    if ( not ( udg_MF_Chance <= 60 ) ) then
        return false
    endif
    if ( not ( udg_MF_Chance >= 53 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mega_Flare_cont_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 0
    set bj_forLoopAIndexEnd = 7
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call KillUnit( udg_MF_Dummy[GetForLoopIndexA()] )
        call DestroyEffectBJ( udg_MF_Effect[GetForLoopIndexA()] )
        set udg_MF_Dummy[GetForLoopIndexA()] = null
        set udg_MF_Extra[GetForLoopIndexA()] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DestroyGroup (udg_MF_Group[0])
    call DestroyGroup (udg_MF_Group[1])
    call DestroyGroup (udg_MF_Group[2])
    call DestroyGroup (udg_MF_Group[3])
    call DestroyGroup (udg_MF_Group[4])
    call DestroyGroup (udg_MF_Group[5])
    call DestroyGroup (udg_MF_Group[6])
    call DestroyGroup (udg_MF_Group[7])
    call RemoveLocation (udg_MF_Point[0])
    call RemoveLocation (udg_MF_Point[1])
    call RemoveLocation (udg_MF_Point[2])
    call RemoveLocation (udg_MF_Point[3])
    call RemoveLocation (udg_MF_Point[4])
    call RemoveLocation (udg_MF_Point[5])
    call RemoveLocation (udg_MF_Point[6])
    call RemoveLocation (udg_MF_Point[7])
    set bj_forLoopAIndex = 0
    set bj_forLoopAIndexEnd = 7
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_MF_Point[GetForLoopIndexA()] = PolarProjectionBJ(udg_MF_Point[8], GetRandomReal(100.00, 700.00), GetRandomDirectionDeg())
        set udg_MF_Chance = GetRandomInt(1, 60)
        if ( Trig_Mega_Flare_cont_Func020Func003C() ) then
            call CreateNUnitsAtLoc( 1, 'ewsp', GetOwningPlayer(udg_MF_Unit), udg_MF_Point[GetForLoopIndexA()], bj_UNIT_FACING )
            set udg_MF_Extra[GetForLoopIndexA()] = GetLastCreatedUnit()
            call ShowUnitHide( udg_MF_Extra[GetForLoopIndexA()] )
            call SetUnitAbilityLevelSwapped( 'A00F', udg_MF_Extra[GetForLoopIndexA()], 4 )
            call IssuePointOrderLocBJ( udg_MF_Extra[GetForLoopIndexA()], "earthquake", udg_MF_Point[GetForLoopIndexA()] )
            call GroupAddUnitSimple( udg_MF_Extra[GetForLoopIndexA()], udg_MF_Kill )
        else
        endif
        if ( Trig_Mega_Flare_cont_Func020Func004C() ) then
            set udg_MF_Damage[GetForLoopIndexA()] = ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_MF_Unit, true)) * 1.40 )
            set udg_MF_Group[GetForLoopIndexA()] = GetUnitsInRangeOfLocAll(300.00, udg_MF_Point[GetForLoopIndexA()])
            call ForGroupBJ( udg_MF_Group[GetForLoopIndexA()], function Trig_Mega_Flare_cont_Func020Func004Func003A )
            call AddSpecialEffectLocBJ( udg_MF_Point[GetForLoopIndexA()], "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl" )
            set udg_MF_Effect[GetForLoopIndexA()] = GetLastCreatedEffectBJ()
            call ForGroupBJ( udg_MF_Group[GetForLoopIndexA()], function Trig_Mega_Flare_cont_Func020Func004Func006A )
        else
        endif
        if ( Trig_Mega_Flare_cont_Func020Func005C() ) then
            set udg_MF_Damage[GetForLoopIndexA()] = ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_MF_Unit, true)) + 50.00 )
            set udg_MF_Group[GetForLoopIndexA()] = GetUnitsInRangeOfLocAll(300.00, udg_MF_Point[GetForLoopIndexA()])
            call ForGroupBJ( udg_MF_Group[GetForLoopIndexA()], function Trig_Mega_Flare_cont_Func020Func005Func003A )
            call AddSpecialEffectLocBJ( udg_MF_Point[GetForLoopIndexA()], "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl" )
            set udg_MF_Effect[GetForLoopIndexA()] = GetLastCreatedEffectBJ()
            call ForGroupBJ( udg_MF_Group[GetForLoopIndexA()], function Trig_Mega_Flare_cont_Func020Func005Func006A )
        else
        endif
        if ( Trig_Mega_Flare_cont_Func020Func006C() ) then
            set udg_MF_Damage[GetForLoopIndexA()] = ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_MF_Unit, true)) * 2.00 )
            set udg_MF_Group[GetForLoopIndexA()] = GetUnitsInRangeOfLocAll(300.00, udg_MF_Point[GetForLoopIndexA()])
            call ForGroupBJ( udg_MF_Group[GetForLoopIndexA()], function Trig_Mega_Flare_cont_Func020Func006Func003A )
            set udg_MF_Dummy[GetForLoopIndexA()] = GroupPickRandomUnit(udg_MF_Group[GetForLoopIndexA()])
            call AddSpecialEffectTargetUnitBJ( "overhead", udg_MF_Dummy[GetForLoopIndexA()], "Abilities\\Spells\\Other\\Tornado\\TornadoElementalSmall.mdl" )
            set udg_MF_Effect[GetForLoopIndexA()] = GetLastCreatedEffectBJ()
            call ForGroupBJ( udg_MF_Group[GetForLoopIndexA()], function Trig_Mega_Flare_cont_Func020Func006Func007A )
        else
        endif
        if ( Trig_Mega_Flare_cont_Func020Func007C() ) then
            set udg_MF_Group[GetForLoopIndexA()] = GetUnitsInRangeOfLocAll(300.00, udg_MF_Point[GetForLoopIndexA()])
            call ForGroupBJ( udg_MF_Group[GetForLoopIndexA()], function Trig_Mega_Flare_cont_Func020Func007Func002A )
            set udg_MF_Dummy[GetForLoopIndexA()] = GroupPickRandomUnit(udg_MF_Group[GetForLoopIndexA()])
            call CreateNUnitsAtLoc( 1, 'ewsp', GetOwningPlayer(udg_MF_Unit), udg_MF_Point[GetForLoopIndexA()], bj_UNIT_FACING )
            set udg_MF_Extra[GetForLoopIndexA()] = GetLastCreatedUnit()
            call ShowUnitHide( udg_MF_Extra[GetForLoopIndexA()] )
            call IssueTargetOrderBJ( udg_MF_Extra[GetForLoopIndexA()], "frostnova", udg_MF_Dummy[GetForLoopIndexA()] )
            call GroupAddUnitSimple( udg_MF_Extra[GetForLoopIndexA()], udg_MF_Kill )
        else
        endif
        if ( Trig_Mega_Flare_cont_Func020Func008C() ) then
            call CreateNUnitsAtLoc( 1, 'ewsp', GetOwningPlayer(udg_MF_Unit), udg_MF_Point[8], bj_UNIT_FACING )
            set udg_MF_Dummy[GetForLoopIndexA()] = GetLastCreatedUnit()
            call ShowUnitHide( udg_MF_Dummy[GetForLoopIndexA()] )
            if ( Trig_Mega_Flare_cont_Func020Func008Func004C() ) then
                call SetUnitAbilityLevelSwapped( 'A00I', udg_MF_Dummy[GetForLoopIndexA()], 1 )
            else
                call SetUnitAbilityLevelSwapped( 'A00I', udg_MF_Dummy[GetForLoopIndexA()], 2 )
            endif
            call IssuePointOrderLocBJ( udg_MF_Dummy[GetForLoopIndexA()], "shockwave", udg_MF_Point[GetForLoopIndexA()] )
            call GroupAddUnitSimple( udg_MF_Dummy[GetForLoopIndexA()], udg_MF_Kill )
        else
        endif
        call DisplayTimedTextToForce( GetPlayersAll(), 5.00, R2S(udg_MF_Damage[GetForLoopIndexA()]) )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set bj_forLoopAIndex = 0
    set bj_forLoopAIndexEnd = 7
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_MF_Damage[GetForLoopIndexA()] = 0.00
        call DestroyEffectBJ( udg_MF_Effect[GetForLoopIndexA()] )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Mega_Flare_cont takes nothing returns nothing
    set gg_trg_Mega_Flare_cont = CreateTrigger(  )
    call DisableTrigger( gg_trg_Mega_Flare_cont )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Mega_Flare_cont, 1.00 )
    call TriggerAddCondition( gg_trg_Mega_Flare_cont, Condition( function Trig_Mega_Flare_cont_Conditions ) )
    call TriggerAddAction( gg_trg_Mega_Flare_cont, function Trig_Mega_Flare_cont_Actions )
endfunction

11-16-2007, 01:56 PM#2
Castlemaster
Collapse JASS:
    call ForGroupBJ( udg_MF_Kill, function Trig_Mega_Flare_Func009A )

I couldn't find where you set the variable "udg_MF_Kill", but if that is includes all units around the caster, then all units will go through this function

Collapse JASS:
function Trig_Mega_Flare_Func009A takes nothing returns nothing
    call KillUnit( GetEnumUnit() )
endfunction

I didn't wade through all of your random effects stuff, but that would possibly be the problem. Disable that function and see what happens (put "//" in front of it, and it will be read as a comment not code)

As far as the rest of your code, I highly suggest you read some of our JASS tutorials, seeing as how it seems that all your code is GUI --> JASS written (which is fine for learning JASS, but there are alot of ways you can optimize your code). Read how to use local variables, which can work wonders for optimization.

Here's some ways you can change your code
Collapse JASS:
function Trig_Mega_Flare_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00J' ) ) then
        return false
    endif
    return true
endfunction

change to

Collapse JASS:
function Trig_Mega_Flare_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00J' 
endfunction

I'd personally also rename all your functions to names you can recognize, instead of "Trig_Mega_Flare_cont_Func020Func005Func003A" name it "MegaFlareGroupRemoval"
11-16-2007, 03:30 PM#3
Deaod
PLEASE, next time dont post converted GUI code, this really hurts my eyes.

Ok, I've looked through your code and changed it a little bit (should run faster now, I didnt change functionality)

Expand New Code:

I dont know if this solves your problems, you will have to test it.

Regards,

Deaod
11-19-2007, 10:19 PM#4
shadowange1
Thank you guys for attempting to help me but the glich still happens and i have no idea on how to fix it but i will keep going at it untill i find a way.

______________________

Okay i finally found my error after fixing damage and stuff to 0 and making nothing do damage units still died so i knew it wasnt anything to do with that. So i looked at the starting if my main function and saw my error.

call KillUnit( udg_MF_Dummy[GetForLoopIndexA()] )

I kill Dummy unit which in some cases is the actualy target of trigger damage done(this was done to use less vars).
ty for the help anyways guys really appreciate it.