Hero related triggers causing fatal errors

Cal1991

New Member
Reaction score
7
Ok, I am horrible with jass, so bear with my GUI-coverted triggers.
--

As far as I know, this trigger never used to cuase any errors, but with the latest verson of the map it cuases a fatal error nearly every time.

All that has been added in the more recent version are a bunch of computer AI related triggers, and I can't see how any of them could possibly conflict with this trigger.

Anyway, here is the trigger, anyone see something in it that could cuase a fatal error?

Code:
function Trig_Retire_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'ANtm' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Retire_Actions takes nothing returns nothing
    local unit a
    local player p 
    set p = GetOwningPlayer(GetSpellTargetUnit())
    set a = GetSpellTargetUnit()
    call UnitRemoveAbilityBJ( 'AInv', a )
    call UnitRemoveAbilityBJ( 'A00K', a )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 12
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if p == udg_Player[GetForLoopIndexA()] then
            set udg_Numb[1] = GetUnitUserData(a)
            call AdjustPlayerStateBJ( udg_Numb[1], udg_Player[GetForLoopIndexA()], PLAYER_STATE_RESOURCE_GOLD )
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call PolledWait( 3.00 )
    call RemoveUnit( a )
    call PolledWait( 1.00 )
    set p = null
    set a = null
endfunction
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Why is it in JASS? Did you convert it to JASS from GUI?
If you have the GUI triggers, you should post them, instead.
 

Chocobo

White-Flower
Reaction score
409
Code:
function Trig_Retire_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='ANtm' then
endfunction

function Trig_Retire_Actions takes nothing returns nothing
    local unit a=GetTriggerUnit()
    local player p=GetOwningPlayer(a)
    local integer i=1
    call UnitRemoveAbility(a,'AInv')
    call UnitRemoveAbility(a,'A00K')
    loop
        exitwhen i>12
        if p == udg_Player[i] then
            set udg_Numb[1]=GetUnitUserData(a)
            call SetPlayerState(udg_Player[i],ConvertPlayerState(1),GetPlayerState(udg_Player[i],ConvertPlayerState(1))+udg_Numb[1])
        else
        endif
        set i=i+1
    endloop
    call PolledWait(3.0)
    call RemoveUnit(a)
    call PolledWait(1.0)
    set p=null
    set a=null
endfunction

No idea if they may work. No idea why it crashes, it may be simply because you are removing the hero inventory. ('AInv')
 

Evan1993

Ultra Cool Member
Reaction score
30
No. I'm working on the map with him, and its changing the custom value that makes it crash. It crashes every time we change the custom value of any unit that belongs to the AI.

All of our other triggers that change the custom value of a AI unit crash too.
 

Cal1991

New Member
Reaction score
7
Why is it in JASS? Did you convert it to JASS from GUI?
If you have the GUI triggers, you should post them, instead.

Heh, I may suck at JASS but it's still easier to convert it when I need to use locals.
If you are just wondering what the trigger is supposed to do, it is this:
When a player uses the Retire hero ability(based off of transmute) on one of thier heros, it gives them gold equal to the cost to build the hero + the heros custom value. (the custom value keeps track of the cost of the abilitys/tomes the hero has bought)
The the hero is removed so they can't revive it and re-sell it.

Anyway, after testing it for a while I've come to the same conclusion as Evan: the custom values are to blame.
Why it didn't cuase a fatal error before is still beyond me, but I do know it cuases no error if I get rid of the custom value parts.
 

Sooda

Diversity enchants
Reaction score
318
Code:
function Trig_Retire_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='ANtm' then
endfunction

function Trig_Retire_Actions takes nothing returns nothing
    local unit a=GetTriggerUnit()
    local player p=GetOwningPlayer(a)
    local integer i=1
    call UnitRemoveAbility(a,'AInv')
    call UnitRemoveAbility(a,'A00K')
    loop
        exitwhen i>12
        if p == udg_Player[i] then
            set udg_Numb[1]=GetUnitUserData(a)
            call SetPlayerState(udg_Player[i],ConvertPlayerState(1),GetPlayerState(udg_Player[i],ConvertPlayerState(1))+udg_Numb[1])
       exitwhen true
        endif
        set i=i+1
    endloop
    call PolledWait(3.0)
    call RemoveUnit(a)
    call PolledWait(1.0)
    set p=null
    set a=null
endfunction
There isn' t need for else if there isn' t nothing to do also when right player is found no point to loop on we could just end loop. If really custom value makes it crash try to set it 0 before removing unit. Otherway I suspect your removing trigger may cause it.
 

Cal1991

New Member
Reaction score
7
The else isn't needed, ok, but it shouldn't be cuasing any errors ethier.


I tested some more and I found that both the retire trigger AND the swap exp were fatal erroring now when they used to work perfectly.
And I found out when I disabled Evans Launch Attack trigger for the AI we are working on, both the triggers worked perfectly without fatal erroring.

Thus I'm thinking the problem is related to his trigger which I had nothing to do with:

Code:
function IsBad takes nothing returns boolean
    return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), ConvertedPlayer(udg_Numb[1])) == true )
endfunction
function IsGood takes nothing returns boolean
    return ( IsPlayerAlly(GetTriggerPlayer(), ConvertedPlayer(udg_Numb[1])) == true )
endfunction

function Attack takes nothing returns nothing
    call IssuePointOrderLocBJ( GetEnumUnit(), "attack", udg_Point )
endfunction
function Noworkers takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) != 'uaco' ) and GetUnitStateSwap(UNIT_STATE_LIFE, GetFilterUnit()) >= 10 
endfunction
function Trig_LaunchAttacks_Actions takes nothing returns nothing
    local location array l
    local integer i = GetRandomInt(1, 5)
    local integer start = 1
    local integer end = 12
    local boolean stop
    local integer count = 0
    local group a
    local group e
    set l[1] = GetPlayerStartLocationLoc(Player(0))
    set l[2] = GetPlayerStartLocationLoc(Player(3))
    set l[3] = GetPlayerStartLocationLoc(Player(6))
    set l[4] = GetPlayerStartLocationLoc(Player(9))
    set l[5] = GetRectCenter(gg_rct_Region_001)
    loop
        exitwhen start > end
        set start = start + 1
        set udg_Spawns[start] = GetUnitsOfPlayerMatching(ConvertedPlayer(start), Condition(function Noworkers))
        loop
            set udg_Numb[1] = start
            set e = GetUnitsInRangeOfLocAll(655.0, l[i]) 
            call PolledWait(2.0)
            if CountUnitsInGroup(GetUnitsInRangeOfLocMatching(655.0, l[i], Condition(function IsBad) )) == 0 then
                set i = GetRandomInt(1, 5)
                set stop = false
            else
                set stop = true
            endif
            exitwhen stop == true
        endloop
        set udg_Point = l[i]
        call ForGroupBJ( udg_Spawns[start], function Attack )
    endloop
endfunction

//===========================================================================
function InitTrig_LaunchAttacks takes nothing returns nothing
    set gg_trg_LaunchAttacks = CreateTrigger(  )
    call TriggerAddAction( gg_trg_LaunchAttacks, function Trig_LaunchAttacks_Actions )
endfunction

:rolleyes: The plot thickens. But I still don't see why Evans trigger could cuase the other two to fatal error. This is the swap exp one in GUI:
Code:
Exp Transfer
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Chain Lightning (item)
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Owner of (Casting unit)) controller) Equal to Computer
            Then - Actions
                Skip remaining actions
            Else - Actions
                Do nothing
        Set TempUnit = (Casting unit)
        Set TempTarget = (Target unit of ability being cast)
        Item - Remove (Item carried by TempUnit of type Mind Swap)
        Set Numb[1] = (Hero experience of TempUnit)
        Set Numb[2] = (Hero experience of TempTarget)
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (TempTarget is in HeroTechGroup[(Integer A)]) Equal to True
                    Then - Actions
                        Set Numb[3] = (Integer A)
                    Else - Actions
                        Do nothing
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (TempTarget is in TechieGroup[(Integer A)]) Equal to True
                    Then - Actions
                        Set Numb[3] = 4
                    Else - Actions
                        Do nothing
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (TempUnit is in HeroTechGroup[(Integer A)]) Equal to True
                    Then - Actions
                        Set Numb[4] = (Integer A)
                    Else - Actions
                        Do nothing
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (TempUnit is in TechieGroup[(Integer A)]) Equal to True
                    Then - Actions
                        Set Numb[4] = 4
                    Else - Actions
                        Do nothing
        Set Numb[5] = (Abs((Numb[3] - Numb[4])))
        Set Numb[6] = (Numb[1] / 100)
        Set Numb[7] = (Numb[2] / 100)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Numb[5] Equal to 0
            Then - Actions
                Set Numb[6] = 0
                Set Numb[7] = 0
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Numb[5] Equal to 1
                    Then - Actions
                        Set Numb[6] = (Numb[6] x 15)
                        Set Numb[7] = (Numb[7] x 15)
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Numb[5] Equal to 2
                            Then - Actions
                                Set Numb[6] = (Numb[6] x 30)
                                Set Numb[7] = (Numb[7] x 30)
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Numb[5] Equal to 3
                                    Then - Actions
                                        Set Numb[6] = (Numb[6] x 45)
                                        Set Numb[7] = (Numb[7] x 45)
                                    Else - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                Numb[5] Equal to 4
                                            Then - Actions
                                                Set Numb[6] = (Numb[6] x 60)
                                                Set Numb[7] = (Numb[7] x 60)
                                            Else - Actions
                                                Do nothing
        Set Numb[1] = (Numb[1] - Numb[6])
        Set Numb[2] = (Numb[2] - Numb[7])
        Hero - Set TempUnit Hero-level to 1, Hide level-up graphics
        Hero - Set TempTarget Hero-level to 1, Hide level-up graphics
        Hero - Add Numb[1] experience to TempTarget, Show level-up graphics
        Hero - Add Numb[2] experience to TempUnit, Show level-up graphics
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (TempTarget is in TechieGroup[(Integer A)]) Equal to True
                    Then - Actions
                        Unit Group - Pick every unit in TechieGroup[(Integer A)] and do (Actions)
                            Loop - Actions
                                Hero - Set (Picked unit) Hero-level to 1, Hide level-up graphics
                                Hero - Add Numb[1] experience to (Picked unit), Show level-up graphics
                    Else - Actions
                        Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (TempUnit is in TechieGroup[(Integer A)]) Equal to True
                    Then - Actions
                        Unit Group - Pick every unit in TechieGroup[(Integer A)] and do (Actions)
                            Loop - Actions
                                Hero - Set (Picked unit) Hero-level to 1, Hide level-up graphics
                                Hero - Add Numb[2] experience to (Picked unit), Show level-up graphics
                    Else - Actions
                        Do nothing

I don't feel like explaining what it does so I'll just copy the description off the item:
This item switches the experience of two heros owned by you when used. The greater the difference in tech level the more exp is lost.
Same tech level heros = No exp lost.
Tech level difference of 1: 15% lost.
Tech level difference of 2 levels: 30% lost.
Tech level difference of 3 levels: 45% lost.
Tech level difference of 4 levels: 60% lost.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top