Jump to content

Could someone please modify this script


iron_war_lord

Recommended Posts

Please could someone modify this code to that I can attach it to a specific scroll so as to change the Magic Effect Icon to the same icon as the scroll itself. You see I have this card that I put in the game, so the card acts as a scroll, a one use magic spell basically. When the player equips the card, the Magic Effect Icon turns to the Magic Effect Enchantment I attach to the card (Scroll). What I want to happen is that if I have a script attached to the Card (Scroll), the enchantment (Or Magic Effect) Icon changes to the Card's (Scroll's) Icon.

 

I would do this myself and would like to learn scripting, but this is seriously confusing and complicated (For me)

 

scriptname SetSpellIconScript

;parameters
ref spellRef
string_var iconPath
array_var spellRefs
array_var iconPaths

long spellKey
long arrayIndex
ref ithSpellRef
long spellIndex
long iconPathsIndex
array_var nullArray	;could use ar_Null but this is easier to work with

array_var spells
array_var iconData
short doOnce

string_var spellName

begin OnActivate

if (doOnce == 0)
let spells := ar_Construct Map
let iconData := ar_Construct Map
let nullArray := ar_Null
let spellRefs := ar_Null
let iconPaths := ar_Null
set doOnce to 1
endif

if ((iconPath != 0) && (iconPaths == nullArray))
if (spellRef != 0)
	let spellKey := (ar_Find spellRef spells)
	if (spellKey == ar_BadNumericIndex)
		let spells[spellIndex] := spellRef
		set spellKey to spellIndex
		set spellIndex to (spellIndex + 1)
	endif
	let iconData[spellKey] := $iconPath
	let spellName := (GetName spellRef)
	sv_Replace " |_" spellName
	SetMenuStringValue "magic_background\magic_window\magic_pane\magic_list_contents\%z\magic_item_icon\filename|Icons\%z" spellName, iconPath 1022
endif

if (spellRefs != nullArray)
	let arrayIndex := (ar_First spellRefs)
	while (arrayIndex != ar_BadNumericIndex)
		let ithSpellRef := spellRefs[arrayIndex]
		let spellKey := (ar_Find ithSpellRef spells)
		if (spellKey == ar_BadNumericIndex)
			let spells[spellIndex] := ithSpellRef
			set spellKey to spellIndex
			set spellIndex to (spellIndex + 1)
		endif
		let iconData[spellKey] := $iconPath
		let spellName := (GetName ithSpellRef)
		sv_Replace " |_" spellName
		SetMenuStringValue "magic_background\magic_window\magic_pane\magic_list_contents\%z\magic_item_icon\filename|Icons\%z" spellName, iconPath 1022
		let arrayIndex := (ar_Next spellRefs arrayIndex)
	loop
endif
elseif ((iconPaths != nullArray) && (spellRefs != nullArray))
let arrayIndex := (ar_First spellRefs)
let iconPathsIndex := (ar_First iconPaths)
while ((arrayIndex != ar_BadNumericIndex) && (iconPathsIndex != ar_BadNumericIndex))
	let ithSpellRef := spellRefs[arrayIndex]
	let spellKey := (ar_Find ithSpellRef spells)
	if (spellKey == ar_BadNumericIndex)
		let spells[spellIndex] := ithSpellRef
		set spellKey to spellIndex
		set spellIndex to (spellIndex + 1)
	endif
	let iconData[spellKey] := iconPaths[iconPathsIndex]
	let iconPath := iconPaths[iconPathsIndex]
	let spellName := (GetName ithSpellRef)
	sv_Replace " |_" spellName
	SetMenuStringValue "magic_background\magic_window\magic_pane\magic_list_contents\%z\magic_item_icon\filename|Icons\%z" spellName, iconPath 1022
	let iconPathsIndex := (ar_Next iconPaths iconPathsIndex)
	let arrayIndex := (ar_Next spellRefs arrayIndex)
loop
endif

set spellRef to 0
set iconPath to 0
let spellRefs := ar_Null
let iconPaths := ar_Null
set CustomSpellIcons.refresh to 1

end

 

All the credit goes to statttis for this script.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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