Automatcially remove armour for an autohealer mod

Started by SFDMerch, July 01, 2020, 06:26:54 PM

SFDMerch

Hi im trying to make an auto healer and i am having trouble trying to remove pants/armour from the character to activate peredozin automatically, i have a system that works ok for using items for healing and such, i just cant figure out how to remove armour automatically, any help would be appreciated. Also if anyone has a better way to activate items let me know as my way is pretty janky. https://prnt.sc/ta4zii Also sorry for the link i have no idea how to post screenshots to the fourm.

ai_enabled

Hello!

You need to get the player character equipment items container and move the armor from there to any other container such as inventory/hotbar/hand. Then apply the peredozin, then move the armor back to the same slot it was taken from the equipment container.
To get an items container from the player character, you can use an extension method SharedGetPlayerContainerEquipment, also SharedGetPlayerContainerHotbar, SharedGetPlayerContainerInventory, SharedGetPlayerContainerHand (you can find plenty of examples in Core.cpk code).
To move an item from one container to another you need to use Api.Client.Items service, method MoveOrSwapItem (also plenty of examples in Core.cpk code).

As a side note, please note that in A27 Update (since the experimental launch on 31 June) we've already changed the peredozin application mechanic so it's best to save your time and stop working on the peredozin auto-application idea. In A27 this drug cannot be applied quickly. The player has to remove the armor, apply the peredozin, wait 5 seconds, and only then the armor could be put back. So while applying the peredozin players have to take cover and the moment of application should be chosen carefully otherwise the player will risk dying in combat quickly without an armor (in A27 there is no longer a pants slot as the chest+pants now combined in a single slot). This way any advantage from the potential auto-healing mod is minimized.

Regards!

SFDMerch

Ahh thankyou for the heads up. That saves me alot of effort.

ai_enabled

Sure! By the way, please consider sharing your mod. :-)

Regards!