1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Check for player's available food.

Discussion in 'Triggers & Scripts' started by xYours Trulyx, Aug 22, 2019.

  1. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    946
    Resources:
    0
    Resources:
    0
    I'm creating a custom training system that works entirely with triggers. Checking for player's food available food doesn't seem to exist in the Integer - Player Properties.

    There must be some weird math to get the player's available food, right? I tried most of the calculations but none of them seem to be working. It would work like this:

    - Player has 4 out of 10 available food.
    - Player attempts to train a unit that costs 5 food.
    - Player will get an error saying they don't have enough food.

    Thanks in advanced.
     
  2. Cespie

    Cespie

    Joined:
    May 21, 2019
    Messages:
    344
    Resources:
    0
    Resources:
    0
    It isn't clear to me what you're trying to accomplish. How exactly do you want this system to work? What makes it different from how food currently works, apart from it having to make manual workarounds for things that already work perfectly in the existing system?
     
  3. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    946
    Resources:
    0
    Resources:
    0
    I need everything to work in triggers. I'm not trying to replicate the vanilla Warcraft training system. I just need to know how their unit food cost works.
     
  4. Cespie

    Cespie

    Joined:
    May 21, 2019
    Messages:
    344
    Resources:
    0
    Resources:
    0
    Why do you need that?
    I can come up with some hacky solution to using the food resource outside of its own functionality, but it's going to be error-prone, and if you were to explain your intention, it may turn out that there's a much better approach to what you're trying to accomplish.
     
  5. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    946
    Resources:
    0
    Resources:
    0
    It's simple, but to understand it, watch this short video I made explaining how the training system works.

    Everything works perfectly, except it bypass the amount of food the player has, as you can see. All I need is for it to detect that the player has enough food to train the units.
     
  6. Wrda

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    1,100
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Are you that blind to miss this and actually test what it does?
    upload_2019-8-22_14-32-33.png

    I don't see what this does that the normal wc3 food engine doesn't, seems pointless. Maybe elaborate your idea and post triggers.
     
  7. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    946
    Resources:
    0
    Resources:
    0
    Hmm. I'll test that one out immediately.

    And I told you, everything works in triggers. What you tried to point out is the vanilla War3 food engine for its training system. I put the [ Trigger ] in the title for a reason.
     
  8. Wrda

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    1,100
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Also In [Triggers & Scripts] rules they also tell you to post triggers if you need help for a reason.
     
    Last edited: Aug 22, 2019
  9. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,905
    Resources:
    1
    Spells:
    1
    Resources:
    1
    As Wrda showed it's still there under Player - Property.
    • Set TrainPlayer = (Triggering Player) //or whatever
    • Set FoodCost = 5 //or whatever
    • Set FoodUsed = (TrainPlayer Food Used)
    • Set FoodCap = (TrainPlayer Food Cap) //Max is the max food any player COULD have in your map, cap is the current maximum for the player
    • Set CanTrain = ((FoodCap - FoodUsed) greater than FoodCost)
     
    Last edited: Aug 23, 2019
  10. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    946
    Resources:
    0
    Resources:
    0
    That's much more understandable. Thanks. Solved