Masterofnet Posted December 24, 2016 Share Posted December 24, 2016 (edited) This has been allot of fun. Combined with ReDragons script optimization techniques, this script is very simple and very fast. You will find the attacker race list created at the bottom. Simply drag them into a Formlist in that order. Scriptname FormList extends ReferenceAlias {rewritten by MON 2016} ; handles creature to Player bleed damage ; source: MON - ReDragon Spell PROPERTY SmallBleed auto Spell PROPERTY MediumBleed auto Spell PROPERTY LargeBleed auto Spell PROPERTY XLargeBleed auto FormList Property AttackerRace auto Auto State Ready ; HIT REGISTERED ON PLAYER EVENT OnHit(ObjectReference A, Form S, Projectile P, Bool B1, Bool B2, Bool B3, Bool B4) If (S As Spell) Return EndIf If B4 ;Hit Blocked Return EndIf If (A As Actor) Else Return EndIf gotoState("Busy") ReDragon(A As Actor) gotoState("Ready") EndEvent EndState Function ReDragon(Actor A) Int AR = AttackerRace.Find((A As Actor).GetRace()) If AR < 0 Return EndIf int i = Utility.RandomInt() ; = Utility.RandomInt(0,100) Int Ic ;Chance of Bleed Damage Spell Sp If AR == 0 Sp = SmallBleed Ic = 30 ElseIf AR <= 2 Sp = SmallBleed Ic = 70 ElseIf AR <= 8 Sp = MediumBleed Ic = 50 ElseIf AR <= 10 Sp = MediumBleed Ic = 60 ElseIf AR <= 12 Sp = LargeBleed Ic = 40 ElseIf AR <= 19 Sp = LargeBleed Ic = 50 ElseIf AR <= 22 Sp = LargeBleed Ic = 60 ElseIf AR <= 24 Sp = XLargeBleed Ic = 10 Else Sp = XLargeBleed Ic = 20 EndIf If (i >= Ic) objectReference Pl = self.GetReference() sp.Cast(Pl, Pl) EndIf EndFunction State Busy EVENT OnHit(ObjectReference A, Form S, Projectile P, Bool B1, Bool B2, Bool B3, Bool B4) EndEvent EndState ;============================================= ; FormList ;============================================= ;0 SlaughterfishRace - Small - 30 ;1 DLC1DeathHoundRace - Small - 70 ;2 WolfRace - Small - 70 ;============================================= ;3 SabreCatSnowyRace - Medium - 50 ;4 DLC1SabreCatGlowRace - Medium - 50 ;5 BearBlackRace - Medium - 50 ;6 BearSnowRace - Medium - 50 ;7 IceWraithRace - Medium - 50 ;8 DLC2dunKarstaagIceWraithRace - Medium - 50 ;9 BearBrownRace - Medium - 60 ;10 SabreCatRace - Medium - 60 ;============================================= ;11 SprigganEarthMotherRace - Large - 40 ;12 DLC1GargoyleVariantBossRace - Large - 40 ;13 DLC1GargoyleVariantGreenRace - Large - 50 ;14 DLC2WerebearBeastRace - Large - 50 ;15 DwarvenSphereRace - Large - 50 ;16 TrollFrostRace - Large - 50 ;17 DLC1GargoyleRace - Large - 50 ;18 WerewolfBeastRace - Large - 50 ;19 SprigganMatronRace - Large - 50 ;20 SprigganRace - Large - 60 ;21 DLC2SprigganBurntRace - Large - 60 ;22 TrollRace - Large - 60 ;============================================= ;23 DLC1LD_ForgemasterRace - XLarge - 10 ;24 DLC2DwarvenBallistaRace - XLarge - 10 ;25 DwarvenCenturionRace - XLarge - 20 This is another script I did without using a Formlist. There are reasons I like it. Scriptname NoFormList extends ReferenceAlias ; Special thanks to ReDragon for his expert advice and for first addressing the fact ;that the script Lesi is attempting to use is not properly optimized for an OnHit ;Event. Race Property WolfRace Auto Race Property SlaughterfishRace Auto Race Property SabreCatRace Auto Race Property SabreCatSnowyRace Auto Race Property BearBlackRace Auto Race Property BearBrownRace Auto Race Property BearSnowRace Auto Race Property IceWraithRace Auto Race Property WerewolfBeastRace Auto Race Property SprigganRace Auto Race Property SprigganMatronRace Auto Race Property TrollRace Auto Race Property TrollFrostRace Auto Race Property DwarvenSphereRace Auto Race Property DwarvenCenturionRace Auto Race Property DLC1DeathHoundRace Auto Race Property DLC1SabreCatGlowRace Auto Race Property SprigganEarthMotherRace Auto Race Property DLC1GargoyleRace Auto Race Property DLC1GargoyleVariantBossRace Auto Race Property DLC1GargoyleVariantGreenRace Auto Race Property DLC2SprigganBurntRace Auto Race Property DLC2WerebearBeastRace Auto Race Property DLC1LD_ForgemasterRace Auto Race Property DLC2DwarvenBallistaRace Auto Race Property DLC2dunKarstaagIceWraithRace Auto Spell Property SmallBleed Auto Spell Property MediumBleed Auto Spell Property LargeBleed Auto Spell Property XLargeBleed Auto Auto State Ready ; HIT REGISTERED ON PLAYER EVENT OnHit(ObjectReference A, Form S, Projectile P, Bool B1, Bool B2, Bool B3, Bool B4) If (S As Spell) Return EndIf If B4 ;Hit Blocked Return EndIf If (A As Actor) Else Return EndIf gotoState("Busy") ReDragon(A As Actor) gotoState("Ready") EndEvent EndState Function ReDragon(Actor A) Race r = (A).GetRace() Spell Sp Int Ic ; Chance of Bleeding Damage IF (r == SlaughterfishRace) Sp = SmallBleed Ic = 30 ELSEIF (r == WolfRace) Sp = SmallBleed Ic = 70 ELSEIF (r == DLC1DeathHoundRace) Sp = SmallBleed Ic = 70 ;Medium=================================================== ELSEIF (r == SabreCatSnowyRace) Sp = MediumBleed Ic = 50 ELSEIF (r == DLC1SabreCatGlowRace) Sp = MediumBleed Ic = 50 ELSEIF (r == BearBlackRace) Sp = MediumBleed Ic = 50 ELSEIF (r == BearSnowRace) Sp = MediumBleed Ic = 50 ELSEIF (r == IceWraithRace) Sp = MediumBleed Ic = 50 ELSEIF (r == DLC2dunKarstaagIceWraithRace) Sp = MediumBleed Ic = 50 ELSEIF (r == BearBrownRace) Sp = MediumBleed Ic = 60 ELSEIF (r == SabreCatRace) Sp = MediumBleed Ic = 60 ;Large=================================================== ELSEIF (r == SprigganEarthMotherRace) Sp = LargeBleed Ic = 40 ELSEIF (r == DLC1GargoyleVariantBossRace) Sp = LargeBleed Ic = 40 ELSEIF (r == DLC1GargoyleVariantGreenRace) Sp = LargeBleed Ic = 50 ELSEIF (r == DLC2WerebearBeastRace) Sp = LargeBleed Ic = 50 ELSEIF (r == DwarvenSphereRace) Sp = LargeBleed Ic = 50 ELSEIF (r == TrollFrostRace) Sp = LargeBleed Ic = 50 ELSEIF (r == DLC1GargoyleRace) Sp = LargeBleed Ic = 50 ELSEIF (r == WerewolfBeastRace) Sp = LargeBleed Ic = 50 ELSEIF (r == SprigganMatronRace) Sp = LargeBleed Ic = 50 ELSEIF (r == SprigganRace) Sp = LargeBleed Ic = 60 ELSEIF (r == DLC2SprigganBurntRace) Sp = LargeBleed Ic = 60 ELSEIF (r == TrollRace) Sp = LargeBleed Ic = 60 ;XLarge=================================================== ELSEIF (r == DLC1LD_ForgemasterRace) Sp = XLargeBleed Ic = 10 ELSEIF (r == DLC2DwarvenBallistaRace) Sp = XLargeBleed Ic = 10 ELSEIF (r == DwarvenCenturionRace) Sp = XLargeBleed Ic = 20 ENDIF IF Sp Else Return EndIf int i = Utility.RandomInt() ; = Utility.RandomInt(0,100) IF (i >= Ic) objectReference Pl = self.GetReference() Sp.Cast(Pl, Pl) ENDIF EndFunction State Busy EVENT OnHit(ObjectReference A, Form S, Projectile P, Bool B1, Bool B2, Bool B3, Bool B4) EndEvent EndState ReDragon I have updated your script I updated the OnHit conditions, removed the function, created the Array and Formlist and gave some instructions on how to fill them. You deserve some real credit for coming here and pointing out to Lesi that her script was a big part of the problem and for designing this professional script for her. Perfecting this script for an Onhit event has also become interesting to me. I wish I could test all three of these scripts in game and see the differences in performance. This is the script I would go with until actual testing could be performed, but I wanted to give her other options. Great Work ReDragon! :devil: Scriptname MasterOfNetUpdate extends ReferenceAlias {written by ReDragon 2016} ;Updated but MON ; handles creature to Player bleed damage ; original source: PlayerAliasSampleHitScript made by ReDragon ; https://forums.nexusmods.com/index.php?/topic/5174600-throttling-onhit-scripts/page-6 Spell PROPERTY SmallBleed auto Spell PROPERTY MediumBleed auto Spell PROPERTY LargeBleed auto Spell PROPERTY XLargeBleed auto ; formlist and array have to be of the same size FormList PROPERTY AttackerRace auto ; list of races you like to see as attacker to make player bleeding Int[] PROPERTY AttackChance auto ; array of chances. See simple instructions at bottom of page. ;=============================== Auto State Ready ; HIT REGISTERED ON PLAYER ;=============== EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4) gotoState("Busy") IF (akSource as Spell) gotoState("Ready") Return ENDIF IF ( b4 ) ; b4 = abHitBlocked gotoState("Ready") Return EndIf IF (akAggressor as Actor) ELSE gotoState("Ready") Return ENDIF int n = AttackerRace.Find((akAggressor as Actor).GetRace()) ;I believe this to be Thread safe. The property and function are on the same script. IF (n < 0) gotoState("Ready") Return ; - STOP - race not found inside our formlist, abort function! ENDIF IF (AttackerRace.GetSize() == AttackChance.Length) ELSE gotoState("Ready") Return ENDIF int i = Utility.RandomInt(0, 100) ; "int Utility.RandomInt()" is the same code int iChance = AttackChance[n] ; get the chance of using for the bleeding spell spell sp IF (iChance < 100) sp = SmallBleed ; small ELSEIF (iChance < 200) sp = MediumBleed ; medium ELSEIF (iChance < 300) sp = LargeBleed ; large ELSE sp = XLargeBleed ; xlarge ENDIF ; ----------------------- WHILE (iChance > 100) iChance = iChance - 100 ; update the value from our integer formlist until we are in range (0..100) ENDWHILE IF (i >= iChance) objectReference oRef = self.GetReference() sp.Cast(oRef, oRef) ENDIF gotoState("Ready") Return EndEvent EndState State Busy EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4) EndEvent EndState ; How to use! base value + chance ; small bleed + 0 ; medium bleed + 100 ; large bleed + 200 ; xlarge bleed + 300 ;For the Array, these will be filled in the properties section of this script. It is very easy. ; # = [0] Value = 30 ; # = [1] Value = 70 Etc. ;For the Formlist you simply create it in the creation kit and drag the races into it in this order ;============================================= ;Array FormList ;============================================= ;AttackChance[0] = 30 ;SlaughterfishRace ;AttackChance[1] = 70 ;DLC1DeathHoundRace ;AttackChance[2] = 70 ;WolfRace ;============================================= ;AttackChance[3] = 150 ;SabreCatSnowyRace ;AttackChance[4] = 150 ;DLC1SabreCatGlowRace ;AttackChance[5] = 150 ;BearBlackRace ;AttackChance[6] = 150 ;BearSnowRace ;AttackChance[7] = 150 ;IceWraithRace ;AttackChance[8] = 150 ;DLC2dunKarstaagIceWraithRace ;AttackChance[9] = 160 ;BearBrownRace ;AttackChance[10] = 160 ;SabreCatRace ;============================================= ;AttackChance[11] = 240 ;SprigganEarthMotherRace ;AttackChance[12] = 240 ;DLC1GargoyleVariantBossRace ;AttackChance[13] = 250 ;DLC1GargoyleVariantGreenRace ;AttackChance[14] = 250 ;DLC2WerebearBeastRace ;AttackChance[15] = 250 ;DwarvenSphereRace ;AttackChance[16] = 250 ;TrollFrostRace ;AttackChance[17] = 250 ;DLC1GargoyleRace ;AttackChance[18] = 250 ;WerewolfBeastRace ;AttackChance[19] = 250 ;SprigganMatronRace ;AttackChance[20] = 260 ;SprigganRace ;AttackChance[21] = 260 ;DLC2SprigganBurntRace ;AttackChance[22] = 260 ;TrollRace ;============================================= ;AttackChance[23] = 310 ;DLC1LD_ForgemasterRace ;AttackChance[24] = 310 ;DLC2DwarvenBallistaRace ;AttackChance[25] = 320 ;DwarvenCenturionRace Edited December 26, 2016 by Masterofnet Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 25, 2016 Share Posted December 25, 2016 Dear MasterOfNet, let it end here. It seems to me nobody is really interested in our private script conversation. We are not really discuss anymore about throttling of OnHit() event. The major bug in lesi123 original script version is the blood spell.It was probably casted too often. Who knows, he retired this topic. Your oneformlist and noformlist scripts are a bit too much simplified. The names are like sound and smoke (in German: Namen sind Schall und Rauch!)Both version should work, what I have seen so far (not yet verified by compiler). The rewrote for my approach was bad (yesterday). The code line "gotoState("Busy")" has to be before "Find" method, becausethe script loses the lock on self here, that is not thread safe (if I'm right). Now I see you have changed the content of the third spoiler, now it looks right for me. I wish all people a peaceful Christmas and for 2017 alltogether a lot of health.Every day a good deed and our world will be better! Link to comment Share on other sites More sharing options...
Masterofnet Posted December 25, 2016 Share Posted December 25, 2016 (edited) Dear MasterOfNet, let it end here. It seems to me nobody is really interested in our private script conversation. Yes we have taken this as far as it can go without Lesi rejoining us and testing the scripts. We are not really discuss anymore about throttling of OnHit() event. The major bug in lesi123 original script version is the blood spell.It was probably casted too often. Who knows, he retired this topic. Just applying bleeding damage, I doubt it, but it would depend on the spell itself. Your oneformlist and noformlist scripts are a bit too much simplified. The names are like sound and smoke (in German: Namen sind Schall und Rauch!)Both version should work, what I have seen so far (not yet verified by compiler). Your first script although technically sound was way to complicated and performed to many functions. Your second attempt with the Formlist and Array probably nailed it. I can't see it being done better to any significant degree. Both of my scripts compile and neither are too simple. Whatever that means. My Oneformlist script would probably perform as well as your second attempt. Just look at the functions the scripts perform after they get the position of the race in the Formlist. They are very close. The rewrote for my approach was bad (yesterday). The code line "gotoState("Busy")" has to be before "Find" method, becausethe script loses the lock on self here, that is not thread safe (if I'm right). Now I see you have changed the content of the third spoiler, now it looks right for me. I could certainly get the position of the Race in the Formlist in the conditions of the OnHitEvent and make it work (even with a function but I would need to test it to be sure).The problem with putting that outside of the conditions is it will kick back over 70% off the time. I would rather do that before setting the script state to Busy. I would look into that further if Lesi ever comes back and finishes what she started. Every day a good deed and our world will be better! It certainly wouldn't hurt. Merry Christmas ReDragon. Edited December 25, 2016 by Masterofnet Link to comment Share on other sites More sharing options...
cdcooley Posted December 26, 2016 Share Posted December 26, 2016 Very interesting scripts you guys have been writing but I'm going to jump in one last time too. The problem with putting that outside of the conditions is it will kick back over 70% off the time. I would rather do that before setting the script state to Busy. You always need to set the script state to busy first. Swapping the state isn't some overhead to be avoided, it's a required feature for thread safety. No matter how small some other bit of code might look you leave an opening for multiple copies of the event to start. Technically I'm not sure that even making simple checks against local variables (which don't normally unlock the object) are safe before switching the state. (And both of you have been doing doing that.) The potential problem from that would be very rare because it requires the script be interrupted at the end of a timeslice for a particular frame. But if the script would get paused at the end of a frame without switching states it would be possible for more events to be triggered by the game before Papyrus got back to processing that particular script instance again on the next frame. That would result in calls against the event getting queued for the wrong state. SmkViper's code is very clear in saying to change state, do stuff, then change the state back. The importance of states isn't just to protect Papyrus from itself. States are also there to protect Papyrus from unwanted interactions with the rest of the game engine. That's why I originally said that they are critical and can't be replaced by flag variables if your goal is to actually provide a locking mechanism for things like OnHit. It's fine to look at the assembly language behind the Papyrus code but that's still not capturing everything because Papyrus is just one part of a larger game system and most of that system is invisible to us. Link to comment Share on other sites More sharing options...
Masterofnet Posted December 26, 2016 Share Posted December 26, 2016 (edited) Very interesting scripts you guys have been writing but I'm going to jump in one last time too. I agree, I feel much more comfortable with the Busy State coming first. At least until the script can be tested. This is the last script I came up with. Any other thoughts? Scriptname MasterOfNetUpdate extends ReferenceAlias {written by ReDragon 2016} ;Updated but MON ; handles creature to Player bleed damage ; original source: PlayerAliasSampleHitScript made by ReDragon ; https://forums.nexusmods.com/index.php?/topic/5174600-throttling-onhit-scripts/page-6 Spell PROPERTY SmallBleed auto Spell PROPERTY MediumBleed auto Spell PROPERTY LargeBleed auto Spell PROPERTY XLargeBleed auto ; formlist and array have to be of the same size FormList PROPERTY AttackerRace auto ; list of races you like to see as attacker to make player bleeding Int[] PROPERTY AttackChance auto ; array of chances. See simple instructions at bottom of page. ;=============================== Auto State Ready ; HIT REGISTERED ON PLAYER ;=============== EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4) gotoState("Busy") IF (akSource as Spell) gotoState("Ready") Return ENDIF IF ( b4 ) ; b4 = abHitBlocked gotoState("Ready") Return EndIf IF (akAggressor as Actor) ELSE gotoState("Ready") Return ENDIF int n = AttackerRace.Find((akAggressor as Actor).GetRace()) ;I believe this to be Thread safe. The property and function are on the same script. IF (n < 0) gotoState("Ready") Return ; - STOP - race not found inside our formlist, abort function! ENDIF IF (AttackerRace.GetSize() == AttackChance.Length) ELSE gotoState("Ready") Return ENDIF int i = Utility.RandomInt(0, 100) ; "int Utility.RandomInt()" is the same code int iChance = AttackChance[n] ; get the chance of using for the bleeding spell spell sp IF (iChance < 100) sp = SmallBleed ; small ELSEIF (iChance < 200) sp = MediumBleed ; medium ELSEIF (iChance < 300) sp = LargeBleed ; large ELSE sp = XLargeBleed ; xlarge ENDIF ; ----------------------- WHILE (iChance > 100) iChance = iChance - 100 ; update the value from our integer formlist until we are in range (0..100) ENDWHILE IF (i >= iChance) objectReference oRef = self.GetReference() sp.Cast(oRef, oRef) ENDIF gotoState("Ready") Return EndEvent EndState State Busy EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4) EndEvent EndState ; How to use! base value + chance ; small bleed + 0 ; medium bleed + 100 ; large bleed + 200 ; xlarge bleed + 300 ;For the Array, these will be filled in the properties section of this script. It is very easy. ; # = [0] Value = 30 ; # = [1] Value = 70 Etc. ;For the Formlist you simply create it in the creation kit and drag the races into it in this order ;============================================= ;Array FormList ;============================================= ;AttackChance[0] = 30 ;SlaughterfishRace ;AttackChance[1] = 70 ;DLC1DeathHoundRace ;AttackChance[2] = 70 ;WolfRace ;============================================= ;AttackChance[3] = 150 ;SabreCatSnowyRace ;AttackChance[4] = 150 ;DLC1SabreCatGlowRace ;AttackChance[5] = 150 ;BearBlackRace ;AttackChance[6] = 150 ;BearSnowRace ;AttackChance[7] = 150 ;IceWraithRace ;AttackChance[8] = 150 ;DLC2dunKarstaagIceWraithRace ;AttackChance[9] = 160 ;BearBrownRace ;AttackChance[10] = 160 ;SabreCatRace ;============================================= ;AttackChance[11] = 240 ;SprigganEarthMotherRace ;AttackChance[12] = 240 ;DLC1GargoyleVariantBossRace ;AttackChance[13] = 250 ;DLC1GargoyleVariantGreenRace ;AttackChance[14] = 250 ;DLC2WerebearBeastRace ;AttackChance[15] = 250 ;DwarvenSphereRace ;AttackChance[16] = 250 ;TrollFrostRace ;AttackChance[17] = 250 ;DLC1GargoyleRace ;AttackChance[18] = 250 ;WerewolfBeastRace ;AttackChance[19] = 250 ;SprigganMatronRace ;AttackChance[20] = 260 ;SprigganRace ;AttackChance[21] = 260 ;DLC2SprigganBurntRace ;AttackChance[22] = 260 ;TrollRace ;============================================= ;AttackChance[23] = 310 ;DLC1LD_ForgemasterRace ;AttackChance[24] = 310 ;DLC2DwarvenBallistaRace ;AttackChance[25] = 320 ;DwarvenCenturionRace Out of respect for the Big Man I have done another version I think he would be more approving of. I like it better myself. Scriptname MasterOfNetReFunctionScript extends ReferenceAlias {written by ReDragon 2016} ;Updated but MON ; handles creature to Player bleed damage ; original source: PlayerAliasSampleHitScript made by ReDragon ; https://forums.nexusmods.com/index.php?/topic/5174600-throttling-onhit-scripts/page-6 Spell PROPERTY SmallBleed auto Spell PROPERTY MediumBleed auto Spell PROPERTY LargeBleed auto Spell PROPERTY XLargeBleed auto ; formlist and array have to be of the same size FormList PROPERTY AttackerRace auto ; list of races you like to see as attacker to make player bleeding Int[] PROPERTY AttackChance auto ; array of chances. See simple instructions at bottom of page. ;=============================== Auto State Ready ; HIT REGISTERED ON PLAYER ;=============== EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4) gotoState("Busy") ReDragon(akAggressor As Actor, akSource As Spell, B4) gotoState("Ready") EndEvent EndState Function ReDragon(Actor aRef, Spell S, Bool B4) IF (S) Return ENDIF IF ( b4 ) ; b4 = abHitBlocked Return EndIf IF (aRef) ELSE Return ENDIF int n = AttackerRace.Find((aRef).GetRace()) ;I believe this to be Thread safe. The property and function are on the same script. IF (n < 0) Return ; - STOP - race not found inside our formlist, abort function! ENDIF IF (AttackerRace.GetSize() == AttackChance.Length) ELSE Return ENDIF int i = Utility.RandomInt(0, 100) ; "int Utility.RandomInt()" is the same code int iChance = AttackChance[n] ; get the chance of using for the bleeding spell spell sp IF (iChance < 100) sp = SmallBleed ; small ELSEIF (iChance < 200) sp = MediumBleed ; medium ELSEIF (iChance < 300) sp = LargeBleed ; large ELSE sp = XLargeBleed ; xlarge ENDIF ; ----------------------- WHILE (iChance > 100) iChance = iChance - 100 ; update the value from our integer formlist until we are in range (0..100) ENDWHILE IF (i >= iChance) objectReference oRef = self.GetReference() sp.Cast(oRef, oRef) ENDIF Return EndFunction State Busy EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4) EndEvent EndState ; How to use! base value + chance ; small bleed + 0 ; medium bleed + 100 ; large bleed + 200 ; xlarge bleed + 300 ;For the Array, these will be filled in the properties section of this script. It is very easy. ; # = [0] Value = 30 ; # = [1] Value = 70 Etc. ;For the Formlist you simply create it in the creation kit and drag the races into it in this order ;============================================= ;Array FormList ;============================================= ;AttackChance[0] = 30 ;SlaughterfishRace ;AttackChance[1] = 70 ;DLC1DeathHoundRace ;AttackChance[2] = 70 ;WolfRace ;============================================= ;AttackChance[3] = 150 ;SabreCatSnowyRace ;AttackChance[4] = 150 ;DLC1SabreCatGlowRace ;AttackChance[5] = 150 ;BearBlackRace ;AttackChance[6] = 150 ;BearSnowRace ;AttackChance[7] = 150 ;IceWraithRace ;AttackChance[8] = 150 ;DLC2dunKarstaagIceWraithRace ;AttackChance[9] = 160 ;BearBrownRace ;AttackChance[10] = 160 ;SabreCatRace ;============================================= ;AttackChance[11] = 240 ;SprigganEarthMotherRace ;AttackChance[12] = 240 ;DLC1GargoyleVariantBossRace ;AttackChance[13] = 250 ;DLC1GargoyleVariantGreenRace ;AttackChance[14] = 250 ;DLC2WerebearBeastRace ;AttackChance[15] = 250 ;DwarvenSphereRace ;AttackChance[16] = 250 ;TrollFrostRace ;AttackChance[17] = 250 ;DLC1GargoyleRace ;AttackChance[18] = 250 ;WerewolfBeastRace ;AttackChance[19] = 250 ;SprigganMatronRace ;AttackChance[20] = 260 ;SprigganRace ;AttackChance[21] = 260 ;DLC2SprigganBurntRace ;AttackChance[22] = 260 ;TrollRace ;============================================= ;AttackChance[23] = 310 ;DLC1LD_ForgemasterRace ;AttackChance[24] = 310 ;DLC2DwarvenBallistaRace ;AttackChance[25] = 320 ;DwarvenCenturionRace I have updated the other two also in-spite of Lesi abandoning her thread. I must admit I have really lost faith in her. She seems to have no respect for the quality of her work or the help of other people. It only took me a couple of minutes to do so this is the final version of my OneFormlistScript. Scriptname OneFormList extends ReferenceAlias {rewritten by MON 2016} ; handles creature to Player bleed damage ; source: MON - ReDragon Spell PROPERTY SmallBleed auto Spell PROPERTY MediumBleed auto Spell PROPERTY LargeBleed auto Spell PROPERTY XLargeBleed auto FormList Property AttackerRace auto Auto State Ready ; HIT REGISTERED ON PLAYER EVENT OnHit(ObjectReference A, Form S, Projectile P, Bool B1, Bool B2, Bool B3, Bool B4) gotoState("Busy") ReDragon(A As Actor, S as Spell, B4) gotoState("Ready") EndEvent EndState Function ReDragon(Actor A, Spell S, Bool B4) If (S) Return EndIf If B4 ;Hit Blocked Return EndIf If (A) Else Return EndIf Int AR = AttackerRace.Find((A).GetRace()) If AR < 0 Return EndIf int i = Utility.RandomInt() ; = Utility.RandomInt(0,100) Int Ic ;Chance of Bleed Damage Spell Sp If AR == 0 Sp = SmallBleed Ic = 30 ElseIf AR <= 2 Sp = SmallBleed Ic = 70 ElseIf AR <= 8 Sp = MediumBleed Ic = 50 ElseIf AR <= 10 Sp = MediumBleed Ic = 60 ElseIf AR <= 12 Sp = LargeBleed Ic = 40 ElseIf AR <= 19 Sp = LargeBleed Ic = 50 ElseIf AR <= 22 Sp = LargeBleed Ic = 60 ElseIf AR <= 24 Sp = XLargeBleed Ic = 10 Else Sp = XLargeBleed Ic = 20 EndIf If (i >= Ic) objectReference Pl = self.GetReference() sp.Cast(Pl, Pl) EndIf EndFunction State Busy EVENT OnHit(ObjectReference A, Form S, Projectile P, Bool B1, Bool B2, Bool B3, Bool B4) EndEvent EndState ;============================================= ; FormList ;============================================= ;0 SlaughterfishRace - Small - 30 ;1 DLC1DeathHoundRace - Small - 70 ;2 WolfRace - Small - 70 ;============================================= ;3 SabreCatSnowyRace - Medium - 50 ;4 DLC1SabreCatGlowRace - Medium - 50 ;5 BearBlackRace - Medium - 50 ;6 BearSnowRace - Medium - 50 ;7 IceWraithRace - Medium - 50 ;8 DLC2dunKarstaagIceWraithRace - Medium - 50 ;9 BearBrownRace - Medium - 60 ;10 SabreCatRace - Medium - 60 ;============================================= ;11 SprigganEarthMotherRace - Large - 40 ;12 DLC1GargoyleVariantBossRace - Large - 40 ;13 DLC1GargoyleVariantGreenRace - Large - 50 ;14 DLC2WerebearBeastRace - Large - 50 ;15 DwarvenSphereRace - Large - 50 ;16 TrollFrostRace - Large - 50 ;17 DLC1GargoyleRace - Large - 50 ;18 WerewolfBeastRace - Large - 50 ;19 SprigganMatronRace - Large - 50 ;20 SprigganRace - Large - 60 ;21 DLC2SprigganBurntRace - Large - 60 ;22 TrollRace - Large - 60 ;============================================= ;23 DLC1LD_ForgemasterRace - XLarge - 10 ;24 DLC2DwarvenBallistaRace - XLarge - 10 ;25 DwarvenCenturionRace - XLarge - 20 It only took me a couple of minutes to do so this is the final version of my NoFormlistScript. Scriptname NoFormList extends ReferenceAlias Race Property WolfRace Auto Race Property SlaughterfishRace Auto Race Property SabreCatRace Auto Race Property SabreCatSnowyRace Auto Race Property BearBlackRace Auto Race Property BearBrownRace Auto Race Property BearSnowRace Auto Race Property IceWraithRace Auto Race Property WerewolfBeastRace Auto Race Property SprigganRace Auto Race Property SprigganMatronRace Auto Race Property TrollRace Auto Race Property TrollFrostRace Auto Race Property DwarvenSphereRace Auto Race Property DwarvenCenturionRace Auto Race Property DLC1DeathHoundRace Auto Race Property DLC1SabreCatGlowRace Auto Race Property SprigganEarthMotherRace Auto Race Property DLC1GargoyleRace Auto Race Property DLC1GargoyleVariantBossRace Auto Race Property DLC1GargoyleVariantGreenRace Auto Race Property DLC2SprigganBurntRace Auto Race Property DLC2WerebearBeastRace Auto Race Property DLC1LD_ForgemasterRace Auto Race Property DLC2DwarvenBallistaRace Auto Race Property DLC2dunKarstaagIceWraithRace Auto Spell Property SmallBleed Auto Spell Property MediumBleed Auto Spell Property LargeBleed Auto Spell Property XLargeBleed Auto Auto State Ready EVENT OnHit(ObjectReference A, Form S, Projectile P, Bool B1, Bool B2, Bool B3, Bool B4) gotoState("Busy") ReDragon(A As Actor, S As Spell, B4) gotoState("Ready") EndEvent EndState Function ReDragon(Actor A, Spell S, Bool B4) If (S) Return EndIf If B4 ;Hit Blocked Return EndIf If (A) Else Return EndIf Race r = (A).GetRace() Spell Sp Int Ic ; Chance of Bleeding Damage IF (r == SlaughterfishRace) Sp = SmallBleed Ic = 30 ELSEIF (r == WolfRace) Sp = SmallBleed Ic = 70 ELSEIF (r == DLC1DeathHoundRace) Sp = SmallBleed Ic = 70 ;Medium=================================================== ELSEIF (r == SabreCatSnowyRace) Sp = MediumBleed Ic = 50 ELSEIF (r == DLC1SabreCatGlowRace) Sp = MediumBleed Ic = 50 ELSEIF (r == BearBlackRace) Sp = MediumBleed Ic = 50 ELSEIF (r == BearSnowRace) Sp = MediumBleed Ic = 50 ELSEIF (r == IceWraithRace) Sp = MediumBleed Ic = 50 ELSEIF (r == DLC2dunKarstaagIceWraithRace) Sp = MediumBleed Ic = 50 ELSEIF (r == BearBrownRace) Sp = MediumBleed Ic = 60 ELSEIF (r == SabreCatRace) Sp = MediumBleed Ic = 60 ;Large=================================================== ELSEIF (r == SprigganEarthMotherRace) Sp = LargeBleed Ic = 40 ELSEIF (r == DLC1GargoyleVariantBossRace) Sp = LargeBleed Ic = 40 ELSEIF (r == DLC1GargoyleVariantGreenRace) Sp = LargeBleed Ic = 50 ELSEIF (r == DLC2WerebearBeastRace) Sp = LargeBleed Ic = 50 ELSEIF (r == DwarvenSphereRace) Sp = LargeBleed Ic = 50 ELSEIF (r == TrollFrostRace) Sp = LargeBleed Ic = 50 ELSEIF (r == DLC1GargoyleRace) Sp = LargeBleed Ic = 50 ELSEIF (r == WerewolfBeastRace) Sp = LargeBleed Ic = 50 ELSEIF (r == SprigganMatronRace) Sp = LargeBleed Ic = 50 ELSEIF (r == SprigganRace) Sp = LargeBleed Ic = 60 ELSEIF (r == DLC2SprigganBurntRace) Sp = LargeBleed Ic = 60 ELSEIF (r == TrollRace) Sp = LargeBleed Ic = 60 ;XLarge=================================================== ELSEIF (r == DLC1LD_ForgemasterRace) Sp = XLargeBleed Ic = 10 ELSEIF (r == DLC2DwarvenBallistaRace) Sp = XLargeBleed Ic = 10 ELSEIF (r == DwarvenCenturionRace) Sp = XLargeBleed Ic = 20 ENDIF IF Sp Else Return EndIf int i = Utility.RandomInt() ; = Utility.RandomInt(0,100) IF (i >= Ic) objectReference Pl = self.GetReference() Sp.Cast(Pl, Pl) ENDIF EndFunction State Busy EVENT OnHit(ObjectReference A, Form S, Projectile P, Bool B1, Bool B2, Bool B3, Bool B4) EndEvent EndState Edited December 27, 2016 by Masterofnet Link to comment Share on other sites More sharing options...
lesi123 Posted December 27, 2016 Author Share Posted December 27, 2016 I have updated the other two also in-spite of Lesi abandoning her thread. I must admit I have really lost faith in her. She seems to have no respect for the quality of her work or the help of other people. Masterofnet, When you PM’ed me on Dec 22 about the script rewrites you and ReDragon had done, I replied with the following PM: "Ah, it's okay! It was the wait function that I needed to add in on top of your addition to shut down the whole script. Thank you very much for that, I must add you to my credits if I ever publish it for helping me. :) I have been running regular tests and stress tests with no problems and it's thanks to you. The script I saw from ReDragon was very hard for me to read, sadly. I can look at others you have written but Skyrim is the only game code I have ever looked in to (and that was almost 3 years ago!) so I must do a lot of research and testing to understand how things work (again). I stuck with my own script and very happy it's working as intended, even in a very full load order. Sadly, testing and development will need to be put on hold for the holidays so maybe sometime next year I can feel good enough to publish. Thank you again and Happy Holidays!” I did not abandoned this thread; I stated in my last post I would update this thread if I had anything else to report after using the wait function in addition to using states. Since then, I’ve run into no issues and thus had no reason to check back in except for when you PM’d me and asked me to, which I did. However, my script was working fine and there was so much back and forth between script rewrites that I didn’t feel it prudent to partake in that conversation. I was actually surprised that this thread was still going. Also, I clearly stated that I would not be working on the mod during the holidays. I am spending time with friends and family and occasionally checking my mod pages for questions. As for respect, if you read the PM I sent you and my previous posts on this thread, I have thanked everyone for their time and help because it has truly been helpful. I do not mod for a living. I do not script for a living. I don’t even work with computers for a living, so to find time to mod is somewhat challenging for me but I do this to relax, offer help when I can, ask for help when I need it, and offer my thanks to anyone involved, but the original problem of throttling OnHit has been solved. If you’ve lost faith in me, that’s your problem. All that said, I will not be revisiting this thread again. Link to comment Share on other sites More sharing options...
Masterofnet Posted December 27, 2016 Share Posted December 27, 2016 I did not abandoned this thread; I will not be revisiting this thread again. Yes you did and you just clearly stated that. Why would you not revisit this thread when the people here have only gone out of their way to help you? Are you allergic to competent help? Sadly, testing and development will need to be put on hold for the holidays so maybe sometime next year I can feel good enough to publish. Publish?? You have a script for an OnHit event that needs to use the wait function in order to work properly? That is not realistic. Your script performs way to many functions and is way to slow for use on an OnHit event. How can you not grasp that? Please show some respect for the quality of your work and the help people have offered you and look at the scripts that we came up with. BTW- You do not post a PM on a thread. You also don't seem to have any respect for privacy. Link to comment Share on other sites More sharing options...
theFuzzyWarble Posted February 6, 2018 Share Posted February 6, 2018 (edited) Outstanding thread.. "old" as it is!It's helping me wrap my head around optimizing my code better.I've been trying to rework an apparently abandoned mod that I have in my load order and I've learned more in the past hour than I've scrapped together in the past few days, fumbling around the CK wiki and elsewhere. So, many thanks all around!! Edited February 6, 2018 by theFuzzyWarble Link to comment Share on other sites More sharing options...
Recommended Posts