• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Trigger to kill all of one players units?

Status
Not open for further replies.
Level 6
Joined
Mar 22, 2009
Messages
276
Can you tell us the event you used to say that a player was defeated?
Is it when a player had his main structure destroyed or a special unit was killed?
You can use:
  • kill all
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to YOURUNIT
    • Actions
      • Set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
but then if it does not fit what you need, can you tell us more about the map you're doing?
 
Last edited:
Level 6
Joined
May 13, 2009
Messages
260
swipe5sweeps trigger leaks here's the same without leak :)
  • Leakfree
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to YOURUNIT
    • Actions
      • Set aleak_group = (Units owned by (Owner of (Triggering unit)))
      • Unit Group - Pick every unit in aleak_group and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Custom script: call DestroyGroup( udg_aleak_group )
aleak_group is a variable of the type unit group.
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,550
JASS:
scope killForPlayer initializer i
    globals
        private constant integer KINGID='hfoo'  //Change this to your king type unit
        private group grp=CreateGroup()
        private player tempPlayer
    endglobals
    
    private function f2 takes nothing returns boolean
        if GetOwningPlayer(GetFilterUnit())==tempPlayer then
            call KillUnit(GetFilterUnit())
        endif
        return false
    endfunction
    
    private function f takes nothing returns boolean
        if GetUnitTypeId(GetFilterUnit())==KINGID then
            set tempPlayer=GetOwningPlayer(GetFilterUnit())
            call GroupEnumUnitsInRect(grp,bj_mapInitialPlayableArea,Filter(function f2))
        endif
        return false
    endfunction
    
    private function i takes nothing returns nothing
        local trigger t=CreateTrigger()
        local integer index=0
        loop
            exitwhen index>11
            call TriggerRegisterPlayerUnitEvent(t,Player(index),EVENT_PLAYER_UNIT_DEATH,Filter(function f))
            set index=index+1
        endloop
    endfunction
endscope

Doubt it's possible to do it better than that.
 
Status
Not open for further replies.
Top