• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Preventing Air Units from Accessing Shops

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
I don't think you can disable it. A workaround that comes to mind:
When you purchase a unit check to see if the owner of the purchased unit has at least 1 eligible buyer (in this case a Ground unit) within range of the Mercenary Camp. If the player doesn't, remove the purchased unit and refund the gold/lumber spent. You'll probably have to adjust the Stock of the Mercenary Camp in order to add the unit back to it.

And for your advanced system you could make "key" items that unlock the shop. Give them an activate-able ability. Then detect when a unit uses the "key" item and check to see if it's near a Mercenary Camp. If it is, you can allow access to that Mercenary Camp and remove the "key" item. You could also use charges to make the "keys" stack and add/remove them accordingly.

I would use a Unit Indexer to keep track of these things as it allows you store information to individual units. So you'd have variables like "UnitsAvailable[MercCamp1]" which would be an Integer. Then when you use a "key" near MercCamp1 you increase this Integer by 1. And when you purchase a unit you can subtract 1 from UnitsAvailable[MercCamp1]. And if UnitsAvailable for that Merc Camp is equal to 0 then you simply refund the unit after it's purchased since.

However, if your map is singleplayer only then you have a lot more freedom.

You could instead remove the "Select Unit" ability from the Mercenary Camp until an eligible unit comes within range of it. This could be done easily with regions. "A unit enters Merc Camp Region 1 -> If it's a Ground Unit -> Add ability "Sell Units" to Merc Camp 1" then have another trigger to detect when a unit leaves the Merc Camp Region and check to see if there are no more eligible units nearby. If there aren't any then remove the "Sell Units" ability from it.
You might have to add some more conditions like "Owner of triggering unit equal to Player 1"
  • Enter
    • Events
      • Unit - A unit enters (Merc Camp Region)
    • Conditions
      • ((Triggering unit) is alive) Equal to True
      • ((Triggering unit) is A ground unit) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Sell Units for (Merc Camp) Equal to 0
        • Then - Actions
          • Unit - Add Sell Units to (Merc Camp)
        • Else - Actions
  • Leave
    • Events
      • Unit - A unit leaves (Merc Camp Region)
    • Conditions
    • Actions
      • Set TargetFound = False
      • -------- - --------
      • Unit Group - Pick every unit in (Units within 450.00 of (Merc Camp Region) 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
              • ((Picked unit) is A ground unit) Equal to True
            • Then - Actions
              • Set TargetFound = True
            • Else - Actions
      • -------- - --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TargetFound Equal to False
        • Then - Actions
          • Unit - Remove Sell Units from (Merc Camp)
        • Else - Actions

I can create a system for you but I need to know if it's Singleplayer Only or for Multiple Players.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
So I was hopeful that I could get this system to work well but Warcraft 3 has too many limitations and bugs to do so.

Regardless, I managed to piece together a somewhat working system.

Pros:
1) Air units cannot purchase mercenaries

2) You can make any Shop require a "Key" in order to purchase a mercenary from it. You get 1 use per key. (I can modify the key stuff. I wasn't sure how you wanted it to work exactly)

3) Each "Locked" Shop will track it's own Key uses. So when you use a Key on a Shop you only unlock that specific Shop, not ALL Shops of it's type.

Cons:
1) Stock Start Delay does work in delaying the units from being purchased, however the Cooldown doesn't display. Instead, the units are missing until the delay is up.

2) Stock Replenish Interval has a similar problem. You can sort of work around it though. This is hard to explain but in the Object Editor you can change the Stock Replenish Interval for your Mercenaries and it will work. But it MUST be set to at a minimum 1 second longer than whatever you set it as in the Configuration Trigger. This "fix" will make the Cooldown visual display when the Mercenary is out of stock although it'll be 1 second off (The longer the cooldown the less noticeable it becomes). This is because I use triggers for Stock Replenish/Stock Delay instead of the standard hardcoded way and as long as the Trigger happens BEFORE the hardcoded method it won't cause any problems.

3) Hotkeys stop working because Warcraft 3 limitations. Apparently adding a unit to a Neutral Building via triggers just breaks the game.

4) The sound of a unit being purchased plays even if it failed to purchase.

I wouldn't blame you if you didn't want to use this in your map, the Stock Delay/Replenish issues and lack of hotkeys is pretty annoying. Anyway, fingers crossed that Reforged fixes some of these issues.
 

Attachments

  • Merc Camps v.3.w3x
    32.4 KB · Views: 28
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Is the map singleplayer or multiplayer? Because that changes everything. Pausing the Shop would make it unusable by all players.

Also, when pausing/unpausing buildings I've run into problems before. This might not apply here but try ordering the Building to issue a "Stop" order right before Pausing it.

Edit: I sent you a friend request on Discord. Names Uncle.
 
Last edited:
Level 4
Joined
Jan 9, 2019
Messages
70
Erm, Isn't more easly make the select ability of the shop unable to target air units? I still using an old version of Warcraft 3, so, I don't know if this was changed, but is fair more easly instead to make that!
 
Level 6
Joined
Oct 25, 2010
Messages
203
Isn't more easly make the select ability of the shop unable to target air units?

that was my original plan, but i wanted to take it one step further and require players to collect an item which is used to unlock the shops before items can be purchased, that way it doesnt matter if its an air unit or not.

I actually chose a dumb title when I created this thread lol, cuz I should have said "how to lock/unlock shops with items" or something but I didnt think of the item thing until after talking to Uncle, originally I was using a stupid elevator trigger which was not very good lol

either way... Uncle was incredibly helpful and created a very complex set of triggers for me which work amazingly :)

thanks!
 
Status
Not open for further replies.
Top