[script] the plague, works but needs refinement

Post » Sat Nov 17, 2012 4:40 am

What I'm trying to do is give NPCs around me a Spell (plague).
I've got a script that works but i need a little help refining it to work more fluidly and possibly more efficiently.

Scriptname plagueTestScript extends QuestSpell property plagueSpell autoEvent OnInit()Debug.MessageBox("You've got the plague.")RegisterForSingleUpdateGameTime(0.03)endEventEvent OnUpdateGameTime()Actor randomActor = Game.FindRandomActorFromRef(Game.GetPlayer(), 500)while (randomActor.HasSpell(plagueSpell))randomActor = Game.FindRandomActorFromRef(Game.GetPlayer(), 500)endWhilerandomActor.AddSpell(plagueSpell , false)Debug.Notification("A new actor has the plague")RegisterForSingleUpdateGameTime(0.03)endEvent

Problems with this script so far:
  • Walking into a group of people causes 1 person to get the plague and then there is a wait for the next UpdateGameTime before someone else can get it. (I have consider just putting in 10 FindRandomActorFromRef lines with 10 proceeding while loops, thoughts?)
  • For system efficiency reasons, I want to avoid such a fast RegisterForSingleUpdateGameTime.
  • Game.FindRandomActorFromRef(Game.GetPlayer(), 500) sometimes returns the player, an obviously inefficient roll of the dice.
For demonstration im referring to this script as a plague because conceptually it makes sense. But in reality it's for NPCs in my Get http://skyrim.nexusmods.com/mods/19660, a feature a lot of people are requesting. --- That said, i'll probably release a plague mod separately, maybe to do with Peryite - The Daedric Prince of Pestilence :smile:
User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am

Post » Sat Nov 17, 2012 2:02 am

http://www.creationkit.com/Dynamically_Attaching_Scripts is the best way to attach abilitys/scripts to many actors. No need of a quest.
User avatar
Ladymorphine
 
Posts: 3441
Joined: Wed Nov 08, 2006 2:22 pm

Post » Sat Nov 17, 2012 5:21 am

That seems awesome, thanks for the link! Now if only I could find time to implement it.
User avatar
Caroline flitcroft
 
Posts: 3412
Joined: Sat Nov 25, 2006 7:05 am


Return to V - Skyrim