Page 1 of 1
Detecting Player Movement..
Posted: Sun Mar 16, 2008 7:30 am
by DeKiN
I was trying to make a counter to know how many tiles a player walked during a X period..
Code: Select all
while (p<1100)
beux := me.x;
beuy := me.y;
if(aeux!=beux)
controla := controla+1;
aeux := beux;
endif
if(aeuy!=beuy)
controla := controla+1;
aeuy := beuy;
endif
p := p + 1;
endwhile
Didn't work.. ;/
Have some funcion to make that easy?
Posted: Sun Mar 16, 2008 11:49 pm
by ncrsn
This might not be exactly what you needed, but here goes anyway.
Code: Select all
/*
GetTilesWalked
Sleeps time milliseconds and calculates the distance
character moved during that time.
Returns: distance in tiles
*/
use os;
use uo;
function GetTilesWalked( character, time )
if (character.isa(POLCLASS_MOBILE) && time > 0)
var first := struct{ "x" := character.x, "y" := character.y };
SleepMS(time);
return CoordinateDistance(character.x, character.y, first.x, first.y);
endif
endfunction
Posted: Mon Mar 17, 2008 4:42 am
by CWO
What version of POL are you using? If its 096 or better, you could do this in a packethook very easily.
Posted: Mon Mar 17, 2008 5:35 am
by DeKiN
It's not exactly this but you gave me a light.
What i really wantes is to get the number of tiles walked on a definied period.
This calculate the distance the person moved from a x,y location to a x1,y1 location in X seconds. If the person moved from x,y 5 tiles and returned to x,y before the X seconds expire, it will return 0 where it was to return 10 ;P
Thank you anyway. Ill try to fix it to solve my problem
Im using the 95. I'm starting now with POL and i'm having some problems. xP
Thank you again.

Posted: Mon Mar 17, 2008 2:27 pm
by DeKiN
What i'm really trying to do is edit spellRestrictions.ini for:
When a person casts a spell he don't get frozen and he can walk "10 - circleSpell" tiles.. If he walk more than that he Loses the concentration..
I'm fighting with the script.. hehe.. If anyone knows how to help me, i would be greatfull.
Posted: Mon Mar 17, 2008 4:24 pm
by MontuZ
Here's a txtcmd I use to test players speed. It counts steps pretty accurately, but it's not perfect. Just to give you more ideas on how to get what you need done.
Code: Select all
use uo;
use os;
include "include/client";
const DEFAULT_WAIT_TIME := 10;
const MAX_STEPS_MOUNTED := 18;
const MAX_STEPS_WALKING := 9;
program TextCMD_TestSpeed(mobile, text)
SendSysMessage(mobile, "Select a mobile to test.");
var targ := Target(mobile);
if ( !targ )
SendSysMessage(mobile, "Aborted.");
return 0;
endif
var timer := CInt(text);
if ( !timer )
timer := DEFAULT_WAIT_TIME;
text := DEFAULT_WAIT_TIME;
SendSysMessage(mobile, (targ.Name)+" will be tested for "+(timer)+" seconds.");
else
SendSysMessage(mobile, (targ.Name)+" will be tested for "+(text)+" seconds.");
endif
SendSysMessage(mobile, "Please wait...");
Sleep(2);
SendSysMessage(mobile, "Starting Speedcheck.");
var orig_x := targ.x;
var orig_y := targ.y;
var steps := 0;
var steps_per_second := 0;
var mounted := GetEquipmentByLayer(targ, LAYER_MOUNT);
if ( mounted )
steps_per_second := MAX_STEPS_MOUNTED;
else
steps_per_second := MAX_STEPS_WALKING;
endif
var move_timeout := 0;
while ( timer )
orig_x := targ.x;
orig_y := targ.y;
while ( (orig_x == targ.x) && (orig_y == targ.y) )
SleepMS(10);
if ( move_timeout >= 100 )
break;
else
move_timeout += 1;
endif
endwhile
if ( move_timeout >= 100 )
timer -= 1;
move_timeout := 0;
else
steps += 1;
endif
endwhile
SendSysMessage(mobile, (targ.Name)+" walked "+(steps)+" steps in "+(text)+" seconds.");
if ( steps > (steps_per_second * CInt(text)) )
SendSysMessage(mobile, (targ.Name)+" is possibly using a speedhack.");
endif
return 1;
endprogram