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

Resource generating building

Status
Not open for further replies.
Level 12
Joined
Jun 1, 2010
Messages
748
In my type of map, peasants should not gather lumber or gold, but instead, resources generate from a building, the Lumber Mill and Gold Mine. How can I make Lumber Mill and Gold mine generate resources without peasant harvesting. To do that, I need a trigger. It is like, I need it like this (EVENT-every 20 seconds, CONDITION-if Lumber Mill exists and is owned by Player 3, ACTION- Add property, add 100 lumber to Player 3).

How do I make the condition?
 
Level 8
Joined
Jan 8, 2010
Messages
493
  • Events
    • Time - Every 20.00 seconds of game time
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 12, do (Actions)
      • Loop - Actions
        • Custom script: set bj_wantDestroyGroup=true
        • Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Lumbermill) and do (Actions)
          • Loop - Actions
            • Player - Add 100 to (Player((Integer A))) Current lumber
you don't really need a condition. you just have to pick how many Lumbermills the player has. if he has at least one, the trigger will add 100 lumber with every Lumbermill. if the player has none, then nothing will be added.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Pick Every units of Type leaks. It's not solved with "set bj_wantDestroyGroup = true". I think you need to use "call DestroyGroup(sourceGroup)" or something like that.

"Get Units of Type" is
JASS:
function GetUnitsOfTypeIdAll takes integer unitid returns group
    local group   result = CreateGroup()
    local group   g      = CreateGroup()
    local integer index

    set index = 0
    loop
        set bj_groupEnumTypeId = unitid
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call GroupAddGroup(g, result)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)

    return result
endfunction

And "GroupAddGroup" is

JASS:
function GroupAddGroup takes group sourceGroup, group destGroup returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupAddGroupDest = destGroup
    call ForGroup(sourceGroup, function GroupAddGroupEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(sourceGroup)
    endif
endfunction

I'm not sure how to use/make it though.
 
Status
Not open for further replies.
Top