Tes3Mod talk:Position

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

"Also, if you PositionCell something you have never met into your current cell then its local script will not start running (until you leave the area and return anyways)."

In some cases this can be a real problem. I tried to write a script that makes an NPC change cell depending on GameHour. For the script is only processed when the player is in the same cell as the calling object is, the NPC only changed to the other cell when the player was in the same cell as the NPC and never appeared in the target cell when time had come.

I found a rather simple way to solve the problem:

instead of using PositionCell x y z zrot "CellID" and attaching the script to my Object (in the mentioned case an NPC) I used object_id->PositionCell x y z zrot "CellID" and made it a global script. It all works fine now.

For showing Details, here is the full source code of the script:


begin my_positioning_script
short Place                ;set to avoid positioning everey frame
;without setting "Place" at leat once the conditions later used might not become true at the same  time
;haven't tried to set it using a "doOnce", but I guess that should work as well (or better (performance issue))
if (CellChanged == 1)
if ( GameHour < 8 )
        set Place to 3
endif
if ( GameHour > 8 )
        if (GameHour < 13 )
                Set Place to 0
        endif
endif
if ( GameHour > 13 )
        if ( GameHour < 18 )
                Set Place to 1
        endif
 endif
If ( GameHour > 18 )
        Set Place to 2
endif
endif
; here the positioning happens
if ( GameHour <= 7.9999 )
   if ( Place == 3 )
                My_NPC_1->PositionCell 5000 4200 15250 270 "Nexurad, Avirr Khans Haus"
                My_NPC_2->PositionCell 3600 4200 14125 0 "Nexurad, Ashravens Haus"
                Set Place to 0
        endif
endif
if ( GameHour >= 8.0000 )
   if ( GameHour <= 12.9999 )
        if ( Place == 0 )
        My_NPC_1->PositionCell 3800 4250 14260 0 "Nexurad, Schule"
        My_NPC_2->PositionCell 4200 4300 13775 270 "Nexurad, Schule"
                Set Place to 1
        endif
   endif
 endif
 if ( GameHour >= 13.0000 )
   if ( GameHour <= 17.9999 )
        if ( Place == 1 )
        My_NPC_1->PositionCell 5400 4800 13500 270  "Nexurad, Schule"
        My_NPC_2->PositionCell 5525 4170 14000 270  "Nexurad, Schule"
                Set Place to 2
        MessageBox "Studi"
        endif
   endif
 endif
 if ( GameHour >= 18.0000 )
        if ( Place == 2 )
                My_NPC_1->PositionCell 5000 4200 15575 0 "Nexurad, Avirr Khans Haus"
                My_NPC_2->PositionCell 3600 4200 14125 0 "Nexurad, Ashravens Haus"
                Set Place to 3
        endif
 endif
 end

Greetings

Marcus

78.52.121.23 09:59, 5 December 2007 (EST)