From 540143797690b16d3f7b71649f394ec91dfeb854 Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Sun, 21 Jan 2024 05:41:41 +0100 Subject: [PATCH] Optimized FXBirdFleeSCRIPT --- scripts/fxbirdfleescript.pex | Bin 1475 -> 1747 bytes source/scripts/fxbirdfleescript.psc | 55 ++++++++++++++++++---------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/scripts/fxbirdfleescript.pex b/scripts/fxbirdfleescript.pex index 3f1d98528323e018487c1c2cf295cd493972c46f..2c47a14be6edcfabe478f7bc76165c0078f30c38 100644 GIT binary patch literal 1747 zcmZ`&T~pge6g_JT{28ENLP8p%q%E{1p*Dm7dT0j%WIU588JsqK>nPINsECzET9@*p z`XBlu`rIGVr=DF|2FgT>(Y<%?J?GrJtA9WI^-sA30Y382RfX2^F9%T?9>-GlUY~Z~ zz26vS0qRF#n2geF6uX#_g}reZDHk5*`hR?6O`kPckVZpIu<9GBd)n6$wKs`Qaqj{oU%Q)WG+7Hf9JyAamLsMV*z@kVEFq5eFX*3wf^hjx$ zqBizqi0QK^45dONNL0w|MENmhPd@%81AQv{GLHuVgyWVr!g(B#F_CRHl70cMscbl)Fk} zW6dudsDtMlj7sIv@Xp9aVGb=QEIvIAy!$!kD-?we@T@R%4Ycrp%9>LX@8WvIL)@J!$fdUh<7`B=bZ^vfGjN-dFK zCD&k3@@m1nudefi^Ml!|-b^fGl?|`46+`FD2&}Szbzck23#=Jd!61nj>2jld1F*!g zH%N91@>==rROca&PT-qyFGO85sQGc%h*G~6Ch#p~Re3@!dqx}h4sHHA^o`I>?ru@^ zd|hB&V1c^%TBpQygIA;foEUs{Xx-<_gr}(BrNFkphV9GzYcZ$I)LENKYa=h}@I}ZD zYb|8uPU{UuUfE$-a8bezYc?n2n-kcwGz>EJ&Ox;7CNG)b#kg^HCEMXHJDs}2InBtP R<=i#ZpgL=qd-4f_{{Y2SJ~99R literal 1475 zcmZuwYf}?T5IvIzArJ^Cpx|rpg&<(!<5t~#xK>b5s#L6mQomX2W|FKdGpXIlrTBOE zm-s{cg<0!+#ba~ zCc55nY&5Fv&f(kl2M3)do@4I!RANlNQMPM6t5AJotVzw9(XUh(wypL2Au6A}zy^AN zS)&i5U@%b8uC^+|#4zafl*Y7gbdM=Udm-uv-@Yr~c2r+QO8W{cSxqdzk!LKek^S&g zdMDl~7Fw;8yz!5^W~_T(|Meo2V`rik=-7IM*nizc8anh1V*>R*P!%#_o98n`HIVKOF(rTshmp&M+@b~4q z_$07o!-+@A5Bh=XWk{1+oup9JR?C5XqN-Cy@9JLGAy#1@JmwuW2y_}_ zd#jE|4adV7O;pA<2m^bHlDh#YIfYQ|nGc2>IN7v!)J`VjVdqs(QBL&9{b#xH993>m zh6~9r^3A_49d;9?fp_d~q_XL$V8;Eob#UxC2u$T}qlsGAn$doCRr2p*2_;@`fr9%^ zoKegT#>-g1VzQPPEn@<7ZgJiIm; zrbZoe&L{)(`CbuMXeLxEthjpa%#+z1$?&P5PSTEe0ZX{%Lg^z`1g6 z$x!i{z%7B>^pc5Zm@9CD(K{ESB)XjTcL>F#QgV(}k}fX`+!eT&A&AmTrpyXR))VHw zz_h@s0~ZVupTAXZ6wmQRf#W`4Mwv|}&RYpQWRpp(;Stt3=LX-$v>owH?rgFBHs3|I zTVpbjAJd|@E>K_MpKI#~J`reeCmAtKUaKcr=lSbt+4^EuR%F5kVaje8;%(%3)&G%y qz(_M0XCs-jfTyh4JQHAEU@H?~lN`6{{z){(Y68!4A*s|tQuPZ)>>Gyw diff --git a/source/scripts/fxbirdfleescript.psc b/source/scripts/fxbirdfleescript.psc index 4a5bf78b..c4842533 100644 --- a/source/scripts/fxbirdfleescript.psc +++ b/source/scripts/fxbirdfleescript.psc @@ -1,10 +1,7 @@ Scriptname FXBirdFleeSCRIPT extends ObjectReference {Triggers birds to fly away} -import debug ; import debug.psc for acces to trace() -import game ; game.psc for access to getPlayer() -import utility ; utility.psc for access to wait() -import sound ; sound.psc for access to play() +; Eddoursul 2024.01.21: Use states and updates, added OnReset sound property BirdFlockSound auto sound property BirdFlockFleeSound auto @@ -15,32 +12,50 @@ int instanceID00 ;************************************************* -Event onCellAttach() - ;USKP 2.0.1 - Short delay added to let 3D catch up. - Utility.Wait(0.5) - instanceID00 = BirdFlockSound.Play(Self) - gotoState("Waiting") -endEvent +auto state Init + Event OnCellAttach() + RegisterForSingleUpdate(0.5) + endEvent + + event OnUpdate() + instanceID00 = BirdFlockSound.Play(Self) + GotoState("Waiting") + endevent +endstate ;************************************************* State Waiting Event onTriggerEnter(ObjectReference akActionRef) - Actor actionRef = akActionRef as Actor - if(((PlayerTriggered) && (actionRef == game.GetPlayer() as Actor)) || (PlayerTriggered == False)) - gotoState("doNothing") - Self.PlayAnimation("PlayAnim01") - int instanceID01 = BirdFlockFleeSound.Play(Self) - wait (0.5) - StopInstance(instanceID00) + if ! PlayerTriggered || (akActionRef as Actor && akActionRef == Game.GetForm(0x14)) + GotoState("Triggered") + PlayAnimation("PlayAnim01") + BirdFlockFleeSound.Play(Self) + RegisterForSingleUpdate(0.5) endif endEvent endState ;************************************************* -State doNothing - ;do nothing +State Triggered + event OnUpdate() + GotoState("WaitForReset") + Sound.StopInstance(instanceID00) + instanceID00 = 0 + endevent +endState + +;************************************************* + +State WaitForReset + event OnReset() + GotoState("Init") + ; OnReset fires after onCellAttach() + if Is3DLoaded() + RegisterForSingleUpdate(0.5) + endif + endevent endState -;************************************************* \ No newline at end of file +;*************************************************