Complete Example Scripts: Difference between revisions

Jump to navigation Jump to search
m
→‎Usage of Arrays to Make Scripts Compact: GetPlayer swapped with PlayerREF | rDraugr Δ kDraugr
imported>JustinOther
m (→‎Set Quest Stage When Picked Up By Player: GetPlayer swapped with PlayerREF | Prefixed Int property name)
imported>JustinOther
m (→‎Usage of Arrays to Make Scripts Compact: GetPlayer swapped with PlayerREF | rDraugr Δ kDraugr)
Line 277: Line 277:
* turn their AI off and make them invisible
* turn their AI off and make them invisible
I have different conditions within my level for when each of these two actions should occur. I could divide this into two scripts, but instead I wrote one script and passed a property to the script with each instance of the script to determine which aspect of the script would run.
I have different conditions within my level for when each of these two actions should occur. I could divide this into two scripts, but instead I wrote one script and passed a property to the script with each instance of the script to determine which aspect of the script would run.
<source lang="papyrus">Actor[] Property DraugrArray Auto ; Contains 30 elements filled in CK with the 30 Draugr
<source lang="papyrus">
Actor Property PlayerREF Auto
Actor[] Property DraugrArray Auto ; Contains 30 elements filled in CK with the 30 Draugr
Bool Property bEnableBeasts Auto ; Can be set from another script and/or initialized true or false
Bool Property bEnableBeasts Auto ; Can be set from another script and/or initialized true or false


Event OnTriggerEnter(ObjectReference akActionRef)
Event OnTriggerEnter(ObjectReference akActionRef)
If akActionRef == Game.GetPlayer()
If akActionRef == PlayerREF
Int iIndex = DraugrArray.Length ; Will return 30
Int iIndex = DraugrArray.Length ; Will return 30
While iIndex > 0
While iIndex > 0
iIndex -= 1 ; 29'th element is 30'th Draugr
iIndex -= 1 ; 29'th element is 30'th Draugr
Actor rDraugr = DraugrArray[iIndex]
Actor kDraugr = DraugrArray[iIndex]
rDraugr.EnableAI(bEnableBeasts)
kDraugr.EnableAI(bEnableBeasts)
rDraugr.SetAlpha(bEnableBeasts As Float)
kDraugr.SetAlpha(bEnableBeasts As Float)
EndWhile
EndWhile
EndIf
EndIf
Anonymous user

Navigation menu