Author Topic: keeping distance from npc  (Read 4494 times)

0 Members and 1 Guest are viewing this topic.

Offline kdzhiiTopic starter

  • Jr. Member
  • **
  • Posts: 44
  • Activity:
    0.4%
  • Reputation Power: 1
  • kdzhii has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
keeping distance from npc
« on: November 07, 2013, 10:30:20 AM »
0
hey ppl.
i`m trying to figure out how i could make my character to keep a distance from a dragon while in the same time i cast spells on it. note: i play on a shard where mags can cast spells while moving

so.. my first idea is that event pathfind would be a cool thing.

i have a spot where i land after teleport. dragon will be somewhere around.
how could i create a movement so i dont get too far and attract others monsters and in the same i maximally keep distance ? no worries if i take a hit from dragon or get damaged with a spell. we have 50% faster cast armors here..
thanks - any help appreciated.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: keeping distance from npc
« Reply #1 on: November 07, 2013, 11:01:26 AM »
0
Record a Rail using one of the handy Rail Writing Tools Around the Site, then you'll need to get a Rail Engine(Typically Provided by the same Coder). Then you will do a basic Math Check.

Finditem (ID for Dragon) G_10
if #Finddist < (How close you want it to get before you move)
Gosub Rail_Engine Rail Direction Distance etc etc etc etc etc



The Nice thing about doing it this way, is you can actually Draw the Path you want your Character to take as he's being eaten by the Dragon. The Rail engine will take you to the Closest Location at first, and then will actually follow the Rail Each time to use it.
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: keeping distance from npc
« Reply #2 on: November 08, 2013, 12:25:36 AM »
0
Snippet from my Doomscript :

Code: [Select]
Sub MoveAway
  FindItem %1 G_
  If #FindID = X
    Return N/A
  If #FindDist => %2
    Return
  If #FindDist = 0
  {
    Set !TargetPosX #FindX + 1
    Set !TargetPosY #FindY - 1
  }
  Else
  {
    Set !TargetPosX #FindX
    Set !TargetPosY #FindY
  }
  Set !TX !TargetPosX - #CharPosX
  Set !TY !TargetPosY - #CharPosY
  Set !TX ( !TX / ABS ( !TX ) )
  Set !TY ( !TY / ABS ( !TY ) )
  Set !TX !TX * ( %2 - #FindDist )
  Set !TY !TY * ( %2 - #FindDist )
  Set !MoveX #CharPosX - !TX
  Set !MoveY #CharPosY - !TY
  Gosub BMPathfind !MoveX !MoveY 0 3s
Return 1

And how to call :

Code: [Select]
Gosub MoveAway %CurrentEnemy 10
I used it back then for running away from Darkfather if iam too damaged. You may need replace "Gosub BMPathfind !MoveX !MoveY 0 3s" with your own mover routine or use badmadiancs pathfind. if #result is 1 it were successfully.

To Cast while you walk you must handle on your own ;)
« Last Edit: November 08, 2013, 12:28:04 AM by Crome969 »

Offline kdzhiiTopic starter

  • Jr. Member
  • **
  • Posts: 44
  • Activity:
    0.4%
  • Reputation Power: 1
  • kdzhii has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: keeping distance from npc
« Reply #3 on: November 18, 2013, 07:38:27 AM »
0
how do i create my own routine... ?

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: keeping distance from npc
« Reply #4 on: November 18, 2013, 10:19:38 AM »
0
how do i create my own routine... ?
You Get X , you Get Y. Now you must have a function to run to X\Y.If you dont know how, i would suggest using existing code from people around here or easyuo

Offline kdzhiiTopic starter

  • Jr. Member
  • **
  • Posts: 44
  • Activity:
    0.4%
  • Reputation Power: 1
  • kdzhii has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: keeping distance from npc
« Reply #5 on: November 20, 2013, 02:00:32 AM »
0
so what i have right now is something like this:
Code: [Select]

mainloop:
for %i 1 17
{
set %rail_filename railfile . %i , .txt
set %rail_label LABEL . %i
call %railsubs TM_Initialize
call %railsubs TM_LoadRail %rail_filename
gosub castinvis
gosub setpagebutton
;gosub hide
gosub setrecallbutton
gosub openrunebook
set %charx #charposx
set %chary #charposy
gosub calculatex %i
click %resultx %y
wait 10
click %recallx %recally
repeat
{
wait 1
}
until #charposx <> %charx || #charposy <> %chary
finditem %dragontypes G
 if #findcnt > 0
  gosub combat
gosub flybank
gosub checkreagents
}
goto mainloop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sub combat
set %target #findid
repeat
 {
 gosub castlight %target
 gosub castscan
 finditem %target g_15
 if #finddist < 4
  call %railsubs TM_GotoClosestWaypoint
 }
until #findcnt = 0 || ( #charposx = 5703 && #charposy = 639 )
if ( #charposx = 5703 && #charposy = 639 )
set %recycle #true
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ends up doing a pathfind in the closest waypoint and spams lighting too fast.. hmm.

« Last Edit: November 20, 2013, 02:05:35 AM by kdzhii »

Offline Paulonius

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: keeping distance from npc
« Reply #6 on: November 20, 2013, 02:53:56 AM »
0
Rail scripts that do things are not easy to get right. Start smaller. Go to the documentation tab on easyuo.com and read about the move and the event pathfinder commands. Make a small snippet of code that does something like this:


Event pathfind X Y Z
Halt

Then look at your charposition information, walk around and try using the code snippet to move. You can evolve it by adding more moves, waits, and checks to see if you moved to the right spot. Now when you try to use someone else's more complete rail and movement code to build your script you will have some experience to help you troubleshoot when it doesn't work well.

Get comfortable with how the movement options work, plan what you want the script to do, preferably by practicing the routine in the game yourself. In this case I would go to the place you want to run the rail and actually do it live six or eight times so that you can anticipate potential failure points. Make a plan for the rail that you think will work that accounts for how the move commands work and what your environment will be like.

Now go look at some of the rail and movement code out there and try to build the script to run in a safe environment first. Don't introduce anything else until you have your rail working -- and don't run it live until you can run it consistently somewhere safe. No sense dying while you try to get it working.  
« Last Edit: November 20, 2013, 02:58:27 AM by Paulonius »
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline kdzhiiTopic starter

  • Jr. Member
  • **
  • Posts: 44
  • Activity:
    0.4%
  • Reputation Power: 1
  • kdzhii has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: keeping distance from npc
« Reply #7 on: November 20, 2013, 03:40:13 AM »
0
Code: [Select]
sub combat
set %target #findid
repeat
 {
 gosub castlight %target
 gosub castscan
 finditem %target g_15
 if #finddist < 4
 {
  call %railsubs TM_GotoClosestWaypoint
  call %railsubs TM_DetermineCurrentRailName
  call %railsubs TM_RunRail #RESULT PRESENT END FW
 }
until #findcnt = 0 || ( #charposx = 5703 && #charposy = 639 )
this does something more .. how can i make it to change dirrection?

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: keeping distance from npc
« Reply #8 on: November 20, 2013, 01:06:52 PM »
0
You want to go back to the beginning of the rail?
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: keeping distance from npc
« Reply #9 on: November 20, 2013, 04:58:52 PM »
0
Bah, I'll just make a tutorial for my rail engine/recorder. eventually....... *Dies of old age before he finishes anything*
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline kdzhiiTopic starter

  • Jr. Member
  • **
  • Posts: 44
  • Activity:
    0.4%
  • Reputation Power: 1
  • kdzhii has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: keeping distance from npc
« Reply #10 on: November 20, 2013, 05:12:40 PM »
0
dont need it no more.
« Last Edit: November 20, 2013, 05:15:10 PM by kdzhii »

Tags: