The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TestRun for NPC navgation
Author Message
Soulless
Super Moderator
****

Posts: 335
Likes Given: 29
Likes Received: 49 in 27 posts
Joined: Jun 2012
Reputation: 12

Ye Olde Sphere

Post: #1
TestRun for NPC navgation
Okay, so this script is just a concept for an idea im trying to bloom.
basically im in an attempt of making "bots" for my server. their eventual functionality will be hopefully rather in depth.

obviously the first part of a bot is making it move to a place it wants to get to. and not looking like it's too NPCish. so i've made this script that has been able to successfully move an NPC from the graveyard to the sweetdreams inn.

just add this to your scripts, add c_h_fighter, and type .testrun then target the fighter and watch him make his way.

im looking for feedback, ideas, brainstorms to make this better. its pretty basic, but i think this is the best way i could think of at the time.

let me know what you think, and feel free to help me with this project if you are ableWoot

Code:
//Created by Soulless
//this script is a concept to make npc's travel like regular players, to a location of your choice.
//you could make npcs that run to a mine, do some mining for 10 minutes, then run back to the bank
//currently this will take the npc to britain right out front of the SweetDreams Inn

//v.01
//Ive tested it several times, and he's made it from the graveyard, while it's not a beautiful journey, he does make it
//he also made it once from britain to minoc all on his own twice


//just go spawn an npc at the graveyard and type .testrun, then target your npc and follow him to see how it goes.

[defname testrun_settings]
running_control        2        //in tenths of a second how often to run (2 seems to be normal speed of running)
movement_attempts    10        //how many attempts failed in one direction till the npc diverts
diversion_tiles        10        //how many tiles will the npc divert in an attempt to get around obstacles
expected_eta        unused        //how many minutes until they just get teleported to their destination


[function testrun]
targetf testrun2
sysmessage who should testrun? npc only?

[function testrun2]
ref1=<argo.uid>
serv.newitem i_testrun
new.link <ref1>
new.p britain
new.update
new.timer=1
endif

[itemdef i_testrun]
id=i_shield_chaos
name=TestRun

on=@create
attr=090

on=@timer
timerd 2
if (<distance <link>> < 6)                //npc has reached his destination, remove the travelbit
remove
return 1
endif

if <more1>                        //this means he needs to divert his course, because he couldnt move in his targets direction
link.run <tag0.divert>
more1 -= 1
if <more1><1
tag0.divert=
endif
return 1
endif

link.face <uid>                        //face the target destination
if (<link.canmove <link.dir>>)                 //can run in the direction of his target
  if <more2>
  more2 -= 1                        //more2 keeps track of how many times he has ran into something, if he's moving without issue, remove a count on more2
  endif
link.run <link.dir>                    //so do it, run, bitch.
else    
more2 += 1                        //more2 keeps track of how many times he has ran into something, if he's running into things, add a count on more2
  if <more2>>=<def0.movement_attempts>            //he's been stuck 10 times in a row, divert his course
  more1=<def0.diversion_tiles>                //divert course by 10 tiles
  more2=                        //clear his obstruction count
//serv.log can't move <dir_convert <link.dir>>
   if !<tag0.divert>
   if <link.canmove <eval <link.dir>-1>>        //movecheck 45 degrees left
    tag0.divert=<eval <link.dir>-1>            //switch direction 45 degrees left
    elseif <link.canmove <eval <link.dir>+1>>        //movecheck 45 degrees right
    tag0.divert=<eval <link.dir>+1>            //switch direction 45 degrees right
    elseif <link.canmove <eval <link.dir>-2>>        //movecheck 90 degrees left
    tag0.divert=<eval <link.dir>-2>            //switch direction 90 degrees left
    elseif <link.canmove <eval <link.dir>+2>>        //movecheck 90 degrees right
    tag0.divert=<eval <link.dir>+2>            //swicth direciton 90 degrees right
   endif

  if (<tag0.divert> < 0 )                //0 is true north, if its less than 0
  // serv.log <eval <tag0.divert>>
   local.offset=<tag0.divert>
   tag0.divert=<eval (8 - <local.offset>)>
  elseif (<tag0.divert> > 7)
   tag0.divert -= 8
  endif
  // serv.log diverting <dir_convert <tag0.divert>>
   tag0.divert=<dir_convert <tag0.divert>>
   endif
  endif
endif

return 1

[function dir_convert]
doswitch <args>
  return n
  return ne
  return e
  return se
  return s
  return sw
  return w
  return nw
enddo

What am I working on?
(This post was last modified: 09-16-2013 03:59 PM by Soulless.)
09-16-2013 03:56 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #2
RE: TestRun for NPC navgation
First of all, this is a great idea and a very nice adition for roleplaying purposes or some kind of events (LOL-Like minions, ie).

I've tried it with an skeleton from Britain Graveyard, making britain unguarded, you have to mess with homedist, it doesn't go so far after entering the city, wich is just easy to do.

But the real problem comes searching for a correct path, it will be a pain in the ass to make a pathfinding in scripts since you can calculate to move one tile, two, three, four... but the whole correct path it would be a very largue calculation when it may be possible that someone give us a function related to 'MoveToPos' from NPC_AI_ALWAYSINT or NPC_AI_PATH or somewhat/somehow/somewhere it's calculated?

Coming back to topic, it goes so nice with 1x1,2x2 obstacles, but it's hard to him to get out from graveyard now (wich I asume you already knew Tongue )
09-16-2013 09:38 PM
Find all posts by this user Like Post Quote this message in a reply
Soulless
Super Moderator
****

Posts: 335
Likes Given: 29
Likes Received: 49 in 27 posts
Joined: Jun 2012
Reputation: 12

Ye Olde Sphere

Post: #3
RE: TestRun for NPC navgation
well any enclosed area presents a serious problem for him. because there's no logic in the script in how to get out. but when he's outside of any trapping building anything that is a square shape, or anything thats small and can be re-routed by going 10 feet in either 45* or 90* along side it, can be handled decently.

hpoefully we could get some more information on pathfinding or possibley work some kind of a RUNTO function in ( i know a dev mentioned that being a possibility in IRC when i was bugging people about it Smile )

though i bet as a community we can all make this work seamlessly !
It's just a matter of getting it done and testing it out. the good news about bots is that they test themselves out Tongue

What am I working on?
(This post was last modified: 09-17-2013 02:49 AM by Soulless.)
09-17-2013 02:30 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Rattlehead
Master
**

Posts: 290
Likes Given: 3
Likes Received: 8 in 6 posts
Joined: Jun 2012
Reputation: 8



Post: #4
RE: TestRun for NPC navgation
well, one thing RunUO has that we dont, that we SHOULD have, are waypoint gems, no scripting required and they work (last time i checked 10 years ago) pretty well, i had one with 20 waypoints, all of which he flawlessly executed in a dungeon, so if the devs implemented something like this, we would be one step closer to having functionality on their level.

[Image: matts_siggy.gif]
09-18-2013 09:28 AM
Find all posts by this user Like Post Quote this message in a reply
Anarch Cassius
Master
**

Posts: 273
Likes Given: 19
Likes Received: 10 in 9 posts
Joined: Mar 2012
Reputation: 2



Post: #5
RE: TestRun for NPC navgation
I've seen a way point based caravan but then you just have a static route.

Ideally you'd have the waypoints form a nodemap and use an A* variant to navigate that. Possibly using square grid based A* for finer dynamic navigation at other times.

The question is how to do that most efficiently without bogging down the server.

Current Projects: Necromancy SCP overhaul. Custom Faction AI/System. Imbuing.
09-18-2013 10:31 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #6
RE: TestRun for NPC navgation
GOD's have heard us ^^

Code:
small change to NPC_Act_Runto and NPC_Act_Goto to prevent invalid point errors.

bencro1028    r1629    18.09.13

-Added: Runto npc command. Accepts a point or region name as argument.
-Changed: Goto npc command to accept region name as argument.
-Added: NPC_AI_PERSISTENTPATH 0x0400 to the NPCAI setting in sphere.ini
-Updated: Sphere.ini and sphere_msg.scp with new settings

Can't wait for it to compile!
09-18-2013 04:56 PM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #7
RE: TestRun for NPC navgation
Don't go calling him a god... it'll go to his head lol

[Image: 2nis46r.jpg]
09-18-2013 08:54 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
amonvangrell
Banned

Posts: 337
Likes Given: 17
Likes Received: 32 in 20 posts
Joined: Aug 2012

britannia shard

Post: #8
RE: TestRun for NPC navgation
LOL >:]
09-19-2013 07:12 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #9
RE: TestRun for NPC navgation
I've been waiting for this nightly for testing this and at first view it does the same that Soulless script is doing atm, NPCs aren't moving like they will when chasing you in combat.
09-19-2013 08:19 AM
Find all posts by this user Like Post Quote this message in a reply
Soulless
Super Moderator
****

Posts: 335
Likes Given: 29
Likes Received: 49 in 27 posts
Joined: Jun 2012
Reputation: 12

Ye Olde Sphere

Post: #10
RE: TestRun for NPC navgation
i beleive new_positioning walkcheck diaganaol walkcheck and the persistent_path flags should all be on to get the most out of the runto command.

What am I working on?
09-19-2013 05:25 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)