Aller au contenu

Photo

How do I set int NW_FLAG_BEHAVIOR_HERBIVORE ?


  • Veuillez vous connecter pour répondre
14 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I want to make animals hostile but run away.  Digging through the AI, I found the int NW_FLAG_BEHAVIOR_HERBIVORE  that is supposed to make the animal flee.  I looked it up on the NWNLexicon and it said that I needed to set the switch to

int NW_FLAG_BEHAVIOR_HERBIVORE = 0x00000008; //Will never attack. Will alway flee.


I don't exactly know how to set this flag on a creature.  Is it just setting a local int on the creature, or is there a function that needs to go in the on spawn script?

#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
You should be able to do either.

#3
kevL

kevL
  • Members
  • 4 070 messages
I think it can be set anytime (incl. spawn) w/

SetBehaviorState(NW_FLAG_BEHAVIOR_HERBIVORE, TRUE);


( darn bitwise in 'X0_I0_BEHAVIOR', but i think i got it lol ) - hopefully the AI respects the switch, but if not ya might have to make a call to DetermineSpecialBehavior() in 'nw_i0_generic' ...

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages
The behavior flags are set by adding them bitwise to the one behavior variable to Rule Them All--which I think is something like NW_BEHAVIOR_MASTER.

So, if you wanted ambient animations and hebivore behaviors, for example, you'd bitwise add these and set the local int (NW_BEHAVIOR_MASTER should be set equal to the name of this variable in X0_I0_BEHAVIOR IIRC) equal to the combined value.

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Well I set it, but it makes the AI act crazy. The deer will run away from you then, change it's mind and come back at you, then lose it's nerve and run away, then come and attack for a round or so, and then run away again. The flag should be called NW_FLAG_BEHAVIOR_RABIES.

#6
kevL

kevL
  • Members
  • 4 070 messages
lol, i remember now!

#7
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
Probably because you have it set to hostile. It will probably work if you set the faction to neutral.  Why have it set to hostile? Are you intending to bow-hunt?

Modifié par Kaldor Silverwand, 11 février 2012 - 04:29 .


#8
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I thought it would be cool to have the deer run away from you when you walked by as opposed to just standing around like a petting zoo. I guess I could just do a short on perception script to get the same effect without all the attacking...

#9
MasterChanger

MasterChanger
  • Members
  • 686 messages
The herbivore behavior is pretty weird, especially if you make the creature hostile as Kaldor mentioned. The creature is getting conflicting commands, but only every six seconds.

It's probably better to make the creature non-hostile and allow the PC to attack neutrals if you want them to be forced to bow-hunt.

Alternatively, if you want the deer to rush the player once they are attacked, make an OnPhysicallyAttacked script that removes the flag and sets them hostile.

#10
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
I think if you just want the deer to run away set it to a neutral or friendly faction and set NW_FLAG_BEHAVIOR_HERBIVORE. There is no reason to set them hostile unless you want to attack them.

#11
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Many other event scripts call the DetermineCombatRound function, which orders creatures to attack. On Damage and On Physically Attacked, of course, as well as the Perception event. Additionally, Creatures will shout to their allies to attack, which I think involves something in the on-conversation script, or buried deep elsewhere. I ended up adding special checks all throughout the event scripts, to get creatures to consistently flee, even when attacked. Even then, one time my PC was down to one hp, so I killed a rabbit so I could eat it and rest, and then this other rabbit comes charging at my PC, and takes her out with one lucky hit.

With every patch or expansion, going all the way back to the NWN OC, the developers have added layer upon layer of code to get the AI to kinda work, to the point where I don't think anyone really knows how everything works. NWN/2 AI is just one big dank labyrinth of spaghetti, abandon all hope ye who enter here.

#12
kevL

kevL
  • Members
  • 4 070 messages
i put on my Orpheus costume and things looked verry tewweible.

3 things I noticed, though,

1. the SoZ NPC event slot scripts (ie, nw_c2_default* ) use Tony's (?) more advanced Hench* functions, including HenchDetermineSpecialBehavior() & HenchDetermineCombatRound().
2. those scripts typically make an either-or call to hDSB *OR* hDCR ( just DSB / DCR for earlier ai ), so it appears DSB is not (always?) a subfunction of DCR ...
3. DSB seems to rely on a nearby nonFriendly to move away; hDSB doesn't seem to require that.

#13
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I ended up just making them neutral and adding a basic on perception script that made them run away when they see someone. It looks okay.

#14
Dann-J

Dann-J
  • Members
  • 3 161 messages
Feel free to check out my timid animal heartbeat scripts in Dragonglade. They check for player proximity, then make the creature run away if you get too close. I think I may have added checks for hiding or invisibility, and I planned to allow druids to approach them (I can't remember if I implemented that last check though).

Each group of animals has a home waypoint, which if they wander too far away from they return to. They also make rapid running noises when they flee. They're all in a neutral faction, so you can attack them if you choose (but hostiles won't attack them, and they will never attack the player). The chickens near the ranger's hut, and the deer in the forest, all use the 'timid' HB script.

I used a variation for the sand beetles in Isle of Shrines as well.

#15
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
That sounds good, and that's the behavior I'm looking for. Thanks.