Advertisement
Arvyn

AVN11_ESOSet

Jul 8th, 2019
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. Scriptname AVN11_ESOSet extends ObjectReference
  2.  
  3. ;/
  4. Imitation of The Elder Scrolls Online's item set gameplay concept
  5. For The Elder Scrolls V: Skyrim and The Elder Scrolls V: Skyrim Special Edition
  6. By Arvyn
  7. Haphazard description:
  8. 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).
  9. Otherwise, set minimum to one item (as set instance count = -1 due to zero-based indexing).
  10. 2. Checks for set's items equipped by the Actor. Add 1 to set instance count for every detected set item.
  11. 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.
  12. if OnEquipped:
  13. 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.
  14. A check for already-added bonuses is not implemented in the interest of performance, and duplicates are not granted by default to begin with.
  15. if OnUnequipped:
  16. 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,
  17. from the length of the bonuses' FormList to lesser, as long as the length is greater than set instance count.
  18. /;
  19.  
  20. FormList Property Effects auto
  21. FormList Property Set auto
  22.  
  23. GlobalVariable Property MinimumItemCount auto
  24.  
  25. Keyword Property WeapTypeBattleAxe auto
  26. Keyword Property WeapTypeBow auto
  27. Keyword Property WeapTypeGreatsword auto
  28. Keyword Property WeapTypeWarhammer auto
  29.  
  30.  
  31. Event OnEquipped(Actor akActor)
  32. int iMinimumItemCount = MinimumItemCount.GetValueInt()
  33. int iSetInstance = -1
  34. if (iMinimumItemCount > 0)
  35. iSetInstance = iSetInstance - (iMinimumItemCount - 1)
  36. endif
  37.  
  38. int iIndex = 0
  39. While (iIndex < Set.GetSize())
  40. if (HasSetPresence(akActor, iIndex, Set) == TRUE)
  41. iSetInstance+=1
  42. if (IsWeapTypeTwohander(Set.GetAt(iIndex) as Weapon) == TRUE)
  43. iSetInstance+=1
  44. endif
  45. endif
  46. iIndex+=1
  47. endWhile
  48.  
  49. iIndex = 0
  50. While (iIndex <= iSetInstance)
  51. AddOrRemoveBonus(akActor, iIndex, Effects, TRUE)
  52. iIndex+=1
  53. endWhile
  54. endEvent
  55.  
  56. Event OnUnequipped(Actor akActor)
  57. int iMinimumItemCount = MinimumItemCount.GetValueInt()
  58. int iSetInstance = -1
  59. if (iMinimumItemCount > 0)
  60. iSetInstance = iSetInstance - (iMinimumItemCount - 1)
  61. endif
  62.  
  63. int iIndex = 0
  64. While (iIndex < Set.GetSize())
  65. if (HasSetPresence(akActor, iIndex, Set) == TRUE)
  66. iSetInstance+=1
  67. if (IsWeapTypeTwohander(Set.GetAt(iIndex) as Weapon) == TRUE)
  68. iSetInstance+=1
  69. endif
  70. endif
  71. iIndex+=1
  72. endWhile
  73.  
  74. iIndex = Effects.GetSize()
  75. iIndex-=1
  76. While (iIndex > iSetInstance)
  77. AddOrRemoveBonus(akActor, iIndex, Effects, FALSE)
  78. iIndex-=1
  79. endWhile
  80. endEvent
  81.  
  82.  
  83. bool Function HasSetPresence(Actor akActor, Int aiIndex, FormList akSetFormList)
  84. if ( (akActor.GetEquippedWeapon(TRUE) == akSetFormList.GetAt(aiIndex)) \
  85. || (akActor.IsEquipped(akSetFormList.GetAt(aiIndex) as Form)) ) ;valid only for the right hand
  86. return TRUE
  87. else
  88. return FALSE
  89. endif
  90. endFunction
  91.  
  92. bool Function IsWeapTypeTwohander(Weapon akWeap)
  93. if ( (akWeap.HasKeyword(WeapTypeBattleAxe)) \
  94. || (akWeap.HasKeyword(WeapTypeBow)) \
  95. || (akWeap.HasKeyword(WeapTypeGreatsword)) \
  96. || (akWeap.HasKeyword(WeapTypeWarhammer)) )
  97. return TRUE
  98. else
  99. return FALSE
  100. endif
  101. endFunction
  102.  
  103. Function AddOrRemoveBonus(Actor akActor, Int aiIndex, FormList akEffectFormList, Bool bAdd)
  104. FormList FLwithinFL = (akEffectFormList.GetAt(aiIndex)) as FormList
  105. if (bAdd == TRUE)
  106. if ((FLwithinFL as FormList) == TRUE)
  107. int iIndex = 0
  108. While (iIndex < FLwithinFL.GetSize())
  109. akActor.AddSpell(FLwithinFL.GetAt(iIndex) as Spell, FALSE)
  110. iIndex+=1
  111. endWhile
  112. return
  113. else
  114. akActor.AddSpell(akEffectFormList.GetAt(aiIndex) as Spell, FALSE)
  115. return
  116. endif
  117. elseif (bAdd == FALSE)
  118. if ((FLwithinFL as FormList) == TRUE)
  119. int iIndex = FLwithinFL.GetSize()
  120. While (iIndex >= 0)
  121. akActor.RemoveSpell(FLwithinFL.GetAt(iIndex) as Spell)
  122. iIndex-=1
  123. endWhile
  124. return
  125. else
  126. akActor.RemoveSpell(akEffectFormList.GetAt(aiIndex) as Spell)
  127. return
  128. endif
  129. endif
  130. endFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement