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

Unit Indexer

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,611
Hi

im using bribe's unit indexer (i think u know it)
just one question: do i use it correctly in that trigger?
how to do the trigger better or more efficient?
  • Holy Cure 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) equal to Ability[1]
    • Actions
      • Set Cure_Caster = (Triggering unit)
      • Set Cure_Integer = (Custom value of Cure_Caster)
      • Set Cure_Target[Cure_Integer] = (Target unit of ability being cast)
      • Set Cure_Time[Cure_Integer] = 1.75
      • Unit Group - Add Cure_Caster to Cure_Group
      • Trigger - Turn on Holy Cure 3 <gen>
  • Holy Cure 2
    • Events
      • Unit - A unit stops casting an ability
    • Conditions
      • (Ability being cast) equal to Ability[1]
    • Actions
      • Set Cure_Caster = (Triggering unit)
      • Set Cure_Integer = (Custom value of Cure_Caster)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • Cure_Time[Cure_Integer] smaller than 0.00
        • 'THEN'-Actions
          • Unit - Cause Cure_Caster to damage Cure_Target[Cure_Integer], dealing ((Real((Intelligence of Cure_Caster (include bonuses)))) x -2.50) damage of attack type spells and damage type Normal
          • Special Effect - Create a special effect attached to the origin of Cure_Target[Cure_Integer] using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
        • 'ELSE'-Actions
      • Unit Group - Remove Cure_Caster from Cure_Group
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • (Number of units in Cure_Group) equal to 0
        • 'THEN'-Actions
          • Trigger - Turn off Holy Cure 3 <gen>
        • 'ELSE'-Actions
  • Holy Cure 3
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Cure_Group and do (Actions)
        • Loop - Actions
          • Set Cure_Caster = (Picked unit)
          • Set Cure_Integer = (Custom value of Cure_Caster)
          • Set Cure_Time[Cure_Integer] = (Cure_Time[Cure_Integer] - 0.10)
TY !!!!
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
With
  • Special Effect - Destroy (Last created special effect)
Anyway: you can create an integer variable to keep track of the unit group count. That way you don't have to count units in the group (which sucks big times), you just set groupCount + 1 when a unit is added and subtract 1 when a unit is removed.
You then use the integer comparison to see if groupCount == 0 to see if you need to turn off the trigger.

That's about all I can think of, maybe someone else has more ideas.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
It calls this function:

JASS:
function CountUnitsInGroupEnum takes nothing returns nothing
    set bj_groupCountUnits = bj_groupCountUnits + 1
endfunction

function CountUnitsInGroup takes group g returns integer
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupCountUnits = 0
    call ForGroup(g, function CountUnitsInGroupEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(g)
    endif
    return bj_groupCountUnits
endfunction

Using an integer variable will add 2 lines (1 line to add, the second to subtract), which is obviously shorter than the above script.
 
Status
Not open for further replies.
Top