• 🏆 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!

[JASS] "stop" order triggers this over conditions.

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
I'm making a TD where a Wisp can upgrade to several elemental tower types. I create a Special effect and do some stuff when that happens, and I take the order of the first upgrade (custom_UpgradeUnitID) and then the name (Substring 0,4 = "...."), however, whenever I order one of the units to "stop" this runs and displays the special effect.

I'm a bit new to JASS so, please, be patient.

JASS:
function TowerEffects_Conditions takes nothing returns boolean 
    return GetPlayerId(GetTriggerPlayer()) <= 3
endfunction

function TowerEffects_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer s = GetIssuedOrderId()
    local string name = SubString(GetUnitName(u), 0, 4)
        
    if s == String2OrderIdBJ("custom_h00P") or name == "Dark"
        set udg_RealEffect = (udg_RealEffect + 1.00)
        set udg_SfxQ = (udg_SfxQ + 1)
        set udg_Sfx[udg_SfxQ] = AddSpecialEffect("war3mapImported\\s_ShadowEruption_Rain.mdx", GetUnitX(u), GetUnitY(u))
    elseif s == String2OrderIdBJ("custom_h01I") or name == "Eart"
        set udg_RealEffect = (udg_RealEffect + 1.00)
        set udg_SfxQ = (udg_SfxQ + 1)
        set udg_Sfx[udg_SfxQ] = AddSpecialEffect("Abilities\\Spells\\Other\\Volcano\\VolcanoDeath.mdl", GetUnitX(u), GetUnitY(u))
    elseif s == String2OrderIdBJ("custom_h01Q") or name == "Elec"
        set udg_RealEffect = (udg_RealEffect + 1.00)
        set udg_SfxQ = (udg_SfxQ + 1)
        call TriggerSleepAction(0.35)
        set udg_Sfx[udg_SfxQ] = AddSpecialEffect("war3mapImported\\LightningsLong.mdx", GetUnitX(u), GetUnitY(u))
    elseif s == String2OrderIdBJ("custom_h00U") or name == "Fire"
        set udg_RealEffect = (udg_RealEffect + 1.00)
        set udg_SfxQ = (udg_SfxQ + 1)
        set udg_Sfx[udg_SfxQ] = AddSpecialEffect("war3mapImported\\NewGroundEX.mdx", GetUnitX(u), GetUnitY(u))
    elseif s == String2OrderIdBJ("custom_h00V") or name == "Fros"
        set udg_RealEffect = (udg_RealEffect + 1.00)
        set udg_SfxQ = (udg_SfxQ + 1)
        set udg_Sfx[udg_SfxQ] = AddSpecialEffect("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl", GetUnitX(u), GetUnitY(u))
    elseif s == String2OrderIdBJ("custom_h01P") or name == "Wind"
        set udg_RealEffect = (udg_RealEffect + 1.00)
        set udg_SfxQ = (udg_SfxQ + 1)
        set udg_Sfx[udg_SfxQ] = AddSpecialEffect("war3mapImported\\CyclonExplosion.mdx", GetUnitX(u), GetUnitY(u))
    endif
    
    set u = null
    set name = 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 20
Joined
Jul 14, 2011
Messages
3,213
@Maker: The first upgrade condition was the order (custom_targetunitID) and from there on, was the Substring(name, 1, 4) (Dark, Elec, etc.)

Any order was triggering since the "name" was always true. I managed to reduce the script lines and filter the order first, and the name later, but now in the first upgrade the Triggering Unit is the Wisp, and I can't get the "Target Upgrade" unit to compare and filter.... yet.

EDIT: The best solution I found was adding a unique special effect for the first upgrade for all towers, but this way doesn't seem to be the best. I would really like to do this in the most optimal way.

EDIT2: Lied, the last "solution" wasn't a solution at all. Finally got it working without bugs and as desired BUT, I still want to improve this as much as it's possible. Any ideas?

JASS:
function TowerEffects_Conditions takes nothing returns boolean 
    return GetPlayerId(GetTriggerPlayer()) <= 3 and IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true
endfunction

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 
        set udg_SfxQ = (udg_SfxQ + 1)
        if name == "Elem"
            set udg_Sfx[udg_SfxQ] = AddSpecialEffect("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl", GetUnitX(u), GetUnitY(u))
        elseif name == "Dark"
            set udg_Sfx[udg_SfxQ] = AddSpecialEffect("war3mapImported\\s_ShadowEruption_Rain.mdx", GetUnitX(u), GetUnitY(u))
        elseif name == "Eart"
            set udg_Sfx[udg_SfxQ] = AddSpecialEffect("Abilities\\Spells\\Other\\Volcano\\VolcanoDeath.mdl", GetUnitX(u), GetUnitY(u))
        elseif name == "Elec"
            call TriggerSleepAction(0.35)
            set udg_Sfx[udg_SfxQ] = AddSpecialEffect("war3mapImported\\LightningsLong.mdx", GetUnitX(u), GetUnitY(u))
        elseif name == "Fire"
            set udg_Sfx[udg_SfxQ] = AddSpecialEffect("war3mapImported\\NewGroundEX.mdx", GetUnitX(u), GetUnitY(u))
        elseif name == "Fros"
            set udg_Sfx[udg_SfxQ] = AddSpecialEffect("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl", GetUnitX(u), GetUnitY(u))
        elseif name == "Wind"
            set udg_Sfx[udg_SfxQ] = AddSpecialEffect("war3mapImported\\IceSparks.mdx", GetUnitX(u), GetUnitY(u))
        endif
        set udg_RealEffect = (udg_RealEffect + 1.00)
    endif
    
    set u = null
    set name = 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
 
Last edited:
Status
Not open for further replies.
Top