System GetDelay

cleeezzz

The Undead Ranger.
Reaction score
268
GetDelay v1.0c

Requirements:
-NewGen
(OPTIONAL)
-Vex's dummy model, (Attached)

JASS:

//  ____      _   ____       _             
// / ___| ___| |_|  _ \  ___| | __ _ _   _ 
//| |  _ / _ \ __| | | |/ _ \ |/ _` | | | |
//| |_| |  __/ |_| |_| |  __/ | (_| | |_| |
// \____|\___|\__|____/ \___|_|\__,_|\__, |
//                                   |___/ 
// GetDelay v1.0c
//
//  By cleeezzz, saw792, Jesus4Lyf, and Azlier
//
//  What does it do?
//         -Gets the delay/response time between the host and the players
//        
//    Pros
//         -Don't know, you get the delay (Delay from player to host and then host to player
//
//    Cons
//         -A non-locust unit has to be created somewhere in the map
//         -Calling this function as a player is trying to cast a target spell will cancel target selection
//         -Adding onto the previous con, it is not recommended to check delay with a periodic timer
//
//  How to use:
//         -Set DUMMYID to the raw id of the dummy unit that will detect clicks, DO NOT USE THIS UNIT FOR ANYTHING ELSE.
//         -Whenever you want to refresh everyone's delay, call the function DelayCalc like this --> call DelayCalc(), in GUI, Custom Script: call DelayCalc()
//         -To retrieve a player's delay, use GetDelay(whichplayer) like this --> call GetDelay(Player(0)), which gives the delay of player 1, in GUI, i recommend creating a real variable, Custom Script: set udg_real = GetDelay(Player(0))
//
//  How to import:
//         - Either create a unit specifically for this system, or copy the Dummy unit the map
//         - Create a trigger named GetDelay.
//         - Convert it to custom text and replace the whole trigger text with this.
//
library GetDelay initializer Init
  
globals
    //VALUES BELOW CAN BE MODIFIED
    private constant integer DUMMYID = 'h000'//Can not have locust..., preferably set to Vex's model, dummy.mdx
    private boolean TO_AND_FROM_HOST = false //Gets the time to ping from the player to the host and back. Set to false for just player to host. (Basically half of to and from)
    private real MULTIPLIER = 1000. //If 1000., returns delay in Milliseconds, if 1., returns in Seconds.
    //DO NO MODIFY BEYOND THIS LINE
    private real array D
    private group g = CreateGroup()
    private timer T = CreateTimer()
    private real Game_maxX
    private real Game_maxY
    private unit dummy
endglobals
  
function DelayCalc takes nothing returns nothing
    local integer i = 0
    local unit fog
    if TimerGetRemaining(T) == 0 then
        call ShowUnit(dummy,true)
        loop
            exitwhen i == 12
            call SetUnitOwner(dummy,Player(i),true)
            call GroupClear(g)
            call GroupEnumUnitsSelected(g, Player(i),null)
            if GetLocalPlayer() == Player(i) then    
                call ClearSelection()
                call SelectUnit(dummy, true)
                call ClearSelection()
                loop
                    set fog = FirstOfGroup(g)
                    exitwhen fog == null
                    call SelectUnit(fog, true)
                    call GroupRemoveUnit(g,fog)
                endloop
            endif
            set i = i + 1
        endloop
        call TimerStart(T, 5, false, null)
    endif
endfunction
  
function GetDelay takes player p returns real
    return D[GetPlayerId(p)]
endfunction
  
  //====================================================
private function Conditions takes nothing returns boolean
    if GetUnitTypeId(GetTriggerUnit()) == DUMMYID then
        if TimerGetElapsed(T) != 0 then
            if TO_AND_FROM_HOST == true then
                set D[GetPlayerId(GetTriggerPlayer())] = TimerGetElapsed(T)*MULTIPLIER
            else
                set D[GetPlayerId(GetTriggerPlayer())] = (TimerGetElapsed(T)/2)*MULTIPLIER
            endif
            if GetLocalPlayer() == GetTriggerPlayer() then
                call ShowUnit(dummy,false)
            endif
        endif
    endif
    return false
endfunction
  
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger() 
    set Game_maxX = GetRectMaxX(bj_mapInitialPlayableArea)+50.00
    set Game_maxY = GetRectMaxY(bj_mapInitialPlayableArea)+50.00
    set dummy = CreateUnit(Player(13), DUMMYID, Game_maxX, Game_maxY, 0) 
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SELECTED)
    call TriggerAddCondition(t, Condition(function Conditions))
endfunction
  
endlibrary


CHANGELOG:
1.0c
  • System now creates a universal dummy that is reused. It is shown and hidden to prevent players from selecting it when not checking delay.
  • Added Detail to implementation about dummy unit
1.0b
  • Dummy now spawns slightly outside map bounds (no need for user configuration)
  • Added a Boolean TO_AND_FROM_HOST, if true, returns ping from player to host and back, if false, returns half the ping (or just one way ping)
  • Added a Real MULTIPLIER, if set to 1000., delay will be returned in Milliseconds, if set to 1., delay will be returned in Seconds
1.0 - Initial Release

EXAMPLE USAGE:
JASS:
scope Delay initializer Init

private function Actions takes nothing returns nothing
    local real d
    set d = GetDelay(GetTriggerPlayer())
    call DisplayTextToPlayer( GetTriggerPlayer(),0.,0.,"|cffffcc00Your Delay: |r" + R2S(d) + "|cffffcc00 seconds|r")
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    local integer i
    set i = 0
    loop
        exitwhen i == 12
        call TriggerRegisterPlayerChatEvent( trig, Player(i), "-delay", true )
        set i = i + 1
    endloop
    call TriggerAddAction( trig, function Actions )
endfunction

endscope

scope RD initializer Init
   
private function Actions takes nothing returns nothing
    call DelayCalc()
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic(trig, 10.)
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


The example refreshes delay every 10 seconds and displays delay whenever a player types "-delay"

I don't believe this needs a test map, but oh well.
 

Attachments

  • dummy.mdx
    34.2 KB · Views: 326
  • GetDelay v1.0.w3x
    27.9 KB · Views: 297
  • GetDelay v1.0b.w3x
    28.2 KB · Views: 296
  • GetDelay v1.0c.w3x
    28.5 KB · Views: 356

Troll-Brain

You can change this now in User CP.
Reaction score
85
Are you sure that it works as intended ?
Did you compare it with a tool that give you the real delay ?
Because AFAIK selections got by themselves some delay.
 
Reaction score
341
Are you sure that it works as intended ?
Did you compare it with a tool that give you the real delay ?
Because AFAIK selections got by themselves some delay.

It's not like it needs to be 100% accurate, as long as you get the general idea and the outcome isn't too far off.
 

cleeezzz

The Undead Ranger.
Reaction score
268
selections do have a delay of about .15 ish through my tests. anything above is the delay. but it is a true delay because thats how long it takes for the character to respond, not purely the response time of the connections (those would be slightly faster)

>Did you compare it with a tool that give you the real delay ?

ping tools create a lot of misunderstandings about latency and ping. some are LC ping style (pings cut in half). you may think 300 lat/ping is high, but 300/1000 is only .3 of a second. sure they are faster no matter which tool you use. 1 because of the selection delay but if you think about it, if theres a selection delay, that counts as the delay to control your character as well.
 

cleeezzz

The Undead Ranger.
Reaction score
268
no effects on gameplay, it deselects your current selections and instantly reselects, no visible changes

btw, jesus, can you go on chat lmao.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I suggest to put the dummy unit outside the playable map area (but not outside the entire map) with functions SetUnitX/Y instead of using 2 real constants.
 

RaiJin

New Member
Reaction score
40
I suggest to put the dummy unit outside the playable map area (but not outside the entire map) with functions SetUnitX/Y instead of using 2 real constants.

qft this is a good idea but don't make it to far out or it'll crash
 

cleeezzz

The Undead Ranger.
Reaction score
268
leftover from another trig, i think i deleted it in the test map though, not sure.
 

Nestharus

o-o
Reaction score
84
So, to get the actual delay, you'd do host delay - user delay?

I heard from a few people who tried this that they were getting delays of 700+ when they were host =).
 

Nestharus

o-o
Reaction score
84
Hmmmmm, well.

After talking with Sevion in chat, it sounds like this works for the most part : D

While it is cool, I'm not sure how it would be applied o-o.

I mean, it'd be interesting for a player to get to know their own delay, but I don't see how it'd help or take away from a map ; ).
 

Sevion

The DIY Ninja
Reaction score
413
When we tested (me Cleeezzz and Renny), I felt it was inaccurate :-/ But I'm not sure if it was the same sys. I got ~700+ delay times. It felt more like 300.
 

Sevion

The DIY Ninja
Reaction score
413
I thought so. It seemed like the delays were doubled :-/

Plus he kept going on about something with pings being halved.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Bump for Approval. (I was asked to by Cleeezzz.)

Edit: Pssh, don't lie, you hinted at it.
 

cleeezzz

The Undead Ranger.
Reaction score
268
i never asked for the bump, anyway, updated to 1.0b
CHANGELOG:
1.0b

* Dummy now spawns slightly outside map bounds (no need for user configuration)
* Added a Boolean TO_AND_FROM_HOST, if true, returns ping from player to host and back, if false, returns half the ping (or just one way ping)
* Added a Real MULTIPLIER, if set to 1000., delay will be returned in Milliseconds, if set to 1., delay will be returned in Seconds

Test Map uploaded, it is set up to show delay in milliseconds.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    that sucks i bet they are expensive
  • Varine Varine:
    Not really
  • Varine Varine:
    The entire hot end is like 20 dollars, I just can't get anymore until next week
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top