• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Slide, Slider, Slide - Submission

Status
Not open for further replies.
The uploaded Map contains all classes of Slider (7-11), each is a own Trigger-File.
wex is needed to use the precreated Map.
I changed the Filed "Value - can escape" of all Sliders in Object Editor to "false".
JASS:
function InitTrig_Class_Slider takes nothing returns nothing
    set udg_Hash = InitHashtable()
    //Sliding Intervall = 1/32
    set udg_SlidingSpeed = 400.0/32.0
endfunction
JASS:
function selectCar takes nothing returns nothing
   local integer uType = LoadInteger(udg_Hash, GetHandleId(GetClickedButton () ),0)
   local player p = GetTriggerPlayer()
   local integer pStart = GetPlayerStartLocation(p)
   local unit car = CreateUnit(p, uType,  GetStartLocationX (pStart), GetStartLocationY (pStart), 270)
 
   //Trick
   call UnitAddAbility(car, 'Aloc')
   call ShowUnit(car, false)
   call ShowUnit(car, true)
   call UnitRemoveAbility(car, 'Aloc')
 
   //Select car, Move Cam
   if ( GetLocalPlayer() == p) then
       call PanCameraToTimed(GetUnitX(car),GetUnitY(car),0)
       call ClearSelection()
       call SelectUnit(car, true)
   endif
   set car = null
   set p = null
endfunction

function initDialog takes nothing returns nothing
   local trigger triggerSelectCar = CreateTrigger()
   local dialog  dia = DialogCreate()
   local integer diaId = GetHandleId(dia)
   local button  but
   local integer loopA = 0
 
 
   //Create Dialog, Buttons and Save UnitTypes onto Buttons
   call SaveDialogHandle(udg_Hash, GetHandleId(triggerSelectCar), 0, dia)
   set but = DialogAddButton (dia, "Tank [1]", 49) //Asci 49 = "1"
   call SaveButtonHandle(udg_Hash, diaId, 0, but)
   call SaveInteger(udg_Hash, GetHandleId(but), 0, 'H000')
   set but = DialogAddButton (dia, "Bike [2]", 50) //Asci 50 = "2"
   call SaveButtonHandle(udg_Hash, diaId, 1, but)
   call SaveInteger(udg_Hash, GetHandleId(but), 0, 'H001')
    call TriggerRegisterDialogEvent (triggerSelectCar, dia)
   call TriggerAddAction(triggerSelectCar, function selectCar)
   call DialogSetMessage(dia, "Select a Car")
 
   //Show Dialog to all Players
   loop
       exitwhen loopA > 11
       call DialogDisplay (Player(loopA), dia, true)
       set loopA = loopA + 1
   endloop
 
   call DestroyTimer( GetExpiredTimer ())
   set triggerSelectCar = null
   set dia = null
   set but = null
endfunction


//===========================================================================
function InitTrig_Class_7 takes nothing returns nothing
   //set udg_Hash = InitHashtable()
   call TimerStart(CreateTimer(), 0.00, false, function initDialog)
endfunction
JASS:
function timerExpires takes nothing returns nothing
   local timer t = GetExpiredTimer()
   local unit timerUnit = LoadUnitHandle(udg_Hash,GetHandleId(t),0)
   local real x = GetUnitX(timerUnit)
   local real y = GetUnitY(timerUnit)
   local integer terrainType = GetTerrainType(x,y)
   //Paused Units do not slide
   if IsUnitPaused(timerUnit) then
       return
   endif
   //Stands on Snow? -> Kill Unit and Timer
   if ( terrainType == 'Nsnw') then
       call KillUnit(timerUnit)
       call PauseTimer(t)
       //call DestroyTimer(t)
       //call FlushChildHashtable(udg_Hash, GetHandleId(t))
       return
   endif
 
   //Stands on "Northrend - Ice", "Icerown Glacier - Dark Ice" and "Underground - Lava"?
   if ( terrainType == 'Nice' or terrainType == 'Idki' or terrainType == 'Glav') then
       call SetUnitPropWindow(timerUnit, 0)
       call SetUnitX(timerUnit,x + udg_SlidingSpeed*Cos(GetUnitFacing(timerUnit)*bj_DEGTORAD))
       call SetUnitY(timerUnit,y + udg_SlidingSpeed*Sin(GetUnitFacing(timerUnit)*bj_DEGTORAD))
   else
       call SetUnitPropWindow(timerUnit, GetUnitDefaultPropWindow(timerUnit))
   endif
endfunction

function registerSlider takes nothing returns nothing
   local timer t
   local unit triggerUnit = GetTriggerUnit()
   if (GetUnitTypeId(triggerUnit) == 'H000' or GetUnitTypeId(triggerUnit) == 'H001') then
       set t = CreateTimer()
       call SaveUnitHandle(udg_Hash,GetHandleId(t),0,triggerUnit)
       call TimerStart(t, 1.0/32.0, true, function timerExpires)
       call SaveTimerHandle(udg_Hash,GetHandleId(triggerUnit),0,t)
   endif
   set t = null
   set triggerUnit = null
endfunction

//===========================================================================
function InitTrig_Class_8 takes nothing returns nothing
   local trigger triggerEnter = CreateTrigger()
   //set udg_Hash = InitHashtable()
   call TriggerRegisterEnterRectSimple( triggerEnter, GetPlayableMapRect() )
   call TriggerAddAction(triggerEnter, function registerSlider)
endfunction
JASS:
function steeringCondition takes nothing returns boolean
   //  move=851986 smart=851971
   return (GetUnitTypeId(GetTriggerUnit()) == 'H000' or GetUnitTypeId(GetTriggerUnit()) == 'H001' ) and ( GetIssuedOrderId() == 851986 or GetIssuedOrderId() == 851971)
endfunction

function steeringAction takes nothing returns nothing
   local unit triggerUnit = GetTriggerUnit()
   local real x = GetUnitX(triggerUnit)
   local real y = GetUnitY(triggerUnit)
   local real facing = GetUnitFacing(triggerUnit)
   local integer terrainType = GetTerrainType(x,y)
   if ( terrainType == 'Idki') then
       call DisableTrigger(GetTriggeringTrigger())
       set facing = facing*bj_DEGTORAD
       call IssuePointOrder(triggerUnit, "move", x + 200*Cos(facing), y + 200*Sin(facing))
       call EnableTrigger(GetTriggeringTrigger())
   else
       if ( terrainType == 'Glav') then
           call DisableTrigger(GetTriggeringTrigger())
           set facing = Atan2(GetOrderPointY() - y, GetOrderPointX() - x)
           set facing = facing + bj_PI
           call IssuePointOrder(triggerUnit, "move", x + 200*Cos(facing), y + 200*Sin(facing))
           call EnableTrigger(GetTriggeringTrigger())
       endif
   endif
endfunction

//===========================================================================
function InitTrig_Class_9 takes nothing returns nothing
   //set udg_Hash = InitHashtable()
    set gg_trg_Class_9 = CreateTrigger(  )
    call TriggerAddAction(gg_trg_Class_9, function steeringAction)
   call TriggerAddCondition(gg_trg_Class_9, Condition( function steeringCondition))
   call TriggerRegisterAnyUnitEventBJ( gg_trg_Class_9, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
endfunction
JASS:
function ReviveCon takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'H000' or GetUnitTypeId(GetTriggerUnit()) == 'H001'
endfunction

function Revive takes nothing returns nothing
   local player p = GetTriggerPlayer()
   local unit hero = GetTriggerUnit()
   local integer pStart = GetPlayerStartLocation(p)
   call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, ( GetPlayerName(p) + " died!" ))
    call TriggerSleepAction( 3.00 )
   call ReviveHero (hero, GetStartLocationX (pStart),GetStartLocationY (pStart), true )
   //Select hero, Move Cam
 
   if ( GetLocalPlayer() == p) then
       call PanCameraTo(GetUnitX(hero),GetUnitY(hero))
       call ClearSelection()
       call SelectUnit(hero, true)
   endif
   call TimerStart(LoadTimerHandle(udg_Hash,GetHandleId(hero),0), 1.0/32.0, true, function timerExpires)
   set p = null
   set hero = null
endfunction

//===========================================================================
function InitTrig_Class_10 takes nothing returns nothing
    set gg_trg_Class_10 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Class_10, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Class_10, Condition( function ReviveCon ) )
    call TriggerAddAction( gg_trg_Class_10, function Revive)
endfunction
JASS:
function Win takes nothing returns nothing
   local unit hero = GetTriggerUnit()
   local player p = GetOwningPlayer(hero)
   local group g = CreateGroup()
   local unit fog
   call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 99999, ( GetPlayerName(p) + " won!" ))
   call PauseAllUnitsBJ(true)
   call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_AGGRESSIVE), null)
   loop
       set fog = FirstOfGroup(g)
       exitwhen fog == null
       call GroupRemoveUnit(g,fog)
       call RemoveUnit(fog)
   endloop
   call DestroyGroup(g)
   set hero = null
   set g = null
   set p = null
endfunction

//===========================================================================
function InitTrig_Class_11 takes nothing returns nothing
   local group g = CreateGroup()
   local unit fog
    set gg_trg_Class_11 = CreateTrigger(  )
    call TriggerRegisterUnitInRange(gg_trg_Class_11, gg_unit_n000_0001, 90, null)
    call TriggerAddAction( gg_trg_Class_11, function Win )
   //Make Preplaced Creeps locust
   call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_AGGRESSIVE), null)
   loop
       set fog = FirstOfGroup(g)
       exitwhen fog == null
       call GroupRemoveUnit(g,fog)
       //Trick
       call UnitAddAbility(fog, 'Aloc')
   //   call ShowUnit(fog, false)
   //   call ShowUnit(fog, true)
   //   call UnitRemoveAbility(fog, 'Aloc')
   endloop
   call DestroyGroup(g)
   set g = null
endfunction
 

Attachments

  • JASS Class Slide - All.w3x
    35.9 KB · Views: 78
I (still) can't technically test the demo, sorry, though I now just give code Feedback and judge it from shown code. : )

Slider Class:

We could put the interval into a constant, and then we the timers timeout, and the Speed calculs can refer to this value.

Slider Dialog

Functionally Looks good and should work.

Technically marks:

call DialogDisplay (GetLocalPlayer(), dia, true)

^To Show Dialog to all playing players.

Why is the Dialog saved to hashtable? Just curious.

It might be some sugar if the functionality to bind a button with unit type to the existing Dialog is de-coupled into an extra function.
From main code then, like "call DialogAddHero(whichDialog, whichName, whichData" with:
call DialogAddHero(dia, "Tank [1]", 'H000')
call DialogAddHero(dia, "Bike [2]", 'H001')
etc.

Slider Slide

GetPlayableMapRect()

^Don't be lazy! Don't do all BJs.

I would technically prefer if we we logially bind the Registration to the unit creation from the Dialog in a way.
That way, we can Limit the slider Registration only to Units which the Player creates with Dialog, and not (possibly) other creations of the unit type. It's probably not likely to happen, but it's good practice not to create Logical gaps.

Slider Steer

No move orders are needed, as we can use SetUnitFacing() functionality.

Here, we also check for unit's type instead of a water-proof slider check, which can leak technically.
We could for example put all sliders into a Group "Sliders" and then check for Group Integration if the unit exists there, or not.

Slider Death

Same concern with unit type check as before.
Using TriggerSleepAction() is sub-optimal for such issues, and precise timers should be used. We can even use the very same unit-timer, fire it as one-shot to revive the unit, and then use it as periodic timer again for sliding.

Slider Death

We need to ensure it's a slider that is getting in the range.

==

How was your feel about the missions, and the demo? I'm sorry that I can't test it right now.
Though that I dont test it wont stop us from going on.
 
It is a fine simple basic slider-road, but i would suggest to disable escaping from the slider units as i wrote above.
Each mission contains 1 or 2 simple tasks which add further functionallty to the overall code, allowing to handle each one independent and seperated, if one insist doing that, quite good.

Group "Sliders
dat is a really good idea.

Why is the Dialog saved to hashtable? Just curious.
To be theorically able to destroy it as soon selection is over, what i did not.
But now that i think a second time, clickedDialog() could simply be used and is faster.

I would technically prefer if we we logially bind the Registration to the unit creation from the Dialog in a way.
That way, we can Limit the slider Registration only to Units which the Player creates with Dialog, and not (possibly) other creations of the unit type. It's probably not likely to happen, but it's good practice not to create Logical gaps.
Yeah it would be, but I done this mission with the idea that each part of it works as independent part.
Hmm, could throw an event instead of using the default entering event. It would maintain current structure.

No move orders are needed, as we can use SetUnitFacing() functionality.
A while past but i think there were some problems with using SetUnitFacing() here.
Now i know it, overwriting Orders, i would have to wait 0 seconds and stop the current order to make SetUnitFacing work, was in my opinon not worth it.

We need to ensure it's a slider that is getting in the range.
Ah, such a weak misstake how i could miss that. Guess the not used sliderGroup which makes completly sense to use.

An update will be uploaded soon.
Thanks for your feedback and providing this missions.
 
A while past but i think there were some problems with using SetUnitFacing() here.
Now i know it, overwriting Orders, i would have to wait 0 seconds and stop the current order to make SetUnitFacing work, was in my opinon not worth it.
I think you dont have to wait 0 seconds when you pause the unit/unpause it as trick.
This logic is from Sliding System v3.4:
JASS:
                    if( (order == SMART) and (Terrain[terrainType].allowSteer)) then
                        // Let the slider turn.
                        call SetUnitFacing( u, (Atan2(GetOrderPointY() - y , GetOrderPointX() - x) * bj_RADTODEG) + Terrain[terrainType].angle)
                        
                    elseif ((order != SMART) and (order != MOVE) and (order != PATROL) and (Terrain[terrainType].allowCast)) then
                        // The slider is casting an ability. Let him face wanted position, if allowed.
                        call SetUnitFacing( u, Atan2(GetOrderPointY() - y , GetOrderPointX() - x) * bj_RADTODEG)
                        set b = false
                    endif
                    
                    if ((order == SMART) or (order == MOVE) or (order == PATROL) or (b)) then
                        call DisableTrigger( steerTrigger )
                        call PauseUnit (u,true)
                        call IssueImmediateOrderById(u, STOP)   // That will abbort unit's order if unit is not casting.
                        call PauseUnit (u,false)
                        call EnableTrigger( steerTrigger )
                    endif

Thanks, too. Can you share some thoguhts, especially about the sliding Mission, if Tasks are hard/Long, or just what you think. It helps us for more future missions I guess, too! : )
 
The updated Version:
In this Version the preincluded Code is disabled.
JASS:
General

Added udg_SliderGroup
Added constant function SliderIntervall
Removed the deactivaded hash creating in many classes

Class 7


Show dialog with GetLocalPlayer()
Overworked the Button/Dialog Hash generation
Buttons/Dialog and Trigger get destroyed after all Players selected.
Throws the Event udg_SliderCreatedEvent = 1 with udg_sliderCreatedUnit = car

class 8

catches now the in class 7 provided Event to register new Cars.
Destroyes the Entering Trigger as soon all Players have registered.
moved the Pausetimer before the killunit, which prevented to reuse the timer for reviving.

Class 9

Uses now IsUnitInGroup instead of UnitTypes.
Changed Orderchecks -> Orders pass which are not stun/stop

Class 10

Uses now IsUnitInGroup instead of UnitTypes.
Insert an new function CarDeath in which the timer is reused to revive

Class 11

Added an Trigger Condition IsUnitInGroup
JASS:
function SliderIntervall takes nothing returns real
   return 1.0/32.0
endfunction
function InitTrig_Class_Slider takes nothing returns nothing
    set udg_Hash = InitHashtable()
    set udg_SlidingSpeed = 400.0 * SliderIntervall()
endfunction
JASS:
function selectCar takes nothing returns nothing
   local integer uType = LoadInteger(udg_Hash, GetHandleId(GetClickedButton () ),0)
   local player p = GetTriggerPlayer()
   local integer pStart = GetPlayerStartLocation(p)
   local unit car = CreateUnit(p, uType,  GetStartLocationX (pStart), GetStartLocationY (pStart), 270)
   local integer diaId
   local integer currentIndex
   local integer lastIndex
   //Trick
   call UnitAddAbility(car, 'Aloc')
   call ShowUnit(car, false)
   call ShowUnit(car, true)
   call UnitRemoveAbility(car, 'Aloc')
   call GroupAddUnit(udg_SliderGroup, car)
   //Select car, Move Cam
   if ( GetLocalPlayer() == p) then
       call PanCameraToTimed(GetUnitX(car),GetUnitY(car),0)
       call ClearSelection()
        call SelectUnit(car, true)
   endif
   set udg_SliderCreatedUnit = car
   set udg_SliderCreatedEvent = 1.0
   set udg_SliderCreatedEvent = 0.0
   //DestroyDialog if all Players picked
   if (GetTriggerExecCount(GetTriggeringTrigger()) == CountPlayersInForceBJ(bj_FORCE_ALL_PLAYERS) ) then
       call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, "Destory Dialog")
       set diaId = GetHandleId(GetClickedDialog())
       set currentIndex = 1
       set lastIndex = LoadInteger(udg_Hash,diaId,0)
       //Loop all include Buttons and Clear their hash stuff
       loop
           exitwhen currentIndex > lastIndex
           call FlushChildHashtable(udg_Hash, GetHandleId(LoadButtonHandle(udg_Hash,diaId,currentIndex))) 
           set currentIndex = currentIndex + 1
       endloop
       call FlushChildHashtable(udg_Hash, diaId)
       call DialogClear(GetClickedDialog())
       call DialogDestroy(GetClickedDialog())
       call DestroyTrigger(GetTriggeringTrigger())
   endif
   set car = null
   set p = null
endfunction

// carId is an UnitTypeId
// text is the shown Text
// hotkey is the used hotkey to call this button, check asci tables to use it.
function addCarToDialog takes integer carId, dialog dia, string text, integer hotkey returns nothing
   local button but
   local integer diaId = GetHandleId(dia)
   local integer size = LoadInteger(udg_Hash,diaId,0) + 1
   call SaveInteger(udg_Hash,diaId,0,size)
   set but = DialogAddButton (dia, text, hotkey)
   call SaveButtonHandle(udg_Hash, diaId, size, but)
   call SaveInteger(udg_Hash, GetHandleId(but), 0, carId)
   set but = null
endfunction

function initDialog takes nothing returns nothing
   local trigger triggerSelectCar = CreateTrigger()
   local dialog  dia = DialogCreate()
 
   //Create Dialog, Buttons and Save UnitTypes onto Buttons
   call addCarToDialog('H000',dia,"Tank [1]", 49)  //Asci 49 = "1"
   call addCarToDialog('H001',dia,"Bike [2]", 50) //Asci 50 = "2"
   call DialogSetMessage(dia, "Select a Car")
 
   //Register DialogEvent
    call TriggerRegisterDialogEvent (triggerSelectCar, dia)
   call TriggerAddAction(triggerSelectCar, function selectCar)
 
   //Show Dialog to all Players
   call DialogDisplay (GetLocalPlayer(), dia, true)
 
   call DestroyTimer( GetExpiredTimer ())
   set triggerSelectCar = null
   set dia = null
endfunction


//===========================================================================
function InitTrig_Class_7 takes nothing returns nothing
   call TimerStart(CreateTimer(), 0.00, false, function initDialog)
endfunction
JASS:
function timerExpires takes nothing returns nothing
   local timer t = GetExpiredTimer()
   local unit timerUnit = LoadUnitHandle(udg_Hash,GetHandleId(t),0)
   local real x = GetUnitX(timerUnit)
   local real y = GetUnitY(timerUnit)
   local integer terrainType = GetTerrainType(x,y)
   //Paused Units do not slide
   if IsUnitPaused(timerUnit) then
       return
   endif 
   //Stands on Snow? -> Kill Unit
   if ( terrainType == 'Nsnw') then
       call PauseTimer(t)
       call KillUnit(timerUnit)
       return
   endif
 
   //Stands on "Northrend - Ice", "Icerown Glacier - Dark Ice" and "Underground - Lava"?
   if ( terrainType == 'Nice' or terrainType == 'Idki' or terrainType == 'Glav') then
       call SetUnitPropWindow(timerUnit, 0)
       call SetUnitX(timerUnit,x + udg_SlidingSpeed*Cos(GetUnitFacing(timerUnit)*bj_DEGTORAD))
       call SetUnitY(timerUnit,y + udg_SlidingSpeed*Sin(GetUnitFacing(timerUnit)*bj_DEGTORAD))
   else
       call SetUnitPropWindow(timerUnit, GetUnitDefaultPropWindow(timerUnit))
   endif
endfunction

//Called if udg_SliderCreatedEvent = 1.0
//Destroys itself, if executed by all players
function registerSlider takes nothing returns nothing
   local timer t = CreateTimer()
   local unit triggerUnit = udg_SliderCreatedUnit
   call SaveUnitHandle(udg_Hash,GetHandleId(t),0,triggerUnit)
   call TimerStart(t, SliderIntervall(), true, function timerExpires)
   call SaveTimerHandle(udg_Hash,GetHandleId(triggerUnit),0,t)
   //Destroy if all Players have selected, normaly you would have to count down if players leave but lets skip that.
   if (GetTriggerExecCount(GetTriggeringTrigger()) == CountPlayersInForceBJ(bj_FORCE_ALL_PLAYERS) ) then
       call DestroyTrigger(GetTriggeringTrigger())
       call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, "destory CarCreating Listener")
   endif
   set t = null
   set triggerUnit = null
endfunction

//===========================================================================
function InitTrig_Class_8 takes nothing returns nothing
   local trigger triggerEnter = CreateTrigger()
   call TriggerRegisterVariableEvent( triggerEnter, "udg_SliderCreatedEvent", EQUAL, 1.00 )
   call TriggerAddAction(triggerEnter, function registerSlider)
endfunction
JASS:
// 851973 = stuned
// 851972 = stop
function steeringCondition takes nothing returns boolean
   return IsUnitInGroup(GetTriggerUnit(), udg_SliderGroup) and GetIssuedOrderId() != 851972 and GetIssuedOrderId() != 851973
endfunction

function steeringAction takes nothing returns nothing
   local unit triggerUnit = GetTriggerUnit()
   local real x = GetUnitX(triggerUnit)
   local real y = GetUnitY(triggerUnit)
   local real facing = GetUnitFacing(triggerUnit)
   local integer terrainType = GetTerrainType(x,y)
   //Don't Turn?
   if ( terrainType == 'Idki') then
       call PauseUnit(triggerUnit, true)
       call IssueImmediateOrderById(triggerUnit, 851972)
       call SetUnitFacing(triggerUnit,facing)
       call PauseUnit(triggerUnit, false)
   else
       //Turn by Angle to target Point + 180?
       if ( terrainType == 'Glav') then
           set facing = Atan2(GetOrderPointY() - y, GetOrderPointX() - x)
           set facing = facing + bj_PI
           set facing = facing * bj_RADTODEG
           call PauseUnit(triggerUnit, true)
           call IssueImmediateOrderById(triggerUnit, 851972)
           call SetUnitFacing(triggerUnit,facing)
           call PauseUnit(triggerUnit, false)
       endif
   endif
endfunction

//===========================================================================
function InitTrig_Class_9 takes nothing returns nothing
    set gg_trg_Class_9 = CreateTrigger(  )
    call TriggerAddAction(gg_trg_Class_9, function steeringAction)
   call TriggerAddCondition(gg_trg_Class_9, Condition( function steeringCondition))
   call TriggerRegisterAnyUnitEventBJ( gg_trg_Class_9, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
endfunction
JASS:
function ReviveCon takes nothing returns boolean
    return IsUnitInGroup(GetTriggerUnit(), udg_SliderGroup)
endfunction

function Revive takes nothing returns nothing
   local timer t = GetExpiredTimer()
   local unit hero = LoadUnitHandle(udg_Hash,GetHandleId(t),0)
   local player p =  GetOwningPlayer (hero)
   local integer pStart = GetPlayerStartLocation(p)
   local real x = GetStartLocationX (pStart)
   local real y = GetStartLocationY (pStart)
   call ReviveHero (hero, x,y, true )
   //Select hero, Move Cam
   if ( GetLocalPlayer() == p) then
       call PanCameraToTimed(x,y,0)
       call ClearSelection()
        call SelectUnit(hero, true)
   endif
   call TimerStart(t, SliderIntervall(), true, function timerExpires)
   set p = null
   set hero = null
   set t = null
endfunction

function CarDeath takes nothing returns nothing
   local timer t = LoadTimerHandle(udg_Hash,GetHandleId(GetTriggerUnit()),0)
   call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, ( GetPlayerName(GetTriggerPlayer()) + " died!" ))
   call TimerStart(t, 3.0, false, function Revive)
   set t = null
endfunction

//===========================================================================
function InitTrig_Class_10 takes nothing returns nothing
    set gg_trg_Class_10 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Class_10, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Class_10, Condition( function ReviveCon ) )
    call TriggerAddAction( gg_trg_Class_10, function CarDeath)
endfunction
JASS:
function WinCon takes nothing returns boolean
   return IsUnitInGroup(GetTriggerUnit(), udg_SliderGroup)
endfunction

function Win takes nothing returns nothing
   local unit hero = GetTriggerUnit()
   local player p = GetOwningPlayer(hero)
   local group g = CreateGroup()
   local unit fog
   call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 99999, ( GetPlayerName(p) + " won!" ))
   call PauseAllUnitsBJ(true)
   call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_AGGRESSIVE), null)
   loop
       set fog = FirstOfGroup(g)
       exitwhen fog == null
       call GroupRemoveUnit(g,fog)
       call RemoveUnit(fog)
   endloop
   call DestroyGroup(g)
   set hero = null
   set g = null
   set p = null
endfunction

//===========================================================================
function InitTrig_Class_11 takes nothing returns nothing
   local group g = CreateGroup()
   local unit fog
    set gg_trg_Class_11 = CreateTrigger(  )
    call TriggerRegisterUnitInRange(gg_trg_Class_11, gg_unit_n000_0001, 90, null)
   call TriggerAddCondition(gg_trg_Class_11, Condition(function WinCon))
    call TriggerAddAction( gg_trg_Class_11, function Win )
   //Make Preplaced Creeps locust
   call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_AGGRESSIVE), null)
   loop
       set fog = FirstOfGroup(g)
       exitwhen fog == null
       call GroupRemoveUnit(g,fog)
       //Trick
       call UnitAddAbility(fog, 'Aloc')
   //   call ShowUnit(fog, false)
   //   call ShowUnit(fog, true)
   //   call UnitRemoveAbility(fog, 'Aloc')
   endloop
   call DestroyGroup(g)
   set g = null
endfunction
:) now i see the "5" in the created slider-road.
 

Attachments

  • JASS Class Slide - All.w3x
    36 KB · Views: 60
Dialog:

Looks good, the whole thing. The dialog-destroy should only account active players and no comps, but it wasn't asked for anyways at first, so it's up to you to change it.

Btw, just my personal opinion: we should not consider too much with implementing logics for destroying static objects (trigger). For example the registration trigger; yes in this scenatio one player creates one slider, and never ever again; though if there are functional changes in gameplay, or so, then you need to change the code again. What I mean is that we win really nothing at all with this extra logic, but we only limit our code and hardcode it to one slider/player at the game for no reason. Just my opinion.

The TriggerRegisterVariableEvent is okay to use ; running a global trigger would be also an alternative, for just naming it. Or to put register functions into the header.

Overall, a good piece of code! Neat.

I personaly would prefer using some JassHelper sugar like putting logis together in scopes or libraries for better structering and readability. Idk if you're not using in on purpose, but if you want to use it and just have questions we can always talk in chat or so -- or of course maybe you simply don't want, then it's fine, too.

can't test the map as said, but I suppose it should work, and will mark it as solved tomorrow, or so after I read it once more. : )
 
with "5" i mean this :)

5 in road.jpg

 
Status
Not open for further replies.
Top