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

Unit sold unavailable for training/construction by all players

Status
Not open for further replies.
Level 2
Joined
Sep 23, 2013
Messages
18
Hi, I've been searching and been doing all that seems to be the suggestion of each post I've been in but sadly it still doesn't work for me. I am unsure at what the problem is, or if there is a better solution to what I'm doing and what the name of that solution is.

I have set-up multiple barracks on the map owned by player2(computer).
The barracks sells the unit footman.
The goal is, a hero/unit is in range of any of the barracks and buys the footman. Footmen starts spawning at the base of the barracks towards the enemy. I have got this part down and it is working. The sad thing is that the footman unit must only be available once. It is a one time purchase. Am I doing this wrong? :vw_wtf:

defnum_footman is a variable i'm using to identify that the first level of footman is bought.

  • Footman Start
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Sold unit)) Equal to Footman Level 1
    • Actions
      • Set defnum_footman = (defnum_footman + 1)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Make Footman Level 1 Unavailable for training/construction by (Picked player)
      • Game - Display to (All players) the text: ((Player_Colors[(Player number of (Owner of (Sold unit)))] + (Name of (Owner of (Sold unit)))) + (Player_Colors[13] + ( has bought + (Name of (Sold unit)))))
      • Unit - Remove (Sold unit) from the game
 
Level 6
Joined
Oct 1, 2012
Messages
166
  • Player - Make Footman Level 1 Unavailable for training/construction by (Picked player)
Well, if I got it correctly, you BUY the unit. Like Ogres or Trolls in Melee maps, right?

I believe that the above funtion works only for training units in your own buildings.

I believe that it would be much better for you to make an item, no at unit for sale. After buying the item, you'd be able to remove it from hero and then do all the triggers you need.

There is a function in 'Neutral Building' section, which removes an item from stock. The tricky part is, you can't remove items, which were available for sale from the beginning (I mean, the ones you added to the shop with Object Editor). But if you script adding the item to the stock (also in 'Neutral Building' section in Trigger Editor), it can be removed with no problem.

It is possible that you can do the same thing with units, you'd have to check. I can't atm, have no WC3 here.

Hope I helped :)
 
Level 2
Joined
Sep 23, 2013
Messages
18
I have this variable defend_type[] variable..
defend_type[1] = footman level 1
defend_type[2] = footman level 2

and my spawn triggers are

create 1 defend_type[defnum_footman] for player2 in location facing default building degrees.

so using just 1 trigger, if the player buys level 2.. defnum_footman = defnum_footman+1 making the trigger spawn footman level 2...
 
Level 2
Joined
Sep 23, 2013
Messages
18
  • Player - Make Footman Level 1 Unavailable for training/construction by (Picked player)
Well, if I got it correctly, you BUY the unit. Like Ogres or Trolls in Melee maps, right?

I believe that the above funtion works only for training units in your own buildings.

I believe that it would be much better for you to make an item, no at unit for sale. After buying the item, you'd be able to remove it from hero and then do all the triggers you need.

There is a function in 'Neutral Building' section, which removes an item from stock. The tricky part is, you can't remove items, which were available for sale from the beginning (I mean, the ones you added to the shop with Object Editor). But if you script adding the item to the stock (also in 'Neutral Building' section in Trigger Editor), it can be removed with no problem.

It is possible that you can do the same thing with units, you'd have to check. I can't atm, have no WC3 here.

Hope I helped :)

So essentially, since it is player2(computer)'s building the function wont work? I'm a bit confused, so neutral buildings are treated as my buildings when i'm near one or something?

But what then would happen if the player has full inventory? :O

sorry about the double post, didn't notice the other post was also after both 2 posts
 
Last edited:
Level 6
Joined
Oct 1, 2012
Messages
166
So essentially, since it is player2(computer)'s building the function wont work? I'm a bit confused, so neutral buildings are treated as my buildings when i'm near one or something?

But what then would happen if the player has full inventory? :O

sorry about the double post, didn't notice the other post was also after both 2 posts

The 'Neutral Building' refers to a shop. Any shop. That is, in Jass there are no 'Unit - blablabla' or 'Neutral Building - blablabla' functions. They just are. The names like those are only to help beginners (mostly) and make it easier to find what you are looking for.

So, if you want to manipulate items sold by ANY unit selling stuff, the 'Neutral Building' refers to it.

Ok, I found WC3 on this mule-laptop. It seems, that you can add/remove sold units from a shop, so you can stick to buying units, not items.

So, bear one thing in mind - you can't remove sold units from shop when you add them via Object Editor. You'll have to add them with a trigger after, let's say, 2 secs of gameplay (Don't use 'Map Initialization', it's weird).

Like that:

  • Add Me A Footman
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Neutral Building - Add Footman to <Your Barracks> with 0 in stock and a max stock of 1
the '0 in stock' is how many footmen will be available after adding them, 'max stock' is... well, how many they will refill to. Since you want it to be bought only once, set it to 1. The first value... keep it like that and let it refill after time set in Object Editor or set to 1 and leave it be.

Afterwards, this is a way to remove them:

  • Remove Me a Footman
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Footman
    • Actions
      • Neutral Building - Remove Footman from (Triggering unit)
Hope I helped :)
 
Level 2
Joined
Sep 23, 2013
Messages
18
Wow that works wonders, I didn't notice that.
Thank you both for your time and patience.
 
Status
Not open for further replies.
Top