Author Topic: Preventing faction members from turning hostile  (Read 386 times)

Legacy_Beccarte

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Preventing faction members from turning hostile
« on: July 05, 2014, 01:41:23 am »


               

  I made a "neutral" faction in my module and disabled the "global effect" flag and set its reaction to all factions, including itself, to 50. I intend to use it for animals who should generally ignore everything. However, I made a hunting grounds area and noticed that all of the animals in the neutral faction that are nearby will turn hostile if the PC attacks one of them. This seems ridiculous, so I decided to try to prevent the other faction members from turning hostile. Unfortunately, this has proven to be quite difficult. I decided I would create a variable on the animals called "IGNOREHELP" that prevents them from shouting or responding to shouts. These are the steps I have tried so far:


 


If "IGNOREHELP" is set to 1 on the creature:


1. SetListening(OBJECT_SELF, FALSE) at the end of the OnSpawn script.


2. Do not speak the "NW_ATTACK_MY_TARGET", "NW_I_WAS_ATTACKED", and "NW_I_AM_DEAD" in the OnPerception, OnPhysicalAttacked, OnDeath, and OnSpellCastAt scripts.


3. Prevent the "nw_i0_generic" script function RespondToShout() from executing. (I did a build of the module after this step.)


4. Disable SetListeningPatterns() in the OnSpawn script.


 


None of these had the desired effect. Indeed, all of them together do not prevent the other animals from going hostile. There may be something simple that I am overlooking since I have not used the NWN toolset in some time. The only custom content I am using is Project Q. I did a search of the forum and found this short thread, but it was not helpful:


http://forum.bioware...le#entry7261578


 


I appreciate your feedback. Thanks!



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #1 on: July 05, 2014, 02:36:09 am »


               

When editting the faction, did you also first check the "Full Detail" box as well? If not, you should and it'll likely reveal your problem.



               
               

               
            

Legacy_Beccarte

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #2 on: July 05, 2014, 02:42:08 am »


               

  All of the bars are at the '50' level, the green ones also.



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #3 on: July 05, 2014, 03:16:43 am »


               

Try adding this to the top of the OnPhysicalAttacked Event:


 



object oPC = GetLastAttacker();


if (GetIsPC(oPC) && GetLocalInt(OBJECT_SELF, "IS_HOSTILE") == 0)


{


     ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_HOSTILE);


     SetLocalInt(OBJECT_SELF, "IS_HOSTILE", 1);


     return; //bail out from the script


}



 


Use this in the top of the OnSpellCastAt Event:


 



object oPC = GetLastSpellCaster();


if (GetIsPC(oPC) && GetLastSpellHarmful() == TRUE && GetLocalInt(OBJECT_SELF, "IS_HOSTILE") == 0)


{


     ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_HOSTILE);


     SetLocalInt(OBJECT_SELF, "IS_HOSTILE", 1);


     return; //bail out from the script


}



 


These blocks of code MUST be placed above any other code in each script under the void main() section. I have not tested them so some tweaks might be in order.



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #4 on: July 05, 2014, 04:03:48 am »


               

Sounds like your problem has nothing to do with your set values of 50 for the "neutral faction", but in other faction's bars for neutral.  Look at hostile, defender, merchant, and whatever other faction you have and see if their bars for "neutral" are all at 50.


 


Edit: Whoops, seems like kalbaern beat me to it. '^_^'



               
               

               
            

Legacy_Beccarte

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #5 on: July 05, 2014, 07:48:57 am »


               

Interesting thought, pstemarie, thanks. I tried it and it didn't work, though. Interestingly, I deleted ALL of the scripts from the creature and the surrounding members of the same faction still went hostile. I then deleted ALL of the scripts from the surrounding creatures as well and they STILL went hostile! That means that this process is independent of both the scripts on the attacked creature and the scripts on the creatures turning hostile... It may be some sort of hardcoded shenanigans.


 


I tried a workaround where the creature clears its personal reputation towards the PC if they are hostile and have never been attacked by a PC. That successfully makes them ignore the PC unless attacked. However, they are still "red" and summoned creatures and familiars with pick a fight with them. Oh well.


 


I suppose the only recourse I have is to make 30 different neutral factions and assign one randomly to animals as they are spawned. That should minimize the odds of having strange effects, but it is a cumbersome solution.



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #6 on: July 05, 2014, 11:49:15 am »


               I find this puzzling, as I have a faction which is not global and 50 relative to itself and others, which doesn't seem to have this problem.

At risk of motherhood, did you update instances after changing the templates?

Other workarounds include setting the plot flag, or spawning with the herbivore variable NW_BEHAVIOR_MASTER set to 9.

The latter causes the animal to flee 10m, which is a bit puny, so my preference is to change it to 40m in x0_i0_talent, recompliling the AI scripts as necessary.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #7 on: July 05, 2014, 11:58:35 am »


               I also believe that factions are one of the few thing that require a rebuild of the module.
               
               

               
            

Legacy_Beccarte

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #8 on: July 05, 2014, 05:37:27 pm »


               

Just to check, I did a build of the module and the problem persists. I have "solved" the issue by making 15 neutral factions and randomly assigning one to a creature on spawn if it has an int "RANDOMFACTION" set to 1. Thanks for the assistance, everyone!


 


Also, I did not know about the herbivore flag as it is not mentioned in the switches include file. Thanks, Proleric.



               
               

               
            

Legacy_Scrotok

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Preventing faction members from turning hostile
« Reply #9 on: December 08, 2014, 06:11:06 pm »


               

Started a new thread, same topic (didn't realize this thread already existed):


 


http://forum.bioware...to-turn-hostile