Author Topic: How to make deer run away when they see a hostile creature or PC?  (Read 254 times)

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0


               There's this nifty "herbivore" script in OnSpawn of deer that makes them passive and causes them to scatter if one of them is attacked.

Here is the cut out part of the script:

SetBehaviorState(NW_FLAG_BEHAVIOR_HERBIVORE);//Creature will flee those that close within 7m if they are not friends, Rangers or Druids.

Sounds nice, but for some reason they don't work this way. They only scatter AFTER being attacked and neither non-druid and non-ranger PCs nor other creatures cause the stags to flee (unless they attack).

It would be more natural if these stags, well, tried to avoid any contact with any creature (apart from rangers and druids).
Can anything be done about it?

Thanks. '<img'>
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
How to make deer run away when they see a hostile creature or PC?
« Reply #1 on: June 13, 2013, 12:05:39 am »


               http://nwvault.ign.c....Detail&id=3219

There was another one someone made in the scripting forum, but I think it was on the old Bioboards and the Omnibus has no record of it, nor can I find the package on NWvault. The above package will do what you ask though.

And another package:

http://nwvault.ign.c...s.Detail&id=539

FP!
               
               

               


                     Modifié par Fester Pot, 12 juin 2013 - 11:12 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
How to make deer run away when they see a hostile creature or PC?
« Reply #2 on: June 13, 2013, 12:08:32 am »


               The herbivore check is made on-heartbeat using DetermineSpecialBehavior() from nw_i0_generic.  The distance there is set to 6.0 meters in the following line:

if(GetIsObjectValid(oTarget) && GetDistanceToObject(oTarget) <= 6.0)

Increasing the distance will improve the animal's reaction to approaching hostiles.  Alternatively you could have the special behavior run twice as often by inserting a 3.0 second delay command.
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
How to make deer run away when they see a hostile creature or PC?
« Reply #3 on: June 13, 2013, 11:45:53 am »


               

Fester Pot wrote...

http://nwvault.ign.c....Detail&id=3219

There was another one someone made in the scripting forum, but I think it was on the old Bioboards and the Omnibus has no record of it, nor can I find the package on NWvault. The above package will do what you ask though.

And another package:

http://nwvault.ign.c...s.Detail&id=539

FP!


Ah, thanks! Exactly what I needed!
               
               

               
            

Legacy_Killmonger

  • Sr. Member
  • ****
  • Posts: 349
  • Karma: +0/-0
How to make deer run away when they see a hostile creature or PC?
« Reply #4 on: June 15, 2013, 04:26:42 am »


               Thanks for pointing those two out FP ...

<edited>
However, upon examining them closely I wonder what it would take to make the next form of animal ai,
The Carnivore /predator.
I notice how unclever the natural animal carnivores behave. (aka not using stealth, multiple attacks from multiple sources, feint and dodge etc, etc) I am no scripter, but such a program, if it exsists, in conjunction with a spawner and perhaps a "flocking" sub-routine, it might help create a more realistic ecology which could run in an area independent of a quest or basic spawn. Perhaps a placeable which spawns a simple food chain.

Or even, due to the stealthy nature of the carnivore(s), it might be possible to even have a foxhunt. Or even a raptor hunt. (hehehe..)

Any thoughts....?
               
               

               


                     Modifié par Killmonger, 16 juin 2013 - 02:15 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
How to make deer run away when they see a hostile creature or PC?
« Reply #5 on: June 18, 2013, 09:18:24 pm »


               Take a look at Second God War in my signature and look for wolves and deer.  Some of the behaviors you mention can be evidenced there.