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

Dummies Ignoring Orders when owned by Computer

Status
Not open for further replies.
Level 15
Joined
Aug 31, 2009
Messages
778
Hey all, I've got a problem with some dummy units involved in a teleport ambush type spell I'm making.

When the caster is owned by a player, the spell works perfectly, but if a computer is the owner, the dummy units will not cast their spells (the stun and the Bloodlust type effect called Flurry).

This leads me to believe that somehow the computer is taking control of the dummies and making them not cast their spells.

Can anyone find a way to stop this happening?

Here's the spell:

  • Ambush
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ambush
    • Actions
      • Set point = (Position of (Triggering unit))
      • Set point2 = (Position of (Target unit of ability being cast))
      • Set point3 = (point2 offset by 90.00 towards ((Facing of (Target unit of ability being cast)) + 180.00) degrees)
      • Special Effect - Create a special effect at point using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at point2 facing Default building facing degrees
      • Unit - Add Dummy Stun to (Last created unit)
      • Unit - Order (Last created unit) to Neutral - Firebolt (Target unit of ability being cast)
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Custom script: call SetUnitX(udg_unit, GetLocationX(udg_point3))
      • Custom script: call SetUnitY(udg_unit, GetLocationY(udg_point3))
      • Unit - Order (Triggering unit) to Attack (Target unit of ability being cast)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at point3 facing Default building facing degrees
      • Unit - Add Flurry to (Last created unit)
      • Unit - Order (Last created unit) to Orc Shaman - Bloodlust (Triggering unit)
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_point)
      • Custom script: call RemoveLocation(udg_point2)
      • Custom script: call RemoveLocation(udg_point3)
The teleport mechanic and the forced attack order work perfectly, but I don't understand why the dummy units will not cast when this is performed by a computer owned unit.
 
Last edited:
Level 15
Joined
Aug 31, 2009
Messages
778
Can't say I've ever done anything in JASS before, but the best I can do is convert it to custom script:

JASS:
function Trig_Ambush_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00E' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Ambush_Actions takes nothing returns nothing
    set udg_unit = GetTriggerUnit()
    set udg_point = GetUnitLoc(GetTriggerUnit())
    set udg_point2 = GetUnitLoc(GetSpellTargetUnit())
    set udg_point3 = PolarProjectionBJ(udg_point2, 90.00, ( GetUnitFacing(GetSpellTargetUnit()) + 180.00 ))
    call AddSpecialEffectLocBJ( udg_point, "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call AddSpecialEffectTargetUnitBJ( "origin", GetTriggerUnit(), "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call CreateNUnitsAtLoc( 1, 'n003', GetOwningPlayer(GetTriggerUnit()), udg_point2, bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'A00G', GetLastCreatedUnit() )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "firebolt", GetSpellTargetUnit() )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
    call SetUnitX(udg_unit, GetLocationX(udg_point3))
    call SetUnitY(udg_unit, GetLocationY(udg_point3))
    call IssueTargetOrderBJ( GetTriggerUnit(), "attack", GetSpellTargetUnit() )
    call CreateNUnitsAtLoc( 1, 'n003', GetOwningPlayer(GetTriggerUnit()), udg_point3, bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'A00F', GetLastCreatedUnit() )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "bloodlust", GetTriggerUnit() )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
    call RemoveLocation(udg_point)
    call RemoveLocation(udg_point2)
    call RemoveLocation(udg_point3)
endfunction

//===========================================================================
function InitTrig_Ambush takes nothing returns nothing
    set gg_trg_Ambush = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ambush, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ambush, Condition( function Trig_Ambush_Conditions ) )
    call TriggerAddAction( gg_trg_Ambush, function Trig_Ambush_Actions )
endfunction

I also changed the "Unit Move Instantly" to the JASS version using Set Unit X and Set Unit Y, because I hear that's a better one to use due to it not interrupting orders.

EDIT: Got rid of the need for the udg_real variables.
 
Last edited:
Sorry, it took me a lot longer than usual because I wanted to try to organize it so you'd understand what's happening.

I switched the dummy's owner to "Neutral Passive". That'll stop the computer from seizing control :)

JASS:
//*
//* Configurable Settings
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    constant function Ambush_Spell_Id takes nothing returns integer
        return 'A00E'
    endfunction
        
    constant function Ambush_Dummy_Id takes nothing returns integer
        return 'n003'
    endfunction
        
    constant function Ambush_Firebolt_Id takes nothing returns integer
        return 'A00G'
    endfunction
    
    constant function Ambush_Bloodlust_Id takes nothing returns integer
        return 'A00F'
    endfunction
//*
//*
//* Actions
//* ¯¯¯¯¯¯¯
function Ambush_Actions takes nothing returns nothing
    // ----
    // Handles
    // ----
    local unit Target = GetSpellTargetUnit()
    local unit Caster = GetTriggerUnit()
    local unit Dummy  = null
    // ----
    // Non-handles
    // ----
    local real Target_X = GetWidgetX(Target)
    local real Target_Y = GetWidgetY(Target)
    
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl",GetWidgetX(Caster),GetWidgetY(Caster)))
    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl",Caster,"origin"))
    // ----
    // Issue Firebolt Order
    // ----
    set Dummy = CreateUnit(Player(15),Ambush_Dummy_Id(),Target_X,Target_Y,270. )
    call UnitAddAbility(Dummy,Ambush_Firebolt_Id())
    call IssueTargetOrder(Dummy,"firebolt",Target)
    call UnitApplyTimedLife(Dummy,'BTLF',2.)
    // ----
    // Polar Projection X,Y
    // ----
    set Target_X = Target_X+90.*Cos(3.14159265+bj_DEGTORAD*GetUnitFacing(Caster))
    set Target_Y = Target_Y+90.*Sin(3.14159265+bj_DEGTORAD*GetUnitFacing(Caster))
    call SetUnitX(Caster,Target_X)
    call SetUnitY(Caster,Target_Y)
    call IssueTargetOrder(Caster, "attack",Target)
    // ----
    // Issue Bloodlust Order
    // ----
    set Dummy = CreateUnit(Player(15),Ambush_Dummy_Id(),Target_X,Target_Y, 270. )
    call UnitAddAbility(Dummy,Ambush_Bloodlust_Id())
    call IssueTargetOrder(Dummy,"bloodlust",Caster)
    call UnitApplyTimedLife(Dummy,'BTLF',2.)
    // ----
    // Clear handle pointers
    // ----
    set Dummy  = null
    set Caster = null
    set Target = null
endfunction
//*
//*
//* Conditions
//* ¯¯¯¯¯¯¯¯¯¯
function Ambush_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == Ambush_Spell_Id() then
        call Ambush_Actions()
    endif
    return false
endfunction
//*
//*
//* Initializer
//* ¯¯¯¯¯¯¯¯¯¯¯
function InitTrig_Ambush takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Ambush_Conditions ) )
endfunction
 
Level 15
Joined
Aug 31, 2009
Messages
778
That works great, thanks.

Still, did it really require it to be changed to JASS? Apart from ordering the code a little more efficiently, the only real difference I can see is that the owner of the dummy has changed.

@Watermelon_1234: In this situation, it's okay because I'm just using the Stun and not any bonus damage. You could also just use Damage Target if you wanted some damage from that to be credited correctly. By the way, that Osaka avatar is awesome.
 
Last edited:
Status
Not open for further replies.
Top