Jump to content

CK Shortcut - Adding Script to Actors


Recommended Posts

Hi, I have a script that I require each "Human" actor to run OnLoad. Its pretty cumbersome to manually add a script to every human actor in the CK (given there are hundreds). I've tried to look up some workarounds, most of the examples I've seen don't quite hit the mark. The script compares forms in the actor's inventory to a formlist and equips or unequips any matches based on conditional statements. This is preferably done before the Player is within the immediate vicinity (for visual consistency)

 

TL:DR - Are there any simple ways I can add a script to every raceHuman actor without manually adding the script to each actor?

Link to comment
Share on other sites

I'm actually not adding forms to the actors themselves, they currently already have the items I am checking against (Gasmasks) but I do need to check against the Gasmasks' forms to determine whether it is or isn't in the actors inventory. Formlist of GasMasks [ i ] -> Actor has this GasMask? -> Equip

 

This isn't the most efficient method because it has to run through the form list for every actor encountered, but since I can't get access to the items in their inventory directly it's my workaround. Will FindRandomActor find a new actor on each call or do I need to filter it as the actors are found?

Link to comment
Share on other sites

Can I filter FindRandomActor in some way? Doesn't seem like I would be able to control how I get "fresh" actors. Do you know if Actors who inherit a template will inherit corresponding scripts?

Edited by D1v1ne122
Link to comment
Share on other sites

If actors are based off a template actor, they should inherit the template actor's scripts. And there is no way to filter FindRandomActor directly, since it is a native function and it doesn't offer any built-in filtering capabilities. There are certainly other methods to find nearby actors (such as using a cloak spell AoE) but using FindRandomActor is much less complicated to implement.

Link to comment
Share on other sites

After reviewing the RegisterForUpdate I realized Timers have replaced it, problem fixed:)

 

 


I'm setting up an Alias Quest to apply scripts to actors, and an Update Quest to refresh and apply to additional actors.

I've run into an error while trying to use RegisterForUpdate(1.0) on a papyrus fragment. This calling a new instance of the quest that will attach scripts to 4 additional actors.

Error: ...\Quests\QF_GasMask_UpdateQuest_02002E44.psc(7,0): RegisterForUpdate is not a function or does not exist

Any suggestions?

I'm following this example: Link

 

Edited by D1v1ne122
Link to comment
Share on other sites

  • Recently Browsing   0 members

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