Modifié par Knight_Shield, 21 juillet 2011 - 04:36 .
animals
#1
Posté 21 juillet 2011 - 04:34
#2
Posté 21 juillet 2011 - 04:44
#3
Posté 21 juillet 2011 - 04:59
Or easiest solution is to set the chicken walk waypoints, (click on chicken, and then right click at location and use one choice, cant remember the name atm but it will make a waypoint, then the chicken will go from spawn at those waypoints in order you made then and after she walk last then she return to the spawn point again.
#4
Posté 21 juillet 2011 - 08:33
Modifié par Morbane, 21 juillet 2011 - 08:34 .
#5
Posté 21 juillet 2011 - 01:07
#6
Posté 21 juillet 2011 - 01:09
#include "x0_i0_anims"
void main()
{
SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
SetListeningPatterns();
WalkWayPoints();
}
#7
Posté 21 juillet 2011 - 10:47
Morbane wrote...
Usually the randomwalk function would be placed in the heartbeat - so in effect the random direction is rechosen every 6 seconds - the chicken will not get far before changing path. But potentially they can actually roam anywhere.
Adding the RandomWalk stright to the HB without a filter is a bad Idea. Random walk does not need to be called every HB. Once it is called it will continue untill a clear all actions is called. If you just place it into the HB you are going to be adding a action to the Que ever round with the chance of non of them ever being removed. I am not sure what the limit is on the number of actions in the que, but if left unchecked this can cause problems.
Modifié par Lightfoot8, 21 juillet 2011 - 10:48 .
#8
Posté 21 juillet 2011 - 11:31
//Goes OnUserDefined of a creature, or on perception.
#include "NW_I0_GENERIC"
void main()
{
if (d100()>25)
//fires % of the time.
return;
object oPC = GetLastPerceived();
object oBale= GetNearestObjectByTag ("HayBale");
object oBale1= GetNearestObjectByTag ("HayBale01");
object oTrough = GetNearestObjectByTag ("WaterTrough");
effect eRegenerate = EffectRegenerate(5, 6.0);
{
if (GetIsInCombat())
return;//if fighting fight on.
}
switch( d6())
{
case 1: ActionInteractObject (oBale);break;
case 2: AssignCommand(oPC, PlaySound("as_an_cows1")); break;
case 3: AssignCommand(oPC, PlaySound("as_an_cows2")); break;
case 4: ActionInteractObject (oBale1);break;
case 5: ActionInteractObject (oTrough);break;
case 6: ActionInteractObject (oBale1);break;
}
if (GetDistanceToObject(oTrough) < 2.0)
DelayCommand (2.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRegenerate, OBJECT_SELF, 30.0));
}
Now you want to put an object tagged HayBale HayBale01 and WaterTrough. The cows will roam around only if they perceive something nearby as I put them on short range perception with one cow having a medium ranged perception. This is for cows in a pen but I have used it effectively in open fields too. Usually the cows simply graze, and if you have ever observed cows, something I would guess most have not, they are are normally very placid. Only if something comes close do they react. I delete their hb and just use the script above. With this method I have achieved a method which emulates reality pretty well. The original if % returns most of the time so they won't just change behaviors, flip back and forth, a lot. So a higher number will return the script less often and of course only onperception. The result is if you move towards the cows they react, if you move away they settle down, though sometimes the perception will refire if they perceive another object, like Bill the Bull who roams around and tends to get the gals riled up a bit. He is on a seperate script. Anyway just an alternative method for dealing with animals. You can also tag a waypoint WaterTrough and put it in a stream.
I did one for chickens, cats, dogs, and the aforementioned Bill the Bulls script.
Modifié par ffbj, 21 juillet 2011 - 11:35 .
#9
Posté 21 juillet 2011 - 11:42
#10
Posté 22 juillet 2011 - 02:56
Very good in game...........
// Deer OnPerceive script
const string DEER_TRACKS_RESREF = "x0_tracks";
int GetIsNearMapEdge( object oObject, float fDistanceAway = 2.5)
{ if( !GetIsObjectValid( oObject) || !GetIsObjectValid( GetAreaFromLocation( GetLocation( oObject))) || (fDistanceAway <= 0.0)) return FALSE;
// If near edge of map, vanish leaving footprints behind
float fMaxX = IntToFloat( GetAreaSize( AREA_WIDTH, GetArea( OBJECT_SELF))) *10.0;
float fMaxY = IntToFloat( GetAreaSize( AREA_HEIGHT, GetArea( OBJECT_SELF))) *10.0;
vector vPos = GetPosition( oObject);
return ((vPos.x <= fDistanceAway) || (vPos.y <= fDistanceAway) || ((fMaxX -vPos.x) <= fDistanceAway) || ((fMaxY -vPos.y) <= fDistanceAway));
}
void SpawnTracks( location lSpawnAt, string sResref, string sCreatureName, string sTAG = "")
{ if( !GetIsObjectValid( GetAreaFromLocation( lSpawnAt)) || (sResref == "") || (sCreatureName == "")) return;
string sLowerName = GetStringLowerCase( sCreatureName);
string sUpperName = GetStringUpperCase( GetStringLeft( sLowerName, 1)) +GetStringRight( sLowerName, GetStringLength( sLowerName) -1);
object oTracks = CreateObject( OBJECT_TYPE_PLACEABLE, sResref, lSpawnAt, FALSE, sTAG);
if( !GetUseableFlag( oTracks)) { SetUseableFlag( oTracks, TRUE); SetUseableFlag( oTracks, FALSE); }
SetName( oTracks, sUpperName +" tracks");
SetDescription( oTracks, "A fresh set of " +sLowerName +" tracks.");
AssignCommand( oTracks, DelayCommand( HoursToSeconds( 1), SetDescription( oTracks, "These tracks indicate a " +sLowerName +" came this way a little over an hour ago.")));
AssignCommand( oTracks, DelayCommand( HoursToSeconds( 3), SetDescription( oTracks, "Looks like a " +sLowerName +" ran through here a few hours ago.")));
AssignCommand( oTracks, DelayCommand( HoursToSeconds( 15), SetDescription( oTracks, "These " +sLowerName +" tracks are almost a day old.")));
AssignCommand( oTracks, DelayCommand( HoursToSeconds( 24), SetDescription( oTracks, "It's been over a day since the " +sLowerName +" that made these tracks ran through here.")));
AssignCommand( oTracks, DelayCommand( HoursToSeconds( 36), DestroyObject( oTracks)));
}
void main()
{ // If being chased
if( GetIsInCombat())
{ if( GetIsNearMapEdge( OBJECT_SELF))
{ // Chased away -- reached edge of map. Vanish and leave some tracks behind.
DestroyObject( OBJECT_SELF);
SpawnTracks( GetLocation( OBJECT_SELF), DEER_TRACKS_RESREF, "Deer", "DeerTracks");
return;
}
// Not near a map edge keep running away.
// See if the perceived is a closer enemy
if( GetLastPerceptionSeen() || GetLastPerceptionHeard())
{ object oPerceived = GetLastPerceived();
if( !GetIsObjectValid( oPerceived) || !GetIsEnemy( oPerceived)) { ExecuteScript( "nw_c2_default2", OBJECT_SELF); return; }
// If nobody is attacking. run from the nearest enemy.
object oEnemy = GetLastHostileActor();
if( !GetIsObjectValid( oEnemy) || GetIsDead( oEnemy))
{ oEnemy = GetNearestCreature( CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1, CREATURE_TYPE_IS_ALIVE, TRUE, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if( !GetIsObjectValid( oEnemy)) oEnemy = GetNearestCreature( CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1, CREATURE_TYPE_IS_ALIVE, TRUE, CREATURE_TYPE_PERCEPTION, PERCEPTION_HEARD_AND_NOT_SEEN);
}
// Switch who we are running from if necessary
if( !GetIsObjectValid( oEnemy) || ((oPerceived != oEnemy) && (GetDistanceToObject( oPerceived) < GetDistanceToObject( oEnemy)))) oEnemy = oPerceived;
// Run away
ClearAllActions( TRUE);
ActionMoveAwayFromObject( oEnemy, TRUE);
return;
}
}
// Do default OnPerception behavior
ExecuteScript( "nw_c2_default2", OBJECT_SELF);
}
#11
Posté 22 juillet 2011 - 07:22
#include "NW_I0_GENERIC"
void main()
{
object oPC = GetLastPerceived();
object oSpawn;
oSpawn = OBJECT_SELF;
object oArea = GetArea(oSpawn);
effect eRegenerate = EffectRegenerate(2, 10.0);
location lWP = GetLocation(GetNearestObjectByTag("WP_Chicken_01"));
location lWP1 = GetLocation(GetNearestObjectByTag("WP_Chicken_02"));
location lWP2= GetLocation(GetNearestObjectByTag("WP_Chicken_03"));
location lWP3 = GetLocation(GetNearestObjectByTag("WP_Chicken_04"));
if (GetIsInCombat())
return;
if (GetIsNight() || (GetWeather(oArea) == WEATHER_RAIN))
{
DelayCommand (2.0, ActionForceMoveToLocation(lWP3,TRUE));
DelayCommand (6.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRegenerate, oSpawn, 20.0));
return;
}
if (d100()< 25)
switch( d4())
{
case 1: ActionMoveAwayFromObject(oPC, FALSE, 5.0);break;
case 2: ActionMoveToLocation(lWP,FALSE);break;
case 3: ActionMoveToLocation(lWP1,FALSE);break;
case 4: ActionMoveToLocation(lWP2,FALSE);break;
}
}
So you paint down four wp for the chickens, two in the corn and one near the granary . The fourth wp is where they run to in bad weather, usually under the open shed tile, where they roost at night. I also put a small chicken clucking sound placeable there. I don't like the chickens squawking all the time. Anyway that is my general approach to animals you can see in the above scripts, again no heartbeats. Then if you want the cat and dog just let me know, or make your own. I am pretty happy with my cat. I used a re-sized panther for him and then scaled down rats for the mice he chases and kills. On chickens there is a nice thing you can add, chicken feed where they run to it and gobble it up, so you could have npc's or pc's feed the chickens. I don't use that but it is fun and easy to do. The reason for no hb btw is that I don't want the walkwaypoints script or other things interferring with the chickens above script. Typically they move randoml but then stop and peck and scratch at the ground for a bit, then move on. So a bit of a workaround and you don't half to deal with the endless random walk.
Modifié par ffbj, 22 juillet 2011 - 07:27 .
#12
Posté 22 juillet 2011 - 08:01
#13
Posté 22 juillet 2011 - 08:49
#14
Posté 22 juillet 2011 - 08:50
Lightfoot8 wrote...
Morbane wrote...
Usually the randomwalk function would be placed in the heartbeat - so in effect the random direction is rechosen every 6 seconds - the chicken will not get far before changing path. But potentially they can actually roam anywhere.
Adding the RandomWalk stright to the HB without a filter is a bad Idea. Random walk does not need to be called every HB. Once it is called it will continue untill a clear all actions is called. If you just place it into the HB you are going to be adding a action to the Que ever round with the chance of non of them ever being removed. I am not sure what the limit is on the number of actions in the que, but if left unchecked this can cause problems.
You just need a simple check to make sure it doesn't fire every single heartbeat. Something like this:
if ((GetCurrentAction() == ACTION_INVALID) )
{
ClearAllActions();
ActionRandomWalk();
}
#15
Posté 22 juillet 2011 - 09:14
#16
Posté 22 juillet 2011 - 10:57
although Second God War, which contains many of my proto ideas is downloadable, some of my latest stuff is still under wraps.
#17
Posté 22 juillet 2011 - 11:06
#include "NW_I0_GENERIC"
void main()
{
object oPC = GetLastPerceived();
object oSpawn = OBJECT_SELF;
object oArea = GetArea(oSpawn);
object oEnemy = GetNearestObjectByTag("Mouse");
effect eRegenerate = EffectRegenerate(1, 8.0);
float fDistance = GetDistanceToObject(oEnemy);
location lWP1 = GetLocation(GetNearestObjectByTag("CatHouse"));
if (d100()>66)
return;
if (IsInConversation(OBJECT_SELF) || GetIsInCombat())
return;
ClearAllActions();
if (fDistance < 10.0)
{
DelayCommand (0.4,ActionForceFollowObject(oEnemy,0.5));
DelayCommand (3.5, ActionAttack(oEnemy));
return;
}
if (GetIsDay())
{
DelayCommand (10.0, ActionForceMoveToLocation(lWP1,FALSE));
DelayCommand (20.0,ActionPlayAnimation(ANIMATION_LOOPING_DEAD_FRONT, 4.0f, 200.0f));
//sleeping
DelayCommand (22.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRegenerate, oSpawn, 30.0));
return;
}
string sSoundName = ("as_an_catmeow" + IntToString(Random(4)+1));
string sWPTag1 = "wp_random";//seed tag of wp. wp's must be placed.
string sRan = IntToString(d6()); //change dsize for more wp
string sWPTag = sWPTag1 + sRan; //selects wp_random1-10
location lWP = GetLocation(GetNearestObjectByTag(sWPTag));
switch( d6())
{
case 1: ActionForceFollowObject(oPC,3.0);break;
case 2: PlaySound(sSoundName); break;
case 3: DelayCommand (2.0,ActionMoveToLocation(lWP1,FALSE));
case 4: PlaySound(sSoundName); break;
case 5: PlaySound(sSoundName); break;
case 6: DelayCommand (3.0,ActionMoveToLocation(lWP,TRUE));
}
}
I used the invisible creature panther L_020 20% of size. You can also use the appearance 2da on the vault which gets rid of the annoying glow, can't remember what's it's called. You want to spawn some mice I think it's rats S_40 and tag them mouse of course, and a Cat House wp where you want him to lay down.
And a must have for all scaled creatures is Monkey_Magics glow killer:
http://nwvault.ign.c....Detail&id=1374
Modifié par ffbj, 22 juillet 2011 - 11:15 .





Retour en haut







