My cows onperception:
//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 .