Remade ToArray() formlist loops to vanilla

This commit is contained in:
Eddoursul 2024-02-08 04:01:22 +01:00
parent 90a5a2868e
commit 810ded0020
20 changed files with 102 additions and 59 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -17,10 +17,10 @@ EndFunction
Function RemoveCombatSoundtracks() Function RemoveCombatSoundtracks()
int nItems = _00E_MUS_AllCombatSoundtracks.GetSize()
Int iIndex = 0 Int iIndex = 0
Form[] tracks = _00E_MUS_AllCombatSoundtracks.ToArray() While iIndex < nItems
While iIndex < tracks.Length (_00E_MUS_AllCombatSoundtracks.GetAt(iIndex) as MusicType).Remove()
(tracks[iIndex] as MusicType).Remove()
iIndex += 1 iIndex += 1
EndWhile EndWhile

View File

@ -119,9 +119,9 @@ Function VisionEffectNoTimestop(Formlist RefsInvolved, Formlist ActorsToFreeze =
if RefsInvolved != None if RefsInvolved != None
Int iIndex = 0 Int iIndex = 0
Form[] actors = RefsInvolved.ToArray() int nItems = RefsInvolved.GetSize()
While iIndex < actors.Length While iIndex < nItems
Actor VisionREF = actors[iIndex] as Actor Actor VisionREF = RefsInvolved.GetAt(iIndex) as Actor
if VisionREF.IsDisabled() if VisionREF.IsDisabled()
VisionREF.EnableNoWait() VisionREF.EnableNoWait()
EndIf EndIf
@ -165,10 +165,10 @@ Function VisionEffectNoTimestopStop(Formlist RefsInvolved, Formlist ActorsToFree
EndIf EndIf
if RefsInvolved != None if RefsInvolved != None
int nItems = RefsInvolved.GetSize()
Int iIndex = 0 Int iIndex = 0
Form[] actors = RefsInvolved.ToArray() While iIndex < nItems
While iIndex < actors.Length Actor VisionREF = RefsInvolved.GetAt(iIndex) as Actor
Actor VisionREF = actors[iIndex] as Actor
MS04MemoryFXBody01VFX.Stop(VisionREF) MS04MemoryFXBody01VFX.Stop(VisionREF)
VisionRef.SetAlpha(1) VisionRef.SetAlpha(1)
iIndex += 1 iIndex += 1

View File

@ -26,7 +26,7 @@ Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldCo
If akNewContainer == PlayerREF If akNewContainer == PlayerREF
; Take All, no need to check for equipped items ; Take All, no need to check for equipped items
If UI.IsMenuOpen("ContainerMenu") == False If SKSE.GetVersion() > 0 && UI.IsMenuOpen("ContainerMenu") == False
return return
EndIf EndIf
@ -43,9 +43,31 @@ EndEvent
Function UpdateSpells() Function UpdateSpells()
Int iIndex = 0 bool bSKSE = (SKSE.GetVersion() > 0)
Int iIndex
Int nEquippedPieces = 0 Int nEquippedPieces = 0
Form[] setPieces = __Config_SetList.ToArray() Form[] setPieces
if bSKSE
setPieces = __Config_SetList.ToArray()
else
int nPieces = __Config_SetList.GetSize()
if nPieces == 4
setPieces = new Form[4]
elseif nPieces == 5
setPieces = new Form[5]
else
setPieces = new Form[6]
endif
iIndex = 0
while iIndex < nPieces
setPieces[iIndex] = __Config_SetList.GetAt(iIndex)
iIndex += 1
endwhile
endif
iIndex = 0
While iIndex < setPieces.Length While iIndex < setPieces.Length
If PlayerREF.IsEquipped(setPieces[iIndex] as Armor) If PlayerREF.IsEquipped(setPieces[iIndex] as Armor)
nEquippedPieces += 1 nEquippedPieces += 1
@ -59,8 +81,26 @@ Function UpdateSpells()
Int nBonusSpells = nEquippedPieces - 1 Int nBonusSpells = nEquippedPieces - 1
Bool bSpellRemoved = False Bool bSpellRemoved = False
Bool bSpellAdded = False Bool bSpellAdded = False
Form[] bonusSpells
if bSKSE
bonusSpells = __Config_SetBonusesList.ToArray()
else
int nSpells = __Config_SetBonusesList.GetSize()
if nSpells == 4
bonusSpells = new Form[4]
elseif nSpells == 5
bonusSpells = new Form[5]
else
bonusSpells = new Form[6]
endif
iIndex = 0
while iIndex < nSpells
bonusSpells[iIndex] = __Config_SetBonusesList.GetAt(iIndex)
iIndex += 1
endwhile
endif
Form[] bonusSpells = __Config_SetBonusesList.ToArray()
iIndex = 0 iIndex = 0
While iIndex < bonusSpells.Length While iIndex < bonusSpells.Length
Spell bonusSpell = bonusSpells[iIndex] as Spell Spell bonusSpell = bonusSpells[iIndex] as Spell

View File

@ -3,12 +3,12 @@ Scriptname _00E_Func_GetPointsInClass Hidden
int Function Run(Formlist akClassPerkformlist) Global int Function Run(Formlist akClassPerkformlist) Global
Actor PlayerREF = Game.GetForm(0x14) as Actor Actor PlayerREF = Game.GetForm(0x14) as Actor
Form[] perkForms = akClassPerkformlist.ToArray()
int PointsSpentInClass int PointsSpentInClass
int iClassIndex = 0 int iClassIndex = 0
While iClassIndex < perkForms.Length int nItems = akClassPerkformlist.GetSize()
Perk iPerk = perkForms[iClassIndex] as Perk While iClassIndex < nItems
Perk iPerk = akClassPerkformlist.GetAt(iClassIndex) as Perk
If iPerk && PlayerREF.HasPerk(iPerk) If iPerk && PlayerREF.HasPerk(iPerk)
PointsSpentInClass += 1 PointsSpentInClass += 1
EndIf EndIf

View File

@ -20,6 +20,10 @@ Float Property IdleUpdatePeriod = 30.0 AutoReadOnly
Event OnEffectStart(Actor akTarget, Actor akCaster) Event OnEffectStart(Actor akTarget, Actor akCaster)
if SKSE.GetVersion() == 0
return
endif
LockEquipUpdates() LockEquipUpdates()
CooldownShouts = New Shout[128] CooldownShouts = New Shout[128]

View File

@ -431,10 +431,10 @@ Function StartCer()
MQ06_SC05_JorekBench.SetFactionOwner(MQ06_SC05_JorekBenchFaction) MQ06_SC05_JorekBench.SetFactionOwner(MQ06_SC05_JorekBenchFaction)
Form[] idleMarkers = MQ06_SC05_IdleMarkerList.ToArray() int nItems = MQ06_SC05_IdleMarkerList.GetSize()
Int iIndex = 0 Int iIndex = 0
While iIndex < idleMarkers.Length While iIndex < nItems
(idleMarkers[iIndex] as ObjectReference).Disable() (MQ06_SC05_IdleMarkerList.GetAt(iIndex) as ObjectReference).Disable()
iIndex += 1 iIndex += 1
EndWhile EndWhile
@ -508,11 +508,11 @@ EndFunction
Function FillSpectators() Function FillSpectators()
Form[] spectators = MQ06_SC05_RitualList.ToArray() int nItems = MQ06_SC05_RitualList.GetSize()
Int iIndex = 0 Int iIndex = 0
While iIndex < spectators.Length While iIndex < nItems
Actor akSpectator = (spectators[iIndex] as Actor) Actor akSpectator = (MQ06_SC05_RitualList.GetAt(iIndex) as Actor)
If akSpectator.IsDead() == False If ! akSpectator.IsDead()
akSpectator.MoveTo(CaliaRitualMarker) akSpectator.MoveTo(CaliaRitualMarker)
SC05_SpectatorArray[iIndex].ForceRefTo(akSpectator) SC05_SpectatorArray[iIndex].ForceRefTo(akSpectator)
EndIf EndIf
@ -542,10 +542,10 @@ Function UnfillSpectators()
MQ06_SC05_JorekBench.SetFactionOwner(None) MQ06_SC05_JorekBench.SetFactionOwner(None)
Form[] idleMarkers = MQ06_SC05_IdleMarkerList.ToArray() int nItems = MQ06_SC05_IdleMarkerList.GetSize()
iIndex = 0 iIndex = 0
While iIndex < idleMarkers.Length While iIndex < nItems
(idleMarkers[iIndex] as ObjectReference).Enable() (MQ06_SC05_IdleMarkerList.GetAt(iIndex) as ObjectReference).Enable()
iIndex += 1 iIndex += 1
EndWhile EndWhile

View File

@ -477,14 +477,14 @@ EndFunction
Function EnableEnemiesInFormlist(Formlist formlistToProcess, GlobalVariable counterGlobal) Function EnableEnemiesInFormlist(Formlist formlistToProcess, GlobalVariable counterGlobal)
Int Index Int Index
Form[] enemies = formlistToProcess.ToArray() int nItems = formlistToProcess.GetSize()
counterGlobal.SetValueInt(enemies.Length) counterGlobal.SetValueInt(nItems)
bDoneBattleFailsave = True bDoneBattleFailsave = True
Index = 0 Index = 0
While Index < enemies.Length While Index < nItems
Actor enemyRef = (enemies[Index] as Actor) Actor enemyRef = (formlistToProcess.GetAt(Index) as Actor)
enemyRef.Enable() enemyRef.Enable()
enemyRef.SetAlpha(0.0) enemyRef.SetAlpha(0.0)
Index += 1 Index += 1
@ -494,7 +494,7 @@ Function EnableEnemiesInFormlist(Formlist formlistToProcess, GlobalVariable coun
Utility.Wait(1) Utility.Wait(1)
MQ07a_EnemiesLeft.SetValueInt(enemies.Length) MQ07a_EnemiesLeft.SetValueInt(nItems)
UpdateCurrentInstanceGlobal(MQ07a_EnemiesLeft) UpdateCurrentInstanceGlobal(MQ07a_EnemiesLeft)
If MQ07a_CurrentWave.GetValueInt() == 1 If MQ07a_CurrentWave.GetValueInt() == 1
@ -768,11 +768,11 @@ Function EnableSigilStone()
MQ07a_SC14_SigilstoneFX.EnableNoWait() MQ07a_SC14_SigilstoneFX.EnableNoWait()
MQ07a_SC14_SigilStoneLight2.EnableNoWait() MQ07a_SC14_SigilStoneLight2.EnableNoWait()
Form[] refsToDisable = MQ07a_SC14_FurnitureToDisable.ToArray()
ActorBase dummyOwner = PlayerREF.GetActorBase() ActorBase dummyOwner = PlayerREF.GetActorBase()
int nItems = MQ07a_SC14_FurnitureToDisable.GetSize()
Int Index = 0 Int Index = 0
While Index < refsToDisable.Length While Index < nItems
(refsToDisable[Index] as ObjectReference).SetActorOwner(dummyOwner) (MQ07a_SC14_FurnitureToDisable.GetAt(Index) as ObjectReference).SetActorOwner(dummyOwner)
Index += 1 Index += 1
EndWhile EndWhile
@ -813,10 +813,10 @@ EndFunction
Function EndSC14() Function EndSC14()
Form[] refsToDisable = MQ07a_SC14_FurnitureToDisable.ToArray() int nItems = MQ07a_SC14_FurnitureToDisable.GetSize()
Int Index = 0 Int Index = 0
While Index < refsToDisable.Length While Index < nItems
(refsToDisable[Index] as ObjectReference).SetActorOwner(None) (MQ07a_SC14_FurnitureToDisable.GetAt(Index) as ObjectReference).SetActorOwner(None)
Index += 1 Index += 1
EndWhile EndWhile

View File

@ -191,12 +191,11 @@ EndFunction
Function DisableWolfPack() ; Disable Wolf pack if still alive, to make sure they don't interrupt the scene Function DisableWolfPack() ; Disable Wolf pack if still alive, to make sure they don't interrupt the scene
Form[] wolfRefs = MQ11a_SC6_WolfPackGates.ToArray() Int iIndex = MQ11a_SC6_WolfPackGates.GetSize()
Int iIndex = wolfRefs.Length
While iIndex > 0 While iIndex > 0
iIndex -= 1 iIndex -= 1
Actor WolfToDisable = wolfRefs[iIndex] as Actor Actor WolfToDisable = MQ11a_SC6_WolfPackGates.GetAt(iIndex) as Actor
If WolfToDisable.IsDead() == False If ! WolfToDisable.IsDead()
WolfToDisable.DisableNoWait() WolfToDisable.DisableNoWait()
EndIf EndIf
EndWhile EndWhile
@ -1620,10 +1619,10 @@ Function StartTrackingFight(Int fightId, Int postFightQuestStage, FormList enemy
EndFunction EndFunction
Function RaiseDeadServants(Formlist corpseList, ObjectReference corpseActivatorRef) Function RaiseDeadServants(Formlist corpseList, ObjectReference corpseActivatorRef)
Form[] corpses = corpseList.ToArray() int nItems = corpseList.GetSize()
Int Index = 0 Int Index = 0
While Index < corpses.Length While Index < nItems
(corpses[Index] as ObjectReference).Activate(corpseActivatorRef) (corpseList.GetAt(Index) as ObjectReference).Activate(corpseActivatorRef)
index += 1 index += 1
EndWhile EndWhile
EndFunction EndFunction
@ -1652,18 +1651,18 @@ Function RegisterFightEnd(Int fightId, Int postFightQuestStage)
EndFunction EndFunction
Function GiveKeyToEnemies(FormList enemyList, Key keyToGive) Function GiveKeyToEnemies(FormList enemyList, Key keyToGive)
Form[] enemies = enemyList.ToArray() int nItems = enemyList.GetSize()
Int Index Int Index
Index = 0 Index = 0
While Index < enemies.Length While Index < nItems
(enemies[Index] as ObjectReference).AddItem(keyToGive) (enemyList.GetAt(Index) as ObjectReference).AddItem(keyToGive)
Index += 1 Index += 1
EndWhile EndWhile
Index = 0 Index = 0
While Index < enemies.Length While Index < nItems
_00E_Questshader.Play(enemies[Index] as ObjectReference) _00E_Questshader.Play(enemyList.GetAt(Index) as ObjectReference)
Index += 1 Index += 1
EndWhile EndWhile
EndFunction EndFunction

View File

@ -42,11 +42,11 @@ Function PostFightCleanup()
If EnemyList If EnemyList
; Kill'em all as a safeguard! ; Kill'em all as a safeguard!
Form[] enemies = EnemyList.ToArray() int nItems = EnemyList.GetSize()
Int Index = 0 Int Index = 0
While Index < enemies.Length While Index < nItems
Actor enemyRef = (enemies[Index] as Actor) Actor enemyRef = (EnemyList.GetAt(Index) as Actor)
If enemyRef.IsDead() == False If ! enemyRef.IsDead()
enemyRef.Kill(enemyRef) ; "Suicide" -> no XP for the player, hehe enemyRef.Kill(enemyRef) ; "Suicide" -> no XP for the player, hehe
EndIf EndIf
Index += 1 Index += 1
@ -57,10 +57,10 @@ Function PostFightCleanup()
EndFunction EndFunction
Bool Function CheckEnemiesAreDead() Bool Function CheckEnemiesAreDead()
Form[] enemies = EnemyList.ToArray() int nItems = EnemyList.GetSize()
Int Index = 0 Int Index = 0
While Index < enemies.Length While Index < nItems
If (enemies[Index] as Actor).IsDead() == False If (EnemyList.GetAt(Index) as Actor).IsDead() == False
Return False Return False
EndIf EndIf
Index += 1 Index += 1

View File

@ -255,10 +255,10 @@ Function EnterCombat()
MQ13c_SC04_SpiderParent.Enable() MQ13c_SC04_SpiderParent.Enable()
; Activate all spiders to get them released into the room ; Activate all spiders to get them released into the room
Form[] enemies = MQ13c_Nexushall_Spiders.ToArray() int nItems = MQ13c_Nexushall_Spiders.GetSize()
Int index = 0 Int index = 0
While index < enemies.Length While index < nItems
Actor enemy = enemies[index] as Actor Actor enemy = MQ13c_Nexushall_Spiders.GetAt(index) as Actor
if enemy != MQ13c_SC04_CenturionREF if enemy != MQ13c_SC04_CenturionREF
enemy.Activate(akCompanionRomance) enemy.Activate(akCompanionRomance)
EndIf EndIf