Jump to content

[HELP] RemoveAddedForm


IsharaMeradin

Recommended Posts

I've set up a container that when items are added, they will be added to a form list that starts out empty. When items are removed from the container, they are supposed to be removed from the form list but that doesn't happen.

 

 

Here is the whole script. This was a recent addition to an existing script which auto-stored various crafting supplies on a one minute update cycle. The quest item auto-store prevention is also an earlier recent addition. It has been working fine. The only issue is with the RemoveAddedForm in the OnItemRemoved event.

 

 

 

Scriptname abIM_StorageAndRetrieval extends ObjectReference

Import Utility
Import Game
Import Debug

;the container used
ObjectReference Property abIM_SoS_CONT Auto

;the formlists of items
FormList Property abIM_SLGM_INGR_ALCH auto
FormList Property abIM_MISC auto
FormList Property abIM_CRAP auto

;the intergers needed
Int Check1
Int Check2

;global variables
GlobalVariable Property abIM_DoUpdate Auto
GlobalVariable Property abIM_DoOnce Auto

;Frost Salt related quests
Quest Property FreeformWhiterunQuest05 Auto
Quest Property FreeformKynesgroveA Auto
Ingredient Property FrostSalts Auto

;Void Salt related quests
Quest Property FreeformShipsDawnstar Auto
Ingredient Property VoidSalts Auto

;Daedra Heart related quests
Quest Property FreeformMarkarthN Auto
Ingredient Property DaedraHeart Auto

;Jazbay related quests
Quest Property FreeformSarethiFarm Auto
Ingredient Property JazBay Auto

;Bear pelt related quests
Quest Property FreeformIvarstead03 Auto
MiscObject Property BearPelt Auto
MiscObject Property BearSnowPelt Auto
MiscObject Property BearCavePelt Auto

;Fire Salt related quests
Quest Property FreeformRiften10 Auto
Ingredient Property FireSalts Auto

;Nirnroot, Deathbell & Nightshade related quests
Quest Property FreeformRiften04 Auto
Ingredient Property Deathbell Auto
Ingredient Property Nightshade Auto
Ingredient Property Nirnroot Auto

;Misc stuff for Ringmaker quest
Quest Property FreeformRiften18 Auto
;MiscObject Property MammothTusk Auto
MiscObject Property OreGold Auto
MiscObject Property GemSapphireFlawless Auto

;Ice Wraith Teeth related quests
Quest Property FreeformRiften07 Auto
Ingredient Property IceWraithTeeth Auto

;Flawless Amethyst Gem related quests
Quest Property FreeformRiften06 Auto
MiscObject Property GemAmethystFlawless Auto

;Mammoth Tusk related quests
Quest Property Favor110 Auto
MiscObject Property MammothTusk Auto

bool transfered

Event OnActivate(ObjectReference Turtle)
If abIM_DoOnce.GetValueInt() == 0
	RegisterForSingleUpdate(60)
	abIM_DoOnce.SetValueInt(1)
EndIf
EndEvent

Function abimTransferING(Ingredient ItemToTransfer, ObjectReference ContainerToTransferTo, Actor ContainerToTransferFrom, Quest RunningQuest, Int StartStage, Int EndStage)
int count = ContainerToTransferFrom.GetItemCount(ItemToTransfer)
If (count >= 1) && !((RunningQuest.GetStage() > StartStage) && (RunningQuest.GetStage() < EndStage))
	ContainerToTransferFrom.RemoveItem(ItemToTransfer, count, True, ContainerToTransferTo)
	transfered = true
EndIf
EndFunction
Function abimTransferINGTwoQuest(Ingredient ItemToTransfer, ObjectReference ContainerToTransferTo, Actor ContainerToTransferFrom, Quest RunningQuest, Int StartStage, Int EndStage, Quest RunningQuest2, Int StartStage2, Int EndStage2)
int count = ContainerToTransferFrom.GetItemCount(ItemToTransfer)
If (count >= 1) && !((RunningQuest.GetStage() > StartStage) && (RunningQuest.GetStage() < EndStage)) && !((RunningQuest2.GetStage() > StartStage2) && (RunningQuest2.GetStage() < EndStage2))
	ContainerToTransferFrom.RemoveItem(ItemToTransfer, count, True, ContainerToTransferTo)
	transfered = true
EndIf
EndFunction
Function abimTransferMO(MiscObject ItemToTransfer, ObjectReference ContainerToTransferTo, Actor ContainerToTransferFrom, Quest RunningQuest, Int StartStage, Int EndStage)
int count = ContainerToTransferFrom.GetItemCount(ItemToTransfer)
If (count >= 1) && !((RunningQuest.GetStage() > StartStage) && (RunningQuest.GetStage() < EndStage))
	ContainerToTransferFrom.RemoveItem(ItemToTransfer, count, True, ContainerToTransferTo)
	transfered = true
EndIf
EndFunction
Function abimTransferMOTwoQuest(MiscObject ItemToTransfer, ObjectReference ContainerToTransferTo, Actor ContainerToTransferFrom, Quest RunningQuest, Int StartStage, Int EndStage, Quest RunningQuest2, Int StartStage2, Int EndStage2)
int count = ContainerToTransferFrom.GetItemCount(ItemToTransfer)
If (count >= 1) && !((RunningQuest.GetStage() > StartStage) && (RunningQuest.GetStage() < EndStage)) && !((RunningQuest2.GetStage() > StartStage2) && (RunningQuest2.GetStage() < EndStage2))
	ContainerToTransferFrom.RemoveItem(ItemToTransfer, count, True, ContainerToTransferTo)
	transfered = true
EndIf
EndFunction

Event OnUpdate()
RegisterForSingleUpdate(60)
transfered = false
Actor Player = GetPlayer()
If abIM_DoUpdate.GetValueInt() == 1 &&  !(Player.IsInCombat())
        int PlayerBaseMagicka = Player.GetBaseActorValue("magicka") as int
        float PercentOfMagicka = PlayerBaseMagicka * 0.33
	Check1 = Player.GetItemCount(abIM_SLGM_INGR_ALCH)
	Check2 = Player.GetItemCount(abIM_MISC)
	Int quantity = Player.GetItemCount(abIM_CRAP)

	If Check1 >= 1
		Player.RemoveItem(abIM_SLGM_INGR_ALCH,Check1,True,abIM_SoS_CONT)
		transfered = true
	EndIf
	If Check2 >= 1
		Player.RemoveItem(abIM_MISC,Check2,True,abIM_SoS_CONT)
		transfered = true
	EndIf
	If quantity >= 1
		Player.RemoveItem(abIM_CRAP,quantity,True,abIM_SoS_CONT)
		transfered = true
	EndIf


	abimTransferINGTwoQuest(FrostSalts, abim_SoS_CONT, Player, FreeformKynesgroveA, 0, 200, FreeformWhiterunQuest05, 0, 255)
	abimTransferING(VoidSalts, abim_SoS_CONT, Player, FreeformShipsDawnstar, 0, 200)
	abimTransferING(DaedraHeart, abim_SoS_CONT, Player, FreeformMarkarthN, 0, 20)
	abimTransferING(JazBay, abim_SoS_CONT, Player, FreeformSarethiFarm, 10, 20)
	abimTransferING(FireSalts, abim_SoS_CONT, Player, FreeformRiften10, 10, 200)
	abimTransferING(Deathbell, abim_SoS_CONT, Player, FreeformRiften04, 10, 200)
	abimTransferING(Nirnroot, abim_SoS_CONT, Player, FreeformRiften04, 10, 200)
	abimTransferING(Nightshade, abim_SoS_CONT, Player, FreeformRiften04, 10, 200)
	abimTransferING(IceWraithTeeth, abim_SoS_CONT, Player, FreeformRiften07, 10, 200)


	abimTransferMO(BearPelt, abim_SoS_CONT, Player, FreeformIvarstead03, 10, 200)
	abimTransferMO(BearCavePelt, abim_SoS_CONT, Player, FreeformIvarstead03, 10, 200)
	abimTransferMO(BearSnowPelt, abim_SoS_CONT, Player, FreeformIvarstead03, 10, 200)
	abimTransferMOTwoQuest(MammothTusk, abim_SoS_CONT, Player, Favor110, 0, 200, FreeformRiften18, 10, 200)
	abimTransferMO(OreGold, abim_SoS_CONT, Player, FreeformRiften18, 10, 200)
	abimTransferMO(GemSapphireFlawless, abim_SoS_CONT, Player, FreeformRiften18, 10, 200)
	abimTransferMO(GemAmethystFlawless, abim_SoS_CONT, Player, FreeformRiften06, 10, 200)

	If transfered == true
   		Player.DamageActorValue("magicka",PercentOfMagicka)
   		Debug.Notification(Utility.GameTimeToString(Utility.GetCurrentGameTime()) + ": GoE - Stuff stored")
	EndIf
EndIf
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
If akSourceContainer == Game.GetPlayer()
	If (abIM_MISC.HasForm(akBaseItem) == False) && (abIM_SLGM_INGR_ALCH.HasForm(akBaseItem) == False) && (abIM_CRAP.HasForm(akBaseItem) == False)
		If (akBaseItem != FrostSalts) && (akBaseItem != VoidSalts) && (akBaseItem != DaedraHeart) && (akBaseItem != JazBay) && (akBaseItem != FireSalts) && (akBaseItem != Deathbell) && (akBaseItem != Nirnroot) && (akBaseItem != Nightshade) && (akBaseItem != IceWraithTeeth) && (akBaseItem != BearPelt) && (akBaseItem != BearCavePelt) && (akBaseItem != BearSnowPelt) && (akBaseItem != MammothTusk) && (akBaseItem != OreGold) && (akBaseItem != GemSapphireFlawless) && (akBaseItem != GemAmethystFlawless) && (Game.GetPlayer().IsEquipped(akBaseItem) == False)
			abIM_CRAP.AddForm(akBaseItem)
			Debug.trace(akBaseItem + " added to form list " + abIM_CRAP)
		EndIf
	EndIf
EndIf
EndEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
If akDestContainer == Game.GetPlayer()
	If (abIM_MISC.HasForm(akBaseItem) == False) && (abIM_SLGM_INGR_ALCH.HasForm(akBaseItem) == False) && (abIM_CRAP.HasForm(akBaseItem) == True)
		abIM_CRAP.RemoveAddedForm(akBaseItem)
		Debug.trace(akBaseItem + " removed from form list " + abIM_CRAP)
	EndIf
EndIf
EndEvent

 

 

The exact scenario: Had Orcish bow equipped. Picked up Falmer bow equipped it. Stored the Orcish bow. Later became over encoumbered by excess Falmer bows. Chose to retrieve the Orcish bow & store the Falmer bows. Next auto-store update cycle the Orcish bow was removed from my hands and stored...

 

I could probably try to come up with a check against having items in the form list equipped BUT if the RemoveAddedForm is supposed to work under this scenario.... I'd rather get that working properly.

 

Any thoughts?

 

EDIT:

I switced to Revert() since the form list gets reset on each game session. I figure it might as well reset when Items are withdrawn then.

 

That seems to work if I follow this routine. I deposit items to the container within one cycle. Wait for the update to take place. Then withdraw the entire stack amount of the given item I want. Close the container access menu. Reopen the inventory only menu. Equip the item. Wait for the update to take place again.

 

Got that to take place twice in a row...

Edited by IsharaMeradin
Link to comment
Share on other sites

  • Recently Browsing   0 members

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