Karawasa Posted September 8, 2008 That is exactly the kind of thing I was hoping to do with registering Undead/Mechanical. Thanks again for your help. Go to top Share this post Link to post
Karawasa Posted September 8, 2008 I tried to apply this to Undead as well because I did not want to have 30*8 triggers in wait for 5 seconds. I got it all working except the damn move order. Regardless of TSA(even no TSA) the move order never gets executed. library UndeadReincarnate uses PUI globals private trigger array PUI_Trigger endglobals //=========================================================================== private function Revive takes nothing returns boolean local integer id = GetPlayerId(udg_CreepOwner[GetUnitUserData(GetTriggerUnit())]) local unit u = GetTriggerUnit() //if GetUnitAbilityLevel(u,'A00U') > 0 then call UnitRemoveAbility(u,'A00U') call SetUnitLifePercentBJ(u,33.33) call TriggerSleepAction(0.1) call IssuePointOrder(u,"move",udg_LeakX[id],udg_LeakY[id]) //endif set u = null return false endfunction //=========================================================================== public function Register takes unit whichUnit returns nothing local integer index = GetUnitIndex(whichUnit) if PUI_Trigger[index] != null then call DestroyTrigger(PUI_Trigger[index]) endif set PUI_Trigger[index] = CreateTrigger() call TriggerRegisterUnitStateEvent(PUI_Trigger[index], whichUnit, UNIT_STATE_LIFE, GREATER_THAN_OR_EQUAL, 0.405) call TriggerAddCondition(PUI_Trigger[index], Condition(function Revive)) endfunction endlibrary Go to top Share this post Link to post
Guest cohadar Posted September 8, 2008 You cannot handle undeads that way. I really think it is better you do with undeads as I described on TH. Go to top Share this post Link to post
Guest cohadar Posted September 8, 2008 library TTWait initializer Init uses TT globals private unit array Units private integer array Ticks private real array X private real array Y private integer N = 0 private constant real WAIT = 1.0 endglobals //=========================================================================== public function Register takes unit whichUnit, real x, real y returns nothing set Units[N] = whichUnit set Ticks[N] = R2I(WAIT / TT_PERIOD) set X[N] = x set Y[N] = y set N = N + 1 endfunction //=========================================================================== private function Handle takes nothing returns boolean local integer i = N - 1 loop exitwhen i < 0 set Ticks[i] = Ticks[i] - 1 if Ticks[i] <= 0 then call IssuePointOrder(Units[i], "move", X[i], Y[i]) // remove unit from array: set N = N - 1 set Units[i] = Units[N] set Ticks[i] = Ticks[N] set X[i] = X[N] set Y[i] = Y[N] endif endloop return false endfunction //=========================================================================== private function Init takes nothing returns nothing call TT_Start(function Handle, 0) endfunction endlibrary Go to top Share this post Link to post
Twilice Posted September 8, 2008 Stupid Jass, I don't understand so much xD Go to top Share this post Link to post
Guest cohadar Posted September 8, 2008 scope UndeadReincarnation initializer Init globals // based on 'AIrs' // set Number of Corpses to 1 // set Area of Effect to 0 private constant integer AID_resurrection = 'A004' private constant real REINCARNATION_DELAY = 5.0 private constant string FX = "Abilities\\Spells\\Orc\\Reincarnation\\ReincarnationTarget.mdl" endglobals //=========================================================================== private function Conditions takes nothing returns boolean if IsUnitType(GetTriggerUnit(), UNIT_TYPE_UNDEAD) then return true endif return false endfunction //=========================================================================== private function Actions takes nothing returns nothing local unit u = GetTriggerUnit() local real x = GetUnitX(u) local real y = GetUnitY(u) //local integer i = GetPlayerId(udg_CreepOwner[GetUnitUserData(u)]) local effect eff = AddSpecialEffect(FX, x, y) call TriggerSleepAction(REINCARNATION_DELAY) call DestroyEffect(eff) // create dummy unit on position of dead unit call Dummy_create(u, AID_resurrection, 1, 0.0) // cast resurrection call IssueImmediateOrderById(bj_lastCreatedUnit, OID_resurrection) // 852283 // issue move order here call IssuePointOrderById(u, OID_move, 0.0, 0.0) // 851986 //call IssuePointOrder(u, "move", udg_LeakX[id],udg_LeakY[id]) set u = null endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger trig = CreateTrigger() //call TriggerRegisterCreepEventBJ(trig, EVENT_PLAYER_UNIT_DEATH) <-----<< call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_DEATH ) call TriggerAddCondition( trig, Condition( function Conditions ) ) call TriggerAddAction( trig, function Actions ) endfunction endscope Go to top Share this post Link to post
Guest cohadar Posted September 9, 2008 Q: Why is this better than previous wait method? A: Because with native reincarnation there is a 5 sec spell timer + your custom wait 0.0 With custom reincarnation there is only custom 5 sec wait Go to top Share this post Link to post
Karawasa Posted September 13, 2008 I've decided to use your dynamic handling of events using actions instead of conditions so I can get the pause in. In place of TSA I am now trying a timer. Here is the code: library UndeadReincarnate uses PUI globals private trigger array PUI_Trigger private unit array Unit private integer Index = 0 private timer Timer = CreateTimer() endglobals //=========================================================================== private function Order takes nothing returns nothing local integer i local integer index = 0 loop exitwhen index >= Index set i = GetPlayerId(udg_CreepOwner[GetUnitUserData(Unit[index])]) call IssuePointOrder(Unit[index],"move",udg_LeakX[i],udg_LeakY[i]) set index = index + 1 endloop set Index = 0 call PauseTimer(Timer) endfunction //=========================================================================== private function Revive takes nothing returns nothing local unit u = GetTriggerUnit() if GetUnitAbilityLevel(u,'A00U') > 0 then call UnitRemoveAbility(u,'A00U') call SetUnitLifePercentBJ(u,33.33) if Index == 0 then call TimerStart(Timer, .0, false, function Order) endif set Unit[Index] = u set Index = Index + 1 endif set u = null endfunction //=========================================================================== public function Register takes unit whichUnit returns nothing local integer index = GetUnitIndex(whichUnit) if PUI_Trigger[index] != null then call DestroyTrigger(PUI_Trigger[index]) endif set PUI_Trigger[index] = CreateTrigger() call TriggerRegisterUnitStateEvent(PUI_Trigger[index], whichUnit, UNIT_STATE_LIFE, GREATER_THAN_OR_EQUAL, 0.405) call TriggerAddAction(PUI_Trigger[index],function Revive) endfunction endlibrary Go to top Share this post Link to post