Finding the unit selected with "Select Hero"

retupmoc258

New Member
Reaction score
1
Does anybody know how to do this? I have tried all sorts of things to identify who is actually doing stuff at a shop. My shop is set up a little differently. Players don't buy items, they get to the shop and use a "Charge Gold and Lumber" ability that gives them the item (stored in an inventory that's not carried by the actual unit).

The problem is, the select hero selects someone, usually the first person to arrive, and I want to know who exactly it's choosing so I can set the level of Charge Gold and Lumber to the correct barter level for that unit. Right now, whenever any unit comes within range, it switches to his barter level, but the problem still exists where I'm not sure which unit to give the item to. I can identify which player used the ability on the shop, but all references to "GetSpellAbilityUnit" and "GetTriggerUnit" refer to the shop, not the person using the ability. And so far, as far as I have learned, Select Hero does not trigger like other abilities. It has no effect. I have tested to see any conditions that make it register, and I haven't found any that work.

Anybody have any suggestions for either how I can make this work or what I can do to fix the problem? Perhaps, does anyone know a way that I could make the shop activate the "select user" ability?

If not, I suppose I can just use triggers to "create" the effect of a select-Hero ability, which will work just fine for this, but I wish there was a different way. Suggestions or information would be appreciated.
 

Moridin

Snow Leopard
Reaction score
144
Select hero is an ability right? Maybe it fires of the "Unit - A unit starts the effect of an ability" event? You could capture the target unit quite easily then...?

(This might not work at all, I'm just saying :p)
 

retupmoc258

New Member
Reaction score
1
Right now I have a trigger that fires whenever an ability is used. Or rather, whenever the effect of an ability occurs it fires. It finds the name of the ability being used and tells me "Ability used: " + GetAbilityName(GetSpellAbility()), and it never fires for the "Select Hero" ability. No blank, not even when it's manually used. It just doesn't have an "effect" Other tests don't seem to work, either.
 

Moridin

Snow Leopard
Reaction score
144
If the Select Hero isn't an ability, it's most probably an order like attack or move.

Try detecting current order of the unit. I'll test this out myself.
 
Reaction score
107
Does each player have more than one hero? If not, since you know which player is activating the ability, you can detect which hero to give the item if you store all the player heroes into an array, then directly reference the player number to the array slot of the according hero.
 

retupmoc258

New Member
Reaction score
1
Hmm, I hadn't thought of that idea. My plan is for each player to have one main hero, the story character, but you can hire other people to help you . . . and each has its own inventory. Otherwise, this would be entirely feasible. Hmm . . . I think I will just create a manual trigger that works like "Select Hero" but when someone selects the item it only gives it to the hero selected. I can configure it to work for every player, too. I imagine this would take a couple hours to set it all up . . . perhaps, but even then I don't imagine it taking that long. Any other suggestions?
 

vypur85

Hibernate
Reaction score
803
Order ID for Select Hero/Unit is 852566. You can try play around with this to get what you want. Then again, it doesn't work if the shop auto selects the unit. Only works if you manually click the unit using the Select Hero/Unit.

Code:
Test
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        (Triggering unit) Equal to Goblin Merchant 0000 <gen>
    Actions
        Custom script:   set udg_IntegerVar = GetIssuedOrderId()
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                IntegerVar Equal to 852566
            Then - Actions
                Special Effect - Create a special effect attached to the origin of (Target unit of issued order) using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
                Special Effect - Destroy (Last created special effect)
            Else - Actions
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top