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
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 786 - File: showthread.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/showthread.php 786 errorHandler->error






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
Post Reply 


Messages In This Thread
TestRun for NPC navgation - Soulless - 09-16-2013 03:56 PM
RE: TestRun for NPC navgation - XuN - 09-16-2013, 09:38 PM
RE: TestRun for NPC navgation - Soulless - 09-17-2013, 02:30 AM
RE: TestRun for NPC navgation - Rattlehead - 09-18-2013, 09:28 AM
RE: TestRun for NPC navgation - XuN - 09-18-2013, 04:56 PM
RE: TestRun for NPC navgation - Mordaunt - 09-18-2013, 08:54 PM
RE: TestRun for NPC navgation - XuN - 09-19-2013, 08:19 AM
RE: TestRun for NPC navgation - Soulless - 09-19-2013, 05:25 PM
RE: TestRun for NPC navgation - XuN - 09-19-2013, 06:23 PM
RE: TestRun for NPC navgation - darksun84 - 09-19-2013, 09:55 PM
RE: TestRun for NPC navgation - Feeh - 09-20-2013, 07:48 AM
RE: TestRun for NPC navgation - Jim - 02-18-2015, 10:29 PM

Forum Jump:


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