| 12-09-2008, 07:12 AM | #1 |
JASS:scope Revive initializer Init globals private unit Caster endglobals struct RH unit u timer t real rt real mana leaderboard lb method onDestroy takes nothing returns nothing set .u = null call DestroyLeaderboard(.lb) call ReleaseTimer(.t) endmethod endstruct private function PrivateFilter takes nothing returns boolean return GetUnitPointValue(GetFilterUnit()) == 100 and IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) endfunction private function Conditions takes nothing returns boolean return GetUnitPointValue(GetTriggerUnit()) == 100 and IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) endfunction private function Change takes nothing returns nothing local RH d = GetCSData(GetExpiredTimer()) local real x local real y local integer i local real tr = TimerGetRemaining(d.t) set d.rt = d.rt - 1 set i = R2I(d.rt) if i > 0 then call LeaderboardSetItemValue(d.lb, LeaderboardGetPlayerIndex(d.lb, GetOwningPlayer(d.u)), i) else set x = GetUnitX(Building[GetPlayerId(GetOwningPlayer(d.u))]) set y = GetUnitY(Building[GetPlayerId(GetOwningPlayer(d.u))]) call ReviveHero(d.u, x, y, true) call SetUnitState(d.u, UNIT_STATE_MANA, d.mana) if GetLocalPlayer() == GetOwningPlayer(d.u) then call PanCameraTo(x,y) endif call SetPlayerAbilityAvailable(GetOwningPlayer(d.u),'AHds', true) call IssueImmediateOrder(d.u,"divineshield") call SetPlayerAbilityAvailable(GetOwningPlayer(d.u),'AHds', false) if (GetLocalPlayer() == GetOwningPlayer(d.u)) then call ClearSelection() call SelectUnit(d.u, true) endif call d.destroy() endif endfunction private function Actions takes nothing returns nothing local unit u = GetTriggerUnit() local real x1 = GetUnitX(Building[GetPlayerId(GetOwningPlayer(u))]) local real y1 = GetUnitY(Building[GetPlayerId(GetOwningPlayer(u))]) local real x2 local real y2 local group g = NewGroup() local unit fog local real time local real d local real d2 local multiboarditem mbi local RH e = RH.create() set e.t = NewTimer() set e.u = u set e.lb = CreateLeaderboard() set d = 0 set d2 = 0 set Caster = u call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea, Condition(function PrivateFilter)) set fog = FirstOfGroup(g) if fog != null then set d = 100000000.00 loop //loop is for determining closest enemy unit set fog = FirstOfGroup(g) exitwhen fog == null set x2 = GetUnitX(fog) set y2 = GetUnitY(fog) set d2 = DistanceXY(x1,y1,x2,y2) if d2 < d then set d = d2 endif call GroupRemoveUnit(g,fog) endloop else set d = 0.00 endif call ReleaseGroup(g) set g = null set time = R2I(( d/ 1000.00 )) //takes distance of nearest enemy divided by 1000 set e.rt = I2R(R2I(DT + time)) //adds time to death revival the farther away an enemy is set e.mana = GetUnitState(u, UNIT_STATE_MANA) call TimerStart( e.t, 1, true, function Change ) call PlayerSetLeaderboard(GetOwningPlayer(u),e.lb) call LeaderboardSetStyle(e.lb,true,true,true,false) call LeaderboardAddItem(e.lb, "Revive:", 10, GetOwningPlayer(u)) if GetLocalPlayer() == GetOwningPlayer(u) then call LeaderboardDisplay(e.lb, true) endif call SetCSData(e.t, e) endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger trig = CreateTrigger( ) set ReviveTrig = trig call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_DEATH ) call TriggerAddCondition( trig, Condition( function Conditions ) ) call TriggerAddAction( trig, function Actions ) endfunction endscope when a hero dies, it pops up a revive timer using a leaderboard, however, if one hero respawns (no matter which player) before another hero, the leaderboard is destroyed for all players even though its not the same one.. |
| 12-09-2008, 08:01 AM | #2 |
only one board allowed at time, check handles first, board can be "hidden" not destroyed. |
| 12-09-2008, 08:15 AM | #3 |
so in order to fix this, i need a global leaderboard array? |
| 12-09-2008, 08:45 AM | #4 |
you need only one leaderboard at time, with different data for every player. |
| 12-09-2008, 09:00 AM | #5 |
DioD does "only 1 leaderboard at a time" mean that if I create and display 2 leaderboards to 2 players respectively, it won't work? |
| 12-09-2008, 09:08 AM | #6 |
no, creating 2 and displaying 2 works, but destroying 1, destroys all (it seems like) however, if you use 2 for 2 players, you have to hide multiple multiboards, i think diod is saying that it is only necessary to have 1 since setting values and displaying/hiding can be done locally. (doing 2 leaderboards is essentially the same but then you have to mess with arrays) |
| 12-09-2008, 03:17 PM | #7 |
you can setup structs with data and use GetPlayerId(GetLocalPlayer()) on index to load data. all leaderboard data can be local. |
