PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Detecting Player Movement..

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Scripting Help
Display posts from previous:   

Author Message
DeKiN



Joined: 12 Mar 2008
Posts: 5

PostPosted: Sun Mar 16, 2008 11:30 am    Post subject: Detecting Player Movement.. Reply with quote

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?

Author Message
ncrsn



Joined: 10 Feb 2006
Posts: 168

PostPosted: Mon Mar 17, 2008 3:49 am    Post subject: Reply with quote

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

Author Message
CWO



Joined: 04 Feb 2006
Posts: 685
Location: Chicago, IL USA

PostPosted: Mon Mar 17, 2008 8:42 am    Post subject: Reply with quote

What version of POL are you using? If its 096 or better, you could do this in a packethook very easily.

Author Message
DeKiN



Joined: 12 Mar 2008
Posts: 5

PostPosted: Mon Mar 17, 2008 9:35 am    Post subject: Reply with quote

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 Wink

Im using the 95. I'm starting now with POL and i'm having some problems. xP

Thank you again. Wink

Author Message
DeKiN



Joined: 12 Mar 2008
Posts: 5

PostPosted: Mon Mar 17, 2008 6:27 pm    Post subject: Reply with quote

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.

Author Message
MontuZ
Distro Developer


Joined: 10 Feb 2006
Posts: 293
Location: Myrtle Beach, South Carolina

PostPosted: Mon Mar 17, 2008 8:24 pm    Post subject: Reply with quote

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

Post new topic   Reply to topic    PenUltima Online Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty