HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Shop selecting own units only

07-15-2007, 03:33 PM#1
Patpup
Dear wc3campaigns-forum,

How can I create a select-hero abillity that will only select units owned by the player that owns the shop.
Normaly that abillity is used for neutral shops and will target every unit (with inventory) thus granting controll over the building to any player.

I know about the abillity the race-shops use (thats 'common shop' or something) that will only select your own units, but that abillity will not work with 'sell item' (the abillity necessary to add items to shops via trigger) properly.
That means: If you won't to sell items you added using triggers, from a shop that uses 'common shop' instead of 'select hero' you have no way of detecting the unit buying or even the shop selling the item (or at least I didn't find one...)


So my question is: Is there any way to change "select hero' in a way that will make it select only my own units?


You have my gratitude,
Patpup
07-15-2007, 03:48 PM#2
blu_da_noob
Base your unit off the racial shops. Or copy the ability list they have.
07-15-2007, 03:57 PM#3
Patpup
As I wrote, using the ability of the racial shops doesn't work.
Heroes buying stuff using said ability don't get detected via 'buying unit' ! Means you can't use them in triggers.
07-15-2007, 04:04 PM#4
CommanderZ
Idea: make them permanently invisible (the ability shade has) and make sure nothing has True Sight. Only their owner will be able to shop in them as no one else will see them.
07-15-2007, 04:21 PM#5
Patpup
Invisibility would circumvent the problem, thats right, however due to the concept of the map (which I don't really won't to explain unless necessary, its a bit complicated ), the shops themselfes have to be visible.

For now I created a trigger that deselects the shop whenever someone other than the owner selects it. It's not perfect but I guess it does the trick.

Thanks for your braincells CommanderZ, this works for now ;
if someone else has an idea on how to adress this problem more directly, he's welcome!
07-15-2007, 04:22 PM#6
PitzerMike
Quote:
Originally Posted by Yet again the Warcraft III Ability Guide

Apit, Aneu, Aall, Asid (Purchase Item, Neutral, Allied Building, Sell Items): The combination of these abilities will give you a shop that sells items only to the owner of the shop just like the arcane vault. The difference is that AddItemToStock will also work. RemoveItemFromStock only works for items added with triggers, so you'll simply have to clear the items sold and items made field of the shop and instead add the items with a trigger at map initialization. Replace the 'Asid' ability with 'Asud' if you want a shop that sells units and that works with AddUnitToStock and RemoveUnitFromStock. Remove the 'Aall' ability to make it a neutral shop. On a side note, the 'Asud' ability makes a unit visible and clickable on the map for all players, even if that player is an enemy. A side effect of 'Aneu' is also that it allows for shared abilities. Even an enemy can use the abilities of a unit that has 'Aneu'.
07-15-2007, 04:27 PM#7
Patpup
darn... as expected,...what should I say,
maybe I looked up the wrong FAQs, right?

However, I'll try this now. Thank you.

Edit: Sorry, doesn't seem to work. The shop still selects enemy heroes (or enemy shops still select my hero - and sell him items). Are you sure this works the way you describe it? Am I sure I did it right? (no) I just added those 4 abillities (same sequence as above) and nothing else.

Hm I'll remain with the selection-thingie for now.
07-15-2007, 07:30 PM#8
PitzerMike
Too bad :(
I was pretty sure it used to work.
07-15-2007, 09:23 PM#9
Fluff
You could do something like this

Trigger:
Untitled Trigger 001
Collapse Events
Player - Player 1 (Red) Selects a unit
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Tavern
Collapse Actions
If ((Triggering player) Not equal to (Owner of (Triggering unit))) then do (Selection - Select Paladin 0000 <gen> for (Triggering player)) else do (Do nothing)

If a player selects a tavern (or whatever shop) and the player is not the owner of the shop, then they immediately either clear their selection, or go back and select their hero.

EDIT: This is not the shop selecting units, but rather the player clicking on the building. So they enemy heros will still be selected by the shop, but they won't be able to use it. It's not the best solution but it will work.
07-15-2007, 09:26 PM#10
Captain Griffen
Except it ain't immediate. There is a considerable delay; enough for hotkey usage.
07-15-2007, 09:45 PM#11
Patpup
fluff, thanks, thats what I already did .
I tried using hotkeys to trick the system, but I found that to be impossible (although you see the shop, the game doesn't react to your hotkey fast enough).
Doesnt warcraft work off its code trigger by trigger? According to my understanding the game should, the moment the unit is selected and the event kicks in, go through all the trigger before taking into account any buttons you pressed, am I wrong ?
07-17-2007, 04:38 AM#12
Kaz
Hotkeys don't work for items and units added to the shop by trigger.

Select Hero/Select Unit are the abilities that make the shop available to everybody. Unfortunately, they're necessary for items in the "Items Sold" field or items added by trigger (not for "Items Made" though, like ladder race shops).

You could make a workaround with units. Give the shop Shop Sharing and Sell Units. Add your dummy units by trigger. When a unit is purchased, get the player with GetOwningPlayer(GetSoldUnit()) (you cannot use GetBuyingUnit() without Select Hero/Select Unit). Look for a unit owned by the player with an empty inventory slot within range of the shop and give the item to it, else refund the purchase or drop the item on the ground by the shop, or something.
07-17-2007, 12:25 PM#13
Patpup
Well if hotkeys don't work, deselecting the shop is safe anyway so I see no problem with keeping that.