Jump to content

Companion script with a slight problem


Recommended Posts

I have a "Force Equip" script for a follower mod I'm working on that works well. It force equips the tail slot, amulet, both rings and all.

 

The problem is that while testing it during a Legion murdering spree in the IC, the NPC kept being disarmed in fights as it happens normally. The problem is that a new version of the weapon is put back in the inventory by the script, as it reads all equipment from an array of refs.

 

I could just rework the script to avoid doing that but I would rather do the following:

 

1) Stop the follower from being disarmed at all;

- Any ideas on that? I guess I would have to dynamically add an script to any and all equipped weapons to stop them from being dropped by the companion. Is it even possible to add an script to a weapon as it is equipped? No luck researching it.

2) Put the weapon back in the NPC's inventory;

- I had an idea about saving the weapon ref in an array with a "equipped" flag. If an weapon is "equipped == 1" and becomes "unequipped == 0" and it is not in the inventory anymore, then it was dropped. I would scan the immediate vicinity of the actor for a weapon of that kind and put it in the inventory if found or make the actor grab it. Is this possible?

3) Have the dropped weapon disabled if grabbed by the player like the Arena ones;

- I guess it would also need to add scripts to all weapons this actor equips on the fly and that's probably a problem. Any other way?

4) Just make the companion loot some nearby corpse for a new weapon;

- I would like to implement container looting on this follower so she would systematically go from corpse to corpse and chest to chest on the same grabbing anything that is above a X monetary value. I just need a pointer on how to start a system like that.

 

Basically that's it. I would appreciate any pointer, hints or scripts that would help me with those troubles.

Link to comment
Share on other sites

  • 1 month later...

You could set the disarm chance for the blade (expert) and block (master) perks to 0.

SetNumericGameSetting iPerkAttackDisarmChance 0
SetNumericGameSetting iPerkBlockDisarmChance 0
If the game is loaded or restarted you need to set these settings again as they are being reset to their default values each time.
if GetGameRestarted || GetGameLoaded
	SetNumericGameSetting iPerkAttackDisarmChance 0
	SetNumericGameSetting iPerkBlockDisarmChance 0
endif

 

Alternatively, you could search with a GetFirstRef/GetNextRef loop for dropped weapons, shields, etc., and let the companion pick them up with activate.

I did this for some of the temporary companions from the upcoming new version of Abyss Demon.

[...]
short pickweapon
ref droppedweapon
ref revenant
[...]
if pickweapon == 1 
	Set pickweapon to 0 
           
	Set droppedweapon to GetFirstRef 33 
while droppedweapon 

	if revenant.GetDead == 0 
	if revenant.GetEquippedObject 16 == 0 && droppedweapon.GetDistance revenant < 500
; when the NPC has no weapon equipped and any weapon in the cell within a distance of 500 units 
		droppedweapon.Activate revenant
		revenant.AddItem blackhood 1 ; adding, equipping and removing this item updates the inventory of the NPC
		revenant.EquipItem blackhood 
		revenant.RemoveItem blackhood 1                          
		break                               
	endif      
                                    
	endif                          
                               
Set droppedweapon to GetNextRef 
loop 
Set pickshield to 1                
endif
[...]

Note: these script parts need OBSE to work

Edited by Selene310187
Link to comment
Share on other sites

  • Recently Browsing   0 members

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