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

Consuming food.

Status
Not open for further replies.
Level 8
Joined
Feb 20, 2007
Messages
338
I have a method to create more food, as long as the farmers farm food comes in.

Now I need a system to consume food.

I can not figure out how to count all of the living units owned by a player that are not buildings or are not mechanical and remove 1 food per 'live' unit every game night (6:00 pm game time).

Any ideas on a simple GUI (not jass) trigger that would do this?
 
I think you could make a trigger with a variable where it picks every unit in a player owns and does an If Conditions (Picked unit is not mechanical and Picked unit is not a structure [boolean conditions I believe]), Then (Set Variable "Food Count" [integer variable] = Food Count + 1), Else Do Nothing. Then make an action that removes whatever food count's number was worth of food for the player. Then make it set Food Count back to zero and repeat for each player (You might need to do a For Loop Integer (1-12) type thing for that). I'll give you a sample trigger later if I have time :D. Btw plz give me rep!
 
Last edited:
Level 18
Joined
Aug 23, 2008
Messages
2,319
I'm not entirely sure if that'll work, BlueBerryWizard. You'll still pick all units by the player, and not just the non-mech/non-building.

I don't have WE here, so I can't say for sure, but maybe you could try (if possible) to:
  • Actions
    • Unit - Pick every unit owned by Player 1 and do (Actions):
      • Unit - Pick every unit of classification (<everything except building and mechanical>) and do (Actions):
        • Player - Set Food for Player 1 (Red) to (current Food - (Count Picked units in Playable map area))
 
Level 8
Joined
Feb 20, 2007
Messages
338
Yeah I know that one can pick units by classification and type.

The remove food though by number of units (live ones) appears to stymie me.

One can ADD properties or by use of the subtract sign (-) remove properties. I am at a loss how to turn the number of units into a real number that I can subtract from food.

I have been trying different things but it appears I end up having more food than I can possibly generate with my farmers - something somewhere is not adding up - or actually it is, its just not being subtracted.

I tried this:

  • Food EAT
    • Events
      • Game - The in-game time of day becomes Equal to 12.00
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) matching ((((Matching unit) is A structure) Equal to False) or (((Matching unit) is Mechanical) Equal to False))) and do (Player - Add -1 to Player 9 (Gray) Food cap)
But when 12:00 is reached I end up with 42 thousand food (more, just rounding if off).
 
Level 8
Joined
Feb 20, 2007
Messages
338
Where do you get 42k food from?

I don't know.

I harvest 10 crops have three units stopping the units from harvesting so I have 3 food used, 10 food cap. come 12:00 food cap jumps to 42,000 (plus) food -its an odd number not a flat 42,000.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Maybe that's the game's max food cap. Just like the max map area in WE. You probably made a trigger somewhere that adds food cap or activates when a new day dawns. I suggest you find all triggers containing either of these 2, and post them here. There could be a bug in them that causes infinite food cap increasement.
 
Level 8
Joined
Feb 20, 2007
Messages
338
erm y not use the add function first instead of selecting the no of units since it doesnt match the end part of your trigger....
in other words try my trigger i told you about

You said:

" i believe there is something like
event- game time becomes 600hours
action- add (no. of living unit owned by (player) x -1) to (player) current food used"


So your saying I have no other choice but to make a trigger statement for each kind of 'living' (non-building, non-mechanical) unit for each team.

As in:

  • Player - Add ((Number of living Footman units owned by Player 1 (Red)) x -1) to Player 9 (Gray) Food cap
 
Level 8
Joined
Feb 20, 2007
Messages
338
Maybe that's the game's max food cap. Just like the max map area in WE. You probably made a trigger somewhere that adds food cap or activates when a new day dawns. I suggest you find all triggers containing either of these 2, and post them here. There could be a bug in them that causes infinite food cap increasement.

Nope. This is the only trigger that activates at 12:00.

The other is this:

  • Growing Corn
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Corn -temp
        • Then - Actions
          • Unit - Replace (Dying unit) with a Corn new using The new unit's max life and mana
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Corn new
        • Then - Actions
          • Set Crop2 = (Position of (Dying unit))
          • Unit - Replace (Dying unit) with a Corn ready for harvest using The new unit's max life and mana
          • Unit - Set life of (Last replaced unit) to 10.00
          • Custom script: call RemoveLocation( udg_Crop2 )
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Corn ready for harvest
          • ((Killing unit) belongs to an ally of (Owner of (Dying unit))) Equal to True
        • Then - Actions
          • Player - Add 1 to (Owner of (Killing unit)) Food cap
        • Else - Actions
Corn is a special unit coming in three (4) parts. Earlier 'smaller' growing corn has a negative HP regen - meaning as time wears on it loses hit points until it dies. Once it dies it is replaced by a taller more advanced kind of corn - until it reached 'corn Ready for Harvest'.

I have two villager type units both with one ability/spell. the males have a spell I call 'harvest crops' the female has 'plant crops'.

Those spells are regulated by the following trigger:

  • Plant and Harvest
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Harvest Crops
        • Then - Actions
          • Unit - Order (Casting unit) to Attack (Random unit from (Units owned by (Owner of (Casting unit)) of type Corn ready for harvest))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Plant Crops
          • ((Owner of (Casting unit)) Current gold) Greater than or equal to 10
        • Then - Actions
          • Set Crop1 = (Position of (Random unit from (Units owned by (Owner of (Casting unit)) of type Corn ready for harvest)))
          • Unit - Order (Casting unit) to Move To Crop1
          • Player - Add -1 to (Owner of (Casting unit)) Current gold
          • Unit - Create 1 Corn new for (Owner of (Casting unit)) at Crop1 facing (Random angle) degrees
          • Custom script: call RemoveLocation( udg_Crop1 )
        • Else - Actions
What ends up happening in the game a small corn unit 'seed' is 'planted' by the female farmer - this is an auto cast type spell regulated in part by the trigger and in part by the amount of mana she has. she goes to the location of units that are ready for harvest and plants the 'seed' corn. That starts to grow. The male meanwhile goes from corn ready for harvest and attacks, kills the unit and is rewarded one food cap per kill.

For the player they see the crops 'grow' over time. Since I used a doodad model for a unit that had no death sequence or other sequences I stuck with multiple versions. For some odd reason using a trigger to increase the size of one corn resulted in the model vanishing, becoming invisible. I was told by a modeler here or on a another WCIII site that the 'around' to that was consecutive versions.

During my test of 'Food Eat' I stopped both the planter and the harvester in a controlled area of my map. There was no corn ready for harvest standing, I had 'hand planted' 10 corn (without using the autocast spell) harvested them to give me 10 food cap.

When 12:00 rolled around all of my units were just standing around, there was no corn growing or being harvested - there was nothing increasing or decreasing the food cap except the Food Eat trigger.
 
Status
Not open for further replies.
Top