• 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.

Loop Helper System

##############################################
---------Advanced Loop System by Anachron (dhk_undead_lord) ---
--------------------------ALPHA RELEASE-------------------------
##############################################

INDEX
1. What this system does.
2. How this system works.
3. How to use.
4. Misc

::::::::::1 - WHAT THIS SYSTEM DOES::::::::::::

This system allows you to create loops with waittime of 0.3 AND less.
Its thought for jass noobs which are not be able to use handle funcs and gamecaches.

::::::::::::2 - HOW THIS SYSTEM WORKS::::::::::::

You need JASS NEW GEN PACK ( JNGP ) to this to work proberly.

All you need is to force a start of my system (FORCE START TRIGGER) and to order to create a new timeevent based
function (ADD EVENT).


::::::::::::3- HOW TO USE::::::::::::
Well all you need is to create new function with whatever you want.

Example from me was ''function test takes nothing returns nothing''.

You can use any function you want here.
::::::::::::4- MISC::::::::::::
This system has been made by Anachron (dhk_undead_lord).
This system requires JNGP.
This is the ALPHA version.

Thank you for using my system! - Give credits plz


Map Download:
Click here to download
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
816
JASS:
globals
    // Generated
    trigger                 gg_trg_Force_Start         = null
    trigger                 gg_trg_Add_Event           = null
    real ELAPSED_TIME = 0.01


//JASSHelper struct globals:

endglobals
[...]
//***************************************************************************
//*
//*  Custom Script Code
//*
//***************************************************************************
//TESH.scrollpos=66
//TESH.alwaysfold=0

function increase_time_Actions takes nothing returns nothing

local timer t= GetExpiredTimer()
local timer g

    call DestroyTimer(t)

    set ELAPSED_TIME = ELAPSED_TIME + 0.01

    set g = CreateTimer()
    call TimerStart(g , 0.01 , false , function increase_time_Actions)
//call DisplayTextToPlayer(Player(0),0,0, R2S(ELAPSED_TIME))

endfunction


function Loop_System_init_Actions takes nothing returns nothing
local timer g= CreateTimer()

    //call DisplayTextToForce(GetPlayersAll(),"Timerstart!")
    call TimerStart(g , 0.01 , false , function increase_time_Actions)
    
endfunction

//===========================================================================
function Init_Loop_System_init takes nothing returns nothing
    local trigger Loop_System_init= CreateTrigger()
    call TriggerAddAction(Loop_System_init , function Loop_System_init_Actions)
endfunction



function test takes nothing returns nothing
local trigger t= GetTriggeringTrigger()
local unit u
local real x
local real y
local rect r= GetPlayableMapRect()

    set x = GetRectCenterX(r)
    set y = GetRectCenterY(r)
    
    set u = CreateUnit(Player(0) , 'hwat' , x , y , 270)
    call UnitApplyTimedLife(u , '0000' , 0.25)

    call DisplayTextToForce(GetPlayersAll() , R2S(ELAPSED_TIME) + " : A trigger has been executed!")
    call DestroyTrigger(t)
    
endfunction


//===========================================================================
function Init_test takes nothing returns nothing
    local trigger test_init= CreateTrigger()
    call TriggerAddAction(test_init , function test)
endfunction

//#################################################
function ADD_EVENT takes real WhichTime returns trigger
local trigger t= CreateTrigger()
local timer g= CreateTimer()
local real r= 0.00

    set r = WhichTime - ELAPSED_TIME

    call TimerStart(g , r , false , function test)
    
return t

endfunction
//#################################################

function TEST_ACTIONS takes nothing returns nothing
local integer i= 0

local real r= 0.00
local trigger d

loop
    exitwhen i == 10
    
    set r = ELAPSED_TIME + 1.25 + ( i * 0.25 )
    call DisplayTextToForce(GetPlayersAll() , "Current time :" + R2S(ELAPSED_TIME))
    call DisplayTextToForce(GetPlayersAll() , "Execution time :" + R2S(r))

    set d = ADD_EVENT(r)

    call TriggerAddAction(d , function test)
    
    set i = i + 1
    
endloop

endfunction

//===========================================================================
function TEST_init takes nothing returns nothing
    local trigger TEST= CreateTrigger()
    call TriggerAddAction(TEST , function TEST_ACTIONS)
endfunction



//***************************************************************************
//*
//*  Triggers
//*
//***************************************************************************

//===========================================================================
// Trigger: Force Start
//===========================================================================
function Trig_Force_Start_Actions takes nothing returns nothing
    call Loop_System_init_Actions()
endfunction

//===========================================================================
function InitTrig_Force_Start takes nothing returns nothing
    set gg_trg_Force_Start = CreateTrigger()
    call TriggerRegisterTimerEventSingle(gg_trg_Force_Start , 0.00)
    call TriggerAddAction(gg_trg_Force_Start , function Trig_Force_Start_Actions)
endfunction

//===========================================================================
// Trigger: Add Event
//===========================================================================
function Trig_Add_Event_Actions takes nothing returns nothing
    call TEST_ACTIONS()
endfunction

//===========================================================================
function InitTrig_Add_Event takes nothing returns nothing
    set gg_trg_Add_Event = CreateTrigger()
    call TriggerRegisterTimerEventSingle(gg_trg_Add_Event , 1.00)
    call TriggerAddAction(gg_trg_Add_Event , function Trig_Add_Event_Actions)
endfunction

//===========================================================================
function InitCustomTriggers takes nothing returns nothing
    call InitTrig_Force_Start()
    call InitTrig_Add_Event()
endfunction

Thats the whole code.

Suggestion: Use ABCT instead. Whatever you are trying to do, let it be and use ABCT.

It's hard to follow the code with no comments at all and no good explanation what to do.
And using JNGP only for globals is a waste of JASSHelper. Use libraries with initializers. And PLEASE use the keywords private and constant.
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
816
implementing the changes i suggested would help getting this approved.
And as I wrote before, I can't read that code. It's horribly obfuscated, and nothing tells me what you are doing in this specific segment of code.

And why did you paste the system code into the same place as the example's code?

Edit: Ok, i think i figured what hes doing.
- NOT nulling local handle types (--> LEAKS, a _LOT_ of them [at least 100/sec])
- CREATING a new handle every 0.01 seconds (100/sec)
- your handle counter will go up by 100 every second

Verdict: Its basically a custom TriggerRegisterTimerEvent(), though its not hardcoded, thus loosing by far in terms of efficiency. This code is incredibly inefficient (100 NEW Timers per second) and leaking lots of handles (even if they only increase the ref. counter).
 
Last edited:
Top