Jump to content

Photo

Casting random spell from a formlist

formlist creation kit papyrus spell scripting

  • Please log in to reply
2 replies to this topic

#1
Demonman33

Demonman33

    Stranger

  • Members
  • Pip
  • 2 posts

I am making a circlet which gives it's wearer the ability to equip a random spell contained in a formlist. to achieve this I have attached this script to the circlet.

 

 

Scriptname DA_SRPT_RandEnch extends ObjectReference  

 
Formlist Property SpellToEquip Auto
 
 
Event OnEquipped(Actor akActor)
 
Debug.Notification("Event Fired.")
 
int cbstate = akActor.GetCombatState()
 
 
if cbstate == 1
 
int n = SpellToEquip.GetSize() - 1
n = Utility.RandomInt(0, n)
 
akActor.EquipSpell(SpellToEquip.GetAt(n))
 
EndIf
 
EndEvent
 

 

I get an error at akActor.EquipSpell line "akspell and the argument passed to it are incompatible types."

 

Some one please help me understand how do I make it work?

 



#2
ReDragon2013

ReDragon2013

    Old hand

  • Members
  • PipPipPip
  • 542 posts

type casting like this:

akActor.EquipSpell(SpellToEquip.GetAt(n) as Spell)

But imho your way does not really work, have a look to next code for improvement.

 

DA_SRPT_RandEnch

Spoiler

 


Edited by ReDragon2013, 09 August 2020 - 03:32 PM.


#3
Demonman33

Demonman33

    Stranger

  • Members
  • Pip
  • 2 posts

Learned a lot of new things about papyrus script thanks to your elaborate answer. Thank you very much  ReDragon2013 for spending your time to help me.


Edited by Demonman33, 10 August 2020 - 02:22 PM.






Also tagged with one or more of these keywords: formlist, creation kit, papyrus, spell, scripting

Page loaded in: 1.049 seconds