Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname AVN11_ESOSet extends ObjectReference
- ;/
- Imitation of The Elder Scrolls Online's item set gameplay concept
- For The Elder Scrolls V: Skyrim and The Elder Scrolls V: Skyrim Special Edition
- By Arvyn
- Haphazard description:
- 1. Checks whether or not there is a set minimum for equipped item count in order for bonuses to be granted (greater than 0)(minimum-1 due to zero-based indexing).
- Otherwise, set minimum to one item (as set instance count = -1 due to zero-based indexing).
- 2. Checks for set's items equipped by the Actor. Add 1 to set instance count for every detected set item.
- 3. Checks whether each of said set's items is a "Twohander" (weapon equipped with both hands). Add 1 to set instance count for every detected Twohander set's item.
- if OnEquipped:
- 4. Add bonuses according to the amount of set instance count, from a FormList, starting from 0 to greater as long as it is lower than or equal to set instance count.
- A check for already-added bonuses is not implemented in the interest of performance, and duplicates are not granted by default to begin with.
- if OnUnequipped:
- 5. Remove bonuses according to the amount of set instance count after the item has been unequipped, by checking set the instance count against the bonuses' FormList,
- from the length of the bonuses' FormList to lesser, as long as the length is greater than set instance count.
- /;
- FormList Property Effects auto
- FormList Property Set auto
- GlobalVariable Property MinimumItemCount auto
- Keyword Property WeapTypeBattleAxe auto
- Keyword Property WeapTypeBow auto
- Keyword Property WeapTypeGreatsword auto
- Keyword Property WeapTypeWarhammer auto
- Event OnEquipped(Actor akActor)
- int iMinimumItemCount = MinimumItemCount.GetValueInt()
- int iSetInstance = -1
- if (iMinimumItemCount > 0)
- iSetInstance = iSetInstance - (iMinimumItemCount - 1)
- endif
- int iIndex = 0
- While (iIndex < Set.GetSize())
- if (HasSetPresence(akActor, iIndex, Set) == TRUE)
- iSetInstance+=1
- if (IsWeapTypeTwohander(Set.GetAt(iIndex) as Weapon) == TRUE)
- iSetInstance+=1
- endif
- endif
- iIndex+=1
- endWhile
- iIndex = 0
- While (iIndex <= iSetInstance)
- AddOrRemoveBonus(akActor, iIndex, Effects, TRUE)
- iIndex+=1
- endWhile
- endEvent
- Event OnUnequipped(Actor akActor)
- int iMinimumItemCount = MinimumItemCount.GetValueInt()
- int iSetInstance = -1
- if (iMinimumItemCount > 0)
- iSetInstance = iSetInstance - (iMinimumItemCount - 1)
- endif
- int iIndex = 0
- While (iIndex < Set.GetSize())
- if (HasSetPresence(akActor, iIndex, Set) == TRUE)
- iSetInstance+=1
- if (IsWeapTypeTwohander(Set.GetAt(iIndex) as Weapon) == TRUE)
- iSetInstance+=1
- endif
- endif
- iIndex+=1
- endWhile
- iIndex = Effects.GetSize()
- iIndex-=1
- While (iIndex > iSetInstance)
- AddOrRemoveBonus(akActor, iIndex, Effects, FALSE)
- iIndex-=1
- endWhile
- endEvent
- bool Function HasSetPresence(Actor akActor, Int aiIndex, FormList akSetFormList)
- if ( (akActor.GetEquippedWeapon(TRUE) == akSetFormList.GetAt(aiIndex)) \
- || (akActor.IsEquipped(akSetFormList.GetAt(aiIndex) as Form)) ) ;valid only for the right hand
- return TRUE
- else
- return FALSE
- endif
- endFunction
- bool Function IsWeapTypeTwohander(Weapon akWeap)
- if ( (akWeap.HasKeyword(WeapTypeBattleAxe)) \
- || (akWeap.HasKeyword(WeapTypeBow)) \
- || (akWeap.HasKeyword(WeapTypeGreatsword)) \
- || (akWeap.HasKeyword(WeapTypeWarhammer)) )
- return TRUE
- else
- return FALSE
- endif
- endFunction
- Function AddOrRemoveBonus(Actor akActor, Int aiIndex, FormList akEffectFormList, Bool bAdd)
- FormList FLwithinFL = (akEffectFormList.GetAt(aiIndex)) as FormList
- if (bAdd == TRUE)
- if ((FLwithinFL as FormList) == TRUE)
- int iIndex = 0
- While (iIndex < FLwithinFL.GetSize())
- akActor.AddSpell(FLwithinFL.GetAt(iIndex) as Spell, FALSE)
- iIndex+=1
- endWhile
- return
- else
- akActor.AddSpell(akEffectFormList.GetAt(aiIndex) as Spell, FALSE)
- return
- endif
- elseif (bAdd == FALSE)
- if ((FLwithinFL as FormList) == TRUE)
- int iIndex = FLwithinFL.GetSize()
- While (iIndex >= 0)
- akActor.RemoveSpell(FLwithinFL.GetAt(iIndex) as Spell)
- iIndex-=1
- endWhile
- return
- else
- akActor.RemoveSpell(akEffectFormList.GetAt(aiIndex) as Spell)
- return
- endif
- endif
- endFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement