1. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  2. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  3. We have a new contest going on right now! Join the 11th Music Contest! You are to make a Cinematic modern sound-track for this contest, so come and compete with other people for fun.
    Dismiss Notice

[Trigger] Add trained hero to unit group don't work

Discussion in 'Triggers & Scripts' started by Sxar, Jan 11, 2019.

  1. Sxar

    Sxar

    Joined:
    Aug 20, 2014
    Messages:
    222
    Resources:
    3
    Models:
    2
    Skins:
    1
    Resources:
    3
    I have been working on this code all the night. I already tryed to solve the inssue by myself before post here. The problem is that the code don't add the unit to unit group. I don't know why.


    Code (Text):
    function Trig_BladeMasterSet_Conditions takes nothing returns boolean
        if ( not ( IsUnitType(GetTrainedUnit(), UNIT_TYPE_HERO) == true ) ) then
            return false
        endif
        return true
    endfunction

    function Trig_BladeMasterSet_Func007C takes nothing returns boolean
        if ( not ( 'Obla' == GetUnitTypeId(GetTrainedUnit()) ) ) then
            return false
        endif
        return true
    endfunction

    function Trig_BladeMasterSet_Actions takes nothing returns nothing
        set udg_DemonNumber = 1
        call GroupAddUnitSimple( GetTrainedUnit(), udg_BlademasterDeathlist[2] )
        call GroupAddUnitSimple( GetTrainedUnit(), udg_BlademasterDeathlist[1] )
        call GroupAddUnitSimple( GetTrainedUnit(), udg_BlademasterDeathlist[3] )
        call GroupAddUnitSimple( GetTrainedUnit(), udg_BlademasterDeathlist[4] )
        if ( Trig_BladeMasterSet_Func007C() ) then
            set udg_BlademasterCounter = ( udg_BlademasterCounter + 1 )
            set udg_Blademaster[udg_BlademasterCounter] = GetTrainedUnit()
            set udg_BlademasterOwner[udg_BlademasterCounter] = GetOwningPlayer(GetTrainedUnit())
        else
        endif
    endfunction

    //===========================================================================
    function InitTrig_BladeMasterSet takes nothing returns nothing
        set gg_trg_BladeMasterSet = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_BladeMasterSet, EVENT_PLAYER_UNIT_TRAIN_FINISH )
        call TriggerAddCondition( gg_trg_BladeMasterSet, Condition( function Trig_BladeMasterSet_Conditions ) )
        call TriggerAddAction( gg_trg_BladeMasterSet, function Trig_BladeMasterSet_Actions )
    endfunction

     
     
  2. Sxar

    Sxar

    Joined:
    Aug 20, 2014
    Messages:
    222
    Resources:
    3
    Models:
    2
    Skins:
    1
    Resources:
    3
    As you can see there are four unit groups (bleadmasterdeathlist) that must add the created hero but I don't know why it don't work. orz
     
  3. Sxar

    Sxar

    Joined:
    Aug 20, 2014
    Messages:
    222
    Resources:
    3
    Models:
    2
    Skins:
    1
    Resources:
    3
    I know the conditions are fullfilled because "demonnumber" variable is a flag that I'm using for debug, however the unitgroup function is not working orz
     
  4. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    5,821
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
  5. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    24,933
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Unit groups are complex objects while the group variables are references to a unit group object. One has to make sure that a group variable or array references an existing unit group object for one to be able to add, remove or iterate units with it.