Animals Random Walking and Persistent Storage

Moderator: Event DM

Post Reply
Brayon
Team Member; Retired with Honors
Posts: 4084
Joined: Mon Nov 21, 2005 3:57 am
Timezone: GMT -5
Location: Tampa, Florida
Contact:

Animals Random Walking and Persistent Storage

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


CoPaP Ambassador for Arkaz, DM Ralyorm for Arkaz/Hala.
User avatar
Gorgon
Father of Avlis EE
Posts: 6637
Joined: Fri Oct 17, 2003 10:14 pm
Timezone: PST -8
Location: Vancouver, BC, Canada

Re: Animals Random Walking and Persistent Storage

Post by 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 (1942-2018) --


Sprucing up ye olde NWN | NWN:EE Wiki | ~Avlis Theme Song~
Moredo
Team Member; Retired with Honors
Posts: 8330
Joined: Mon May 26, 2003 3:47 pm
Timezone: +2
Location: Norway (GMT +2)

Re: Animals Random Walking and Persistent Storage

Post by Moredo » Thu Aug 19, 2010 7:31 am

You're looking for the ActionRandomWalk(); script. ;)
User avatar
Buddha
Head of Development
Head of Development
Posts: 3243
Joined: Tue Mar 15, 2005 11:06 pm
Timezone: GMT-4 (EST)
Location: Sitting Down
Contact:

Re: Animals Random Walking and Persistent Storage

Post by 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
terror2001
Scholar
Posts: 1149
Joined: Wed Jun 22, 2005 1:48 am
Location: Colorado

Re: Animals Random Walking and Persistent Storage

Post by 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();
}
Terror2001
Playing:
Vicky - Warrior Maiden of Dre'Ana
Delcina Le'te'te'fer - Verossa's Flame-thrower
Sally (Nadiya) Silverbreeze - Indeed
Brandon (Bobb) *grins*
Olivia Stonebridge - Holy imbiber of Mishlekh
Brittany Powers - You gonna die!
Brayon
Team Member; Retired with Honors
Posts: 4084
Joined: Mon Nov 21, 2005 3:57 am
Timezone: GMT -5
Location: Tampa, Florida
Contact:

Re: Animals Random Walking and Persistent Storage

Post by Brayon » Thu Aug 19, 2010 5:44 pm

Thank you folks. :-)

Pleth is the Best!
AJ is Arcadia's Brother


CoPaP Ambassador for Arkaz, DM Ralyorm for Arkaz/Hala.
User avatar
Horred the Plague
Apprentice Scholar
Posts: 500
Joined: Thu Sep 08, 2005 5:21 am

Re: Animals Random Walking and Persistent Storage

Post by 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
Contractor, Avlis
Post Reply