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 able
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