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

Custom Ability Selects only one target

Status
Not open for further replies.
Level 16
Joined
Jul 31, 2012
Messages
2,217
I'm making a spell that makes units in an AoE fall asleep now here is the trigger i made bu it only make one target sleep
  • Dreamcast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Dreamcast
    • Actions
      • Set temp_location = (Target point of ability being cast)
      • Custom script: set bj_wantDestroyGroup = true
      • Special Effect - Create a special effect at temp_location using war3mapImported\MagicExplosion.mdx
      • For each (Integer A) from 1 to (Number of units in (Units within (20.00 + (60.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))) of temp_location)), do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dreamcast for (Owner of (Triggering unit)) at temp_location facing Default building facing degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Set temp_Unit = (Random unit from (Units within (20.00 + (60.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))) of temp_location matching (((Matching unit) is in temp_Unit_Group) Equal to False)))
          • Custom script: call IssueTargetOrderBJ( GetLastCreatedUnit(), "sleep", udg_temp_Unit )
          • Unit Group - Add temp_Unit to temp_Unit_Group
      • Custom script: set udg_temp_Unit = null
      • Custom script: call RemoveLocation(udg_temp_location)
Can anybody help?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You leak a lot of groups....

Anyway the idea is such...
1. Get all units into a group that you want to sleep.
2. If group is not empty then create a dummy caster.
3. Dummy caster has no cast animation point or backswing so casts everything instantly. It is also invisible, invulnerable and un-targetable.
4. Add dummy sleep ability to dummy unit (this makes the dummy unit type recyclable between many triggered abilities).
5. For each unit in the group, order the dummy unit to cast sleep onto it. Orders use order strings so in GUI you need to choose the order for the base ability that the dummy sleep was based on.
6. Clean up everything (destroying groups and removing locations and units as necessary (a proper implementation does not need to do any of that).
 
You must use Pick every unit in unit group action.
No wonder why it doesn't work.
Also,if you want to make it enum units via Integer,you must use FirstOfGroup then remove the unit from the unit group after the effect ends so that it can enumerate all units.

Also,replace that bj with IssueTargetOrder
JASS:
function IssueTargetOrderBJ takes unit whichUnit, string order, widget targetWidget returns boolean

    return IssueTargetOrder( whichUnit, order, targetWidget )

endfunction

and also use bj_lastCreatedUnit because GetLastCreatedUnit() redirects it to bj_lastCreatedUnit:
JASS:
function GetLastCreatedUnit takes nothing returns unit

    return bj_lastCreatedUnit

endfunction
 
Status
Not open for further replies.
Top