System GetDelay

cleeezzz

The Undead Ranger.
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

Troll-Brain

You can change this now in User CP.
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.
 
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.
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.
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.
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.
 
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 =).
 
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
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
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.
Bump for Approval. (I was asked to by Cleeezzz.)

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

cleeezzz

The Undead Ranger.
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.
  • Ghan Ghan:
    The old shoutbox wasn't supported anymore. We updated xenForo, so it had to be replaced.
  • jonas jonas:
    let's see if everyone finds it... the nice thing about the shoutbox was I could check on it even while logged out, but the existence of this one is hidden when you're not logged in
  • Ghan Ghan:
    We can fix that.
  • Ghan Ghan:
    Chat should show on the sidebar when not logged in now.
  • Ghan Ghan:
    (You'll still need to log in to post messages)
  • Ghan Ghan:
    Test!
  • tom_mai78101 tom_mai78101:
    I must be in a test server.
  • tom_mai78101 tom_mai78101:
    Nice, Twitter tweets embedding now works
  • Wizard Wizard:
    Yup.
  • Ghan Ghan:
    Excellent.
  • Ghan Ghan:
    @tom_mai78101 Hello there.
  • Ghan Ghan:
    Tagging works in the chat too.
  • tom_mai78101 tom_mai78101:
    @Ghan Missed it.
  • Wizard Wizard:
    Still fixing things here and there. Added widgets to the portal, will make it match the ones here on the forum index tomorrow.
  • Ghan Ghan:
    The venerable World Editor Tutorials site has been converted to HTTPS at last.
  • jonas jonas:
    cool
  • jonas jonas:
    and I can even edit my messages, nice
  • seph ir oth seph ir oth:
    GENERAL CHIT CHAT, YOU ARE A BOLD ONE
  • Ghan Ghan:
    Hello there
  • The Helper The Helper:
    this new chatbox is great and the forum software update is great too
    +1
  • The Helper The Helper:
    upgrade has fixed forum registration spam problem
  • tom_mai78101 tom_mai78101:
    Something tells me we might be able to customize the chatbox a bit, considering that there's a gap under every message.
  • Wizard Wizard:
    Going to deploy a fix soon, just had to take some time for myself this weekend.
  • Varine Varine:
    Unbelievable. Time for yourself? How dare you!

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top