1. Post #1
    dill pickle pringle EXTREME

    May 2005
    479 Posts
    A* Pathfinding Module

    If you would like to know what the A* algorithm is and does.
    http://en.wikipedia.org/wiki/A%2A

    This is a module for developers, it allows them to use the A* pathfinding algorithm easily. Using a waypoint like system.
    This will always find the shortest path along those waypoints.

    Download: astar.lua

    Features:
    [list][*]Waypoint saving/loading.[*]Map based waypoint saving/loading.[/list]
    Addons for future updates:
    [list][*]Waypoint Editor.[/list]
    Module function list:
    [list][*]astar.CreateSolver[/list]
    Object function list.
    [list][*]Solver:AddNode <position> <extra cost> <data>[*]Solver:AddLink <first node> <second node>[*]Solver:GetNodeForPosition <position>[*]Solver:ClosestNodeForPosition <position>[*]Solver:Load <file>[*]Solver:Save <file>[*]Solver:SaveMap <name>[*]Solver:LoadMap <name>[*]List:Create <sortfunc>[*]List:Put <node>[*]List:Grab[*]List:HasElement[*]List:Empty
    [*]Node.__eq[*]Node:CalculateCost <from start> <heuristic>[*]Node:SetExtraCost <cost>[*]Node:CreateLink <node>[*]Node:GetLinks
    [/list]
    Block functions:
    Block functions are a way to tell the pathfinder whether or not you can travel from a -> b.

    Default functions:
    [list][*]astar.BLOCKFUNC_TRACE_WORLD[*]astar.BLOCKFUNC_TRACE_ALL[/list]
    Example block function:
    BLOCKFUNC_TRACE_WORLD =	function( a, b )
    
    				local trace = {
    					start = a.position,
    					endpos = b.position,
    					mask = MASK_NPCWORLDSTATIC,
    				
    				};
    				local tr = util.TraceLine( trace );
    				
    				return tr.Hit;
    				
    			end

    AddLink will return false if the two nodes in question are already linked in some fashion. Everything was moved into the Solver class. That means you will now do

    mysolver:FindPath( [node/pos], [node/pos], [optional block function] );
    Reply With Quote Edit / Delete Reply United States Show Events Useful Useful x 1 (list)

  2. Post #2
    Gold Member
    Feihc's Avatar
    October 2006
    1,077 Posts
    Ooooh, fancy. Could prove to be useful

  3. Post #3
    mblunk
    Guest
    And here comes the Lua AI.
    Reply With Quote Edit / Delete Reply Dumb Dumb x 1Agree Agree x 1 (list)

  4. Post #4
    Exitus's Avatar
    January 2005
    56 Posts
    How interesting - time for some SNPC

  5. Post #5
    Galliko's Avatar
    November 2006
    17 Posts
    Wicked.
    Will be used.

  6. Post #6
    Gold Member
    terrorclaw's Avatar
    March 2005
    502 Posts
    I wonder, is it possible using something similar to the dodgeball or something, if you can make a bouncy ball just randomly choose a number/waypoint, then it will head to it going from point to point to get here, then once it reaches it it will choose another random one and just randomly roam the map...hmmm.

  7. Post #7
    Mortal-Wound's Avatar
    October 2006
    6 Posts
    Oh fucking yes! YES!

  8. Post #8
    Please waste more of your money changing this title again.
    Gmod4ever's Avatar
    August 2005
    6,792 Posts
    Now we need an easy targeting system.

    :q:

  9. Post #9
    Sliverman's Avatar
    February 2006
    13 Posts
    Now lua make AI for NPC? Cool!

  10. Post #10
    Galliko's Avatar
    November 2006
    17 Posts
    No, but it can help you find the shortest path.

  11. Post #11
    Gold Member
    Megiddo's Avatar
    January 2005
    251 Posts
    A* is a nifty path-finding algorithm. It won't help you create AI, only to help the AI find their way along pre-determined paths. If you'd like to know more about A*, check here.

    By the way Jinto, I'm not sure many of the lua developers here know what A* is or what it means. I wouldn't know myself if I didn't have such a fascination with all things AI. :)

  12. Post #12
    Gold Member
    terrorclaw's Avatar
    March 2005
    502 Posts
    ...So..if I understand this right this lets you, or will let you make new or better ai paths in the maps? *shrugs* or make paths within the map so they can get around the contraptions you make, or run along them? *shrugs* I'm mixed up.

  13. Post #13
    GMod Illuminati
    andyvincent's Avatar
    January 2005
    65 Posts
    Nice work Jinto!

  14. Post #14
    Galliko's Avatar
    November 2006
    17 Posts
    I'll just explain this...
    Imagine a bunch of points scattered around the map.
    Now, between those points are paths, or lines (If there's nothing between those two points ofcourse).
    You're going to set up those points yourself.

    Now imagine a Z-formed corridor. This corridor is filled with points.
    There's an NPC at the start of the corridor that have to reach the other end by going from point to point.
    Ofcourse it'll have to choose the shortest path through those points,
    'cause we can't have it make a random zig-zag through the corridor.
    This program takes those points and calculates the shortest possible path.
    That's useful if you want an NPC to, for example, find it's way through a maze or another set of obstacles.

  15. Post #15
    GcDesign's Avatar
    September 2005
    1 Posts
    Very nice work! A* isn't too easy to implement at all...

  16. Post #16
    Gold Member
    Xeon06's Avatar
    September 2005
    1,223 Posts
    Wow, awesome, it truly is. I'm gonna test that right now!

  17. Post #17
    Gold Member
    Catdaemon's Avatar
    February 2005
    2,821 Posts
    That algorithm is used in Unreal Tournament games for the bots I believe. Should be quite useful for RTS games too.

  18. Post #18
    Mortal-Wound's Avatar
    October 2006
    6 Posts
    I can't fucking beleve one of my ideas was actually used!

  19. Post #19
    FreeWilly's Avatar
    November 2006
    4 Posts
    Awesome stuff, You said "nodes" alot, and I understand that striders move with nodes you can create in the hammer, so does this script allow striders to move on the npc_go command?

  20. Post #20
    Please waste more of your money changing this title again.
    Gmod4ever's Avatar
    August 2005
    6,792 Posts
    FreeWilly posted:
    Awesome stuff, You said "nodes" alot, and I understand that striders move with nodes you can create in the hammer, so does this script allow striders to move on the npc_go command?
    No. Not even close.

    A node is a place.

    It won't make striders work. Those use path_corner entities.

    This uses Lua nodes.

  21. Post #21
    Galliko's Avatar
    November 2006
    17 Posts
    Nodes or points.
    Really just a vector.

  22. Post #22
    pyroguy's Avatar
    January 2006
    37 Posts
    You are awesome. I am so going to use this, eventually. I like the idea of a roaming bouncy ball... I also have ideas in mind for assisting simple Strider, Gunship, and Apache AI (as well as other ground enemies).

  23. Post #23
    FreeWilly's Avatar
    November 2006
    4 Posts
    Oh sorry because I was looking at a strider in the hammer and it had air nodes for the path.

  24. Post #24
    Gold Member
    terrorclaw's Avatar
    March 2005
    502 Posts
    Okay, cool, so I can make mah own paths now it seems >.> or if someone can make a simple to install mod so I can then yay

  25. Post #25
    Gold Member
    Kogitsune's Avatar
    September 2005
    2,829 Posts
    It's a shame that I don't have an exact use for this yet, because this is pretty cool looking.

  26. Post #26
    A Huge Faggot

    June 2005
    377 Posts
    This could be used to make new NPC's that walk around, or a turret that hovers around, etc. It's pretty damn amazing.

  27. Post #27
    Gold Member
    terrorclaw's Avatar
    March 2005
    502 Posts
    I hope you can at least make a basic waypoint editor that has maybe visual stuff too it, I accualy love to do pathing and stuff for maps..*shrugs*

  28. Post #28
    bonecracker's Avatar
    November 2005
    2 Posts
    http://forums.facepunchstudios.com/s...d.php?t=257272
    >.>
    <.<



    time for a combine guard Snpc?

  29. Post #29

    January 2006
    1 Posts
    This would help me greatly in a gamemode i'm making, however...

    The download link is dead... :(

    Does anyone happen to have a copy?

  30. Post #30
    dill pickle pringle EXTREME

    May 2005
    479 Posts
    LoginError posted:
    This would help me greatly in a gamemode i'm making, however...

    The download link is dead... :(

    Does anyone happen to have a copy?
    http://cdbarrett.com/download.php?id...od=view&page=1

  31. Post #31
    absolute0's Avatar
    September 2005
    106 Posts
    Sexy, Shame nobody is using it.

  32. Post #32
    Gold Member
    LPine's Avatar
    April 2007
    260 Posts
    Ouch! My brain!

  33. Post #33

    May 2007
    4 Posts
    Nice but... whatever happened to that "industry leading AI" thing all Source games supposedly already have? Can't NPCs already find their way around maps that have their nodes made out?

  34. Post #34
    Skurmedel's Avatar
    November 2006
    47 Posts
    NPCs made in the Source Engine yes, but not so easily Lua coded ones.

  35. Post #35

    May 2007
    4 Posts
    What kind of lua created NPCs can there be that can't simply inherit from an existing Source NPC? You shouldn't be having to reinvent the wheel here.

  36. Post #36
    dill pickle pringle EXTREME

    May 2005
    479 Posts
    DaddyWarbox posted:
    What kind of lua created NPCs can there be that can't simply inherit from an existing Source NPC? You shouldn't be having to reinvent the wheel here.
    There are uses for it outside of NPCs. I didn't create it because I felt I had to, I did because I wanted to.

  37. Post #37
    IpHa_'s Avatar
    May 2007
    1 Posts
    This could be useful if it got incorporated into wiremod.

  38. Post #38
    Gold Member
    tad2020's Avatar
    December 2006
    163 Posts
    Jinto posted:
    There are uses for it outside of NPCs. I didn't create it because I felt I had to, I did because I wanted to.
    I could see this being used to make some cool laser weapon effect, like from some animes where the beams will bend around obstacles instead of going thought them.

  39. Post #39
    hoobo's Avatar
    August 2006
    21 Posts
    Cool

  40. Post #40
    Skurmedel's Avatar
    November 2006
    47 Posts
    DaddyWarbox posted:
    What kind of lua created NPCs can there be that can't simply inherit from an existing Source NPC? You shouldn't be having to reinvent the wheel here.
    Yes in the case of NPCs you will. Let's say you wanna script an murderous box, in that case, creating a npc_rebel (for example) and setting his model to a box and a bunch of other stuff isn't really the optimal way of doing it. That NPC is made to behave like a rebel, which probably will do, unless you set a shitload of modifiers, and that will probably still present problems.

    If you had the real sourcecode you could easily derive the base NPC, add stuff to it and more or less there wouldn't be a limit to what you could do. But we just have Lua and the NPCs that are already there doesn't work in every scenario.