Jump to content

Check the prepared for casting spell


Stealth21

Recommended Posts

Meanwhile, I complete another script to empty any possible vanilla soulgem (except Azura's star and tomato) from the petty soul inside the player's inventory. Emptying from the lesser,...,grand soul will be a kind of cut copy-past. Here is a complete code:

 

scn zzSMEmptySoulGemPettySoul

Short button
Short combo
ref iter
Short PettyPetty
Short LesserPetty
Short CommonPetty
Short GreaterPetty
Short GrandPetty
Short stage

Begin ScriptEffectStart
ForEach iter <- Player
	if ( iter.GetBaseObject == SoulGemEmpty1Petty ) && ( iter.GetCurrentSoulLevel == 1 )
		let PettyPetty := PettyPetty + iter.GetRefCount
	elseif ( iter.GetBaseObject == SoulGemEmpty2Lesser ) && ( iter.GetCurrentSoulLevel == 1 )
		let LesserPetty := LesserPetty + iter.GetRefCount
	elseif ( iter.GetBaseObject == SoulGemEmpty3Common ) && ( iter.GetCurrentSoulLevel == 1 )
		let CommonPetty := CommonPetty + iter.GetRefCount
	elseif ( iter.GetBaseObject == SoulGemEmpty4Greater ) && ( iter.GetCurrentSoulLevel == 1 )
		let GreaterPetty := GreaterPetty + iter.GetRefCount
	elseif ( iter.GetBaseObject == SoulGemEmpty5Grand ) && ( iter.GetCurrentSoulLevel == 1 )
		let GrandPetty := GrandPetty + iter.GetRefCount
	endif
loop

if ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; ABCDE
	set combo to 1
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Lesser", "Common", "Greater", "Grand"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) ; ABCD
	set combo to 1
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Lesser", "Common", "Greater"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; ABCE
	set combo to 2
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Lesser", "Common", "Grand"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; ABDE
	set combo to 3
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Lesser", "Greater", "Grand"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; ACDE
	set combo to 4
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Common", "Greater", "Grand"
elseif ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; BCDE
	set combo to 9
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Lesser", "Common", "Greater", "Grand"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) ; ABC
	set combo to 1
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Lesser", "Common"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) ; ABD
	set combo to 3
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Lesser", "Greater"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; ABE
	set combo to 5
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Lesser", "Grand"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) ; ACD
	set combo to 4
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Common", "Greater"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; ACE
	set combo to 6
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Common", "Grand"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; ADE
	set combo to 7
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Greater", "Grand"
elseif ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) ; BCD
	set combo to 9
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Lesser", "Common", "Greater"
elseif ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; BCE
	set combo to 10
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Lesser", "Common", "Grand"
elseif ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; BDE
	set combo to 11
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Lesser", "Greater", "Grand"
elseif ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; CDE
	set combo to 13
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Common", "Greater", "Grand"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) ; AB
	set combo to 1
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Lesser"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) ; AC
	set combo to 4
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Common"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) ; AD
	set combo to 7
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Greater"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; AE
	set combo to 8
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Petty", "Grand"
elseif ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) ; BC
	set combo to 9
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Lesser", "Common"
elseif ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) ; BD
	set combo to 11
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Lesser", "Greater"
elseif ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; BE
	set combo to 12
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Lesser", "Grand"
elseif ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) ; CD
	set combo to 13
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Common", "Greater"
elseif ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; CE
	set combo to 14
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Common", "Grand"
elseif ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) && ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; DE
	set combo to 13
	MessageBox "Which soulgem do you want to be purified from the petty soul?", "Cancel", "Greater", "Grand"
elseif ((( Player.GetItemCount SoulGem1Petty1PettySoul ) > 0 ) || ( PettyPetty > 0 )) ; A
	set combo to 1
	MessageBox "Purify the petty soulgem from the petty soul?", "Cancel", "Yes"
elseif ((( Player.GetItemCount SoulGem2Lesser1PettySoul ) > 0 ) || ( LesserPetty > 0 )) ; B
	set combo to 9
	MessageBox "Purify the lesser soulgem from the petty soul?", "Cancel", "Yes"
elseif ((( Player.GetItemCount SoulGem3Common1PettySoul ) > 0 ) || ( CommonPetty > 0 )) ; C
	set combo to 13
	MessageBox "Purify the common soulgem from the petty soul?", "Cancel", "Yes"
elseif ((( Player.GetItemCount SoulGem4Greater1PettySoul ) > 0 ) || ( GreaterPetty > 0 )) ; D
	set combo to 15
	MessageBox "Purify the greater soulgem from the petty soul?", "Cancel", "Yes"
elseif ((( Player.GetItemCount SoulGem5Grand1PettySoul ) > 0 ) || ( GrandPetty > 0 )) ; E
	set combo to 16
	MessageBox "Purify the grand soulgem from the petty soul?", "Cancel", "Yes"
else
	playsound SPLDestructionFail
	Message "You do not have any soulgem filled with a petty soul" 5
endif
set stage to 1
End

Begin ScriptEffectUpdate
if ( stage == 1 )
	Set button to GetButtonPressed
	if ( button == 0 )
		playsound SPLDestructionFail
		set stage to 0
	elseif ( button == 1 )
		if ( combo >= 1 ) && ( combo <= 8 ) ; AXXXX, AXXX, AXX, AX, A
			set stage to 3
		elseif ( combo >= 9 ) && ( combo <= 12 ) ; BXXX, BXX, BX, B
			set stage to 4
		elseif ( combo == 13 ) || ( combo == 14 ) ; CXX, CX, C
			set stage to 5
		elseif ( combo == 15 ) ; DX, D
			set stage to 6
		elseif ( combo == 16 ) ; E
			set stage to 7
		endif
	elseif ( button == 2 )
		if ( combo >= 1 ) && ( combo <= 3 ) || ( combo == 5 ) ; XBXX, XBX, XB
			set stage to 4
		elseif ( combo == 4 ) || ( combo == 6 ) || ( combo == 9 ) || ( combo == 10 ) ; XCXX, XCX, XC
			set stage to 5
		elseif ( combo == 7 ) || ( combo == 11 ) || ( combo == 13 ); XDX, XD
			set stage to 6
		elseif ( combo == 8 ) || ( combo == 12 ) || ( combo == 14 ) || ( combo == 15 ) ; XE
			set stage to 7
		endif
	elseif ( button == 3 )
		if ( combo == 1 ) || ( combo == 2 ) ; XXCX, XXC
			set stage to 5
		elseif ( combo == 3 ) || ( combo == 4 ) || ( combo == 9 ); XXDX, XXD
			set stage to 6
		elseif ( combo >= 5 ) && ( combo <= 7 ) || ( combo == 10 ) || ( combo == 11 ) || ( combo == 13 ) ; XXE
			set stage to 7
		endif
	elseif ( button == 4 )
		if ( combo == 1 ) ; XXXD
			set stage to 6
		elseif ( combo >= 2 ) && ( combo <= 4 ) || ( combo == 10 ) || ( combo == 9 ) ; XXXE
			set stage to 7
		endif
	elseif ( button == 5 )
		;( combo == 1 ) XXXXE single case
			set stage to 7
	endif
elseif ( stage == 3 )
	if ( Player.GetItemCount SoulGem1Petty1PettySoul > 0 )
		Player.RemoveItemNS SoulGem1Petty1PettySoul 1
		Player.AddItemNS Gold001 22
	else
		ForEach iter <- Player
			if ( iter.GetBaseObject == SoulGemEmpty1Petty ) && ( iter.GetCurrentSoulLevel == 1 )
				iter.RemoveMeIR
			endif
		loop
		if ( PettyPetty > 1 )
			set PettyPetty to ( PettyPetty - 1 )
			zzSMPurifiersChestRef.AddItem SoulGemEmpty1Petty PettyPetty
			ForEach iter <- zzSMPurifiersChestRef
				if ( iter.GetBaseObject == SoulGemEmpty1Petty )
					iter.SetCurrentSoulLevel 1
					iter.RemoveMeIR Player
				endif
			loop
		endif
	endif
		Player.AddItemNS SoulGemEmpty1Petty 1
		Message "You have purified a petty soulgem from the petty soul" 5
		playsound UIItemEnchant
		set stage to 0
elseif ( stage == 4 )
	if ( Player.GetItemCount SoulGem2Lesser1PettySoul > 0 )
		Player.RemoveItemNS SoulGem2Lesser1PettySoul 1
		Player.AddItemNS Gold001 11
	else
		ForEach iter <- Player
			if ( iter.GetBaseObject == SoulGemEmpty2Lesser ) && ( iter.GetCurrentSoulLevel == 1 )
				iter.RemoveMeIR
			endif
		loop
		if ( LesserPetty > 1 )
			set LesserPetty to ( LesserPetty - 1 )
			zzSMPurifiersChestRef.AddItem SoulGemEmpty2Lesser LesserPetty
			ForEach iter <- zzSMPurifiersChestRef
				if ( iter.GetBaseObject == SoulGemEmpty2Lesser )
					iter.SetCurrentSoulLevel 1
					iter.RemoveMeIR Player
				endif
			loop
		endif
	endif
	Player.AddItemNS SoulGemEmpty2Lesser 1
	Message "You have purified a lesser soulgem from the petty soul" 5
	playsound UIItemEnchant
	set stage to 0
elseif ( stage == 5 )
	if ( Player.GetItemCount SoulGem3Common1PettySoul > 0 ) && ( Player.GetItemCount Gold001 >= 8 )
			Player.RemoveItemNS SoulGem3Common1PettySoul 1
			Player.RemoveItemNS Gold001 8
			Player.AddItemNS SoulGemEmpty3Common 1
			Message "You have purified a common soulgem from the petty soul" 5
			playsound UIItemEnchant
	elseif ( CommonPetty > 0 )
		ForEach iter <- Player
			if ( iter.GetBaseObject == SoulGemEmpty3Common ) && ( iter.GetCurrentSoulLevel == 1 )
				iter.RemoveMeIR
			endif
		loop
		if ( CommonPetty > 1 )
			set CommonPetty to ( CommonPetty - 1 )
			zzSMPurifiersChestRef.AddItem SoulGemEmpty3Common CommonPetty
			ForEach iter <- zzSMPurifiersChestRef
				if ( iter.GetBaseObject == SoulGemEmpty3Common )
					iter.SetCurrentSoulLevel 1
					iter.RemoveMeIR Player
				endif
			loop
		endif
		Player.AddItemNS SoulGemEmpty3Common 1
		Message "You have purified a common soulgem from the petty soul" 5
		playsound UIItemEnchant
	else
		Message "That action requires 8 golds compensation"
		playsound SPLDestructionFail
	endif
	set stage to 0
elseif ( stage == 6 )
	if ( Player.GetItemCount SoulGem4Greater1PettySoul > 0 ) && ( Player.GetItemCount Gold001 >= 45 )
			Player.RemoveItemNS SoulGem4Greater1PettySoul 1
			Player.AddItemNS SoulGemEmpty4Greater 1
			Player.RemoveItemNS Gold001 45
			Message "You have purified a greater soulgem from the petty soul" 5
			playsound UIItemEnchant
	elseif ( GreaterPetty > 0 )
		ForEach iter <- Player
			if ( iter.GetBaseObject == SoulGemEmpty4Greater ) && ( iter.GetCurrentSoulLevel == 1 )
				iter.RemoveMeIR
			endif
		loop
		if ( GreaterPetty > 1 )
			set GreaterPetty to ( GreaterPetty - 1 )
			zzSMPurifiersChestRef.AddItem SoulGemEmpty4Greater GreaterPetty
			ForEach iter <- zzSMPurifiersChestRef
				if ( iter.GetBaseObject == SoulGemEmpty4Greater )
					iter.SetCurrentSoulLevel 1
					iter.RemoveMeIR Player
				endif
			loop
		endif
		Player.AddItemNS SoulGemEmpty4Greater 1
		Message "You have purified a greater soulgem from the petty soul" 5
		playsound UIItemEnchant
	else
		Message "That action requires 45 golds compensation"
		playsound SPLDestructionFail
	endif
	set stage to 0
elseif ( stage == 7 )
	if ( Player.GetItemCount SoulGem5Grand1PettySoul > 0 ) && ( Player.GetItemCount Gold001 >= 120 )
			Player.RemoveItemNS SoulGem5Grand1PettySoul 1
			Player.AddItemNS SoulGemEmpty5Grand 1
			Player.RemoveItemNS Gold001 120
			Message "You have purified a grand soulgem from the petty soul" 5
			playsound UIItemEnchant
	elseif ( GrandPetty > 0 )
		ForEach iter <- Player
			if ( iter.GetBaseObject == SoulGemEmpty5Grand ) && ( iter.GetCurrentSoulLevel == 1 )
				iter.RemoveMeIR
			endif
		loop
		if ( GrandPetty > 1 )
			set GrandPetty to ( GrandPetty - 1 )
			zzSMPurifiersChestRef.AddItem SoulGemEmpty5Grand GrandPetty
			ForEach iter <- zzSMPurifiersChestRef
				if ( iter.GetBaseObject == SoulGemEmpty5Grand )
					iter.SetCurrentSoulLevel 1
					iter.RemoveMeIR Player
				endif
			loop
		endif
		Player.AddItemNS SoulGemEmpty5Grand 1
		Message "You have purified a grand soulgem from the petty soul" 5
		playsound UIItemEnchant
	else
		Message "That action requires 120 golds compensation"
		playsound SPLDestructionFail
	endif
	set stage to 0
endif
End

Begin ScriptEffectFinish
let iter := 0
End

 


When we are catching the souls, for example, the lesser souls to the stack of 5 empty soulgems, the soulgems are filling not in stacks (however, if drop/relocate them one by one - they will stack). So, I implemented a possible stacks counter in ForEach loop searching like this:
let PettyPetty := PettyPetty + iter.GetRefCount
instead of
let PettyPetty := iter.GetRefCount
cause while passing each inventory's item reference, each soulgem matching those requirements
if ( iter.GetBaseObject == SoulGemEmpty1Petty ) && ( iter.GetCurrentSoulLevel == 0 )
will be "in script's mind" and counted.

Then, let it just "manually" iterate all the cases of vanilla soulgems player possess. Priority is such foundable/buyable soulgems like SoulGem2Lesser1PettySoul ... SoulGem5Grand1PettySoul. But those soulgems are differs in the price/cost, so I implemented a compensation - plus or minus (add or remove).
You can see in code how the proccess is catching the soulgem references which are in the player's inventory. Then they are REMOVING theyselves. And meanwhile, somewhere far-far away from the player, in the player inaccessible cell, there is a container with an appropriately named (zzSMPurifiersChestRef) persisted reference. There is an empty soulgems appearing in there, just a stack, the count of which is equal to the filled with a petty soul soulgems of equal capacity, counted in the beggining of the script, minus one. Then changing the soullevel of that stack to 1 (petty). Then return it to the player. What about the empty soulgem, player is getting one just with a simple additem function.
Why it is like this? First, I tried to change the number of item's reference with a function
SetRefCount
BUT, near it's description, there is a note, that IT IS NOT WORKING (and so it is) when the item inside the container (I do not know about/did not test the case when it is inside the actor, but in my case I am using a container).

Next, you are writting about the function
GetInventoryObject
- you will Get Inventory Object ID. But you actually need to process the references of such objects like soulgems, because having equal ObjectID of an empty soulgem, filled with an appropriate souls, they will be presented in different stacks, so in different references. It is not possible to select the reference with the given ObjectID, neither to choose between references giving ObjectID... well... maybe it IS possible, but is NOT rational... For example, I have in my inventory:
3 SoulGemEmpty3Common without souls
1 SoulGemEmpty3Common with petty soul
2 SoulGemEmpty3Common with lesser soul
3 SoulGemEmpty3Common with common soul
Let's try to select the reference value giving ObjectID SoulGemEmpty3Common
let refvariable := Player.CreateTempRef SoulGemEmpty3Common
For example, for my purposes I need one with a petty soul inside of it. What will be selected with the command above? - I do not know, but I assume it will be the first met stack of SoulGemEmpty3Common objects. If that stack will be not that I am seeking for, being unaavailable to set additional requirement such as soullevel=1, then I have to relovate it to somewhere, and search from the beggining. So that's there is ForEach loop exists, where we can implement additional requirements while iterating the items in that loop proccess. And CreateTempRef is preferable for the cases when there is only one type of object inside the player/container.
HOWEVER, I tested to select
zzSMPurifiersChestRef.AddItem SoulGemEmpty1Petty PettyPetty
let iter := zzSMPurifiersChest.CreateTempRef SoulGemEmpty1Petty
iter.SetCurrentSoulLevel 1
iter.RemoveMeIR Player
- the items did not return to the player. I opened that container in the game and obtained that there is a stack of empty SoulGemEmpty1Petty, which should be filled with petty souls... and which should NOT be inside that container, they should be relocated to the player. So, once again, ForEach loop used at that stage too.

I did not use the CreateTempRef function because further I would needed to set the count of the stack, which SetRefCount function can not do cause the soulgems are inside the container. You can use it (the SetRefCount function), if you are going to do something {not related to change the count of the stack of the object inside the container}
Also, I could not use the function, for example,
RemoveItem SoulGemEmpty3Common 1
on a container I would relocated the filled SoulGemEmpty3Common soulgems, because in case if there are lot of SoulGemEmpty3Common soulgem, equal but not in the stack, once again, I would need a SetRefCount implementation to the container item.
CopyIR was also not used too - if to copy each reference of identical items to the container - they will be presented there not as a single stack of identical items but as a different stacks of one piece even if they are identical. So, I choosed to create anew a single stack of empty soulgems and fill it with the appropriate soullevel, so it will be a one reference to relocate back to the player.

Totally saying, I did not use a function in such way
SetCurrentSoulLevel 0
and the script do not make an actual "purifying" the soul level to zero :D Moreover, and contrarily, my PurifiersChest is a liar!!! It is a SoulFillerChest :D

Thought, the script is complete, I would like to have such sound and visuals when it is casts:
- case when there is no any requireable for the spell proccess soulgems, no visuals and a fail sound
- case when there is not enough money "to pay" for a transformation as a compensation, no visuals and a fail sound
- case when the spell process purify the soulgem, visuals and a success sound
I handled the sounds by adding a constant script effect (ability spell) which searches whenever player selected the certain spell and the script will change the sounds for that particular magic effect. When any of the certain spells are not selected by the player, the sounds changes back to their origins.

It is possible to script in the quest script the awaiting for the casting animation starts when those certain spells are selected by the player, then cast alternative spell with none visual effects in certain cases... But that "awaiting" should "await" with as minimum delay in the frames as possible. I know about the function which changes the frequency of script execution in frames (do not know it's name thought), but I do no want that that script will be executed hundred times in a minute, keeping itself in the game engine's memory. I think that here I just have to accept the engine limits, give up and make a spells with a standard visuals and sounds rules.
---------------------------------------------------------------------

After some tests, I finally understood that is the purpose of the function CreateTempRef! It is NOT working in the way it is selecting the item by it's ObjectID,
it is CREATING a reference from the given ObjectID SOMEWHERE in the game's temporaries. For a one frame. So now I can exclude the container "services", and rewrite the script without it's use:

elseif ( stage == 3 )
	if ( Player.GetItemCount SoulGem1Petty1PettySoul > 0 )
		Player.RemoveItemNS SoulGem1Petty1PettySoul 1
		Player.AddItemNS Gold001 22
	else
		ForEach iter <- Player
			if ( iter.GetBaseObject == SoulGemEmpty1Petty ) && ( iter.GetCurrentSoulLevel == 1 )
				iter.RemoveMeIR
			endif
		loop
		if ( PettyPetty > 1 )
			set PettyPetty to ( PettyPetty - 1 )
			let iter := CreateTempRef SoulGemEmpty1Petty
			iter.SetRefCount PettyPetty
			iter.SetCurrentSoulLevel 1
			iter.CopyIR Player
		endif
	endif
...

instead of

elseif ( stage == 3 )
	if ( Player.GetItemCount SoulGem1Petty1PettySoul > 0 )
		Player.RemoveItemNS SoulGem1Petty1PettySoul 1
		Player.AddItemNS Gold001 22
	else
		ForEach iter <- Player
			if ( iter.GetBaseObject == SoulGemEmpty1Petty ) && ( iter.GetCurrentSoulLevel == 1 )
				iter.RemoveMeIR
			endif
		loop
		if ( PettyPetty > 1 )
			set PettyPetty to ( PettyPetty - 1 )
			zzSMPurifiersChestRef.AddItem SoulGemEmpty1Petty PettyPetty
			ForEach iter <- zzSMPurifiersChestRef
				if ( iter.GetBaseObject == SoulGemEmpty1Petty )
					iter.SetCurrentSoulLevel 1
					iter.RemoveMeIR Player
				endif
			loop
		endif
	endif
...

And so, the functions SetRefCount and CopyIR are used teamwise with CreateTempRef. And looks like the function RemoveMeIR (for example, "iter.RemoveMeIR Player") can be used only for the reference removes, not for the reference relocates, in cases when it is applied to the temporarily created reference value. So many trifles undocumented for imperical understanding...
So, totally saying, I see only one way of selecting a certain item('s stack) from the player/actor/container excluding the player's interactiveness - using the function ForEach loop.

Edited by Stealth21
Link to comment
Share on other sites

Amazing conclusions and a very nice report. I will test this later as well.

Another walk around the problem is actually to just drop the soul gems on the floor, and then use Getfirstref and Getnextref and the sorting will be easy to make. I have focused to much at putting them into a container when it is the container that is the problem, not the soul gems... Well it is a Oblivion problem. :wink: By the way... I saw that there is a bug report made for RemoveMeIR at github xOBSE as I also reported a similar issue with GetNumItems

 

We must add extra checks to our variables to be sure they have any values at all...

Link to comment
Share on other sites

  • Recently Browsing   0 members

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