Вопрос по работе с локальным таймером, по нажатию правой кнопки мыши таймер запускается но когда отпускаешь ее он не останавливается.Не очень пока разбираюсь в jass но пробую по маленьку.
function Trig_LMB21_Actions takes nothing returns nothing
local timer TimerAct2 = CreateTimer()
local integer BB = GetHandleId(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), 0)

call TimerStart(TimerAct2, 0.20, true, function Trig_ShootTest2_Actions)

endfunction
function Trig_LMB1_Actions takes nothing returns nothing
local timer TimerAct2 = GetExpiredTimer()
local integer BB = GetHandleId(TimerAct2)
local real processs = LoadReal(Hash, BB, StringHash("processs"))

call SaveReal(Hash, BB, StringHash("processs"), processs)
call DisplayTextToForce( GetPlayersAll(), "lol2" )
call PauseTimer(TimerAct2)
call DestroyTimer(TimerAct2)

set TimerAct2 = null

 endfunction
 
 function Trig_LMB1_Conditions takes nothing returns boolean  
     if ( not ( BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT ) ) then
        return false
    endif
    return true
endfunction

Принятый ответ

ImNoobTarenas, понятно я кое что напутал , теперь как остановить стрельбу с помощью таймера остановка вроде срабатывает но не совсем
function Trig_LMB1_Actions takes nothing returns nothing
local timer TimerAct2 = GetExpiredTimer()
local integer BB = GetHandleId(TimerAct2)
local real processs = LoadReal(Hash, BB, StringHash("processs"))


call DisplayTextToForce( GetPlayersAll(), "OFF" )
call PauseTimer(TimerAct2)
call DestroyTimer(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), processs)
set TimerAct2 = null

 endfunction

function Trig_ShootTest_Actions3 takes nothing returns nothing
local timer TimerAct = GetExpiredTimer()
local integer id = GetHandleId(TimerAct)
local unit marine = LoadUnitHandle(Hash, id, StringHash("marine"))
local unit Target = LoadUnitHandle(Hash, id, StringHash("Target"))

local unit Dummy = LoadUnitHandle(Hash, id, StringHash("Dummy")) 
local real process = LoadReal(Hash, id, StringHash("process")) + LoadReal(Hash, id, StringHash("Speed"))
local group gACT
local unit u = null

 if process > LoadReal(Hash, id, StringHash("maxDis")) then
 call DestroyGroup(LoadGroupHandle(Hash, id, StringHash("group")))
 call KillUnit(Dummy)
 call FlushChildHashtable(Hash, id)
 call PauseTimer(TimerAct)
 call DestroyTimer(TimerAct)
 
else

 call SaveReal(Hash, id, StringHash("process"), process)
 call SetUnitX(Dummy, GetUnitX(Dummy) + LoadReal(Hash, id, StringHash("Speed")) * Cos(LoadReal(Hash, id, StringHash("angle")) * bj_DEGTORAD))
 call SetUnitY(Dummy, GetUnitY(Dummy) + LoadReal(Hash, id, StringHash("Speed")) * Sin(LoadReal(Hash, id, StringHash("angle")) * bj_DEGTORAD))
 
 set gACT =CreateGroup()
 call GroupEnumUnitsInRange(gACT, GetUnitX(Dummy),GetUnitY(Dummy), LoadReal(Hash, id, StringHash("Aoe")), null )
 
 loop
 
  set u = FirstOfGroup(gACT)
  exitwhen u == null
  
  if GetWidgetLife(u) > 0.405 and not IsUnitInGroup(u, LoadGroupHandle(Hash, id, StringHash("group"))) then
  
      if IsUnitEnemy(u, GetOwningPlayer(marine)) then
         call UnitDamageTarget(marine, u, LoadReal(Hash, id, StringHash("Damege")), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
         call DestroyEffect(AddSpecialEffectTarget(LoadStr(Hash, id, StringHash("BloodEfect")), u, "chest"))
         call RemoveUnit(Dummy)
      else
      
      endif
  
  endif
  
  call GroupRemoveUnit(gACT, u)
  
  endloop
  
   call DestroyGroup(gACT)
   
  endif 
set Target = null
set marine = null
set Dummy = null
set TimerAct = null
set gACT = null

endfunction


function Trig_ShootTest2_Actions takes nothing returns nothing
local unit marine = gg_unit_H000_0003
local unit Target = gg_unit_n000_0005
local real xMarine = GetUnitX(marine)
local real yMarine = GetUnitY(marine)
local real xTarget = GetUnitX(Target)
local real yTarget = GetUnitY(Target)
local real angle = bj_RADTODEG * Atan2(yTarget - yMarine, xTarget - xMarine) + GetRandomReal(-6.00, 6.00)
local unit Dummy = CreateUnit(GetOwningPlayer(marine), 'n001', xMarine, yMarine, angle)

local real maxDis = 1200
local real Damege = 50
local real Aoe = 90
local real Speed = 2000

local string BloodEfect = "Objects/Spawnmodels/Human/HumanBlood/HumanBloodKnight.mdl"
local timer TimerAct = CreateTimer()
local integer id = GetHandleId(TimerAct)
local timer TimerAct2 = CreateTimer()
local integer BB = GetHandleId(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), 0)
if xMarine == xTarget and yMarine == yMarine then
        set angle = GetUnitFacing(marine)
    endif

call SetUnitX(Dummy, xMarine + 106 * Cos(angle * bj_DEGTORAD))
call SetUnitY(Dummy, yMarine + 106 * Sin(angle * bj_DEGTORAD))

call SaveUnitHandle(Hash, id, StringHash("marine"), marine)
call SaveUnitHandle(Hash, id, StringHash("Target"), Target)
call SaveUnitHandle(Hash, id, StringHash("Dummy"), Dummy)

call SaveReal(Hash, id, StringHash("Damege"), Damege)
call SaveReal(Hash, id, StringHash("maxDis"), maxDis)
call SaveReal(Hash, id, StringHash("Aoe"), Aoe)
call SaveReal(Hash, id, StringHash("angle"), angle)
call SaveReal(Hash, id, StringHash("Speed"), Speed * 0.03)
call SaveStr(Hash, id, StringHash("BloodEfect"), BloodEfect)
call SaveReal(Hash, id, StringHash("process"), 0)
call SaveGroupHandle(Hash, id, StringHash("group"), CreateGroup())


call TimerStart(TimerAct, 0.03, true, function Trig_ShootTest_Actions3)

    call StopSoundBJ( gg_snd_GyrocopterImpactHit1, false )
    call PlaySoundBJ( gg_snd_GyrocopterImpactHit1 )
    
    call SetUnitAnimation( gg_unit_H000_0003, "attack" )

set marine = null
set Target = null
set Dummy = null
set TimerAct = null
set TimerAct2 = null


endfunction

function Trig_LMB21_Actions takes nothing returns nothing
local timer TimerAct2 = CreateTimer()
local integer BB = GetHandleId(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), 0)
call DisplayTextToForce( GetPlayersAll(), "ON" )
call TimerStart(TimerAct2, 0.10, true, function Trig_ShootTest2_Actions)
set TimerAct2 = null
endfunction



function Trig_ShootTest2_Conditions takes nothing returns boolean  
     if ( not ( BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT ) ) then
        return false
    endif
    return true
endfunction




//===========================================================================


Таймер не останавливается
function Trig_LMB22_Actions takes nothing returns nothing
local timer TimerAct2 = GetExpiredTimer()
local integer BB = GetHandleId(TimerAct2)



call DisplayTextToForce( GetPlayersAll(), "Off" )
call PauseTimer(TimerAct2)
call DestroyTimer(TimerAct2)

set TimerAct2 = null

 endfunction
 
 
 
 function Trig_LMB21_Actions takes nothing returns nothing
local timer TimerAct2 = CreateTimer()
local integer BB = GetHandleId(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), 0)
call DisplayTextToForce( GetPlayersAll(), "On" )
call TimerStart(TimerAct2, 0.10, false, function Trig_LMB21_Actions)
set TimerAct2 = null
endfunction




 function Trig_LMB22_Conditions takes nothing returns boolean  
     if ( not ( BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT ) ) then
        return false
    endif
    return true
endfunction
function Trig_LMB21_Conditions takes nothing returns boolean  
     if ( not ( BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT ) ) then
        return false
    endif
    return true
endfunction

 
 
//===========================================================================
function InitTrig_LMB2 takes nothing returns nothing
    set gg_trg_LMB2 = CreateTrigger(  )
    
    call TriggerAddCondition( gg_trg_LMB2, Condition( function Trig_LMB22_Conditions ) )
    call TriggerAddCondition( gg_trg_LMB2, Condition( function Trig_LMB21_Conditions ) )

endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
0
19
9 месяцев назад
Отредактирован Таренас
0
поменяйте
call TimerStart(TimerAct2, 0.20, true, function Trig_ShootTest2_Actions)
на
call TimerStart(TimerAct2, 0.20, true, function Trig_LMB1_Actions)
0
8
9 месяцев назад
Отредактирован jasonrus96
0
ImNoobTarenas, понятно я кое что напутал , теперь как остановить стрельбу с помощью таймера остановка вроде срабатывает но не совсем
function Trig_LMB1_Actions takes nothing returns nothing
local timer TimerAct2 = GetExpiredTimer()
local integer BB = GetHandleId(TimerAct2)
local real processs = LoadReal(Hash, BB, StringHash("processs"))


call DisplayTextToForce( GetPlayersAll(), "OFF" )
call PauseTimer(TimerAct2)
call DestroyTimer(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), processs)
set TimerAct2 = null

 endfunction

function Trig_ShootTest_Actions3 takes nothing returns nothing
local timer TimerAct = GetExpiredTimer()
local integer id = GetHandleId(TimerAct)
local unit marine = LoadUnitHandle(Hash, id, StringHash("marine"))
local unit Target = LoadUnitHandle(Hash, id, StringHash("Target"))

local unit Dummy = LoadUnitHandle(Hash, id, StringHash("Dummy")) 
local real process = LoadReal(Hash, id, StringHash("process")) + LoadReal(Hash, id, StringHash("Speed"))
local group gACT
local unit u = null

 if process > LoadReal(Hash, id, StringHash("maxDis")) then
 call DestroyGroup(LoadGroupHandle(Hash, id, StringHash("group")))
 call KillUnit(Dummy)
 call FlushChildHashtable(Hash, id)
 call PauseTimer(TimerAct)
 call DestroyTimer(TimerAct)
 
else

 call SaveReal(Hash, id, StringHash("process"), process)
 call SetUnitX(Dummy, GetUnitX(Dummy) + LoadReal(Hash, id, StringHash("Speed")) * Cos(LoadReal(Hash, id, StringHash("angle")) * bj_DEGTORAD))
 call SetUnitY(Dummy, GetUnitY(Dummy) + LoadReal(Hash, id, StringHash("Speed")) * Sin(LoadReal(Hash, id, StringHash("angle")) * bj_DEGTORAD))
 
 set gACT =CreateGroup()
 call GroupEnumUnitsInRange(gACT, GetUnitX(Dummy),GetUnitY(Dummy), LoadReal(Hash, id, StringHash("Aoe")), null )
 
 loop
 
  set u = FirstOfGroup(gACT)
  exitwhen u == null
  
  if GetWidgetLife(u) > 0.405 and not IsUnitInGroup(u, LoadGroupHandle(Hash, id, StringHash("group"))) then
  
      if IsUnitEnemy(u, GetOwningPlayer(marine)) then
         call UnitDamageTarget(marine, u, LoadReal(Hash, id, StringHash("Damege")), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
         call DestroyEffect(AddSpecialEffectTarget(LoadStr(Hash, id, StringHash("BloodEfect")), u, "chest"))
         call RemoveUnit(Dummy)
      else
      
      endif
  
  endif
  
  call GroupRemoveUnit(gACT, u)
  
  endloop
  
   call DestroyGroup(gACT)
   
  endif 
set Target = null
set marine = null
set Dummy = null
set TimerAct = null
set gACT = null

endfunction


function Trig_ShootTest2_Actions takes nothing returns nothing
local unit marine = gg_unit_H000_0003
local unit Target = gg_unit_n000_0005
local real xMarine = GetUnitX(marine)
local real yMarine = GetUnitY(marine)
local real xTarget = GetUnitX(Target)
local real yTarget = GetUnitY(Target)
local real angle = bj_RADTODEG * Atan2(yTarget - yMarine, xTarget - xMarine) + GetRandomReal(-6.00, 6.00)
local unit Dummy = CreateUnit(GetOwningPlayer(marine), 'n001', xMarine, yMarine, angle)

local real maxDis = 1200
local real Damege = 50
local real Aoe = 90
local real Speed = 2000

local string BloodEfect = "Objects/Spawnmodels/Human/HumanBlood/HumanBloodKnight.mdl"
local timer TimerAct = CreateTimer()
local integer id = GetHandleId(TimerAct)
local timer TimerAct2 = CreateTimer()
local integer BB = GetHandleId(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), 0)
if xMarine == xTarget and yMarine == yMarine then
        set angle = GetUnitFacing(marine)
    endif

call SetUnitX(Dummy, xMarine + 106 * Cos(angle * bj_DEGTORAD))
call SetUnitY(Dummy, yMarine + 106 * Sin(angle * bj_DEGTORAD))

call SaveUnitHandle(Hash, id, StringHash("marine"), marine)
call SaveUnitHandle(Hash, id, StringHash("Target"), Target)
call SaveUnitHandle(Hash, id, StringHash("Dummy"), Dummy)

call SaveReal(Hash, id, StringHash("Damege"), Damege)
call SaveReal(Hash, id, StringHash("maxDis"), maxDis)
call SaveReal(Hash, id, StringHash("Aoe"), Aoe)
call SaveReal(Hash, id, StringHash("angle"), angle)
call SaveReal(Hash, id, StringHash("Speed"), Speed * 0.03)
call SaveStr(Hash, id, StringHash("BloodEfect"), BloodEfect)
call SaveReal(Hash, id, StringHash("process"), 0)
call SaveGroupHandle(Hash, id, StringHash("group"), CreateGroup())


call TimerStart(TimerAct, 0.03, true, function Trig_ShootTest_Actions3)

    call StopSoundBJ( gg_snd_GyrocopterImpactHit1, false )
    call PlaySoundBJ( gg_snd_GyrocopterImpactHit1 )
    
    call SetUnitAnimation( gg_unit_H000_0003, "attack" )

set marine = null
set Target = null
set Dummy = null
set TimerAct = null
set TimerAct2 = null


endfunction

function Trig_LMB21_Actions takes nothing returns nothing
local timer TimerAct2 = CreateTimer()
local integer BB = GetHandleId(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), 0)
call DisplayTextToForce( GetPlayersAll(), "ON" )
call TimerStart(TimerAct2, 0.10, true, function Trig_ShootTest2_Actions)
set TimerAct2 = null
endfunction



function Trig_ShootTest2_Conditions takes nothing returns boolean  
     if ( not ( BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT ) ) then
        return false
    endif
    return true
endfunction




//===========================================================================


Таймер не останавливается
function Trig_LMB22_Actions takes nothing returns nothing
local timer TimerAct2 = GetExpiredTimer()
local integer BB = GetHandleId(TimerAct2)



call DisplayTextToForce( GetPlayersAll(), "Off" )
call PauseTimer(TimerAct2)
call DestroyTimer(TimerAct2)

set TimerAct2 = null

 endfunction
 
 
 
 function Trig_LMB21_Actions takes nothing returns nothing
local timer TimerAct2 = CreateTimer()
local integer BB = GetHandleId(TimerAct2)
call SaveReal(Hash, BB, StringHash("processs"), 0)
call DisplayTextToForce( GetPlayersAll(), "On" )
call TimerStart(TimerAct2, 0.10, false, function Trig_LMB21_Actions)
set TimerAct2 = null
endfunction




 function Trig_LMB22_Conditions takes nothing returns boolean  
     if ( not ( BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT ) ) then
        return false
    endif
    return true
endfunction
function Trig_LMB21_Conditions takes nothing returns boolean  
     if ( not ( BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT ) ) then
        return false
    endif
    return true
endfunction

 
 
//===========================================================================
function InitTrig_LMB2 takes nothing returns nothing
    set gg_trg_LMB2 = CreateTrigger(  )
    
    call TriggerAddCondition( gg_trg_LMB2, Condition( function Trig_LMB22_Conditions ) )
    call TriggerAddCondition( gg_trg_LMB2, Condition( function Trig_LMB21_Conditions ) )

endfunction
Принятый ответ
Чтобы оставить комментарий, пожалуйста, войдите на сайт.