PenUltima Online

It is currently Sat Sep 06, 2008 6:43 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Detecting Player Movement..
PostPosted: Sun Mar 16, 2008 7:30 am 
Offline

Joined: Wed Mar 12, 2008 1:02 pm
Posts: 5
I was trying to make a counter to know how many tiles a player walked during a X period..

Code:
    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?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 16, 2008 11:49 pm 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 217
This might not be exactly what you needed, but here goes anyway.

Code:
/*
    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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 17, 2008 4:42 am 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 748
Location: Chicago, IL USA
What version of POL are you using? If its 096 or better, you could do this in a packethook very easily.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 17, 2008 5:35 am 
Offline

Joined: Wed Mar 12, 2008 1:02 pm
Posts: 5
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. ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 17, 2008 2:27 pm 
Offline

Joined: Wed Mar 12, 2008 1:02 pm
Posts: 5
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 17, 2008 4:24 pm 
Offline
User avatar

Joined: Fri Feb 10, 2006 8:08 am
Posts: 317
Location: Myrtle Beach, South Carolina
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:
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl