Rizalgar Posted December 28, 2018 Share Posted December 28, 2018 Ok, I'm trying to pick up where TripleSixes left off with his Skyscape mod, but Papyrus is a little beyond me. I'm having trouble setting the global RS_GV_MagicXP through the script. I can manually change it in game via console but I need it to change with each spell cast. I have added to one of his scripts, then wrote one myself in efforts to get it to work. Any help would be appreciated. First script is his, with my adding at the bottom, second script is my own attempt. I'll ///// off the code that I added. I asked T6 himself, but haven't been able to get a hold of him. Scriptname RS_Spell_AirStrike Extends ActiveMagicEffect {Script for Air Strike} MiscObject Property AirRune Auto MiscObject Property MindRune Auto Spell Property AirStrike Auto sound property LevelUpSound auto globalvariable property RS_GV_MagicXP auto globalvariable property RS_GV_MagicLVL auto Event OnSpellCast(Form akSpell) ;Do Stuff EndEvent Event OnEffectStart(Actor akTarget, Actor akCaster) If akCaster == game.getplayer() Int AirRuneCt = game.Getplayer().GetItemCount(AirRune) Int MindRuneCt = game.GetPlayer().GetItemCount(MindRune) If AirRuneCt < 1 && MindRuneCt < 1 game.getplayer().UnequipSpell(AirStrike, 0) game.getplayer().UnequipSpell(AirStrike, 1) Debug.Notification("You do not have the required runes to cast this spell!") Else game.getplayer().RemoveItem(AirRune, 1, True) game.getplayer().RemoveItem(MindRune, 1, True) ;============================================= ;Damage Formula Int bd = Utility.RandomInt(1,48);replace this with a real damage formula later ;============================================= akTarget.DamageActorValue("Health", bd) EndIf EndIf game.getplayer().DispelSpell(AirStrike) ////////////////////////////////////////////////////////// float mod float ASExp = 7.5 float modmagicxp float MagicXP = RS_GV_MagicXP.getvalue() Int DamageXP = Utility.RandomInt(1,48) /2 modmagicxp = ((ASExp) + (DamageXP)) RS_GV_MagicXP.setvalue(ModMagicXP) Debug.Notification("Xp recieved") EndEvent //////////////////////////////////////////////////// Scriptname RS_GlobalMagicXP extends Actor {Hopeful magic XP} actor property player auto spell property AirStrike auto sound property LevelUpSound auto globalvariable property RS_GV_MagicXP auto globalvariable property RS_GV_MagicLVL auto globalvariable property RS_GV_MAcounter auto float mod float ASExp = 7.5 Event OnSpellCast(Form akSpell) player = game.getplayer() float ModMagicXP = 0 float MagicXP = RS_GV_MagicXP.getvalue() If (akSpell == AirStrike) Int DamageXP = Utility.RandomInt(1,48) /2 ModMagicXP = ((ASExp) + (DamageXP)) EndIf RS_GV_MagicXP.setvalue(ModMagicXP) CheckForLevelUp() EndEvent Function CheckForLevelUp() Float MaXP = RS_GV_MagicXP.getvalue() Float MaLVL = RS_GV_MagicLVL.getvalue() If MaXP >= 0 && MaXP < 83;1 RS_GV_MagicLVL.SetValue(1) ElseIf MaXP >= 83 && MaXP < 174;2 If MaLVL < 2 LevelUpSound.Play(Game.GetPlayer()) Debug.Notification("Congratulations! you just advanced a Woodcutting level!") Debug.Notification("You have now reached level 2!") RS_GV_MagicLVL.SetValue(2) EndIf EndIf EndFunction Link to comment Share on other sites More sharing options...
NexusComa Posted December 28, 2018 Share Posted December 28, 2018 You did create the global in the Creation Kit as an [ Int ] global .. correct ?Also may want to use setValueInt and getValueInt ... Link to comment Share on other sites More sharing options...
Rizalgar Posted December 28, 2018 Author Share Posted December 28, 2018 (edited) Hmm, want to say it's set as a float.... Let me check into all that real quick like. Thank you for the replyEdit I also neglected to mention that TripleSixes made the original variables so I've only checked them, but from what I'm getting in the CK it's a float. Edited December 28, 2018 by Rizalgar Link to comment Share on other sites More sharing options...
Rizalgar Posted December 29, 2018 Author Share Posted December 29, 2018 (edited) Now I could just be inept (which is highly possible) but you are referring to the globals in 'Miscellaneous' right? Edit -- Addint the int throws a type mismatch on compile, but only there and not RS_GV_MagicXP.setvalueint(ModMagicXP) here float MagicXP = RS_GV_MagicXP.getvalueint() I'm at a loss. Edited December 29, 2018 by Rizalgar Link to comment Share on other sites More sharing options...
NexusComa Posted December 29, 2018 Share Posted December 29, 2018 (edited) Yep call it a short and try. Also make sure to have a fresh .bsa testing from a fresh save. Int stands for Integer (as in not a float). Just set them as short then use the calls setValueInt and getValueInt ... Edited December 29, 2018 by NexusComa Link to comment Share on other sites More sharing options...
NexusComa Posted December 29, 2018 Share Posted December 29, 2018 This is how I used them in a brew scriptSet as shorts in the CK ... Brew.SetValueInt(1) BrewState=(Brew.getValueInt()) If(BrewState==(1)) only other thing different is i used BrewerStage01 Extends ObjectReference <- not Actor Have no clue if that matters without testing but ya .. Link to comment Share on other sites More sharing options...
Evangela Posted December 29, 2018 Share Posted December 29, 2018 (edited) Usually to avoid problems with setting globals, especially if one tries to set the global right after the value is read(hence threading), modValue is the way to go. Edited December 29, 2018 by Rasikko Link to comment Share on other sites More sharing options...
NexusComa Posted December 29, 2018 Share Posted December 29, 2018 After really looking at that script I'm not sure just why some things are being called. Would have to test it to be sure really don't have the time.I do know global are kind of odd to work with when you call them. Looking at a few old scripts I see I called them direct like this ...if(BrewC.GetValueInt()==(1)) BrewC.SetValueInt(0)EndIfI basically used them as switches or mode indicators in the version of a number ... gl Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 29, 2018 Share Posted December 29, 2018 I do not believe it is a problem of SetValue() or SetValueInt().Probably your script changes won't work on existing games (running quest maybe) or your new script is not embedded right to the Airstrike mod. RS_Spell_AirStrike Scriptname RS_Spell_AirStrike extends ActiveMagicEffect {Script for Air Strike} ; https://forums.nexusmods.com/index.php?/topic/7266151-globalvar-not-setting-through-script/ ; Rizalgar wrote: "I'm having trouble setting the global RS_GV_MagicXP through the script." Globalvariable PROPERTY RS_GV_MagicXP auto Globalvariable PROPERTY RS_GV_MagicLVL auto MiscObject PROPERTY AirRune auto MiscObject PROPERTY MindRune auto Spell PROPERTY AirStrike auto Sound PROPERTY LevelUpSound auto ; - EVENTs -- 2 EVENT OnEffectStart(Actor akTarget, Actor akCaster) IF (akCaster == Game.GetPlayer()) ELSE self.Dispel() RETURN ; - STOP - effect not casted by the player, remove from target ENDIF ;--------------------- myF_Action(akCaster, akTarget) akCaster.DispelSpell(AirStrike) ; this might be the spell of this script effect ENDEVENT EVENT OnEffectFinish(Actor akTarget, Actor akCaster) Debug.Notification("Airstrike effect finished..") ENDEVENT EVENT OnSpellCast(Form akSpell) ; Event received when a spell is cast by this object ;Do Stuff ENDEVENT ; -- FUNCTIONs -- 3 ;------------------------- FUNCTION CheckForLevelUp() ;------------------------- IF (RS_GV_MagicLVL.GetValue() >= 2) RETURN ; - STOP - already level 2 or higher ENDIF ;--------------------- float f = RS_GV_MagicXP.GetValue() IF (f >= 0.0) && (f < 83.0) ; 1 0.0 .. 82.999 RS_GV_MagicLVL.SetValue(1) Debug.Notification("You have now reached level_1") RETURN ; - STOP - ENDIF ;--------------------- IF (f < 174) ; 2 83.0 .. 173.999 RS_GV_MagicLVL.SetValue(2) Debug.Notification("You have reached level_2") Utility.Wait(1.5) ; to give time for reading XP notifications LevelUpSound.Play( Game.GetPlayer() ) Debug.Notification("Congratulations!") Debug.Notification("You just advanced the Woodcutting level!") ENDIF ENDFUNCTION ;----------------------------------------- Float FUNCTION myF_GetDamage_SetGlobalXP() ;----------------------------------------- float g = RS_GV_MagicXP.GetValue() ;* get the current value of this globalVar int r = Utility.RandomInt(2, 48) / 2 ; DamageXP float f = 7.5 + (r as Float) ; modmagicxp, ASExp = 7.5 RS_GV_MagicXP.SetValue(f) ; set new value of this globalVar Debug.Notification("Xp old is " +g) ;* Debug.Notification("Xp has been set to " +f) CheckForLevelUp() RETURN f ENDFUNCTION ;------------------------------------------------ FUNCTION myF_Action(Actor player, Actor akTarget) ;------------------------------------------------ bool bOK = (player.GetItemCount(AirRune) > 0) ; TRUE, if player has at least 1 AirRune in the inventory IF (bOK) && (player.GetItemCount(MindRune) > 0) ; TRUE, if player has at least 1 AirRune and 1 MindRune player.RemoveItem(AirRune, 1, TRUE) player.RemoveItem(MindRune, 1, TRUE) ;============================================= ; Damage Formula ;;; float f = Utility.RandomInt(1, 48) as Float ; replace this with a real damage formula later float f = myF_GetDamage_SetGlobalXP() ;============================================= akTarget.DamageActorValue("Health", f) ELSE player.UnequipSpell(AirStrike, 0) ; left and right hand player.UnequipSpell(AirStrike, 1) Debug.Notification("Cannot cast AirStrike, missing of runes!") ENDIF ENDFUNCTION Link to comment Share on other sites More sharing options...
Rizalgar Posted December 30, 2018 Author Share Posted December 30, 2018 I'm sorry to be late getting back to the party. I really appreciate you guys helping me out here. I got a hold of TripleSixes and he told me how to access his API, which was all I needed to do. Thank you again! Link to comment Share on other sites More sharing options...
Recommended Posts