does anyone have experience when exactly the CellChanged function returns true?
I've read (Morrowind scripting for dummies 5) that this is not the case if the PC "teleports" out of the cell. But teleporting is the only way out of a cell - doors do that too, don't they?
I've tried player->position and coc, they don't cause CellChanged returning true. What about spells or maybe other functions that teleport, will they cause CellChanged == 1?
Did anyone of you encounter this problem and fixed it? My attempt, not yet thoroughly tested, consists of a global counter script that is started if the player enters the cell:
---
begin CarDur_moveobj_CCDetectCounter
; global long CarDur_moveobj_globalcounter
set CarDur_moveobj_globalcounter to CarDur_moveobj_globalcounter + 1
end
---
In the script that uses CellChanged, I put this code:
---
-snip-
short globalcounterstarted
; global long CarDur_moveobj_globalcounter
long CCDetect
-snip-
if ( globalcounterstarted == 0 )
startscript CarDur_moveobj_CCDetectCounter
set globalcounterstarted to 1
endif
if ( CarDur_moveobj_globalcounter < CCdetect )
if ( CarDur_moveobj_globalcounter > -2147483648 )
set state to 0
endif
elseif ( ( CarDur_moveobj_globalcounter - CCdetect ) > 1 )
set state to 0
endif
set CCdetect to CarDur_moveobj_globalcounter
-snip-
---
My thoughts behind this are:
- The global timer is incremented one step every frame
- The cell-bound script tests if the global counter indicates more than one frame in between since its last run, and then saves the global counter value for the next frame (to CCdetect)
- The global counter could overflow. To intercept this case, the script tests if its saved counter value is bigger than the global - if yes, it tests if the global counter value is -2.147.483.648, which should be the lowest value for a signed long integer.
- The only case that could break this fix is if the player teleports out of the cell, waits so that the counter overflows and reaches the same value as before, and in exactly *this* frame he must come back to the cell so that the counter difference is 1. But this waiting time is AFAIR about 2 years
I'm reflecting if this global counter and constant testing effort is worth it...
Does this script system look performance lowering to you? Any suggestions how it could be done better?
Regards&TIA...