Server Totals
Mikona - (2)
Elysia - (1)
Wilderness - (1)
Ferrell - (0)
Le'Or - (0)
M'Chek - (0)
Deglos - (0)
Visimontium - (0)
Underdark - (0)
Total players: 4
Gallery

Links Menu

Animals Random Walking and Persistent Storage

Moderators: Nighthawk4, Dungeon Masters

Animals Random Walking and Persistent Storage

PostAuthor: Brayon » Thu Aug 19, 2010 12:56 am

I was asked to help a friend of mine build a mod for personal playing. And I'm stuck trying to do a couple of things.

First, how do you make animals which are static to an area, not encounter spawns, randomly walk? Not looking for way-points, just have them walk around a bit.

Second, without using a ton of DB systems, as this is coding for dummies, how can you make persistent storage using the default Bioware DBs?

Thanks folks. :-)

Pleth is the Best!
AJ is Arcadia's Brother



Dear whoever is reading this.
You're beautiful, and someone out there is crazy about you.
So smile.
Life is too short to be unhappy.
User avatar
Brayon
Team Member; Retired with Honors
 
Posts: 4037
Images: 12
Joined: Mon Nov 21, 2005 3:57 am
Location: Florida USA
Timezone: GMT -5

Re: Animals Random Walking and Persistent Storage

PostAuthor: Gorgon » Thu Aug 19, 2010 1:54 am

I really wouldn't bother with the Bioware db stuff. NWNX is quite easy to install and setup, and it has its own sqlite db built in. I think it comes with a test mod as well that has example chests to see how things work.
http://www.nwnx.org/index.php?id=doc_nwnx#IV

I was surprised how simple it was to install and setup the first time, though I do suggest moving to something like MySQL if you get more serious about it on Windows (even that was simple to switch to following the instructions for both). The documentation on the nwnx site has instructions for both.
"God not only plays dice, he throws them in the corner where you can't see them."
-- Stephen William Hawking (b. 1942) --


Sprucing up ye olde NWN | Modifying nwn.ini and nwnplayer.ini | ~Rare Items Wanted~ | Stealth Modifiers
User avatar
Gorgon
QA's 2nd|CCC Mobster
QA's 2nd|CCC Mobster
 
Posts: 5866
Images: 38
Joined: Fri Oct 17, 2003 10:14 pm
Location: Vancouver, BC, Canada
Timezone: PDT -7

Re: Animals Random Walking and Persistent Storage

PostAuthor: Moredo » Thu Aug 19, 2010 7:31 am

You're looking for the ActionRandomWalk(); script. ;)
User avatar
Moredo
CCC
CCC
 
Posts: 7396
Joined: Mon May 26, 2003 3:47 pm
Location: Norway (GMT +2)
Timezone: +2

Re: Animals Random Walking and Persistent Storage

PostAuthor: Buddha » Thu Aug 19, 2010 4:26 pm

Brayon wrote:First, how do you make animals which are static to an area, not encounter spawns, randomly walk? Not looking for way-points, just have them walk around a bit.

Right-click them in the toolset and go to their properties. Add the variable X2_L_SPAWN_USE_AMBIENT as an int variable with a value of 1 to give them ambient NPC animations. Not sure how this will work on animals, but it should work fine and make them wander around. If they wander too far, try setting the variable NW_ANIM_FLAG_IS_MOBILE_CLOSE_RANGE with a value of 1 in addition to the first variable. You may want to read up on that second one. Something in my brain is tickling that you need to put down some sort of HOME waypoint to make it work. A quick Google search should tell.
User avatar
Buddha
CCC
CCC
 
Posts: 2604
Joined: Tue Mar 15, 2005 11:06 pm
Location: Sitting Down
Timezone: GMT+1 (DST)

Re: Animals Random Walking and Persistent Storage

PostAuthor: terror2001 » Thu Aug 19, 2010 4:30 pm

You don't want just ActionRandomWalk in a heartbeat script. You want them to randomly walk around when they are not in combat or in a conversation, but only if PC's are in the area, so they're not chewing up system resources with pathfinding, so that takes a little more code.

Code: Select all
int CheckForPlayersInArea( object oCreature ) {
    object oPC = GetNearestCreature( CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oCreature );
    if( !GetIsObjectValid(oPC) )
        return 0;
    return 1;
}

int CreatureBusy( object oCreature ) {
    return GetIsInCombat(oCreature) || IsInConversation(oCreature);
}

void main()
{
    if( !CheckForPlayersInArea(OBJECT_SELF) || CreatureBusy(OBJECT_SELF) )
        return;

    ActionRandomWalk();
}
User avatar
terror2001
Apprentice Scholar
 
Posts: 923
Joined: Wed Jun 22, 2005 1:48 am
Location: GMT -7(-6)

Re: Animals Random Walking and Persistent Storage

PostAuthor: Brayon » Thu Aug 19, 2010 5:44 pm

Thank you folks. :-)

Pleth is the Best!
AJ is Arcadia's Brother



Dear whoever is reading this.
You're beautiful, and someone out there is crazy about you.
So smile.
Life is too short to be unhappy.
User avatar
Brayon
Team Member; Retired with Honors
 
Posts: 4037
Images: 12
Joined: Mon Nov 21, 2005 3:57 am
Location: Florida USA
Timezone: GMT -5

Re: Animals Random Walking and Persistent Storage

PostAuthor: Horred the Plague » Fri Aug 20, 2010 5:39 am

All the stock tricks, along with the variable names, are listed in x2_inc_switches script. Yes, RandomWalk() works well with animals, I know of several using it on a certain server when not evaluating if a person perceived is a druid/ranger. It's usually called from their on perception script; if an animal doesn't see or hear an intruder, they random walk. You should even be able to see it in stock nw_c2_default2 script I believe (Bioware's stock on perception script). You can even use the perception script itself to host a shutoff for the random walk, with a procedure quite similar to Terror2001's above.
Senior Designer, Twin Cities Server
User avatar
Horred the Plague
Scholar of Fools
 
Posts: 484
Joined: Thu Sep 08, 2005 5:21 am


Return to NWN General Discussion

Who is online

Registered users: Bing [Bot], Google [Bot]