| 02-06-2007, 02:43 PM | #1 |
Alright, so still running into problems with my AoS type map with hero revival. My function works fine, although I'm afraid I have optimization issues, or some other mis-calculation that's preventing it from being accurate. The revival system is called when a hero dies, setting the revival time to be 3x the dying hero's level and passing that to the multiboard_update function, which counts down on the multiboard. When the multiboard countdown expires, it calls the revive function. The main issue is: the countdown on the multiboard as it counts down is longer than a second.. IE: the board says 53, then changes to 52, 51, 50, etc. but the time in between the change is more than 1 second (thus, its actually doing the following: 53 (triggerwaits for approx 1.5 secs) 52 (triggerwaits again for approx 1.5 secs, etc.) Alliance hero dies: JASS:function Trig_AllianceDead_Conditions takes nothing returns boolean return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true and IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(0)) == true endfunction function Trig_AllianceDead_Actions takes nothing returns nothing local integer a = GetHeroLevel(GetTriggerUnit()) * 3 call Multiboard_Update(a, GetTriggerUnit()) endfunction //=========================================================================== function InitTrig_AllianceDead takes nothing returns nothing set gg_trg_AllianceDead = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_AllianceDead, EVENT_PLAYER_UNIT_DEATH ) call TriggerAddCondition( gg_trg_AllianceDead, Condition( function Trig_AllianceDead_Conditions ) ) call TriggerAddAction( gg_trg_AllianceDead, function Trig_AllianceDead_Actions ) endfunction Multiboard_Update JASS:function Multiboard_Update takes integer atimer, unit hero returns nothing local integer a = GetConvertedPlayerId(GetOwningPlayer(hero)) loop call MultiboardSetItemValueBJ( udg_multiboard, 2, (a + 1), I2S(atimer) ) call TriggerSleepAction( 1 ) set atimer = atimer - 1 exitwhen atimer == 0 endloop call MultiboardSetItemValueBJ( udg_multiboard, 2, a, "" ) if IsPlayerAlly(GetOwningPlayer(hero), Player(0)) then call Alliance_Respawn(hero) elseif IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(6)) then call Ancients_Respawn(hero) endif endfunction Alliance_Respawn: JASS:function Alliance_Respawn takes unit hero returns nothing set udg_loc = GetRectCenter(gg_rct_AllianceSpawn) call ReviveHeroLoc( hero, udg_loc, true ) call RemoveLocation( udg_loc ) endfunction |
| 02-06-2007, 02:54 PM | #2 |
TriggerSleepAction is inaccurate, as is PolledWait. You'll need timers or periodic events. |
| 02-06-2007, 03:16 PM | #3 |
How would I code that to accomodate my multiboard? The only interractions I've had with timers have been with a timer window... Would it be something like: JASS:function Multiboard_Update takes integer dur, unit hero returns nothing local integer a = GetConvertedPlayerId(GetOwningPlayer(hero)) call StartTimerBJ( udg_atimer[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], false, dur ) loop call MultiboardSetItemValueBJ( udg_multiboard, 2, (a + 1), I2S(dur) ) set dur = udg_atimer[a] exitwhen dur == 0 endloop call MultiboardSetItemValueBJ( udg_multiboard, 2, a, (" ") ) if IsPlayerAlly(GetOwningPlayer(hero), Player(0)) then call Alliance_Respawn(hero) elseif IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(6)) then call Ancients_Respawn(hero) endif endfunction ??? Except, on that, I get an error "Cannot convert timer to integer" which makes sense since the timer really isn't an integer counting backwards..its an actual timer with built-in degredation per second and whatnot...but how would I fix that? |
| 02-06-2007, 04:04 PM | #4 |
hmmm Like use 2 timers? One expires every second, the other one expires after 100000 seconds, then when first timer expires set the value of multiboard item to elapsed time of second timer? |
| 02-06-2007, 05:29 PM | #5 |
Not necesarily...I don't mind how many timers are used (even using 1 timer that's set to the appropriate respawn time) so long as I can correctly get the countdown on the multiboard and have the hero respawn at the appropriate time. |
| 02-06-2007, 08:20 PM | #6 |
Thanks for the assistance, but I actually rewrote my multiboard_update function: JASS:function Multiboard_Update takes nothing returns nothing local integer a = 1 // Multiboard_Dead (column 2) loop exitwhen a == 12 if a != 1 and a != 6 then call MultiboardSetItemValueBJ( udg_multiboard, 2, (a + 1), ( "|cffffcc00" + ( I2S(udg_multiboard_dead[a] ) ) + "|r" ) ) endif if udg_multiboard_deadbool[a]== true then if IsPlayerAlly(GetOwningPlayer(udg_hero[a]), Player(0)) and udg_multiboard_dead[a] == 0 then call Alliance_Respawn(udg_hero[a]) set udg_multiboard_deadbool[a] = false elseif IsPlayerAlly(GetOwningPlayer(udg_hero[a]), Player(6)) and udg_multiboard_dead[a] == 0 then call Ancients_Respawn(udg_hero[a]) set udg_multiboard_deadbool[a] = false endif endif // Multiboard_Kills (column 3) call MultiboardSetItemValueBJ( udg_multiboard, 3, (a + 1), ( "|cffffcc00" + ( I2S( udg_multiboard_k[a] ) ) + "|r" ) ) // Multiboard_Dead (column 4) call MultiboardSetItemValueBJ( udg_multiboard, 4, (a + 1), ( "|cffffcc00" + ( I2S( udg_multiboard_d[a] ) ) + "|r" ) ) set a = a + 1 endloop call MultiboardSetItemValueBJ( udg_multiboard, 2, a, (" ") ) endfunction Ok, so does this function leak at ALL? Its called every second, which means in a 45 minute-60 minute game, it could leak a lot of memory. |
