The first piece of this project that I have tackled is the
default perception event. Before starting this project however I had cleaned up the bioware perception event, and added some fun behaviors for Sentries (watchmen, guard dogs) and Packs (wolves, herds). So keep in mind that the framework of the script is not the default. This one captures and responds to every kind of perception event.
The new addition to the script relating to Reputation and Group Membership is a new function
// Determine oSource's reaction type toward oTarget - (FILE: aa_inc_factions)
// Reputation is adjusted by PRR and Group Membership.
// return value of 0 = neutral, 1 = enemy, 2 = friend
int GetReputationReactionType(object oTarget, object oSource=OBJECT_SELF);
I gather the actual personal reputation, the adjustments to this stored in PRR, and then adjust for a charm effect if the PRR Charm duration is still extant. This results in a modified personal reputation for the perceived creature in the eyes of the perceiver (not necessarily a
Beholder). Lastly, if the perceived creature is seen as an enemy by the perceiver (the creature executing the perception event) and yet they both belong to the same group, they are considered neutrals.
Then with this information at the top of the perception event, I change the Reaction of the perceiver toward the pereived to match the Reputation Reaction Type returned by the
GetReputationReactionType function. I have made this reaction change temporary, as I have some concerns about handling it this way.
The reason why I did it is because I wanted the highlight of the creature to be appropriate for PCs. I didn't want PCs to defensively attack a hostile appearing neutral or friend. And I also thought - since the perception event happens before all of the other events when a PC approaches - that the rest of the AI could continue to use the GetIsEnemy and GetIsFriend functions rather than force myself to rerite every single AI script in the game.
However I am concenred by this because GetReputationReactionType will now respond to the new reputation value rather than the actual reputation value. While I am not recording this information in a database, it is tracked on the creature, and I want to track it on the creature, but I think I am working against myself by manipulating the reputation in a gross way, and potentially changing it because of this.
Advice on how to handle this in a more sensitive way is welcomed.
With regards to performance, this appears to be doing well. It doesn't appear to have any more overhead than the creature's heartbeat (other than the fact that perception events run more often when you have many creatures in an area). I tested this in an area with 7 sheep belonging to the same group and having pack behvior (faction domestic herbivore), and 3 dogs also belonging to the same group exhibiting pack behavior, and sentry behavior (faction domestic carnivore). Each of these creatures also runs my own modifications based on low Cash's work on SpecialBehavior. Sheep are Herbiovores, Dogs as carnivores. (How that works is a bit beyond the scope for the moment, but I wanted to include this as I've got a lot going on and do not appear to be adversely affecting resources). I then wandered off into the woods spawning thirteen creatures (mice, deer, boar) and the town spawning a watchmen with a patrol script and behaving as a sentry. (it was night time so all the others didn't spawn). I moved around between areas let it run for 20 minutes, played a bit. Impact on resources was no different than before. Profiling information seems a little higher, but still negligible 750 executions at 154 milliseconds.
Modifié par henesua, 24 novembre 2012 - 11:14 .