TWLan Forum

Full Version: Attack time calculator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello TWlan community. I am trying to make the map tool with the pop-up that is showing the travel time but I have a big problem. I cannot figure out how do dslan calculate the travel time.

$time = ($unit_speed * $distance)/($server_speed*$troops_speed);

This should be correct but is not.

Can someone give the the correct formula for this?


Thanks in advance.


Regards,
KaLa
Try this one:

$distance = hypot($x1 - $x2, $y1 - $y2);
$time = ($distance * $unit_speed)/$server_speed;

Haven´t tried it Wink

MfG Manuel
what about server troops speed ($config[u_speed])?

Code:
$distance = hypot($x1 - $x2, $y1 - $y2);
$time = (($distance * $unit_speed)/$config['movement_speed'])/$server_speed;

MfG Manuel
PHP Code:
<?php
$movement_speed 
0.5;
$server_speed 32;
$unit_speed 720;

$x1 = ;
$y1 = ;

$x2 = ;
$y2 = ;

function 
calc_dist($x1,$y1,$x2,$y2){
    
$a $x1 $x2;
    
$b $y1 $y2;
    
$dist sqrt(($a*$a)+($b*$b));
    return 
$dist;    
}

$distance calc_dist($x1,$y1,$x2,$y2);
$time = (($distance $unit_speed)/$movement_speed)/$server_speed;

function 
minutes$seconds ){
    return 
sprintf"%02.2d:%02.2d"floor$seconds 60 ), $seconds 60 );
}

echo 
minutes($time);
?>

527|527 attack 525|524
My time: 02:42
Server time: 02:52

527|527 attack 525|523
My time: 03:21
Server time: 03:37

Hmm. Then I don´t know. I will try it for you.
But later.
If you want, you can add me on skype: manuel.mannhardt

MfG Manuel