HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Victory Trigger, countdown and player changes

08-23-2008, 12:51 AM#1
Crevax
To help along my learning of JASS/vJASS, I decided to make a small, simple king-of-the-hill-like arena. So far everything has been working fine (whether it's optimal will be figured out as I go along). Last thing on my list is working on the victory trigger (couldn't tell by the topic title, could you?).

Just about everything for it is finished, too. But it's a king-of-the-hill like map. What happens is when the unit gains his "king of the hill" status, a countdown timer starts. If nobody else claims the title in the given time, the game ends. So far that's what I have. I'm not sure on how to factor in another unit throwing off the current "king of the hill."

I don't need to be given exactly what to put down for the code, just a prod in the right direction.

Expand Victory:
08-23-2008, 01:29 AM#2
Anopob
Wait so do you mean the code on how one would replace another unit, or how to do it? If the latter and if I understood you right, couldn't you just remove the timer that is currently ticking away and basically repeat the trigger for the new unit (not sure though since can't tell how a unit replaces another on top of the hill)?
08-23-2008, 01:37 AM#3
Crevax
What happens in that when the obelisk is killed, control in granted to the killing player. The player then has to defend the obelisk for a certain amount of time (it's been 10s for single player testing) in order to win. I just need to know how I'd modify the above code to factor in if the obelisk is destroyed during the countdown, restarting the timer for the new killer. Is really really as simple as removing the timer when the obelisk is destroyed again?

Pardon me. My thoughts are jumbled, and I don't think I'm making any sense. I'm wondering if I'd need to use a timer to detect if the obelisk is destroyed during the time frame. For some reason that doesn't seem like the best option.

Edited because: Added second paragraph.
08-23-2008, 04:03 AM#4
DioD
Timer shoud be pub global.

Collapse JASS:
private function Actions takes nothing returns nothing
    local timer t = ExtractTimerFromGlobal()
    local unit obelisk = GetDyingUnit()
    set remaining = ExtractDialogFromGlobal()
    set adventurer = GetKillingUnit()
    call CreateUnit( GetOwningPlayer(adventurer), 'n000', GetUnitX(obelisk), GetUnitY(obelisk), 0 )
    call RemoveUnit(obelisk)
    call TimerDialogSetTitle(remaining, "Time until " +GetPlayerName(GetOwningPlayer(adventurer))+ " wins.")
    call TimerDialogDisplay(remaining, true)
    call TimerStart(t, 10.0, false, function Finish)
    set t = null
    set remaining = null
endfunction

If you call this function again it will overwrite settings and refresh countdown.

Best way to do this - create struct of timer and dialog and attach it to unit.
08-23-2008, 06:56 PM#5
Anopob
Ah I see now. As DioD said, you pretty much need to make a timer and make sure it's reachable (through a global or whatever) so you can destroy it and repeat it through the new killing unit. It's really simple concept wise, you should get it right away.
08-23-2008, 08:20 PM#6
Crevax
I figured it out this morning. <3 Thanks for the help. Here's what the functional code looks like:

Expand Victory: