• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Upgraded Unit

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
You know the Scout Tower by Human ?
It can be upgraded to 3 different units; Guard / Arcane / Cannon

What is the Event in Trigger Editor to use to detect when the unit has finished upgrade ?

I tried using Unit has finished upgrade/research/construction/training/enters playable map area, no debug message is seen.

Is there any specific Event used to detect "Upgrade To" unit ?

Basically when Scout Tower is upgraded to Guard Tower, I want that Event to be detected, how ?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
The unit that finishes the upgrade is the Scout Tower.

You can check the order given to the ScoutTower when it starts the upgrade and work from there on (add to a group, booleans, etc.). I used it once, as far as I know, the orderstring is "custom_*NameOfTheUpgradedTower*" or something like that.

I used this in a map I made long ago. The orderstring for the upgrade was "custom_*upgradeID*" (Example: custom_h01k)
then I used the name of the triggering unit (Guard Tower) and worked from there.
JASS:
function TowerEffects_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local string s = SubString(UnitId2String(GetIssuedOrderId()), 0, 9)
    local string name = SubString(GetUnitName(u), 0, 4)
    
    if s == "custom_h0" then 
        if name == "Elem"
            // Thing... 
        elseif name == "Dark"
            // Thing... 
        elseif name == "Eart"
            // Thing... 
        elseif name == "Elec"
            // Thing... 
        elseif name == "Fire"
            // Thing... 
        elseif name == "Fros"
            // Thing... 
        elseif name == "Wind"
            // Thing... 
        endif
    endif
    
    set u = null
    set name = null
    set s = null
endfunction

//===========================================================================
function InitTrig_Tower_Effects takes nothing returns nothing
    set gg_trg_Tower_Effects = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Tower_Effects, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition(gg_trg_Tower_Effects, function TowerEffects_Conditions)
    call TriggerAddAction( gg_trg_Tower_Effects, function TowerEffects_Actions )
endfunction
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Ahhh never thought about using order string as a detection event, and pretty funny, the order string is like custom_h001 (referring to my upgraded unit, not the old ones) which is good, I can detect event from here now, thanks :)

EDIT:
But wait, how do I eliminate the unit in Unit Group or Boolean, if the unit has cancelled the upgrade before it is finished ?
It could create an Event leak somehow.
I tried the Event - A unit Is issued an order with no target, the Event did get detected, but it seems there is no specific order string for "cancelling an upgrade" ?
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Actually, I have no idea. I just used it to create an special effect, and upgrades were instant.

You could add the tower to a Unit Group, and use a String Array (if you use Indexer, otherwise, a Hashtable) to hold the unit order. Loop the group checking that the units orders remains the same that those saved in the array (or hash), else, stop everything.
 
Status
Not open for further replies.
Top