Jump to content

How to find cast target type?


Recommended Posts

Trying to get into papyrus, I want to make a spell that specifically targets clutter items, but before getting into the script it has to target the right object in the first place. the items I currently have in mind are conveniently grouped under Items/MiscItem/Clutter in the CK so I imagine there should be a way to find out if they are "clutter"

 

I hope that made sense and thank you in advance.

Edited by urumizawa
Link to comment
Share on other sites

Do you mean target loose items in the world? If so you can use the game function FindRandomReferenceOfAnyTypeInListFromRef. Put your misc items to search for in a formlist. In your script, have it cast the actual spell if an object is found:

 

Formlist Property MyMiscItems Auto 
Spell Property MySpell Auto 

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    ObjectReference MiscRef = Game.FindRandomReferenceOfAnyTypeInListFromRef(MyMiscItems, akCaster, 1000.0)
    ;find a random ObjectReference that's in the MyMiscItems list within a 1000 unit radius from the caster. 
    
    If MiscRef != None 
        MySpell.Cast(akCaster, MiscRef) ;Caster of this spell casts MySpell on the miscRef 
    Else 
        ;misc ref not found 
    Endif 
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...