| 07-03-2006, 03:37 AM | #1 |
I'm triggering added handicap to a team, but only want it affecting units. I couldn't find a way to add handicap to units, but only to players. I built a trigger to restore structures max life to original, but it won't work. Is it not possible to set a non-hero unit's max life via trigger. Here is my trigger. JASS:function TownHandicapBool takes nothing returns boolean return IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) endfunction function Trig_Town_Handicap_Actions takes nothing returns nothing local player p=GetOwningPlayer(GetDyingUnit()) local integer i=9 local integer j=0 local real array mlife local group g=CreateGroup() local boolexpr b=Condition(function TownHandicapBool) local unit u loop exitwhen i>11 if Player(i)!=p then call GroupEnumUnitsOfPlayer(g,Player(i),b) loop set u=FirstOfGroup(g) exitwhen u==null set mlife[j]=GetUnitState(u,UNIT_STATE_MAX_LIFE) set j=j+1 call GroupRemoveUnit(g,u) endloop call SetPlayerHandicap(Player(i),GetPlayerHandicap(Player(i))+0.15) call GroupEnumUnitsOfPlayer(g,Player(i),b) set j=0 loop set u=FirstOfGroup(g) exitwhen u==null call SetUnitState(u,UNIT_STATE_MAX_LIFE,mlife[j]) set j=j+1 call GroupRemoveUnit(g,u) endloop endif set i=i+1 endloop call DestroyGroup(g) call DestroyBoolExpr(b) set g=null set b=null set p=null set u=null endfunction //=========================================================================== function InitTrig_Town_Handicap takes nothing returns nothing set gg_trg_Town_Handicap = CreateTrigger( ) call DisableTrigger( gg_trg_Town_Handicap ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0000, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0006, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0011, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0005, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0041, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0042, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0004, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0058, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( gg_trg_Town_Handicap, gg_unit_hbar_0059, EVENT_UNIT_DEATH ) call TriggerAddAction( gg_trg_Town_Handicap, function Trig_Town_Handicap_Actions ) endfunction |
| 07-03-2006, 03:47 AM | #2 | |
Quote:
Tried already the SetUnitMaxState System? |
| 07-03-2006, 04:30 AM | #3 |
Whoa, awesome. That should work great. Thank god for that bug ![]() |
| 07-03-2006, 04:34 AM | #4 |
Bug's not mine, is blizzard's ;P You're welcome. |
| 07-03-2006, 08:27 AM | #5 |
Blade is the one to thank for noticing it when he was trying his aura spell and it went horribly wrong because of the bug, then he took advantage and turned it into a great system |
