How to calculate everything you need for /warp commands
Hi!
there are many threads in this forum and others where people are asking how to calculate the /warp command parameters because the only public known website that calculates it properly is down a lot.
Exactly for the same reason i did a lot of research on how to calculate them my own and got to this:
xpos = (silkroad_x % 192) * 10
ypos = (silkroad_y % 192) * 10
xsec = (silkroad_x - xpos / 10) / 192 + 135
ysec = (silkroad_y - ypos / 10) / 192 + 92
region = (ysec << 8) | xsec
knowing this i wrote the following small php script to calculate it quickly and spit out the warp code:
PHP Code:
<form action="coord.php" method="post">
<input type="text" name="x" value="X-Coord"><br>
<input type="text" name="y" value="Y-Coord"><br>
<input type="submit" name="submit" value="submit">
</form>
<?php
if(isset($_POST['x']) && isset($_POST['y']))
{
//$silkroad_x = 14714;
//$silkroad_y = 2593;
$silkroad_x = $_POST['x'];
$silkroad_y = $_POST['y'];
$xpos = ($silkroad_x % 192) * 10;
$ypos = ($silkroad_y % 192) * 10;
$xsec = ($silkroad_x - $xpos / 10) / 192 + 135;
$ysec = ($silkroad_y - $ypos / 10) / 192 + 92;
$region = ($ysec << 8) | $xsec;
echo "<br><br>/warp $region $xpos 1000 $ypos";
}
?>
as you can see for the z value in the warp command i always use 1000 which is because in 99.9% of all cases with z being set to 1000 youre in the sky above the place where you want to be warped to, but sro automatically changes it to the value where you hit the ground.
special thanks to: megaman963, kaperucito, NoNStop, sladlejrhfpq and paxemuman (they all contributed parts of all formulas used)
greetz
1 Attachment(s)
Re: How to calculate everything you need for /warp commands
Re: How to calculate everything you need for /warp commands
Re: How to calculate everything you need for /warp commands
Re: How to calculate everything you need for /warp commands
Quote:
Originally Posted by
lemoniscool
region = (ysec << 8) | xsec
That one .... THAT ONE WHO MADE ME CRAZY !! Never thought that shifting the Y sector and using inclusive OR (Inverse XOR) with the result of shifting and the X sector will give us the region ...
Thanks for the release lemoniscool :D, and sorry for no replay for your PM because I didn't get the answer ...
Re: How to calculate everything you need for /warp commands
Quote:
Originally Posted by
megaman963
That one .... THAT ONE WHO MADE ME CRAZY !! Never thought that shifting the Y sector and using inclusive OR (Inverse XOR) with the result of shifting and the X sector will give us the region ...
Thanks for the release
lemoniscool :D, and sorry for no replay for your PM because I didn't get the answer ...
no problem i figured it out .. to be honest i stumbled upon the way to calculate the region on accident ... i was playing around with all known operations that are used in computer science and the values we can get from the x and y coordinates .. and then suddenly i had it lol
anyone who says trial&error doesnt work will be hit by my success with it xDD
Re: How to calculate everything you need for /warp commands
Quote:
Originally Posted by
lemoniscool
trial&error
That is the way of how I get the XorStr key for MeGaMaX's Silkroad C++ Dll Client Protection (Anti Unpacking), all successions happen when you try :D ..
But since the bitwise operations not so much used in math, that why i failed on getting it ...
Re: How to calculate everything you need for /warp commands
Guys Who know in SQL Scripts i need small help i think
Re: How to calculate everything you need for /warp commands
is it related to /warp codes @CoderWaxy?
Re: How to calculate everything you need for /warp commands
XD no i need create System by Script Select High Kills from _UniqueRanking and set hwan level to this high score player to 1
this is the system i tried to create Script but Failed]
And Good JOB Bro
Re: How to calculate everything you need for /warp commands
here is the SQL way if anyone need it
Code:
USE SRO_VT_SHARD
GO
CREATE PROCEDURE _GetWarpCoord
@X INT,
@Y INT
AS
DECLARE @XPOS INT = @X % 192 * 10,
@YPOS INT = @Y % 192 * 10
DECLARE @XSEC INT = (@X - @XPOS / 10) / 192 + 135,
@YSEC INT = (@Y - @YPOS / 10) / 192 + 92
DECLARE @RegionID INT = @YSEC * POWER(2, 8) + @XSEC
SELECT '/warp ' + CAST(@RegionID AS VARCHAR) + ' ' + CAST(@XPOS AS VARCHAR) + ' 1000 ' + CAST(@YPOS AS VARCHAR) AS WarpCoord
after executin sp, usage:
Code:
exec _GetWarpCoord 1,1
@CodeWaxy, just create a trigger for it, it can do that very easily, or create a schedule in sql dunno how you want it
Re: How to calculate everything you need for /warp commands
Quote:
Originally Posted by
Caosfox
I have dissmble it using .NET Reflector, and check it source file ... It is exactly your method lemoniscool :D
Code:
private void Button1_Click(object sender, EventArgs e)
{
int num = (Conversions.ToInteger(this.TextBox1.Text) % 0xc0) * 10;
int num2 = (Conversions.ToInteger(this.TextBox2.Text) % 0xc0) * 10;
int num3 = (int) Math.Round((double) (((Conversions.ToInteger(this.TextBox1.Text) - (((double) num) / 10.0)) / 192.0) + 135.0));
int num4 = (int) Math.Round((double) (((Conversions.ToInteger(this.TextBox2.Text) - (((double) num2) / 10.0)) / 192.0) + 92.0));
int num5 = (num4 << 8) | num3;
try
{
string text = "/warp " + Conversions.ToString(num5) + " " + Conversions.ToString(num) + " 1000 " + Conversions.ToString(num2);
Interaction.MsgBox(text + "\rresult is copied to Clipboard", MsgBoxStyle.ApplicationModal, null);
Clipboard.Clear();
Clipboard.SetText(text);
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
Exception exception = exception1;
ProjectData.ClearProjectError();
}
}
Re: How to calculate everything you need for /warp commands
Quote:
Originally Posted by
megaman963
I have dissmble it using .NET Reflector, and check it source file ... It is exactly your method lemoniscool :D
Code:
private void Button1_Click(object sender, EventArgs e)
{
int num = (Conversions.ToInteger(this.TextBox1.Text) % 0xc0) * 10;
int num2 = (Conversions.ToInteger(this.TextBox2.Text) % 0xc0) * 10;
int num3 = (int) Math.Round((double) (((Conversions.ToInteger(this.TextBox1.Text) - (((double) num) / 10.0)) / 192.0) + 135.0));
int num4 = (int) Math.Round((double) (((Conversions.ToInteger(this.TextBox2.Text) - (((double) num2) / 10.0)) / 192.0) + 92.0));
int num5 = (num4 << 8) | num3;
try
{
string text = "/warp " + Conversions.ToString(num5) + " " + Conversions.ToString(num) + " 1000 " + Conversions.ToString(num2);
Interaction.MsgBox(text + "\rresult is copied to Clipboard", MsgBoxStyle.ApplicationModal, null);
Clipboard.Clear();
Clipboard.SetText(text);
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
Exception exception = exception1;
ProjectData.ClearProjectError();
}
}
yeah sure it is, i told it to him before i even released it here ^^ im working with Caos a lot lately
Re: How to calculate everything you need for /warp commands
lol, yeah, i was uber lazy to ofuscate 17 lines of code (or even finish the error handler... shame on me.....)