hi to remove some triggersleepaction i changed a little bit my functions, i wonder if i did it correctly...
i am not used to play with timers.
[Jass=]
private function Display takes player owner, integer msg returns nothing
if IsPlayerInForce(owner, udg_Team[1]) == true then
if msg == 1 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ("The Gods respect the BloodSpear Tribe !! They gave power to the Totem of " + GetPlayerName(owner) + "." ))
elseif msg == 2 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ( "|c009966ffOld Troll:|r |c00ffff64" + GetPlayerName(owner) + " from the Bloodspear Tribe" + " haz been stricken by lightning!|r" ))
endif
elseif IsPlayerInForce(owner, udg_Team[2]) == true then
if msg == 1 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ("The Gods respect the GoldTooth Tribe !! They gave power to the Totem of " + GetPlayerName(owner) + "." ))
elseif msg == 2 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ( "|c009966ffOld Troll:|r |c00ffff64" + GetPlayerName(owner) + " from the Goldtooth Tribe" + " haz been stricken by lightning!|r" ))
endif
elseif IsPlayerInForce(owner, udg_Team[3]) == true then
if msg == 1 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ("The Gods respect the StoneSkin Tribe !! They gave power to the Totem of " + GetPlayerName(owner) + "." ))
elseif msg == 2 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ( "|c009966ffOld Troll:|r |c00ffff64" + GetPlayerName(owner) + " from the Stoneskin Tribe" + " haz been stricken by lightning!|r" ))
endif
endif
endfunction
private function FlashUnit takes integer t returns nothing
local real x
local real y
local real dmg
local player owner
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call DisplayTimedTextToPlayer( Player(0), 0, 0, 6.00, ( "Units: " + GetUnitName(ztarget[t]) ) )
set x = GetUnitX(ztarget[t])
set y = GetUnitY(ztarget[t])
set i = GetUnitTypeId(ztarget[t])
set owner = GetOwningPlayer(ztarget[t])
if i == TOTEM_ID then
call SetUnitState(ztarget[t], UNIT_STATE_MANA, 500.)
call Display(owner,1)
elseif IsUnitType(ztarget[t], UNIT_TYPE_STRUCTURE) then
set dmg = GetRandomReal(25.00, 50.00)
elseif IsUnitType(ztarget[t], UNIT_TYPE_HERO) then
set dmg = GetRandomReal(100.00, 200.00)
call Display(owner,2)
else
set dmg = GetRandomReal(50.00, 300.00)
endif
if GetUnitState(ztarget[t],UNIT_STATE_LIFE) > dmg then
call SetUnitState(ztarget[t], UNIT_STATE_LIFE, (GetUnitState(ztarget[t], UNIT_STATE_LIFE) - dmg) )
else
call KillUnit( ztarget[t] )
if IsUnitType(ztarget[t], UNIT_TYPE_HERO) then
set udg_Die_Lightning[GetPlayerId(owner)+1] = ( udg_Die_Lightning[GetPlayerId(owner)+1] + 1 )
endif
endif
set lightbolt = AddSpecialEffect( "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl", x, y )
call PlaySoundBJ( gg_snd_LightningBolt1 )
call TriggerSleepAction( 0.10 )
call DestroyEffect( lightbolt )
set owner =null
endfunction
private function FlashTree takes integer t returns nothing
local real x
local real y
local unit fire
local destructable d
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
set x = GetDestructableX(udg_Tree[t])
set y = GetDestructableY(udg_Tree[t])
call DisableTrigger( gg_trg_DropItemDestructible__JASS )
call RemoveDestructable(udg_Tree[t])
call EnableTrigger( gg_trg_DropItemDestructible__JASS )
set d = CreateDestructable( 'NTtw', x, y, 0., 0.90, GetRandomInt(0, 9) )
call TriggerRegisterDeathEvent( gg_trg_DropItemDestructible__JASS, d )
set lightbolt = AddSpecialEffect( "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl", x, y )
if GetRandomInt(1, 20) == 1 then
set fire = CreateUnit( Player(PLAYER_NEUTRAL_AGGRESSIVE), 'n00S', x, y, bj_UNIT_FACING )
call SetUnitUserData( fire, 2)
if udg_Rain == false and udg_Wind == false then
call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 60.) )
call SetUnitAbilityLevel( fire, 'A0H7', 2 )
else
call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 40.) )
if udg_Rain then
call SetUnitAbilityLevel( fire, 'A0H7', 1 )
else
call SetUnitAbilityLevel( fire, 'A0H7', 3 )
endif
endif
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 4.00, "|c009966ffOld Troll:|r |c00ffff64Oh, no, mon, a forest fire!|r" )
call PingMinimap( x, y, 4.00 )
endif
call PlaySoundBJ( gg_snd_LightningBolt1 )
call TriggerSleepAction( 0.10 )
call DestroyEffect( lightbolt )
set d =null
set fire =null
endfunction
private function Lightning takes integer chance, integer count returns nothing
local integer t
if ( GetRandomInt(1, chance) == 1 ) then
set t = GetRandomInt(0, count)
if GetUnitState(ztarget[t], UNIT_STATE_LIFE) > 0.00 then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call TimerStart(flashTimer, 0.2, false, function FlashUnit(t))
endif
else
set t = GetRandomInt(1, udg_Tree_count)
if GetDestructableLife(udg_Tree[t]) > 0 then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call TimerStart(flashTimer, 0.2, false, function FlashUnit(t))
endif
endif
endfunction
[/code]
the variable wich aren't in the locals are globals, ztarget (unit array) , lightbolt (effect)
before FlashUnit and FlashTree were all inside Lightning...
there was a call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
then a wait 0.10 and again a call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )...
i added a globals timer "flashTimer" to wait 0.20 and then launch the rest of the function.
also i would like to know how to clean the timer, or can i use it many time without leak?
the timer is a single shot wich simulate a wait period. i need to use it many time, i created it once in the library globals as a privet globals timer...
i am not used to play with timers.
[Jass=]
private function Display takes player owner, integer msg returns nothing
if IsPlayerInForce(owner, udg_Team[1]) == true then
if msg == 1 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ("The Gods respect the BloodSpear Tribe !! They gave power to the Totem of " + GetPlayerName(owner) + "." ))
elseif msg == 2 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ( "|c009966ffOld Troll:|r |c00ffff64" + GetPlayerName(owner) + " from the Bloodspear Tribe" + " haz been stricken by lightning!|r" ))
endif
elseif IsPlayerInForce(owner, udg_Team[2]) == true then
if msg == 1 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ("The Gods respect the GoldTooth Tribe !! They gave power to the Totem of " + GetPlayerName(owner) + "." ))
elseif msg == 2 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ( "|c009966ffOld Troll:|r |c00ffff64" + GetPlayerName(owner) + " from the Goldtooth Tribe" + " haz been stricken by lightning!|r" ))
endif
elseif IsPlayerInForce(owner, udg_Team[3]) == true then
if msg == 1 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ("The Gods respect the StoneSkin Tribe !! They gave power to the Totem of " + GetPlayerName(owner) + "." ))
elseif msg == 2 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, ( "|c009966ffOld Troll:|r |c00ffff64" + GetPlayerName(owner) + " from the Stoneskin Tribe" + " haz been stricken by lightning!|r" ))
endif
endif
endfunction
private function FlashUnit takes integer t returns nothing
local real x
local real y
local real dmg
local player owner
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call DisplayTimedTextToPlayer( Player(0), 0, 0, 6.00, ( "Units: " + GetUnitName(ztarget[t]) ) )
set x = GetUnitX(ztarget[t])
set y = GetUnitY(ztarget[t])
set i = GetUnitTypeId(ztarget[t])
set owner = GetOwningPlayer(ztarget[t])
if i == TOTEM_ID then
call SetUnitState(ztarget[t], UNIT_STATE_MANA, 500.)
call Display(owner,1)
elseif IsUnitType(ztarget[t], UNIT_TYPE_STRUCTURE) then
set dmg = GetRandomReal(25.00, 50.00)
elseif IsUnitType(ztarget[t], UNIT_TYPE_HERO) then
set dmg = GetRandomReal(100.00, 200.00)
call Display(owner,2)
else
set dmg = GetRandomReal(50.00, 300.00)
endif
if GetUnitState(ztarget[t],UNIT_STATE_LIFE) > dmg then
call SetUnitState(ztarget[t], UNIT_STATE_LIFE, (GetUnitState(ztarget[t], UNIT_STATE_LIFE) - dmg) )
else
call KillUnit( ztarget[t] )
if IsUnitType(ztarget[t], UNIT_TYPE_HERO) then
set udg_Die_Lightning[GetPlayerId(owner)+1] = ( udg_Die_Lightning[GetPlayerId(owner)+1] + 1 )
endif
endif
set lightbolt = AddSpecialEffect( "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl", x, y )
call PlaySoundBJ( gg_snd_LightningBolt1 )
call TriggerSleepAction( 0.10 )
call DestroyEffect( lightbolt )
set owner =null
endfunction
private function FlashTree takes integer t returns nothing
local real x
local real y
local unit fire
local destructable d
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
set x = GetDestructableX(udg_Tree[t])
set y = GetDestructableY(udg_Tree[t])
call DisableTrigger( gg_trg_DropItemDestructible__JASS )
call RemoveDestructable(udg_Tree[t])
call EnableTrigger( gg_trg_DropItemDestructible__JASS )
set d = CreateDestructable( 'NTtw', x, y, 0., 0.90, GetRandomInt(0, 9) )
call TriggerRegisterDeathEvent( gg_trg_DropItemDestructible__JASS, d )
set lightbolt = AddSpecialEffect( "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl", x, y )
if GetRandomInt(1, 20) == 1 then
set fire = CreateUnit( Player(PLAYER_NEUTRAL_AGGRESSIVE), 'n00S', x, y, bj_UNIT_FACING )
call SetUnitUserData( fire, 2)
if udg_Rain == false and udg_Wind == false then
call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 60.) )
call SetUnitAbilityLevel( fire, 'A0H7', 2 )
else
call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 40.) )
if udg_Rain then
call SetUnitAbilityLevel( fire, 'A0H7', 1 )
else
call SetUnitAbilityLevel( fire, 'A0H7', 3 )
endif
endif
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 4.00, "|c009966ffOld Troll:|r |c00ffff64Oh, no, mon, a forest fire!|r" )
call PingMinimap( x, y, 4.00 )
endif
call PlaySoundBJ( gg_snd_LightningBolt1 )
call TriggerSleepAction( 0.10 )
call DestroyEffect( lightbolt )
set d =null
set fire =null
endfunction
private function Lightning takes integer chance, integer count returns nothing
local integer t
if ( GetRandomInt(1, chance) == 1 ) then
set t = GetRandomInt(0, count)
if GetUnitState(ztarget[t], UNIT_STATE_LIFE) > 0.00 then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call TimerStart(flashTimer, 0.2, false, function FlashUnit(t))
endif
else
set t = GetRandomInt(1, udg_Tree_count)
if GetDestructableLife(udg_Tree[t]) > 0 then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call TimerStart(flashTimer, 0.2, false, function FlashUnit(t))
endif
endif
endfunction
[/code]
the variable wich aren't in the locals are globals, ztarget (unit array) , lightbolt (effect)
before FlashUnit and FlashTree were all inside Lightning...
there was a call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
then a wait 0.10 and again a call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )...
i added a globals timer "flashTimer" to wait 0.20 and then launch the rest of the function.
also i would like to know how to clean the timer, or can i use it many time without leak?
the timer is a single shot wich simulate a wait period. i need to use it many time, i created it once in the library globals as a privet globals timer...