Author Topic: Movement with cancelation.  (Read 7537 times)

0 Members and 1 Guest are viewing this topic.

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Movement with cancelation.
« on: August 13, 2008, 07:49:35 AM »
0
Just looking for some random ideas on the best way to do this really while I'm testing out ideas as they come to me haha.

I wanted to create just a 'basic' script for now, that I can really expand upon later depending on what it needs to do.  Right now this is all I want it to do:

Just start a movement to a location, while the movement is being done, execute a sub that does a check, if returning a certian value stop movement.  It keeps doing the check the whole time during the movement until it reaches the destination.

Now the only ways for movement are the move & pathfind commands.  Move will try to move somewhere for a specified time, once that time is done, carry execution of the script.  Pathfinding will start the pathfind and directly after keep executing the script.

I thought pathfinding would be the best way to go, since you can really just start doing your check but canceling the pathfind is 'wierd' for me lol.

I don't really use too many scripts of other peoples, so im sure someone else allready mastered it haha.  I just would like to make my scripts not appear so much as a 'scripter' to others who may see someone running a script (Ie:  moving to points, then running to a creature you passed up on the way to that point).

I've tried a few things but I suck at it basically lol.

Offline Khameleon

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Re: Movement with cancelation.
« Reply #1 on: August 13, 2008, 08:17:58 AM »
0
heh... looks like someone is playing with there omgtamer again.  as far as movement i havent played with that much either... i hate to say it but maybe the best solution is a second script to pause walking and redirect to the new tame. er location

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Movement with cancelation.
« Reply #2 on: August 13, 2008, 10:05:05 AM »
0
yeah that is how i had it last time.  one script controlled only the movement.  I would like to keep everything into one script though if possible haha.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Movement with cancelation.
« Reply #3 on: August 13, 2008, 10:48:53 AM »
0
Are you looking for more of a random motion, or are you thinking to be traveling by waypoint?

I know you don't want to use other people scripts, but you can look at how I implemented the rail engine for ideas.  There's a few modes of operation in it that sound kinda like what you are looking for.  The server mode, and I allow for a subroutine run at each waypoint.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Movement with cancelation.
« Reply #4 on: August 13, 2008, 10:56:33 AM »
0
i would like traveling by way points still.  but maybe traveling one tile at a time and checking, or moving and checking every 1/2 second or something.  but i dont want it to be like walk/stop/walk/stop haha, more smooth ;P

I'll take a look at your rail engine and see if that helps me :D.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Movement with cancelation.
« Reply #5 on: August 13, 2008, 11:13:00 AM »
0
You sound like you need to run like the engine does in "server" mode.  That's how it runs for the zoo collection tamer.  It lets you scan for tames, and when it finds something, it will send a signal to the server to stop at that place.

You can also do it using a state machine; that might be a little more jerky motion-wise, but will allow you to do background processing.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Movement with cancelation.
« Reply #6 on: August 13, 2008, 11:44:36 AM »
0
Yeah that may be what I will have to do.

Now that I think about it I ran this other script that only controlled movement, and the main script told it when to start moving/following, when to stop etc.  It ran pretty decent.

I guess I'll just have to use 2 scripts to do it haha.  One for the bulk of everything, one to just do the pathfinding when it's requested.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Movement with cancelation.
« Reply #7 on: August 13, 2008, 11:52:00 AM »
0
Well, you'll have your own server then!  ;)  I put facilities into mine to allow the calling script to sense whether the server was up and running, so you probably should add those nice little things to keep it "leecher friendly"....

You'll have to get close and warm with global namespaces. (It's a good thing! <In a Martha Stewart voice>)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Movement with cancelation.
« Reply #8 on: August 13, 2008, 02:04:57 PM »
0
I need to get friendly with namespaces in general ;(

I actually do things a lot shittier than I really should.  Like using tags & gotos to perform a loop until the script is ready to continue, rather then a repeat until/while... lol.

I've rewrote a LOT in my taming script really.  Went through one sub at a time to fix bad coding in general.  I've saved quit a bit of code, and really cut back on the tags.

I'm so ashamed.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Movement with cancelation.
« Reply #9 on: August 13, 2008, 02:14:58 PM »
0
You can do some of that with *varables, but that just clutters up your registry if abused.  Global namespaces are a good way to send information between scripts running in the same EUO instance.

Yeh, you're gonna find a better way to do just about anything.  Best is to just be comfortable with your present toolbox, but constantly try new things.  I've met some pretty closed-minded scripters in my travels, so all I can recommend is to not be afraid of what you don't understand.  I'm still learning new things, and little tricks.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Movement with cancelation.
« Reply #10 on: August 13, 2008, 04:59:49 PM »
0
I'll learn about them then on my next script that requires multi script communication via global variables ;P

I always knew the * variables went into registry, so I always used the same ones over and over.  But if I don't need to use them at all that will be even better lol.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Movement with cancelation.
« Reply #11 on: August 14, 2008, 11:53:27 AM »
0
I'll learn about them then on my next script that requires multi script communication via global variables ;P

I always knew the * variables went into registry, so I always used the same ones over and over.  But if I don't need to use them at all that will be even better lol.

Once you become enlightened about local/global variables, you'll be amazed at what things you can do with EasyUO.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Movement with cancelation.
« Reply #12 on: August 18, 2008, 12:54:08 PM »
0
Hopefully this isn;t a thread hijack but I think this discussion is applicable to a logic struggle I've been having with a current project.

I want to Move around an area looking for a target and when target is found, move to the target, perform some actions, then return to moving around the area looking for the next target. I don't want to move too far from the "start point" which is the center of the area and should be able to return there also while looking for targets. A process such as:

Code: [Select]
:walkandscan
Walk to starting point while scanning for targets
While %targets
     {
     Pause walking
     Do stuff
     Scan for next target
     }
Else
     goto walkandscan

;Arrive at start point
:Hunt
look for target
     While ! %target
          {
          Start/Continue along a rail
          Scanning for target
          }
     move to target
     Do stuff
Goto Hunt

Something like that.

I guess this doesn't qualify as generally random movement however it would encompass a level of randomness depending on when/where targets are found.

Anyhow, I don't understand what is meant by a "server" portion and I would hope to do this with a single script. This is also my first attempt at using a movement script (other than a simple pathfind to an object in another script I wrote) so I'm really looking to develop good habits from the start.

Any thoughts/direction/input is welcome.

XII
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Movement with cancelation.
« Reply #13 on: August 18, 2008, 01:03:42 PM »
0
Just for clarity, lemme describe what I mean by server in my rail developer.

In scripts like the heartwood quester, when you want to rail, you just transfer control from the quester script to the called subs that will rail you from point A to point B.  During that time, you cannot be doing anything in the quester since it's waiting for the called sub to return from the rail function.  This is what I call blocking railing.

However, in a "server" arrangement, you have the rail engine actually running in its own separate tab.  From there, instead of calling railing functions, you actually send "signals" to the server to start/stop/monitor.  After that, you leave your script free to execute code until the server does its rail function to completion or failure.  Just by monitoring the status of the server, the script utilizing the server motion can set the server up to rail again, or do another non-rail function in the script.

This gives your script the ability to scan for bad things, monitor health, look for items, update user interfaces, etc.  This is what I call non-blocking railing.

If you take a look at my zoo donator, you can get an idea about the two different modes of operation.
« Last Edit: August 18, 2008, 01:05:16 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Bobkyou

  • Newbie
  • *
  • Posts: 6
  • Activity:
    0%
  • Reputation Power: 0
  • Bobkyou has no influence.
  • Respect: 0
  • Referrals: 1
    • View Profile
Re: Movement with cancelation.
« Reply #14 on: September 09, 2008, 06:24:34 PM »
0
Code: [Select]
While #True
{
 For %i 1 %endspot
 {
  set %x %x . %i     ;this is for use with CEOs rail writter
  set %y %y . %i
  set %z %z . %i
  set %timeout #systime + 15000   ;if you can't get to the waypoint in 15 seconds, skip the rail point
  While ! ( #charposx = %x && #charposy = %y ) && %timeout > #systime
  {
   event pathfind %x %y %z
   wait 1
   if ABS ( #charposx - %x ) > 16 || ABS ( #charposy - %y ) > 16
   {
    set %i %i + 1
    set %x %x . %i
    set %y %y . %i
    set %z %z . %i
   };if it looks like the rail point is too far away, skip to the next rail point
   gosub dosomethingsub
  };while
 };for
};while

sub dosomethingsub
while %dosomething = #True
{
 event pathfind #charposx #charposy #charposz
 gosub slayyourenemiessub
}
return

Well this is how I would do it.  I haven't tested this code, its just a modified snippet from a script I wrote.

Tags: