morrowind1979 Posted February 14, 2019 Share Posted February 14, 2019 So as the title says I am trying to make a magic effect randomly play one of 3 different sounds each time it is cast. I am struggling with the random papyrus function. This is far as I can get but it isnt playing any sound when the spell is cast. Any help would be appreciated. Thanks: Scriptname NSShadowFlareScript extends activemagiceffect Sound Property MSFS1 Auto Sound Property FSFS1 Auto Sound Property MSFS2 Auto Sound Property FSFS2 Auto Sound Property MSFS3 Auto Sound Property FSFS3 Auto EVENT OnEffectStart(Actor akTarget, Actor akCaster) int random = Utility.RandomInt() If (Game.GetPlayer().GetActorBase().GetSex() == 0) If random <= 33 MSFS1.play(Game.GetPlayer()) ElseIf random <= 67 MSFS2.play(Game.GetPlayer()) ElseIf random <= 100 MSFS3.play(Game.GetPlayer()) EndIf ElseIf (Game.GetPlayer().GetActorBase().GetSex() == 1) If random <= 33 MSFS1.play(Game.GetPlayer()) ElseIf random <= 67 MSFS2.play(Game.GetPlayer()) ElseIf random <= 100 MSFS3.play(Game.GetPlayer()) EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
SeraphimKensai Posted February 14, 2019 Share Posted February 14, 2019 Not the random part, but I would drop an actor property with a PlayerRef and use that instead of all that Game.GetPlayer, as it will fire faster than having to reference the game script multiple times. Link to comment Share on other sites More sharing options...
morrowind1979 Posted February 14, 2019 Author Share Posted February 14, 2019 Not the random part, but I would drop an actor property with a PlayerRef and use that instead of all that Game.GetPlayer, as it will fire faster than having to reference the game script multiple times.Everyone says that but in reality it actually makes no difference at all. You can use Game.GetPlayer() fine as many times as u like Link to comment Share on other sites More sharing options...
morrowind1979 Posted February 14, 2019 Author Share Posted February 14, 2019 Finally got it working using the following script. The answer was staring me right in the face all I had to do was simplify the random utiliy: Scriptname NSShadowFlareScript extends ReferenceAlias Sound Property MSFS1 Auto Sound Property FSFS1 Auto Sound Property MSFS2 Auto Sound Property FSFS2 Auto Sound Property MSFS3 Auto Sound Property FSFS3 Auto SPELL Property SFS Auto Actor Property PlayerRef Auto Event OnSpellCast(Form akSpell) int random = Utility.RandomInt(0,2) If akSpell == SFS If (PlayerRef.GetActorBase().GetSex() == 0) If random == 0 MSFS1.play(PlayerRef) ElseIf random == 1 MSFS2.play(PlayerRef) ElseIf random == 2 MSFS3.play(PlayerRef) EndIf ElseIf (PlayerRef.GetActorBase().GetSex() == 1) If random == 0 FSFS1.play(PlayerRef) ElseIf random == 1 FSFS2.play(PlayerRef) ElseIf random == 2 FSFS3.play(PlayerRef) EndIf EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
SeraphimKensai Posted February 15, 2019 Share Posted February 15, 2019 Glad it's working. I'm curious what kind of spell your making having random casting sounds based on player gender though. Are we talking some kind of incantations or such (which would be pretty cool btw). Link to comment Share on other sites More sharing options...
morrowind1979 Posted February 15, 2019 Author Share Posted February 15, 2019 Its my custom races racial power, Shadow Flare. Whenever they cast it plays a random line of dialogue. I.e "This land is ours!" so I need sound files for both male and female Link to comment Share on other sites More sharing options...
SeraphimKensai Posted February 15, 2019 Share Posted February 15, 2019 Ah gotcha. I'll have to check it out at some point when I get some time to play. Link to comment Share on other sites More sharing options...
subhuman0100 Posted February 28, 2021 Share Posted February 28, 2021 Yep, two year old post. But it caught my eye on a late-night meandering... Event OnSpellCast(Form akSpell) if akSpell == SFS string racket = "MSFS" if PlayerRef.GetActorBase().GetSex() racket = "FSFS" endIf racket += Utility.Randomint(1, 3) as string racket.Play(PlayerRef) endIf endEvent Link to comment Share on other sites More sharing options...
Recommended Posts