Skip to content

[AI Fix - Creatures Wander During the Day and Go to Nighttime Posting]

Today I was working on populating a village with some animals that I wanted to have wander the area during the day using ambient animations (NW_FLAG_AMBIENT_ANIMATIONS) then move to a Night Post waypoint at nighttime(NW_FLAG_DAY_NIGHT_POSTING). As I wanted the creatures to wander the area randomly, I had deliberately chosen to not place a Day Post waypoint or placed any walking waypoints.

Everything worked great, the creatures would move randomly around the area then, when nighttime came, they would move to their nighttime postings. HOWEVER, after the transition from nighttime back to daytime, the creatures would stay at their nighttime posting and would not play any ambient animations.

The problem was in nw_c2_default1 - specifically, when a creature moves to its nighttime posting the flag NW_WALK_FLAG_CONSTANT is set to TRUE, which sets the creature into walking between waypoints (using the WalkWaypoints function). However, if no walking waypoints are set up, the creature gets "locked" at its post and will no longer do ambient animations.

Fortunately, I was able to fix this, by adding a block of coding at line 64 in nw_c2_default1:

replace the block of code

else if ( GetWalkCondition(NW_WALK_FLAG_CONSTANT) )
{
WalkWayPoints();
}

with

else if ( GetWalkCondition(NW_WALK_FLAG_CONSTANT) )
{
if (GetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING)
&& GetIsDay())
{
if (GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS)
|| GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS_AVIAN)
|| GetIsEncounterCreature())
{
PlayMobileAmbientAnimations();
}
else if (GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS))
{
PlayImmobileAmbientAnimations();
}
}
else
{
WalkWayPoints();
}
}

This resets the ambient animations state provided that 1) the creature has a day/night posting and 2) the current time of day is not nighttime.
Sign In or Register to comment.