Jump to content

Help with equip-best-armor script


blackbirdwanderer

Recommended Posts

Sorry. Like everything else AI packages are quirky and I don't have that much experience with them.

 

Just thought you'd like to know I reinvented the way I was approaching the problem and broke the armor search and equip AI package into two separate packages. The first package is actually one that does nothing but calls the second successively like a subroutine to search for just one item, then decided when to stop calling it when enough of those items are gathered. I ended up thinking of this as a workaround & better way to repeatedly search for things since the AI won't end when so many of whatever are found.

 

What I accidentally discovered was that the system processor loading is handled MUCH more efficiently this way, and the system is not already trying to determine a path to the next objective in the middle of trying to implement the equip-best-armors behavior. I think that battle for CPU resources was what was causing me problems and erratic behavior before, and caused me to have to lengthen the Utility.Wait() pauses.

 

Now, though, believe it or not, this works perfectly even with these tiny 0.05 sec pauses, at least on my medium-capable machine. I tried it without the pauses, and the equip-best didn't work correctly, so apparently any pause is enough to help it along to completion. And it minimized the naked-flash between armors quite a lot.

 

This is the super simple "On End" section of the AI package that I'm calling like a subroutine, and it self-terminates at the end before returning to the parent AI package. (The required SetPlayerTeammate() to make the equip-best behavior work was called earlier by the "parent" AI package.) The key isn't the code, but where it's placed to ensure no equipping happening at the same time as searching/pathing since it doesn't call until the Acquire [item] part of this AI package has completed for exactly one item. Hopefully my description makes sense to someone besides me.

 

Function Fragment_0(Actor akActor)
; On End Section

	akActor.Unequipall()
	Utility.Wait(0.05)
	akActor.EquipItem(_pchsJunkRing,1)
	Utility.Wait(0.05)
	akActor.Removeitem(_pchsJunkRing,1)

	ActorUtil.RemovePackageOverride(akActor, pchsGoGetArmor) ; Stop searching for armor
	akActor.EvaluatePackage()

EndFunction

 

 

Edited by blackbirdwanderer
Link to comment
Share on other sites

  • 3 years later...

Your solution, worked like a charm.

 

I wanted my potential follower to auto equip the gear I configured in his inventory even before I traded him anything. I put your script in the OnInit Event and passed in the the Follower as an Actor property along with the Silver Ring. When I went to find the guy he was wearing the Inventory armor not the default miners gear.

Actor property akActor auto 

Armor Property SilverRing auto ; Defines "trigger" ring used for convenience and unobtrusiveness.

Event OnInit() 
	akActor.SetPlayerTeammate() ; Sets teammate behavior
.
.       Code from the Fragment
.
	Utility.Wait(1.0) ; pause

EndEvent

Thanks :)
Link to comment
Share on other sites

  • Recently Browsing   0 members

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