[Spell] Multicast Spell Request

Level 6
Joined
May 13, 2023
Messages
72
Hello again Hive, I have a request of an ability which when casted upon an unit it gives it a buff that allows all of it's abilities to fire a second time. I tried to do this but i just can't get the spell's order. Here's my attempt
  • Mimic Dummy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) has buff Mimic ) Equal to True
    • Actions
      • Custom script: local unit caster = GetTriggerUnit()
      • Custom script: local unit target = GetSpellTargetUnit()
      • Custom script: local integer abilityID = GetSpellAbilityId()
      • Custom script: local integer orderID = GetIssuedOrderId()
      • Custom script: local location pos = GetSpellTargetLoc()
      • Custom script: local unit dummy = CreateUnit(GetOwningPlayer(caster), 'n011', GetUnitX(caster), GetUnitY(caster), 1)
      • Custom script: call UnitAddAbility(dummy, abilityID)
      • Custom script: call SetUnitAbilityLevel(dummy, abilityID, GetUnitAbilityLevel(caster, abilityID))
      • Custom script: call IssuePointOrderById(dummy, udg_MimicOrder, GetLocationX(pos), GetLocationY(pos))
      • Custom script: call IssueTargetOrderById(dummy, udg_MimicOrder, target)
      • Custom script: call IssueImmediateOrderById(dummy, udg_MimicOrder)
      • Custom script: call RemoveLocation(pos)
      • Custom script: set caster = null
      • Custom script: set target = null
      • Custom script: call SetUnitState(caster, UNIT_STATE_LIFE, 500)
  • Mimic Order
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • ((Triggering unit) has buff Mimic ) Equal to True
      • (Issued order) Not equal to (Order(stop))
      • (Issued order) Not equal to (Order(smart))
      • (Issued order) Not equal to (Order(move))
      • (Issued order) Not equal to (Order(patrol))
      • (Issued order) Not equal to (Order(attack))
    • Actions
      • Custom script: set udg_MimicOrder = GetIssuedOrderId()
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
So I'm assuming based on your triggers that the Mimic is a visible unit that walks around with the Hero. In other words, not your traditional "hidden" Dummy unit.

Otherwise, I feel like this design would make a lot more sense:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • ((Triggering unit) has buff Mimic ) Equal to True
  • Actions
    • Set Variable Ability = (Ability being cast)
    • Unit - Create 1 Dummy (Hidden) for (Triggering player)
    • Set Variable Dummy = (Last created unit)
    • Unit - Add a 4.00 second expiration timer to Dummy
    • Unit - Add Ability to Dummy
    • Unit - Set level of Ability for Dummy to (Level of Ability)
    • If Ability Equal to Holy Light then Unit - Order Dummy to Human - Paladin - Holy Light (Target unit of ability being cast)
    • If Ability Equal to Thunder Clap then Unit - Order Dummy to Human - Mountain King - Thunder Clap
    • If Ability Equal to Shockwave then Unit - Order Dummy to Orc - Tauren Chieftain - Shockwave (Target point of ability being cast)
 
Last edited:
Level 6
Joined
May 13, 2023
Messages
72
Managed to do this trigger, it gives me the results i want but for some unknown reason sometimes the dummy doesn't cast the spell.
  • Mimic
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) has buff Mimic ) Equal to True
    • Actions
      • Custom script: local unit caster = GetTriggerUnit()
      • Custom script: local unit target = GetSpellTargetUnit()
      • Custom script: local integer abilityID = GetSpellAbilityId()
      • Custom script: local integer orderID = GetUnitCurrentOrder(caster)
      • Custom script: local unit dummy = CreateUnit(GetOwningPlayer(caster), 'n011', GetUnitX(caster), GetUnitY(caster), 1)
      • Custom script: call UnitApplyTimedLife(dummy,'BTLF', 2)
      • Custom script: if orderID != 851970 and orderID != 851971 and orderID != 851972 and orderID != 851983 and orderID != 851986 and orderID != 851990 then
      • Custom script: call UnitAddAbility(dummy, abilityID)
      • Custom script: call SetUnitAbilityLevel(dummy, abilityID, GetUnitAbilityLevel(caster, abilityID))
      • Custom script: call IssueTargetOrderById(dummy, orderID, target)
      • Custom script: set caster = null
      • Custom script: set target = null
      • Custom script: endif
 
Level 6
Joined
May 13, 2023
Messages
72
well i did see the current abilityID and orderID everytime it fired it showed the same, i thought it was about me changing the caster's order before the dummy could get the orderID so that's why added if condition
and on the first trigger GetIssuedOrderId() doesn't work on the Starts the Effect of an ability Event as it showed 0 on all iterations
 
Level 24
Joined
Feb 27, 2019
Messages
833
I dont know if you need the condtion then. Though youre setting the variables to null within the if then else statement. It should be outside, so after endif.

How come in the first trigger you have
  • Custom script: call IssuePointOrderById(dummy, udg_MimicOrder, GetLocationX(pos), GetLocationY(pos))
  • Custom script: call IssueTargetOrderById(dummy, udg_MimicOrder, target)
  • Custom script: call IssueImmediateOrderById(dummy, udg_MimicOrder)
and in the second trigger only
  • Custom script: call IssueTargetOrderById(dummy, udg_MimicOrder, target)
?
 
Level 24
Joined
Feb 27, 2019
Messages
833
Could it be a range issue? Dont know if abilities have a range motion buffer aka if it started to cast it will finish even if the target moves out of range. So if the dummy is created it wont have any range motion buffer.
Is the dummy setup correctly?

In what situations does the spell malfunction? Is it with specific spells? Does it always malfunction for one spell but always works for others? How often does it malfunction?
 
Level 6
Joined
May 13, 2023
Messages
72
range shouldnt be the issues as the dummy is given the same ability thats being casted
dummy is setup correctly
ability plays like on the first ever iteration it doesn't work but after that following ones seem random there were instances where i got 5 in a row not working vice versa.
 
Level 24
Joined
Feb 27, 2019
Messages
833
I feel like I went through all possible problems. From the information that you told me all of these are correct. What else is there?
event is correct
caster is correct
target is correct
abilityID is correct
orderID is correct
Dummy is correct
OrderID condition is correct
Level of ability for dummy is set correctly
Order issued by dummy is correct
Spell is correct
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Range can definitely be an issue. You can't expect the Dummy unit to be placed at the EXACT coordinates of the caster nor can you expect the target to be within Cast Range anymore. Like Duckfarter said, there's Range Motion Buffer which comes into play. The unit begins casting the ability and by the time the ability should execute the game does one final distance check -> Is the target within (Cast range + Range motion buffer) distance of the caster. If true, execute the ability. If false, issue a Stop order.

With that in mind, here's a setup that appears to work:
  • Mimic Order No Target or Object
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Ordered unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet Mimic_CV = (Custom value of (Ordered unit))
      • Custom script: set udg_Mimic_Order_Id[udg_Mimic_CV] = GetIssuedOrderId()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target unit of issued order) Equal to No unit
        • Then - Actions
          • -------- No Target --------
          • Set VariableSet Mimic_Order_Mode[Mimic_CV] = 1
        • Else - Actions
          • -------- Object --------
          • Set VariableSet Mimic_Order_Mode[Mimic_CV] = 2
  • Mimic Order Point
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • ((Ordered unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet Mimic_CV = (Custom value of (Ordered unit))
      • Custom script: set udg_Mimic_Order_Id[udg_Mimic_CV] = GetIssuedOrderId()
      • Set VariableSet Mimic_Order_Mode[Mimic_CV] = 3
  • Mimic Remove Dummy
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Dummy (Mimic)
    • Actions
      • -------- Give enough time for special effects to play out: --------
      • Wait 1.00 game-time seconds
      • Unit - Remove (Triggering unit) from the game
  • Mimic Multicast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet Mimic_Caster = (Triggering unit)
      • Set VariableSet Mimic_CV = (Custom value of Mimic_Caster)
      • Set VariableSet Mimic_Ability = (Ability being cast)
      • Set VariableSet Mimic_Level = (Level of Mimic_Ability for Mimic_Caster)
      • Set VariableSet Mimic_Point = (Position of Mimic_Caster)
      • -------- --------
      • Unit - Create 1 Dummy (Mimic) for (Triggering player) at Mimic_Point facing Default building facing degrees
      • Set VariableSet Mimic_Dummy = (Last created unit)
      • Custom script: call RemoveLocation( udg_Mimic_Point )
      • -------- --------
      • Unit - Add Mimic_Ability to Mimic_Dummy
      • Ability - Set Ability: (Unit: Mimic_Dummy's Ability with Ability Code: Mimic_Ability)'s Real Level Field: Cast Range ('aran') of Level: (Mimic_Level - 1) to 99999.00
      • Unit - Set level of Mimic_Ability for Mimic_Dummy to Mimic_Level
      • Unit - Add a 60.00 second Generic expiration timer to Mimic_Dummy
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Mimic_Order_Mode[Mimic_CV] Equal to 1
        • Then - Actions
          • -------- No Target --------
          • Custom script: call IssueImmediateOrderById( udg_Mimic_Dummy, udg_Mimic_Order_Id[udg_Mimic_CV] )
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Mimic_Order_Mode[Mimic_CV] Equal to 2
            • Then - Actions
              • -------- Object --------
              • Custom script: call IssueTargetOrderById( udg_Mimic_Dummy, udg_Mimic_Order_Id[udg_Mimic_CV], GetSpellTargetUnit() )
            • Else - Actions
              • -------- Point --------
              • Set VariableSet Mimic_Point = (Target point of ability being cast)
              • Custom script: call IssuePointOrderById( udg_Mimic_Dummy, udg_Mimic_Order_Id[udg_Mimic_CV], GetLocationX(udg_Mimic_Point), GetLocationY(udg_Mimic_Point) )
              • Custom script: call RemoveLocation( udg_Mimic_Point )
Notes:
  • I'm relying on a Unit Indexer to track the "mode" of the order. 1 = No Target, 2 = Object, 3 = Point.
  • I use the Set Ability Real Level Field action to give infinite Cast Range to the Dummy's ability. This prevents the issue mentioned earlier. Note that this is a 1.31+ feature and you'll need a different solution on older versions. An alternative could be to move the Dummy unit closer to the (Target unit of ability being cast).
  • You will want to replace this Condition -> ((Ordered unit) is A Hero) Equal to True with your Buff check. I was too lazy to implement an actual Buff as it complicated my testing.
  • The Dummy unit has a 1.00 second Cast Point. This delays it's cast by that much time. Set this to 0.00 in the Object Editor for "instant" casts. This helps visualize the multicast behavior since otherwise the abilities would stack and appear as one. IE: Two Storm Bolts created inside of one another.
  • The Dummy unit has 50,000/100,000 Mana, Cast Backswing = 0.00, Movement Type = None, Speed Base = 0, Attacks Enabled = None. All of these settings are important! You may also want to tweak some of it's Art settings to ensure that the Special Effects from it's Abilities play properly, I believe I addressed all of these in my demo map.
  • The Dummy unit has a 60.00 second Expiration Timer. This is a "just in case" timer as the Dummy unit will also be removed after a 1.00 second Wait (see Mimic Remove Dummy trigger). Both of these are to ensure that the Dummy is always removed while also ensuring that the cast doesn't get interrupted. You will most likely want to extend the 1.00 second Wait to be even longer. IE: When multicasting Thunderclap, the blue ground cracks from the Special Effect would get removed early IF the Dummy was removed from the game too soon.
  • Don't forget about Ability Requirements, Vision, and other issues that can prevent a Dummy unit from casting.
  • Item abilities will be multicasted as well. This can be checked for and prevented in 1.31+ but isn't as simple on older versions.
 

Attachments

  • Multicast Mimic Example 2.w3m
    30.8 KB · Views: 4
Last edited:
Level 6
Joined
May 13, 2023
Messages
72
I figured out the problem, it is with the cast range when the Caster is issued to cast the ability outside it's cast range meaning the caster has to close distance by walking towards the unit and cast it from where cast range is eligible where the dummy created position is a lil far away. When casting abilities within the cast range it works.

I bypassed the problem by creating the dummy a bit closer
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
If you are not using an old patch you could change the cast range of the abilities before attempting to cast them with the ability field modification natives. That would only be relevant if the same dummy has to cast multiple spells which might all need small movement in multiple directions to reach the cast points.
 
Top