Scripting Trouble: Force an actor to sleep

Post » Tue Jun 19, 2012 9:18 pm

I'm trying to create a spell that creates an invisible sleep marker and then force the target to use it, but so far I have no luck in making it happen. Does anyone have a solution?

Scriptname EGPMagicForceSleepScript extends ActiveMagicEffect  {Creates a sleeping/laydown point at the target and forcesit to use it.}Furniture Property EGPLayDownMarker AutoObjectReference Property LayDownMarker AutoIdle Property LayDownSleep AutoEVENT onEffectStart(Actor akTarget, Actor akCaster)		;akTarget.EnableAI(false)	akTarget.StopCombatAlarm()	;akTarget.EnableAI()			LayDownMarker = akTarget.PlaceAtMe(EGPLayDownMarker)		akTarget.PlayIdleWithTarget(LayDownSleep, LayDownMarker)	;akTarget.Activate(LayDownMarker)EndEVENTEVENT onEffectFinish(Actor akTarget, Actor akCaster)			akTarget.ResetHealthAndLimbs()		akTarget.EvaluatePackage()			LayDownMarker.Disable()		LayDownMarker.DeleteWhenAble()		endEVENT

The script properties are:EGPLayDownMarker/LayDownMarker = Renamed LayDownMakerLayDownSleep = LeftBedRollEnter

Creating the sleepmarker is not a problem, it is forcing the target to use it. Since all that happens is that:
1) Target starts to search for the caster when he/she is hit.
2) Target then returns to previous packade
User avatar
Amy Gibson
 
Posts: 3540
Joined: Wed Oct 04, 2006 2:11 pm

Post » Tue Jun 19, 2012 5:20 pm

You might be running into trouble with the AI packages. Try assigning a sleep package with a high priority to the target with an alias (you'd create a "dummy" quest that moved the target through the phases of the spell. Presumably, you want them to wake up again, so you would clear it at the appropriate stage.)
User avatar
Mélida Brunet
 
Posts: 3440
Joined: Thu Mar 29, 2007 2:45 am

Post » Tue Jun 19, 2012 10:36 pm

Hmmm... Tried with this, but no luck...

Scriptname EGPMagicForceSleepScript extends ActiveMagicEffect  {Creates a sleeping/laydown point at the target and forcesit to use it.}EGPForceSleepSpellQuestScript Property QuestRef AutoQuest Property EGPMyForceSleepSpellQuest AutoReferenceAlias Property Alias_akTarget AutoFurniture Property EGPLayDownMarker AutoObjectReference Property LayDownMarker AutoIdle Property LayDownSleep Auto;Event OnInit()    ;EGPMyForceSleepSpellQuest.Start();EndEventEVENT onEffectStart(Actor akTarget, Actor akCaster)        akTarget.StopCombatAlarm()    akTarget.StopCombat()    akTarget.SetAlert(false)        LayDownMarker = akTarget.PlaceAtMe(EGPLayDownMarker)    EGPMyForceSleepSpellQuest.Start()    Alias_akTarget.ForceRefTo(akTarget)    Alias_akTarget.TryToStopCombat()    Alias_akTarget.TryToMoveTo(LayDownMarker)    Alias_akTarget.TryToEvaluatePackage()EndEVENTEVENT onEffectFinish(Actor akTarget, Actor akCaster)        Alias_akTarget.TryToClear()    EGPMyForceSleepSpellQuest.Stop()            akTarget.ResetHealthAndLimbs()    akTarget.EvaluatePackage()        LayDownMarker.Disable()    LayDownMarker.DeleteWhenAble()        endEVENT

Quest Ref Img is here:
bayimg com / LAmlcAAdo
User avatar
Yvonne
 
Posts: 3577
Joined: Sat Sep 23, 2006 3:05 am

Post » Tue Jun 19, 2012 8:58 pm

Darn.... almost there, but I still can't get the target to break its default packages and use the sleep package. It was SO much easier before, when you could use AddScriptPackage.
User avatar
Red Sauce
 
Posts: 3431
Joined: Fri Aug 04, 2006 1:35 pm

Post » Tue Jun 19, 2012 10:07 am

Why all this? You can just to create AI package and in the script to write only one function EvaluatePackage() or without the script
User avatar
Killer McCracken
 
Posts: 3456
Joined: Wed Feb 14, 2007 9:57 pm

Post » Tue Jun 19, 2012 7:59 am

Have you tried a radiant quest?
  • Create the sleep marker as now
  • Create a keyword
  • Use it to fire SendStoryEvent.
  • In the story manager, defiine a reusable quest under script events
  • Add the actor a quest alias
  • Add the marker as a quest alias
  • Add the new package to the actor alias' package stack, pointing to the marker alias
  • When the action completes, finish the quest and clean up
Ought to work. Probably. On a good day with a following wind, anyway
User avatar
Vicki Gunn
 
Posts: 3397
Joined: Thu Nov 23, 2006 9:59 am


Return to V - Skyrim