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

[Trigger] Get abilities of unit (by position x,y or list)

Status
Not open for further replies.
Level 2
Joined
Feb 27, 2019
Messages
14
In essence I'd like to tell a building to train the first type of unit it can train (at position 0,0 in action menu or from Techtree - Units Trained list). So for a Town Hall a peasant, for barracks a footman etc. without having to make and maintain this list myself.

GUI, Jass or Wurst, doesn't matter. Can't find anything similar or a way to access this data from a unit or unittype :/

Thanks
 
Level 2
Joined
Feb 27, 2019
Messages
14
Thanks for the replies. I went for a simple hashmap in the end.

Pastin code just in case someone might find it useful in the future.
Not marked solved because no direct answer but correct me if I'm wrong.
Cheers

Wurst:
import HashMap
import UnitIds

HashMap<int, int> mapMakesUnits // key: building typeId int, value: unit typeId int

/** initMakesUnits() must have been called first, once */
public function unit.getMakesUnits() returns int
    return mapMakesUnits.get(this.getTypeId())
    // so for OP, I simply call this function on a unit, and tell it to train what comes out as result with
    // IssueTrainOrderByIdBJ(trainer, result-of-this-function)
    // (this is used in another place, not in this function)

function initMakesUnits() // I call it from my map initialization
    mapMakesUnits = new HashMap<int, int>
    // humans
    ..put( UnitIds.townhall, UnitIds.peasant )
    ..put( UnitIds.humanbarracks, UnitIds.footman )
    //....
    // orcs
    ..put( UnitIds.greathall, UnitIds.peon )
    // and so on...
 
Last edited:
Level 2
Joined
Feb 27, 2019
Messages
14
Well now that you mention it, besides the point it works on units, it isn't connected at all.
I guess because I've been using it in my project it got connected in my mind.
Deleted for clarity
 
Status
Not open for further replies.
Top