• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Diffrent units for diffrent owners of barracks

Status
Not open for further replies.
Level 4
Joined
Nov 13, 2010
Messages
53
Hi, i'm making a map where buildings are capturable and i would like to know how i can make the same building train diffrent types of units for diffrent owners.
For example,when a human player captures an orc barrack, i would like him not to be able to train grunts but instead train footmen.
Thx in advance.
 
Level 4
Joined
Nov 13, 2010
Messages
53
Aren't there any other ways?
I have about 60 buildings that change ownership and 6 races(each having their own kinds of units) so it would need a huge amount of triggers o.o
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
IssueImmediateOrderById(whichUnit, unitId) might work for training units, but the unit might have to be on the actual training unit.

If worse comes to worse, you can have ability train buttons and use UnitAddAbility. If you are doing spawns, it's much easier =), but if you are doing actual training and what to display a proper UI, you should make a different ability for each type of trained unit. You can set ability cooldowns to different things and do tech upgrades for training units by increasing ability level.


JASS:
call TriggerRegisterPlayerUnitEvent(myTrig, myPlayer, EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
///////////////////////////////////////////////
local integer unitTypeId = LoadInteger(table, GetIssuedOrderId(), 0)
if (unitTypeId != 0) then
    call CreateUnit(GetTriggerPlayer(), unitTypeId, GetWidgetX(GetTriggerUnit()), GetWidgetY(GetTriggerUnit()), GetUnitFacing(GetTriggerUnit()))
endif

///////////////////////////////////////////////////////
call UnitAddAbility(myBarracks, myTrainingAbility)

This is ofc assuming that ability orders follow the same sort of format as train and construction orders.

Another way is to have a generic train button and load the current type of unit trainable by the owning player.

local integer unitTypeId = trainingUnit[GetPlayerId(GetTriggerPlayer())]
 
Status
Not open for further replies.
Top