How to Make a Custom Win (Not what you think)

ZachHandley

New Member
Reaction score
1
So as the title suggests, I need to make a custom win. But it's not the game win, just a battle win. Normally I'd detect every unit thats in the enemies base and when they're all dead just say hey you win now go back to your base. But the problem is that the game I'm making isn't made that way, and the buildings don't die.
Meaning when they get to less than or equal to ten health they go invulnerable and play the death animation.
Here's the code for that trigger.
JASS:
function NoKillBuildings takes nothing returns nothing
local unit u = GetTriggerUnit()
    if ( GetUnitStateSwap(UNIT_STATE_LIFE, u) <= 10) and (IsUnitType(u, UNIT_TYPE_STRUCTURE)) then
        call SetUnitAnimation( u, "death" )
        call SetUnitInvulnerable( u, true )
    endif
set u = null
endfunction
 
//===========================================================================
function InitTrig_No_Kill_Buildings takes nothing returns nothing
    set gg_trg_No_Kill_Buildings = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_No_Kill_Buildings, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddAction( gg_trg_No_Kill_Buildings, function NoKillBuildings )
endfunction


So if that's what happens, which is what's supposed to happen. How do I make it so that when a players buildings are all "destroyed", then they "win" the battle.

About the Map: It's a free for all of 6 players, and to attack they have to spawn units in to kill the enemies buildings from the reserve they have at home.

I was thinking a local boolean loaded from a hashtable. But not sure where to go from there.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
You could use an integer variable to keep track of the number of buildings that die. When that variable goes above X, X buildings will be destroyed, and you can set X to the number of buildings in the base. If new buildings are constructed, then just increase X.
 

ZachHandley

New Member
Reaction score
1
You could use an integer variable to keep track of the number of buildings that die. When that variable goes above X, X buildings will be destroyed, and you can set X to the number of buildings in the base. If new buildings are constructed, then just increase X.

That will work, I'll try it, thanks Kaerf. I can't believe you're still around here by the way, I used to be NeuroToxin, and I remember you being here still.
 

Solu9

You can change this now in User CP.
Reaction score
216
Why don't you use that account then? I can see it's still there.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top