• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[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.
 

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,509
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