Scheduling scripts for NPCs

Post » Wed Aug 07, 2013 10:20 pm

I have been trying to do some script testing using Max a.k.a. ~NOOBDY~'s MWScheduler program.

I generated a simple script to:

enable her at 8 AM, set her to wander
disable her at 11 AM(lunch)
enable her at 12PM to wander
disable her at 6PM (dinner)
enable her to wander at 7PM
disable her for sleep at 9PM

below is the script generated by MWScheduler.

Begin eldafire_sched_sc_01

Short mwc_hour
Short mwc_last

If ( MenuMode )
Return
EndIf

Set mwc_hour to GameHour
If ( mwc_last == mwc_hour )
Return
ElseIf ( "eldafire"-> GetHealth <= 0 )
Return
EndIf

If ( mwc_hour == 8 )
Set mwc_last to 8
If ( "eldafire"-> GetLOS Player != 1 )
"eldafire"-> Enable
EndIf
"eldafire"-> AIWander 512, 3, 10, 10, 10, 10, 10, 10, 10, 10, 10
ElseIf ( mwc_hour == 11 )
Set mwc_last to 11
If ( "eldafire"-> GetLOS Player != 1 )
"eldafire"-> Disable
EndIf
ElseIf ( mwc_hour == 12 )
Set mwc_last to 12
If ( "eldafire"-> GetLOS Player != 1 )
"eldafire"-> Enable
EndIf
"eldafire"-> AIWander 512, 6, 10, 10, 10, 10, 10, 10, 10, 10, 10
ElseIf ( mwc_hour == 18 )
Set mwc_last to 18
If ( "eldafire"-> GetLOS Player != 1 )
"eldafire"-> Disable
EndIf
ElseIf ( mwc_hour == 19 )
Set mwc_last to 19
If ( "eldafire"-> GetLOS Player != 1 )
"eldafire"-> Enable
EndIf
"eldafire"-> AIWander 512, 2, 10, 10, 10, 10, 10, 10, 10, 10, 10
ElseIf ( mwc_hour == 21 )
Set mwc_last to 21
If ( "eldafire"-> GetLOS Player != 1 )
"eldafire"-> Disable
EndIf
EndIf


End



I have attached this script to a saved version of the door to her house.

The script does not seem to run. Does it have to get called. The readme stated it could be attached to any object in the same cell.

Any hints on how to get this to work would be appreciated.

User avatar
jess hughes
 
Posts: 3382
Joined: Tue Oct 24, 2006 8:10 pm

Post » Wed Aug 07, 2013 10:37 pm

I don't think there's anything wrong with your script--I got a slightly modified version working (I removed the LOS thing so I could stare at her and see if she vanished, and attached it to some door in Seyda Neen):

Spoiler
Begin eldafire_sched_sc_01 Short mwc_hourShort mwc_last If ( MenuMode )      ReturnEndIf Set mwc_hour to GameHourIf ( mwc_last == mwc_hour )      ReturnElseIf ( "eldafire"-> GetHealth <= 0 )       ReturnEndIf If ( mwc_hour == 8 )       Set mwc_last to 8       "eldafire"-> Enable       "eldafire"-> AIWander 512, 3, 10, 10, 10, 10, 10, 10, 10, 10, 10ElseIf ( mwc_hour == 11 )       Set mwc_last to 11       "eldafire"-> DisableElseIf ( mwc_hour == 12 )       Set mwc_last to 12       "eldafire"-> Enable       "eldafire"-> AIWander 512, 6, 10, 10, 10, 10, 10, 10, 10, 10, 10ElseIf ( mwc_hour == 18 )       Set mwc_last to 18       "eldafire"-> DisableElseIf ( mwc_hour == 19 )       Set mwc_last to 19       "eldafire"-> Enable       "eldafire"-> AIWander 512, 2, 10, 10, 10, 10, 10, 10, 10, 10, 10ElseIf ( mwc_hour == 21 )       Set mwc_last to 21       "eldafire"-> DisableEndIf  End

The only problem seems to be that it's kinda twitchy about how it triggers. The way it is written she will only go to bed if the player is in the cell at exactly 9. If the player enters Seyda Neen at midnight, she'll still be out and about, so you might want to edit it so that she disables for any nighttime hour and enables for any daytime hour except lunch and such.. And I don't really know how that LOS function works, which is one of the reasons I just removed it.

User avatar
Your Mum
 
Posts: 3434
Joined: Sun Jun 25, 2006 6:23 pm

Post » Wed Aug 07, 2013 9:19 pm

I think this would make her dissappear from 9PM to 8Am, whether or not you arrived at 9PM or not.

Begin eldafire_sched_sc_01 Short mwc_hourShort mwc_last If ( MenuMode )      ReturnEndIf Set mwc_hour to GameHourIf ( mwc_last == mwc_hour )      ReturnElseIf ( "eldafire"-> GetHealth <= 0 )        ReturnEndIf If ( mwc_hour >= 21 )       Set mwc_last to GameHour       If ( "eldafire"-> GetLOS Player != 1 )       "eldafire"-> Disable       EndIfElseIf ( mwc_hour >= 19 )       Set mwc_last to GameHour       If ( "eldafire"-> GetLOS Player != 1 )              "eldafire"-> Enable       EndIf       "eldafire"-> AIWander 512, 2, 10, 10, 10, 10, 10, 10, 10, 10, 10ElseIf ( mwc_hour >= 18 )       Set mwc_last to GameHour       If ( "eldafire"-> GetLOS Player != 1 )       "eldafire"-> Disable       EndIfElseIf ( mwc_hour >= 12 )       Set mwc_last to GameHour       If ( "eldafire"-> GetLOS Player != 1 )              "eldafire"-> Enable       EndIf       "eldafire"-> AIWander 512, 6, 10, 10, 10, 10, 10, 10, 10, 10, 10ElseIf ( mwc_hour >= 11 )       Set mwc_last to GameHour       If ( "eldafire"-> GetLOS Player != 1 )       "eldafire"-> Disable       EndIfElseIf ( mwc_hour >= 8 )       Set mwc_last to GameHour       If ( "eldafire"-> GetLOS Player != 1 )              "eldafire"-> Enable       EndIf       "eldafire"-> AIWander 512, 3, 10, 10, 10, 10, 10, 10, 10, 10, 10Else       Set mwc_last to GameHour       If ( "eldafire"-> GetLOS Player != 1 )       "eldafire"-> Disable       EndIfEndIf  End

Also corrected updating of mwc_last, for optimization.

Not Tested, but should work.

User avatar
Kieren Thomson
 
Posts: 3454
Joined: Sat Jul 21, 2007 3:28 am


Return to III - Morrowind