Jump to content

Need Script to swap an Armor for a MiscObject


Odinml

Recommended Posts

first off i am terrible at writing scripts, so i was wondering if someone could write a script for me that is capable of swaping any "Armor" for any "MiscObject" on a container change. for example if the script was to be added to a barrel and that barrel had an iron armor in it, when the player places the "Iron Armor" into his inventory it becomes a "Garnet"

Link to comment
Share on other sites

It is a simple remove item and add item code. When the player picks up the armor, the script will remove the iron armor and add the garnet equivelent. I can write such a script in my sleep... in Fallout. Skyrim, uses an entirely different scripting system and I've never tried to code in Skyrim (don't own it, don't care to own either). But the basic setup is that the script checks for the iron armor in the barrel, and if it's gone, and the player was the one that picked it up, it will remove that armor from the player and add the garnet armor.

Link to comment
Share on other sites

  • 2 weeks later...

Given your example, you want to swap a specific type of armor with a specific type of misc object, a script like this would work:

 

Scriptname SwapItemScript Extends ObjectReference

Armor Property AnyArmor Auto
MiscObject Property AnyItem Auto
Actor Property PlayerRef Auto

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
		if akBaseItem == AnyArmor && akDestContainer == PlayerRef
			PlayerRef.RemoveItem(AnyArmor, 1, true)
			PlayerRef.AddItem(AnyItem, 1)
		endif
EndEvent

Script needs to be assigned to the container, then the properties filled with the forms for the armor and miscobject to be swapped. And of course the player ref.

 

Though I'm not sure what you mean by 'swap any armor with any misc object'. If it's meant to swap every type of armor with a random misc item, the script would be a bit more complicated.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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