Jump to content

Getting Your Custom Companion to Attack


trilioth

Recommended Posts

Getting Your Custom Companion to Attack

 

I had trouble with a couple of points:

  • Getting my custom companion to attack an NPC
  • Getting my custom companion to attack the player (through dialogue)

I searched the forums to no avail. I even found a post where the maker of Alex Mercer as a companion had trouble, but there was no answer to her question.

 

To get a companion to attack a specific NPC...

 

I used a Use Weapon Package. I did this through a quest script using the AddScriptPackage function. I have tested this in two ways that had positive results. I can't remember all the different things I tried that didn't work. I actually went back through some testing phases in order to document this here as thoroughly I could.

 

  1. One way being that the companion (let's call him Bob) was set to be "fired" before starting the attack . The targeted NPC nor his allies attacked Bob for his actions. Even when it resulted in the death of the targeted NPC. To solve that problem I used the SetEnemy function with Bobs Faction and a common faction for the target NPC and his allies as parameters. I believe the faction that is chosen needs to track crime, but I have not tested for that. The NPCs involved only attacked Bob.
  2. The other way was where he was not "fired" nor waiting. When and only when an NPC died did his allies start attacking and they were hostile to both Bob and the player. Using SetEnemy on the Bob's faction did not change this.

To get a companion to attack the player through dialogue...

 

First, I should mention that I used the function SetIngoreFriendlyHits (SetIngoreFriendlyHits 1 or SIFH 1) in the hire topic result script. I was having trouble getting Bob to attack the player through dialogue and I eventaully I discovered that I had to turn off SIFH (SIFH 0). If you did not use the function SetIngoreFriendlyHits, then this should not be an issue. Also, I had to "fire" him through scripts. I did this in a quest script before the dialogue package was added using AddScriptPackage. It should work just the same if you "fired" him in the result script that initiates combat with the player (startcombat player should be the last command). If he is still a teammate he will not attack the player. This also seems to require that I remove Bob from TeammateFaction using the the RemoveFromFaction function.

To get a companion to attack the player outside of dialogue...

 

Using a quest script, I fire the companion making sure all the needed variables and settings are changed. Then I add the companion to a special faction that is already enemies with the player.

I would like to add that for compatibility's sake, I chose to avoid editing the targeted NPC, nor any of the vanilla NPCs. Also, SetIngoreFriendlyHits is undocumented and the vanilla companions use this, but I have yet to see any scripting that turns it off. In using this funciton, I have learned that while "BobCompREF.SetIngoreFriendlyHits 1" will compile, it will cause problems. So far I have not seen any of the vanilla scripts use this function outside of a dialogue result script. Any further knowledge of this function's use would be greatly appreciated.

 

Please feel free to share any knowledge you have involving initiating combat with custom companions. I thank you in advance for your contributions.

Edited by trilioth
Link to comment
Share on other sites

I will use this comment space to document any changes made to the original post. I intend to as much information on this topic as I can find.

2/12/2023 04:33 AM CST:
Added: This also seems to require that I remove Bob from TeammateFaction using the the RemoveFromFaction function.

2/18/2013 12:53 AM CST:

Added information about setting the companion to attack the player outside of dialogue and made some changes to the formatting.

 

 

Edited by trilioth
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...