wxyu Posted February 16, 2012 Share Posted February 16, 2012 Hi I'm wxyu, a new beginner modder. I have a script that works, but not entirely the way I would like it. I would appreciate some input. The following script is an Enchantment Script written in Creation Kit. The purpose of the Enchantment is to: A weapon that applies three effects for each hit up to the final hit.On the final hit, a separate effect is applied; all previous effects are removed with the final hit.The number of hits to the final hit is random. What doesn't work/could be improved:1) a damage modifier calculation2) an array that I keep re-creating per hit instead of OnInit3) a timer (Utility.Wait) to dispel all effects iff the player has not finished the series of hits within 30 seconds Problem 1 int Modifier = (10 - smiteCountTemp)/10 * WYUPlayerHolder.GetLevel()Debugging smiteCountTemp gives me integers 6 to 1 as expected.Debugging (10 - smiteCountTemp)/10 gives me 0.? Integer/Float mismatch OR math fail?Also, is there a way to have int Modifier = 0.4 * WYUPlayerHolder.GetLevel()As 0.4 is a float Problem 2 Event OnEffectStart (Actor akTarget, Actor akCaster) Spell[] WYUsmiteSpellArray = new Spell[2]This means (I assume) that my array is recreated every time the Enchant is triggered (on Contact in this instance).I tried creating the Array in OnInit, but the OnEffectStart won't recognize the array then.I tried putting the Array into a GlobalVariable. Won't work. :biggrin: I tried creating the Array outside a function. Won't work.I crazily thought I could extend OnEffectStart to receive an Array as an argument. Doesn't work that way. :biggrin: Any ideas? I'd prefer to create the array only OnInit. Problem 3My simplistic thinking was this: (pseudo)When start hitting-chain, set a timer (to dispel all effects), set a flag (to say I'm in hitting-chain)When finish hitting-chain, set flag (to say I'm not in hitting-chain)When timer fires, check if IT is the last timer, then fire (dispel all effects)My concern is a timer created in Iteration 1 of the Enchantment dispels all effects of Iteration 2 mid-way during Iteration 2's 30 second allotment (if that makes sense)A simple solution would be to delete Timer on hitting-chain end. However, I don't know of any other Timer method (that can be deleted) other than Utility.Wait Code Scriptname WYUScriptMGEFSmite extends activemagiceffect Spell Property WYUSpellSmitingStagger Auto Spell Property WYUSpellSmitingDisarm Auto Spell Property WYUSpellSmitingFear Auto Spell Property WYUSpellSmitingFireStorm Auto GlobalVariable Property smiteCountHolder Auto GlobalVariable Property smiteFiredHolder Auto GlobalVariable Property smiteUtilityWaitCountHolder Auto GlobalVariable Property smiteDamageModSumHolder Auto Function SetScale(float afScale) native Actor Property WYUPlayerHolder Auto Event OnEffectStart (Actor akTarget, Actor akCaster) ; MAKE ArrayofSpells, not sure how to avoid this every time Spell[] WYUsmiteSpellArray = new Spell[2] WYUsmiteSpellArray[0] = WYUSpellSmitingStagger WYUsmiteSpellArray[1] = WYUSpellSmitingFear ;WYUsmiteSpellArray[2] = WYUSpellSmitingDisarm int ArrayLengthMinusOne = WYUsmiteSpellArray.length ArrayLengthMinusOne = ArrayLengthMinusOne - 1 int smiteCountTemp = smiteCountHolder.GetValueInt() int smiteFiredTemp = smiteFiredHolder.GetValueInt() int smiteUtilityWaitCountTemp = smiteUtilityWaitCountHolder.GetValueInt() int smiteDamageModSumTemp = smiteDamageModSumHolder.GetValueInt() WYUPlayerHolder = Game.GetPlayer() ; IS THIS LAST HIT int smiteDamageModSumTemp2 = smiteDamageModSumTemp If (smiteCountTemp == 0) ; LAST HIT ; Debug.Notification("LAST HIT") ; CAST the discharge ; DISPEL all earlier effects ; RESET the number of hits to discharge ; RESET the modified damage ; FLAG the reset of the Enchantment ; CHANGE global variables WYUSpellSmitingFireStorm.Cast(WYUPlayerHolder, WYUPlayerHolder) WYUPlayerHolder.ModActorValue("MeleeDamage", -1 * smiteDamageModSumTemp2) WYUPlayerHolder.SetScale(1.0) ; Debug.Notification("Player Damage currently " + WYUPlayerHolder.GetAV("MeleeDamage") + " dropped by " + smiteDamageModSumTemp2) Utility.Wait(1) smiteCountTemp = Utility.RandomInt(3, 6) smiteDamageModSumTemp = 0 smiteFiredTemp = 0 smiteCountHolder.SetValueInt(smiteCountTemp) smiteDamageModSumHolder.SetValueInt(smiteDamageModSumTemp) smiteFiredHolder.SetValueInt(smiteFiredTemp) Else ; NOT LAST HIT If (smiteFiredTemp == 0) ; NEVER FIRED / CEASED / COMPLETED ; FLAG as fired ; INCREMENT the Utility Counter ; MAKE a UtilityTimer to Kill the Enchant Chain if it remains incomplete ; FIRE the UtilityTimer only if it is the last timer standing, to prevent an Earlier Timer from Killing a Younger Chain smiteFiredTemp = 1 smiteFiredHolder.SetValueInt(smiteFiredTemp) smiteUtilityWaitCountTemp = smiteUtilityWaitCountTemp + 1 smiteUtilityWaitCountHolder.SetValueInt(smiteUtilityWaitCountTemp) Debug.Notification("Utility Counter is " + smiteUtilityWaitCountTemp) ; Utility.Wait(30) ; LOAD the Globals Again to UPDATE IT ; smiteUtilityWaitCountTemp = smiteUtilityWaitCountHolder.GetValueInt() ; smiteDamageModSumTemp = smiteDamageModSumHolder.GetValueInt() ;If (smiteUtilityWaitCountTemp <= 1) ; WYUPlayerHolder.ModActorValue("MeleeDamage", -smiteDamageModSumTemp) ; WYUPlayerHolder.SetScale(1.0) ; Debug.Notification("Player Damage currently " + WYUPlayerHolder.GetAV("MeleeDamage") + " dropped by " + smiteDamageModSumTemp) ; smiteCountTemp = Utility.RandomInt(3, 6) ; smiteFiredTemp = 0 ; smiteDamageModSumTemp = 0 ; smiteCountHolder.SetValueInt(smiteCountTemp) ; smiteDamageModSumHolder.SetValueInt(smiteDamageModSumTemp) ; smiteFiredHolder.SetValueInt(smiteFiredTemp) ;EndIf EndIf ; EFFECTS ; give me a random effect ; make me big ; add to my damage ; reduce the smite count ; do weaker things at random (same for now) int ArrayRandomizer = Utility.RandomInt(0, ArrayLengthMinusOne) WYUsmiteSpellArray[ArrayRandomizer].Cast(WYUPlayerHolder, WYUPlayerHolder.GetCombatTarget()) float GetScaleTemp = WYUPlayerHolder.GetScale() GetScaleTemp = GetScaleTemp + 0.1 WYUPlayerHolder.SetScale(GetScaleTemp) ; smiteDamageModSumTemp = smiteDamageModSumTemp + ((10 - smiteCountTemp/10) * WYUPlayerHolder.GetLevel()) int Modifier = WYUPlayerHolder.GetLevel() smiteDamageModSumTemp = smiteDamageModSumTemp + Modifier WYUPlayerHolder.ModActorValue("MeleeDamage", Modifier ) Debug.Notification("Player Damage currently " + WYUPlayerHolder.GetAV("MeleeDamage") + " increased by " + Modifier ) smiteCountTemp = smiteCountTemp - 1 smiteCountHolder.SetValueInt(smiteCountTemp) smiteDamageModSumHolder.SetValueInt(smiteDamageModSumTemp) EndIf EndEvent Thank you for any help/ideas, much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts