• 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] Farm system

Status
Not open for further replies.
Level 15
Joined
Jan 27, 2007
Messages
948
hello, i would like to know how to make a farm system, i mean,

you build a plant - I know how to make this
you wait - I know how to make this
then the plant grow some berrys(in the plant inventory) -I DONT know how to make this
then u pick them up - I know how to make this
and then u eat them - I know how to make this

also how to cook, like:

you pick up some flour - I know how to make this
then u put it in the bakery togheter with water - I know how to make this
and press an ability to cook both into 1 -I DONT know how to make this
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Assumed that the plant grow berries in specific intervals?

The simplest way would be to add the plant in a unit group once it has been finished contructing.
Then you have another trigger with a periodic event, picking every unit in the group adding berries to it (conditions are here as well). Like the trigger below:

  • BerryProduction
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Plants and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of items carried by (Picked unit)) Less than 6
                • Then - Actions
                  • Hero - Create Shimmerweed and give it to (Picked unit)
                • Else - Actions
            • Else - Actions
              • Unit Group - Remove (Picked unit) from Plants
The next one is not that evil either. Basically we check if you have both of the ingredients in the inventory when you use the ability:

  • Cooking
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Cook
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Greater Replenishment Potion) Equal to True
          • ((Triggering unit) has an item of type Essence of Aszune) Equal to True
        • Then - Actions
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Greater Replenishment Potion
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                  • Custom script: set bj_forLoopAIndex = 6
                • Else - Actions
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Essence of Aszune
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                  • Custom script: set bj_forLoopAIndex = 6
                • Else - Actions
          • Hero - Create Keg of Ale and give it to (Triggering unit)
        • Else - Actions
          • Set temp_PlayerGroup = (Player group((Owner of (Triggering unit))))
          • Game - Display to temp_PlayerGroup the text: You cannot cook yet...
          • Custom script: call DestroyForce( udg_temp_PlayerGroup )
If you are confused about the two loops they are there to check, first where the first ingredient are, removing it, setting the loopindex to 6 (prevents the loop from checking more slots since it already removed the item), then checking for the second ingredient.

It should work.
~Eccho~
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Nono, you got that on the wrong foot. You see, if the structure is dying it must be removed from the unit group. Check the condition, if it's alive (and then if the slot is not full), then give it a berry, otherwise remove the unit from the group, since it shouldn't try to create any berry once it's destroyed :)
 
Level 15
Joined
Jan 27, 2007
Messages
948
hey man, i've found a bug :p

when i try to cook it, it gets cooked, but only one ingredient gets removed, the other one keeps there :p

EDIT

Someone already fixed it for me :p

the problem was that if it found flour or water, it stoped the trigger. so instead of putting it at "then actions - " i've putted it as another if then else.

thanks anyway for the main trigger :)
 
Status
Not open for further replies.
Top