HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Removing hero from the tavern

02-17-2007, 02:27 PM#1
abriko
Hi :)

I'm sorry if the question was already posted but i can't find it in the forum.
How can i make disapper all others hero from the tavern after the player choose one ? Like in dota, there is no choice possible after one hero chosen but it does for the others players.
02-17-2007, 02:35 PM#2
Alexander244
Trigger:
Untitled Trigger 001
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Player - Limit training of Heroes to 1 for (Player((Integer A)))
You need to add all your heroes to "advanced -> Techtree - Dependancy equivalents - hero"
02-17-2007, 02:36 PM#3
CommanderZ
There are a few stock operation functions, some are global and some are only for a single shop: RemoveUnitFromStock or global RemoveUnitFromAllStock. the same ar for Items: RemoveItemFromStock/RemoveItemFromAllStock

PS: They are in some form in GUI too
02-17-2007, 03:53 PM#4
Rising_Dusk
Yes, CommanderZ is correct.
Those are the functions you'll want to use.

The trick is, you can't add the heroes to the tavern in the Object Editor.
At map initialization, you'll want to add all of your heroes to the taverns manually with the "Neutral Building - Add YourHero to (Triggering unit) with 0 in stock and a max stock of 1" or the [ljass]call AddUnitToStock(...)[/jass].

Then, when the hero is selected, remove it using the RemoveUnitToStock or GUI equivalent.
It's quite easy, actually.
02-17-2007, 04:09 PM#5
Alexander244
Are you asking how to make a player unable to purchase more heroes after the first hero they buy, or how to make only one of each hero allowed?

For the second:
There is a way to remove the heroes for everyone, and still add the hero in the object editor;

Collapse JASS:
function SoldUnitIsHero takes nothing returns boolean
  return IsUnitType(GetSoldUnit(), UNIT_TYPE_HERO)
endfunction

function MakeHeroUnpurchasable takes nothing returns nothing
  local integer index = 0
  local integer id = GetUnitTypeId(GetSoldUnit())
  loop
    exithwhen index > 11
    call SetPlayerTechMaxAllowed(Player(index), id, 0)
    set index = index + 1
  endloop
endfunction

//===========================================================================
function InitTrig_Hero_Sold takes nothing returns nothing
  local integer index = 0
  set gg_trg_Hero_Sold = CreateTrigger(  )
  loop
    exitwhen index > 11
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Sold, Player(index), EVENT_PLAYER_UNIT_SELL, null)
    set index = index + 1
  endloop
  call TriggerAddCondition(gg_trg_Hero_Sold, Condition(function SoldUnitIsHero))
  call TriggerAddAction(gg_trg_Hero_Sold, function MakeHeroUnpurchasable)
endfunction
02-17-2007, 05:42 PM#6
CommanderZ
Quote:
Originally Posted by Rising_Dusk
Yes, CommanderZ is correct.
Those are the functions you'll want to use.

The trick is, you can't add the heroes to the tavern in the Object Editor.
At map initialization, you'll want to add all of your heroes to the taverns manually with the "Neutral Building - Add YourHero to (Triggering unit) with 0 in stock and a max stock of 1" or the [ljass]call AddUnitToStock(...)[/jass].

Then, when the hero is selected, remove it using the RemoveUnitToStock or GUI equivalent.
It's quite easy, actually.

Yes, but if you have tavers separate for each player (each player has his own), you can easily add them through Object Editor
02-17-2007, 06:09 PM#7
The)TideHunter(
DotA dosent do any of those, although they probally have the same effect, DotA disables buying of that hero, via:

Trigger:
Actions
Player Group - Pick every player in (All players) and do (Player - Make Your Hero Unavailable for training/construction by (Picked player))
02-18-2007, 10:50 PM#8
abriko
Ok thank you all :) The last tip works very well :D