Why doesn't this script work? (Random Int)

Post » Sun Nov 03, 2013 10:50 am

Hello everyone,

I'm currently at the end of my wits with this script. It is part of a script from a spell which creates a magical orb that unleashes one of five possible effects. In order to accomplish that, I scripted this:

Spoiler

int Effect = Utility.RandomInt(0, 100)
Debug.Notification("Random value is" + Effect)
Wait(3)

;---------------DETERMINE EFFECT---------------------

if Effect < 30
ChaosOrbFX.PlaceAtMe(FireExplosion)
ChaosOrbFX.PlaceAtMe(DragonFireballAreaExplosion)
Game.ShakeCamera(afStrength = 1.0)
ElseIf (Effect > 30 && Effect < 60)
ChaosOrbFX.PlaceAtMe(FrostExplosion)
Game.ShakeCamera(afStrength = 1.0)
ElseIf (Effect > 60 && Effect > 90)
ChaosOrbFX.PlaceAtMe(ShockExplosion)
Game.ShakeCamera(afStrength = 1.0)
ElseIf (Effect > 90 && Effect > 95)
_00E_Ability_StaggerSelfSpell.Cast(PlayerREF, PlayerREF)
float PlayerHealth = PlayerREF.GetActorValue("Health")
PlayerREF.ModActorValue("Health", PlayerHealth*0.25)
Game.ShakeCamera(afStrength = 1.0)
ElseIf Effect > 95
ChaosOrbFX.PlaceAtMe(_00E_A2_ChaosOrb_Ultimate, 1)
Game.ShakeCamera(afStrength = 1.0)
EndIf
ChaosOrbFX.MoveTo(Home)

However, nothing happens - None of the If-Expressions are ever returned true. And furthermore, it displays the debug notification twice, each time with a different value for effect. I'm sure it must be something very simple I'm overlooking, but what?

Thanks in advance!

All the best,

Nicolas

User avatar
Katharine Newton
 
Posts: 3318
Joined: Tue Jun 13, 2006 12:33 pm

Post » Sun Nov 03, 2013 2:22 pm

Check the script again, there are several obvious mistakes, i.e. "Effect > 60 && Effect > 90", "Effect > 90 && Effect > 95".
Also if x > 30 elseif x < 30 doesn't handle x == 30, so either of those cases should use <= or >=.

E: :ninja:
User avatar
Chloe Lou
 
Posts: 3476
Joined: Sat Nov 04, 2006 2:08 am

Post » Sun Nov 03, 2013 10:41 am

ElseIf (Effect > 60 && Effect > 90)

ElseIf (Effect > 90 && Effect > 95)

don't make much sense, that'd be just the same as "if >90" and "if > 95".

else, you have like "<60" and ">60", so "=60" is totally ruled out here, make like one ">=60"

and i'd also strongly recommend to go like "if ( ( x > 1 ) && ( y < 1 ) )", so any comparison has it's own paranthesis, so there's no way that like "if effect > 95" gets misinterpreted as "if effect" (true for anything > 0 )

edit: woah, ninjas... :-)

User avatar
claire ley
 
Posts: 3454
Joined: Fri Aug 04, 2006 7:48 pm

Post » Sun Nov 03, 2013 1:06 pm

Jesus, did I really overlook that? Thats probably why I should stick to writing dialogue. Thanks a lot for your help!

User avatar
Heather Dawson
 
Posts: 3348
Joined: Sun Oct 15, 2006 4:14 pm


Return to V - Skyrim