HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unable to SAVE/TEST Map with EXISTENT AND ENABLED Trigger

07-04-2008, 12:54 AM#1
fX_
Trigger doesn't work: I'm unable to SAVE or RUN (TEST) the map when this is existent and enabled in the trigger editor; I am able to enable/disable it in the trigger editor (no error/syntax/whatever message).

Save/run error occurs while "compiling" (?) where the loading bar says "Variables"

Can someone pls tell me what's wrong with it?

Collapse JASS:
//////////////////////////////////////////////////////////////////////////////
//THE BEAST WITHIN
//----------------------------------------------------------------------------
//EFFECTS: 1) EXTRA ABILITIES, ATTRIBUTES AND BONUSES: +STR, DMG, ARMOR, HP
//            CRITICAL STRIKE ABILITY WITH LOW CHANCE BUT HIGH DAMAGE;
//            MULTIPLIER;
//         2) CHANCE TO GO BERSERK UPON TAKING DAMAGE THAT HAS A SOURCE WITHIN
//            X RANGE OF CASTER, CAUSING CASTER TO DO ONLY ATTACK THE DAMAGE
//            SOURCE FOR Y SECONDS;
//         3) INCREASED BESTIAL ABILITY POTENCY AND INCIDENCE, WHATEVER THESE
//            MAY BE ("AOE BERSERK KNOCKBACK WHEN GANGED ABILITY", ETC.)
//////////////////////////////////////////////////////////////////////////////

//CONSTANTS START//
constant function INT_AbilityIdCast takes nothing returns integer
    return 'A001' //ABILITY ID OF HERO-CASTED ABILITY//
endfunction

constant function INT_AbilityIdExtraAbilities takes nothing returns integer
    return 'A003' //ABILITY ID OF SPELLBOOK CONTAINING ALL ++ABILITIES AVAILED FOR DUTAION OF MAIN (CAST) ABILITY//
endfunction

constant function INT_UnitIdDummy takes nothing returns integer
    return 'u002' //UNIT ID OF DUMMY UNIT//
endfunction

constant function INT_AbilityIdNoControlBuffPlacer takes nothing returns integer
    return 'A002' //ABILITY ID OF BERSERKER-NUTS BUFF ON CASTER; BASED-OFF "SPIRIT LINK"//
endfunction

constant function INT_BuffIdNoControl takes nothing returns integer
    return 'B001' //BUFF ID OF NO CONTROL BUFF//
endfunction

constant function INT_BuffIdCast takes nothing returns integer
    return 'B002' //BUFF ID OF HERO-CASTED ABILITY//
endfunction

constant function R_PercentChanceNoControl takes nothing returns real
    return 50.00 //PERCENT CHANCE TO GO BERSERK ON NEARBY DAMAGING UNIT//
endfunction

constant function R_RangeCounterAttack takes nothing returns real
    return 800.00 //RANGE OF COUNTER ATTACK IMPULSE//
endfunction

constant function STR_OrderNoControlBuffPlacer takes nothing returns string
    return "spiritlink"
endfunction
//CONSTANTS END//

function Trig_TheBeastWithin_Conditions takes nothing returns boolean
    return (OrderGetUnitAbilityId() == INT_AbilityIdCast())
endfunction

function TRIG_DamageDetectReceive_Conditions takes nothing returns boolean
    return ((GetEventDamage > 0) and
            (IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()),GetOwningPlayer(GetEventDamageSource())) and
            (GetRandomReal(0.00,R_PercentChanceNoControl())) and
            ((SquareRoot(Pow((GetUnitX(GetTriggerUnit()) - GetUnitX(GetEventDamageSource())),2) + Pow((GetUnitY(GetTriggerUnit()) - GetUnitY(GetEventDamageSource())),2))) <= R_RangeCounterAttack()))
endfunction

function TRIG_NoControlOrderBlock_Conditions takes nothing returns boolean
    return (OrderId2String(GetIssuedOrderId()) != "attack")
endfunction

function TRIG_NoControlOrderBlock_Actions takes nothing returns nothing
    call IssueImmediateOrder(GetTriggerUnit(),"stop")
endfunction

function TRIG_DamageDetectReceive_Actions takes nothing returns nothing
    local unit U_Caster = GetTriggerUnit()
    local unit U_Target = GetEventDamageSource()
    local unit U_Dummy
    local player P_OwnerCaster = GetOwningPlayer(U_Caster)
    local location LOC_CasterPoint = GetUnitLoc(U_Caster)
    local trigger TRIG_NoControlOrderBlock = CreateTrigger()
    call TriggerRegisterUnitEvent(TRIG_NoControlOrderBlock,U_Caster,EVENT_UNIT_ISSUED_ORDER)
    call TriggerAddCondition(TRIG_NoControlOrderBlock,Condition(function TRIG_NoControlOrderBlock_Conditions))
    call TriggerAddAction(TRIG_NoControlOrderBlock,function TRIG_NoControlOrderBlock_Actions)
    set U_Dummy = CreateUnitAtLoc(P_OwnerCaster, INT_UnitIdDummy(),LOC_CasterPoint,GetUnitFacing(U_Caster))
    call RemoveLocation(LOC_CasterPoint)
    call UnitAddAbility(U_Dummy,INT_AbilityIdNoControlBuffPlacer())
    call SetUnitAbilityLevel(U_Dummy,INT_AbilityIdNoControlBuffPlacer(),------MUST GET LEVEL OF "The Beast Within" OF CASTER AT TIME OF CAST----------)
    call IssueTargetOrder(U_Dummy,STR_OrderNoControlBuffPlacer(),U_Caster)
    call UnitApplyTimedLife(U_Dummy,'Atlf',3.00)
    loop
        exitwhen ((GetUnitAbilityLevel(U_Caster,INT_BuffIdNoControl())) <= 0)
        call IssueTargetOrder(U_Caster,"attack",U_Target)
        call TriggerSleepAction(0.50)
    endloop
    call DestroyTrigger(TRIG_NoControlOrderBlock)
endfunction

function Trig_TheBeastWithin_Actions takes nothing returns nothing
    local unit U_Caster = GetTriggerUnit()
    local player P_OwnerCaster = GetOwningPlayer(U_Caster)
    local integer INT_AbilityLevelCast = GetUnitAbilityLevel(U_Caster,INT_AbilityIdCast())
    local trigger TRIG_DamageDetectReceive = CreateTrigger()
    call TriggerRegisterUnitEvent(TRIG_DamageDetectReceive,U_Caster,EVENT_UNIT_DAMAGED)
    call TriggerAddCondition(TRIG_DamageDetectReceive,Condition(function TRIG_DamageDetectReceive_Conditions))
    call TriggerAddAction(TRIG_DamageDetectReceive,function TRIG_DamageDetectReceive_Actions)
    call UnitAddAbility(U_Caster,INT_AbilityIdExtraAbilities())
    call SetPlayerAbilityAvailable(P_OwnerCaster,INT_AbilityIdExtraAbilities(),FALSE)
    call SetUnitAbilityLevel(U_Caster,INT_AbilityIdExtraAbilities(),INT_AbilityLevelCast)
    loop
        exitwhen ((GetUnitAbilityLevel(U_Caster,INT_BuffIdCast())) <= 0)
        call TriggerSleepAction(0.50)
    endloop
    call UnitRemoveAbility(U_Caster,INT_AbilityIdExtraAbilities())
    call DestroyTrigger(TRIG_DamageDetectReceive)
endfunction

//==== Init Trigger TheBeastWithin ====
function InitTrig_TheBeastWithin takes nothing returns nothing
    set gg_trg_TheBeastWithin = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_TheBeastWithin,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_TheBeastWithin,Condition(function Trig_TheBeastWithin_Conditions))
    call TriggerAddAction(gg_trg_TheBeastWithin,function Trig_TheBeastWithin_Actions)
endfunction
07-04-2008, 01:10 AM#2
Switch33
Things that are weird; Booleanexpr functions (or condition functions) should be 1 line without the weird spacing(you might have done this so the forum message wouldn't be ridiculously long though.

There is a ridiculous amount of parenthesis that aren't needed like:
Collapse JASS:
return (OrderId2String(GetIssuedOrderId()) != "attack")
could easily just be:
Collapse JASS:
return OrderId2String(GetIssuedOrderId()) != "attack"

Collapse JASS:
call SetUnitAbilityLevel(U_Dummy,INT_AbilityIdNoControlBuffPlacer(),------MUST GET LEVEL OF "The Beast Within" OF CASTER AT TIME OF CAST----------)
Also just definitely looks like it might cause a crash.
07-04-2008, 01:20 AM#3
fX_
"------MUST GET LEVEL OF "The Beast Within" OF CASTER AT TIME OF CAST----------"

is a placeholder. Problem persists even when I substitute it with an O.K. value.