• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

what is wrong with this script

Status
Not open for further replies.
Level 21
Joined
Mar 2, 2010
Messages
3,069
if i disable the timer it works but i need a timer for the resource system to be correct and with the timer it doesnt work.
Autocast
Events
Time - Every 0.08 seconds of game time
Conditions
Actions
Set Temp_Group = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Obelisk))
Unit Group - Pick every unit in Temp_Group and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Mana of (Picked unit)) Equal to 10.00
Then - Actions
Wait 60.00 seconds
Unit - Order (Picked unit) to Undead Obsidian Statue - Activate Spirit Touch
Unit - Order (Picked unit) to Undead Obsidian Statue - Spirit Touch
Else - Actions
Custom script: call DestroyGroup (udg_Temp_Group)
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
if i disable the timer it works but i need a timer for the resource system to be correct and with the timer it doesnt work.
Autocast
Events
Time - Every 0.08 seconds of game time
Conditions
Actions
Set Temp_Group = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Obelisk))
Unit Group - Pick every unit in Temp_Group and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Mana of (Picked unit)) Equal to 10.00
Then - Actions
Wait 60.00 seconds
Unit - Order (Picked unit) to Undead Obsidian Statue - Activate Spirit Touch
Unit - Order (Picked unit) to Undead Obsidian Statue - Spirit Touch
Else - Actions
Custom script: call DestroyGroup (udg_Temp_Group)

i am not sure useing wait inside the unit group loop could be good.... why dont use a timer for that?

another thing u check if unit mana is 10, but its sure after 60sec still that uunit got 10 mana for casing ur ability?

and i dont think u must destory that group when u use in periodic trigger
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
how do i get the game to wait after the mana of the obelisk reach 10.

in gui, u could make a loop (if each player have 1 obelisk) or linked list(if any player can make more obelisk) a timer trigger what count back from 60 to 0 or use jass timer.

if u tell me how many obelisk have each player and exactly what is ur goal with this (just simple order after 60 sec if obelisk mp reached 10?) then i can do it.

u want activate only 1x or more time? i mean example in your trigger theoritically could make infite ordering if ur obelisk allways have 10 mana.
 
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
i give a example to you

Create this variables:
LL_On - boolean array
LL_Index - integer
LL_Timer integer array
LL_Unit - unit array

(if u dont want spam this ordering then u need unit indexer :p)

map header
(this only must copy to map header)

JASS:
function AddUnitTimer takes unit u, integer dur returns nothing
local integer cv = GetUnitUserData(u)
if not udg_LL_On[cv] then
    set udg_LL_Index = udg_LL_Index + 1
    set udg_LL_Unit[udg_LL_Index] = u
    set udg_LL_Timer[udg_LL_Index] = dur
    set udg_LL_On[cv] = true
    if udg_LL_Index == 1 then
        call EnableTrigger( gg_trg_Timer )
    endif
endif
endfunction

function RemoveUnitTimer takes integer index returns nothing
    set udg_LL_On[GetUnitUserData(udg_LL_Unit[index])] = false
    if index == udg_LL_Index then
        set udg_LL_Unit[udg_LL_Index] = null
        set udg_LL_Timer[udg_LL_Index] = 0
    else
        set udg_LL_Unit[index] = udg_LL_Unit[udg_LL_Index]
        set udg_LL_Timer[index] = udg_LL_Timer[udg_LL_Index]
    endif
    set udg_LL_Index = udg_LL_Index - 1
    if udg_LL_Index == 0 then
        call DisableTrigger( gg_trg_Timer )
    endif
endfunction

timer trigger
JASS:
function Trig_Timer_Actions takes nothing returns nothing
    local integer i = 1
    loop
        exitwhen i > udg_LL_Index
        
        if IsUnitType(udg_LL_Unit[i], UNIT_TYPE_DEAD) then
            call RemoveUnitTimer(i)
        else
            if udg_LL_Timer[i] > 0 then

                set udg_LL_Timer[i] = udg_LL_Timer[i] - 1
            else
                call IssueImmediateOrder( udg_LL_Unit[i], "replenishmanaon" )
                call IssueImmediateOrder( udg_LL_Unit[i], "replenishmana" )
                call SetUnitState(udg_LL_Unit[i], UNIT_STATE_MANA, 0)
                call RemoveUnitTimer(i)
            endif
        endif
 call DisplayTextToForce( GetPlayersAll(), GetUnitName(udg_LL_Unit[i]) + " index " + I2S(i) + " timer " + I2S(udg_LL_Timer[i]) )
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Timer takes nothing returns nothing
    set gg_trg_Timer = CreateTrigger( )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Timer, 1.00 )
    call TriggerAddAction( gg_trg_Timer, function Trig_Timer_Actions )
endfunction

call DisplayTextToForce this is used for show the timer and unit, with unit index, u can remove it if u dont need

ur trigger
  • Periodic
    • Events
      • Time - Every 0.08 seconds of game time
    • Conditions
    • Actions
      • Set UnitGroup = (Units of type Obsidian Statue)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Greater than 115.00
            • Then - Actions
              • Set unit = (Picked unit)
              • Set Delay = 10
              • Custom script: call AddUnitTimer(udg_unit, udg_Delay)
            • Else - Actions

i attached the demo map for timer, i hope if u test it on timer then u can understand how can u skip the wait :)
 

Attachments

  • Timer_Demo.w3x
    21.8 KB · Views: 42
Level 14
Joined
Apr 20, 2009
Messages
1,543
You don't need any knowledge of Jass in order to use this. Simply click on the header inside your trigger editor:

headervyl.jpg


Then simply paste the code that shadowvzs created inside the trigger area, and use
  • Custom script: call AddUnitTimer(udg_unit, udg_Delay)
In order to add a timer to a unit. Where udg_unit is a unit variable and udg_Delay is a integer variable.

The variable names would look like this:

unit
Delay

:goblin_good_job: shadowvzs
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
i am tired of guess work. please give me a solution that i understand.

i am not sure u understand better the gui, but i made for a gui version

  • Timer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to LL_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (LL_Unit[(Integer A)] is dead) Equal to True
            • Then - Actions
              • Set LL_On[(Custom value of LL_Unit[(Integer A)])] = False
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer A) Not equal to LL_Index
                • Then - Actions
                  • Set LL_Timer[(Integer A)] = LL_Timer[LL_Index]
                  • Set LL_Unit[(Integer A)] = LL_Unit[LL_Index]
                • Else - Actions
              • Set LL_Index = (LL_Index - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LL_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LL_Timer[(Integer A)] Greater than 0
                • Then - Actions
                  • Set LL_Timer[(Integer A)] = (LL_Timer[(Integer A)] - 1)
                  • Game - Display to (All players) the text: ((Name of LL_Unit[(Integer A)]) + ( unit, index: + ((String((Integer A))) + ( time + (String(LL_Timer[(Integer A)]))))))
                • Else - Actions
                  • -------- your action here --------
                  • Unit - Order LL_Unit[(Integer A)] to Undead Obsidian Statue - Activate Spirit Touch
                  • Unit - Order LL_Unit[(Integer A)] to Undead Obsidian Statue - Spirit Touch
                  • Unit - Set mana of LL_Unit[(Integer A)] to 0.00
                  • -------- and end here --------
                  • Set LL_On[(Custom value of LL_Unit[(Integer A)])] = False
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Integer A) Not equal to LL_Index
                    • Then - Actions
                      • Set LL_Timer[(Integer A)] = LL_Timer[LL_Index]
                      • Set LL_Unit[(Integer A)] = LL_Unit[LL_Index]
                    • Else - Actions
                  • Set LL_Index = (LL_Index - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LL_Index Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
  • Periodic
    • Events
      • Time - Every 0.08 seconds of game time
    • Conditions
    • Actions
      • Set UnitGroup = (Units of type Obsidian Statue)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Greater than 115.00
            • Then - Actions
              • Set unit = (Picked unit)
              • Set Delay = 10
              • Set CV = (Custom value of unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LL_On[CV] Equal to False
                • Then - Actions
                  • Set LL_Index = (LL_Index + 1)
                  • Set LL_On[CV] = True
                  • Set LL_Timer[LL_Index] = Delay
                  • Set LL_Unit[LL_Index] = unit
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LL_Index Equal to 1
                    • Then - Actions
                      • Trigger - Turn on Timer <gen>
                    • Else - Actions
                • Else - Actions
              • Custom script: call AddUnitTimer(udg_unit, udg_Delay)
            • Else - Actions
 

Attachments

  • Timer_Demo_Gui.w3x
    22.8 KB · Views: 51
Level 14
Joined
Apr 20, 2009
Messages
1,543
i am not sure u understand better the gui, but i made for a gui version

  • Timer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to LL_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (LL_Unit[(Integer A)] is dead) Equal to True
            • Then - Actions
              • Set LL_On[(Custom value of LL_Unit[(Integer A)])] = False
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer A) Not equal to LL_Index
                • Then - Actions
                  • Set LL_Timer[(Integer A)] = LL_Timer[LL_Index]
                  • Set LL_Unit[(Integer A)] = LL_Unit[LL_Index]
                • Else - Actions
              • Set LL_Index = (LL_Index - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LL_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LL_Timer[(Integer A)] Greater than 0
                • Then - Actions
                  • Set LL_Timer[(Integer A)] = (LL_Timer[(Integer A)] - 1)
                  • Game - Display to (All players) the text: ((Name of LL_Unit[(Integer A)]) + ( unit, index: + ((String((Integer A))) + ( time + (String(LL_Timer[(Integer A)]))))))
                • Else - Actions
                  • -------- your action here --------
                  • Unit - Order LL_Unit[(Integer A)] to Undead Obsidian Statue - Activate Spirit Touch
                  • Unit - Order LL_Unit[(Integer A)] to Undead Obsidian Statue - Spirit Touch
                  • Unit - Set mana of LL_Unit[(Integer A)] to 0.00
                  • -------- and end here --------
                  • Set LL_On[(Custom value of LL_Unit[(Integer A)])] = False
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Integer A) Not equal to LL_Index
                    • Then - Actions
                      • Set LL_Timer[(Integer A)] = LL_Timer[LL_Index]
                      • Set LL_Unit[(Integer A)] = LL_Unit[LL_Index]
                    • Else - Actions
                  • Set LL_Index = (LL_Index - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LL_Index Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
  • Periodic
    • Events
      • Time - Every 0.08 seconds of game time
    • Conditions
    • Actions
      • Set UnitGroup = (Units of type Obsidian Statue)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Greater than 115.00
            • Then - Actions
              • Set unit = (Picked unit)
              • Set Delay = 10
              • Set CV = (Custom value of unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LL_On[CV] Equal to False
                • Then - Actions
                  • Set LL_Index = (LL_Index + 1)
                  • Set LL_On[CV] = True
                  • Set LL_Timer[LL_Index] = Delay
                  • Set LL_Unit[LL_Index] = unit
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LL_Index Equal to 1
                    • Then - Actions
                      • Trigger - Turn on Timer <gen>
                    • Else - Actions
                • Else - Actions
              • Custom script: call AddUnitTimer(udg_unit, udg_Delay)
            • Else - Actions

Unless you declared the function AddUnitTimer within the GUI trigger (which you didn't) Then this would be no different then the previous version.

Here is a small trick:
  • Custom script: call ExecuteFunc("callAddUnit")
  • Custom script: endfunction
  • Custom script: function AddUnitTimer takes unit u, integer i returns nothing
  • Custom script: create all that is nessecary in Jass here
  • Custom script: endfunction
  • Custom script: function callAddUnit takes nothing returns nothing
  • Custom script: call AddUnitTimer(udg_u, udg_i)
  • Custom script: endfunction
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Unless you declared the function AddUnitTimer within the GUI trigger (which you didn't) Then this would be no different then the previous version.

Here is a small trick:
  • Custom script: call ExecuteFunc("callAddUnit")
  • Custom script: endfunction
  • Custom script: function AddUnitTimer takes unit u, integer i returns nothing
  • Custom script: create all that is nessecary in Jass here
  • Custom script: endfunction
  • Custom script: function callAddUnit takes nothing returns nothing
  • Custom script: call AddUnitTimer(udg_u, udg_i)
  • Custom script: endfunction

i doubt if jass wass problem then custom script more understandable :p
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
i doubt his main problem was the simply copy & paste :p
at gui version dont have custom script/jass anyway :p

True, the understandability is the problem here. He would have to study your GUI trigger in order to know how it works.

It might be usefull to explain what each variable is meant for and how it works. This way he'll be more statisfied. But that's all up to you... :)
 
Status
Not open for further replies.
Top