Get spell from FormList?

Post » Wed Jun 20, 2012 9:43 am

Hi.

I tried to be clever to make a big list of spells in order easily pick a more powerful one, if the player's level got higher. Here's my code (the relevant part):

FormList property HT_ListTrapPoison autospell property HT_SpellTrapPoison auto;================================================================int worldlevel = CalculateEncounterLevel(0)int index = worldlevel/10   ; My idea here is that for every ten levels the player has; increase the level of the spell (max 100:10, min 10:1)if index < 0  index = 1elseif index > 9  index = 10endif;HT_SpellTrapPoison = HT_ListTrapPoison.GetAt(index)    ; This gives me compilation error. I made this line a comment; then I could save my scriptDebug.Notification(HT_SpellTrapPoison)if canDisease  HT_SpellTrapPoison.cast(myTarget, myTarget)endif;================================================================

Is there any way I can grab the info out of my form list and assign it to my "HT_SpellTrapPoison" property?
User avatar
Bethany Watkin
 
Posts: 3445
Joined: Sun Jul 23, 2006 4:13 pm

Post » Wed Jun 20, 2012 2:38 pm

Hi there. HT_SpellTrapPoison does not necessarily need to be a property. Declaring it as "Spell HT_SpellTrapPoison" should be sufficient.

But now the actual problem: Elements get stored as a Form inside a FormList (hence the name ;)), though every Spell is a Form not every Form is a spell. What you need to do is append "as Spell" after the call to GetAt() to cast the returned object from a Form to a Spell. Like this:

HT_SpellTrapPoison = HT_ListTrapPoison.GetAt(index) as Spell
User avatar
Marina Leigh
 
Posts: 3339
Joined: Wed Jun 21, 2006 7:59 pm

Post » Wed Jun 20, 2012 6:42 am

Hi there. HT_SpellTrapPoison does not necessarily need to be a property. Declaring it as "Spell HT_SpellTrapPoison" should be sufficient.

But now the actual problem: Elements get stored as a Form inside a FormList (hence the name :wink:), though every Spell is a Form not every Form is a spell. What you need to do is append "as Spell" after the call to GetAt() to cast the returned object from a Form to a Spell. Like this:

HT_SpellTrapPoison = HT_ListTrapPoison.GetAt(index) as Spell

Thanks for your reply.
I actually figured that out on my own just now, and it works. I guess I was clever afterall. :P

Anyway I noticed a new problem:
"CalculateEncounterLevel(0)" doesn't work as I intended. For example: If player level = 11, index ~ 4. player level = 22; index ~ 7.
-Is there a better way to get the level of the player and (most of) the stuff around him/her?
User avatar
jadie kell
 
Posts: 3497
Joined: Sat Jul 29, 2006 3:54 pm

Post » Wed Jun 20, 2012 2:10 pm

Game.GetPlayer().GetLevel() should return the exact player's level. Also GetLevel() can be called on any actor (NPCs, Creatures) to get theri Level aswell.
User avatar
Isabel Ruiz
 
Posts: 3447
Joined: Sat Nov 04, 2006 4:39 am

Post » Tue Jun 19, 2012 11:29 pm

Game.GetPlayer().GetLevel() should return the exact player's level. Also GetLevel() can be called on any actor (NPCs, Creatures) to get theri Level aswell.

I was hoping there were some kind of "rounded calculation of all actors levels in the cell"?

I tried "Game.GetPlayer().GetLevel()" it works pretty well actually.
FormLists are what property arrays should've been.
User avatar
Robert Devlin
 
Posts: 3521
Joined: Mon Jul 23, 2007 2:19 pm


Return to V - Skyrim