User Tag List

Results 1 to 7 of 7

Thread: [request] Free Roam

  1. #1
    No Products Registered

    Join Date
    Nov 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [request] Free Roam

    Hey I need someone to help me out.
    I have a science project and to do it I need a free roam type of patch.
    What it will *hopefully* do is make a character move where ever it wants to go. Instead of point A to B back to A etc.
    The full project is due by April so if i could have it by like febuary or sooner if possible it would be a HUGE help.

  2. #2
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: [request] Free Roam

    Do you mean you need help to program a system where the animals/NPCs will wander meaningfully in their environment?

    In which case, you've answered your own question: "to make a character move whereever it wants to go"

    Your NPC needs to know what his objectives are. We can divide these into needs and feeds.

    NEEDS:
    Things the NPC needs to do obtain or to do. E.g.
    - I need Food/Drink
    - I need a Mate
    - I need Ammo
    - I need Health
    - I need Cover (from an attack)
    - I need Help (from an attack)

    FEEDS:
    Things that feed or meet the needs of the NPC. E.g.
    - Meeting a Dead Body (Feed)
    - Meeting a Creature I Can Kill (Feed)
    - Meeting Another NPC of the Opposite Sex (Mate)
    - Encountering an Ammo Box (Ammo)
    - Encountering a Health Kit (Health)
    - Encountering an Area already Marked by the Designer as a Safe Zone (Cover)
    - Encountering an Area that, after analysis, matches 'Safe' criteria (Cover)
    - Meeting a Creature of My Own Species with More Health Than Me (Help)
    - Getting the Attention of A Creature with More Health Than Me (Help)



    So your NPC needs to be aware of his needs, and have a set of solid, specific ways to meet those needs. In brief, he needs objectives.


    Secondary to this, he needs limitations. The main examples would be:

    - How far can I see?
    - Where can I not walk? (obstacles, etc)

    The first one helps ease the load on the system, so we don't have to scan the whole world for every NPC. The more limited his sight is, the faster it'll run.

    The final technique is what I call 'Where-The-Hell-Am-I Awareness'. Some idea of where the NPC is in his world, and more importantly, where he has already been. If he knows this, he won't keep running around in circles to places he's already been to and found no results in.


    Coding Solutions and Suggestions

    Okay, the nitty-gritty, the meat of it.

    Needs can be handled very easily using ALterable Strings and some events. I would do something like:

    Health is Less Than (some value)
    + Only run once when event loops
    --- Set 'IS HUNGRY' to 'YES'

    Health is Greater Than (some value)
    + Only run once when event loops
    --- Set 'IS HUNGRY' to 'NO'

    Remember, you can rename Alterable Strings to whatever you want, making the events easier to read. You would use a code like the above to make sure the NPC always has a set of vars that say 'YES' or 'NO' for all his key needs. This means you can check them quickly thereafter in the events.


    For his line of sight, there are several solutions. The best, in my opinion, is to scan ONE NPC PER FRAME. If you do this, you can use an alterable value within all items (all Health, Ammo, etc) to act as a 'distance to the NPC' value. It's fairly easy to do.

    Then you can instantly check, like this:

    'IS LOW ON HEALTH' = YES
    + 'DISTANCE' of Health is less than 640

    ...then the actions. This will select all Health items that are closer than 640px from the NPC.



    So the NPC would want to look at the nearest Health kit available, and run a Line Of Sight check to see if he can 'see' it. This can be done using Move Safely Object, see the ClickWiki under 'Line of Sight'.

    If he can't see it (there's an obstacle in the way), he tries the second closest, and so on, until he can see one. He then aims straight for that object.


    If he can't see any objects that he's needing, he needs to go into a 'hunt' mode. His objective here is to SEEK those items. Somehow, he's gotta combe the world until he finds what he needs.

    One way is to look at how far he can see (in our case, 640 pixels) and divide the world up into a grid of about that size. He would need (probably in an alterable String), to have a record of what grids/zones he's been to.

    He would select one at random and wander to it, crossing off the grid squares as he passes them, until he finds what he needs. If he reaches his target square and still finds nothing, or still needs something, he can pick another square to move to, one which has not been passed yet.

    This gives him his 'wander' routine. He's not wandering, he's actually searching for something specific.



    Depending what kind of system you use - how you optimise it, for instance - you may want to add the ability to spot items and objects that are NOT needed and note these in the NPC's 'mental map' or 'memory' of the world he's in. So if he needs ammo, he can look to any grids where ammo was seen recently, and go to those areas.


    Your final problem is what to do when the NPC's fairly satisfied with life; doesn't need anything. If he's got a system that can recall the grids where he saw certain things, he could have a system to wander around keeping track of what's where. So he always has an up-to-date view of the world. He would choose squares to go to that he hasn't visited in a while.

    Otherwise, you'd need to think of his personality or behaviour. Would he stay in one general area (a grazing behaviour), or would he wander around the world (a roaming behaviour)? For the latter, just pick a random grid square and move to it. Sooner or later, he'll bump into the player, or get injured, or get hungry, and his other routines (like 'run at the player guns blazing' or 'look for health') would take over.


    For building that mental map, you may be able to get away with using an Alterable String. If you had just one character per grid square, and you had a world of 5,000 x 5,000px, and a grid size of 640x640px, you'd require only 62 characters. I dunno what the limit is for Alt Strings, but whether it's 256 or 124 characters, it's fairly unimportant.

    In addition, if you use an object like the Bitmask object, you can use up to 8 bits per value to act as flags for what your NPC may have seen when exploring his world.

    You could use a second value (bringing us to 124 characters, still not huge), keeping a record of when the square was last considered.

    A simple loop can be run to subtract '1' to every second value in the string. So:

    A1e1k#7e5 would become
    A0e0k#6e4

    So the first two squares being '0' are now due for reinspection.

    This is a very extensive consideration, but I hope it gives food for thought.

  3. #3
    No Products Registered

    Join Date
    Jul 2006
    Posts
    2,289
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Re: [request] Free Roam

    Great "article" on that there, Dines. Thanks for taking the time to post that.

  4. #4
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: [request] Free Roam

    Lol, thanks. Although the simpler answer might be:

    Place an object at a random position in the world and make the NPC walk to it. When he gets close, or after a timed delay, move it to some other random position. The result is a creature that appears to wander randomly.

    I prefer the challenge of a monster that behaves intelligently, however, and you'll get more marks

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2006
    Posts
    696
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: [request] Free Roam

    O_O Logest post ever :P . The point of all this is that this is not a needed extension and it can all be done in MMF2.

  6. #6
    No Products Registered

    Join Date
    Jul 2006
    Posts
    2,289
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Re: [request] Free Roam

    Some users like to experiment, tweak, and figure out ways to accomplish things. Those are the tinkerers. They feel a strong sense of accomplishment with hands on innovation and details.

    Others want a fast, easy way to accomplish something, (like the Space Invaders movement) so that they can focus more on art, storyline, game play, levels, etc.

    I think both worlds are compatible for MMF2. In fact, I prefer to find out and witness what can be done more automatically. That's exciting, too.

  7. #7
    No Products Registered

    Join Date
    Nov 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: [request] Free Roam

    well to explain the project would take awhile but here it is in a nutshell
    the purpose is to design NANORGS (NANO Organisms)to clean up a set amount of sludge within a five minute time slot.
    i have two sides, good and bad. so i thought the data would appear more random if the NANORGS moved freely.
    but thanks for the huge explaination Dines i'll think i'll use the second one though

Similar Threads

  1. Free free platformer Game Art
    By Keith in forum iOS Export Module Version 2.0
    Replies: 0
    Last Post: 10th August 2013, 04:21 PM
  2. Launch new app for free or go from paid to free?
    By JoKa in forum iOS Export Module Version 2.0
    Replies: 2
    Last Post: 6th December 2012, 11:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •