Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[v1.3] Attack time calculator
#1
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
Reply
#2
Try this one:

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

Haven´t tried it Wink

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

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

MfG Manuel
Reply
#5
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

Reply
#6
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
Reply




Users browsing this thread: