• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Income Triggers

Status
Not open for further replies.
It depends on the income type.
If you want to make an income with special buildings/units:
(The world editor is not open, so it isn't the perfect written trigger)
  • Events
    • Time - Every 10.00 seconds of game-time
  • Conditions
  • Actions
    • For each Integer A 1 to 12 do Actions
      • Loop - Actions
        • set IncomeInteger[IntegerA] = 0
        • set TempGroup = All units owned by Player Integer A matching unit equal to farm (example)
        • Unit Group - Pick every units in TempGroup and do Actions
          • Loop - Actions
            • set IncomeInteger[IntegerA] = IncomeInteger[IntegerA] + 1
        • Player - Add IncomeInteger[IntegerA] Gold to Player[IntegerA]
        • Game - Display to Player[IntegerA] the text (Your income: IntegerIncome)
    • call DestroyGroup(udg_TempGroup)
If you don't know the exact triggers, tell it, I will look in the editor.
 
Here are my triggers. One is a "trickle" and the other splits the empire gold among the players.

JASS:
function secondGoldA takes nothing returns nothing
    local integer index=2
    local integer gold
    loop
        exitwhen index>11
        set gold=GetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD)
        if index<7 then
            call SetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD,gold+sgSouth*10)
        else
            call SetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD,gold+sgNorth*10)
        endif
        set index=index+1
    endloop
endfunction

function InitTrig_secondGold takes nothing returns nothing
    set gg_trg_secondGold=CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_secondGold,10,true)
    call TriggerAddAction(gg_trg_secondGold,function secondGoldA)
endfunction

JASS:
function countPlayersInForce takes integer team returns integer
    local integer iReturn=0
    local integer index
    if team==0 then
        set index=2
        loop
            exitwhen index>6
            if GetPlayerSlotState(Player(index))==PLAYER_SLOT_STATE_PLAYING then
                set iReturn=iReturn+1
            endif
            set index=index+1
        endloop
    else
        set index=7
        loop
            exitwhen index>11
            if GetPlayerSlotState(Player(index))==PLAYER_SLOT_STATE_PLAYING then
                set iReturn=iReturn+1
            endif
            set index=index+1
        endloop
    endif
    return iReturn
endfunction

function empireGoldA takes nothing returns nothing
    local integer dTemp
    local integer index
    local integer gold
    call StartSound(gg_snd_Money)
    set dTemp=countPlayersInForce(0)
    set index=2
    loop
        exitwhen index>6
        set gold=GetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD)
        call SetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD,gold+GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)/dTemp)
        call DisplayTextToPlayer(Player(index),0,0,"You got |cff999900"+I2S(GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)/dTemp)+"|r from your Empire.")
        set index=index+1
    endloop
    call SetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD,0)
    set dTemp=countPlayersInForce(1)
    set index=7
    loop
        exitwhen index>11
        set gold=GetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD)
        call SetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD,gold+GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)/dTemp)
        call DisplayTextToPlayer(Player(index),0,0,"You got |cff999900"+I2S(GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)/dTemp)+"|r from your Empire.")
        set index=index+1
    endloop
    call SetPlayerState(Player(1),PLAYER_STATE_RESOURCE_GOLD,0)
endfunction

function InitTrig_empireGold takes nothing returns nothing
    set gg_trg_empireGold=CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_empireGold,180,true)
    call TriggerAddAction(gg_trg_empireGold,function empireGoldA)
endfunction
 
Status
Not open for further replies.
Top