• 🏆 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!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

[JASS] trigger don't work and I try hard but till it don't work :vw_wtf:

Status
Not open for further replies.
Level 2
Joined
Feb 4, 2014
Messages
8
sorry but i try work on it for 3 days
the trigger is: add gold (G) base on time and item. (10 G per 10 S) is the base and extra G if hero/unit have item that add G.

if there are any leak plz tell me too

JASS:
function Unit_Own_By_Player1_And_Hero takes nothing returns boolean
    local unit NextUnit = GetEnumUnit()
    local player NextPlayer = GetOwningPlayer(NextUnit)
    if ( not ( IsUnitType(NextUnit , UNIT_TYPE_HERO) == true ) ) then
        set NextUnit = null
        set NextPlayer = null
        return false
    endif
    if ( not ( NextPlayer == Player(0) ) ) then
        set NextUnit = null
        set NextPlayer = null
        return false
    endif
    set NextUnit = null
    set NextPlayer = null
    return true
endfunction

function Add_Unit_To_Group_Player1 takes nothing returns nothing
    local unit NextUnit = GetEnumUnit()
    if ( Unit_Own_By_Player1_And_Hero() ) then
        call GroupAddUnitSimple( NextUnit, udg_Player1UnitGroup )
    endif
    set NextUnit = null
endfunction

function Run_Main_Function_Money_For_Player1 takes nothing returns nothing
    local integer A = 1
    local integer B = 1
    local integer A1 = 6
    local integer B1 = 17
    local unit NextUnit = GetEnumUnit()

    loop
        exitwhen A > A1
        loop
            exitwhen B > B1
            if (GetItemTypeId(UnitItemInSlotBJ(NextUnit, A)) == udg_CheckItem[B]) then
                set udg_Player1MoneyInteval = udg_Player1MoneyInteval + udg_CheckItemReturnReal[B]
            endif
            set B = B + 1
        endloop
        set A = A + 1
    endloop
    set NextUnit = null
endfunction

function Trig_MoneyPlayer1_Actions takes nothing returns nothing
    local integer A = 1
    local real WaitTimeMoneyPlayer1 = 0.000

    set udg_AllMapRegon = GetPlayableMapRect()

    set udg_CheckItem[ 1] = 'I009'
    set udg_CheckItemReturnReal[ 1] = 3.000
    set udg_CheckItem[ 2] = 'I09F'
    set udg_CheckItemReturnReal[ 2] = 3.000
    set udg_CheckItem[ 3] = 'I012'
    set udg_CheckItemReturnReal[ 3] = 4.000
    set udg_CheckItem[ 4] = 'I01E'
    set udg_CheckItemReturnReal[ 4] = 4.000
    set udg_CheckItem[ 5] = 'I01H'
    set udg_CheckItemReturnReal[ 5] = 4.000

    set udg_CheckItem[ 6] = 'I01I'
    set udg_CheckItemReturnReal[ 6] = 4.000
    set udg_CheckItem[ 7] = 'I01J'
    set udg_CheckItemReturnReal[ 7] = 4.000
    set udg_CheckItem[ 8] = 'I01K'
    set udg_CheckItemReturnReal[ 8] = 4.000
    set udg_CheckItem[ 9] = 'I01M'
    set udg_CheckItemReturnReal[ 9] = 4.000
    set udg_CheckItem[10] = 'I01N'
    set udg_CheckItemReturnReal[10] = 4.000

    set udg_CheckItem[11] = 'I01O'
    set udg_CheckItemReturnReal[11] = 4.000
    set udg_CheckItem[12] = 'I013'
    set udg_CheckItemReturnReal[12] = 4.000
    set udg_CheckItem[13] = 'I07Y'
    set udg_CheckItemReturnReal[13] = 4.000
    set udg_CheckItem[14] = 'I07Z'
    set udg_CheckItemReturnReal[14] = 4.000
    set udg_CheckItem[15] = 'I080'
    set udg_CheckItemReturnReal[15] = 4.000

    set udg_CheckItem[16] = 'I081'
    set udg_CheckItemReturnReal[16] = 4.000
    set udg_CheckItem[17] = 'I01P'
    set udg_CheckItemReturnReal[17] = 4.000

    loop
        exitwhen A == 2
        
        call GroupClear( udg_Player1UnitGroup )
        call GroupClear( udg_AllUnitInMapForMoney )

        set udg_Player1MoneyInteval = 10.000

// All about work

        set udg_AllUnitInMapForMoney = GetUnitsInRectAll(udg_AllMapRegon)
        call ForGroupBJ( udg_AllUnitInMapForMoney, function Add_Unit_To_Group_Player1 )
        call ForGroupBJ( udg_Player1UnitGroup, function Run_Main_Function_Money_For_Player1 )

        set WaitTimeMoneyPlayer1 = 10.000 / udg_Player1MoneyInteval

        call GroupClear( udg_AllUnitInMapForMoney )
        call GroupClear( udg_Player1UnitGroup )

        call DisplayTimedTextToForce( bj_FORCE_PLAYER[0], 30, R2S(udg_Player1MoneyInteval) )

        call PolledWait(WaitTimeMoneyPlayer1)
        call AdjustPlayerStateBJ( 1, Player(0), PLAYER_STATE_RESOURCE_GOLD )
    endloop

endfunction

//===========================================================================
function InitTrig_MoneyPlayer1 takes nothing returns nothing
    set gg_trg_MoneyPlayer1 = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_MoneyPlayer1, 20.00 )
    call TriggerAddAction( gg_trg_MoneyPlayer1, function Trig_MoneyPlayer1_Actions )
endfunction

I will attach the map too
 

Attachments

  • MapNew.w3x
    1.5 MB · Views: 40
Status
Not open for further replies.
Top