chr0n0ss Posted February 10, 2004 Share Posted February 10, 2004 Hi, 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_globalcounterlong CCDetect-snip- if ( globalcounterstarted == 0 ) startscript CarDur_moveobj_CCDetectCounter set globalcounterstarted to 1endif if ( CarDur_moveobj_globalcounter < CCdetect ) if ( CarDur_moveobj_globalcounter > -2147483648 ) set state to 0 endif elseif ( ( CarDur_moveobj_globalcounter - CCdetect ) > 1 ) set state to 0endif 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 :D 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... :) Link to comment Share on other sites More sharing options...
Marxist ßastard Posted February 10, 2004 Share Posted February 10, 2004 ...Can anyone here say "Wile E Coyote plan?" To detect if the player is teleporting out of a cell, you don't need a variable that chews up 768 MB of RAM and an arithmetic function on that variable every frame. All you need to do is either disable teleporting or check to see if the PC acquires a spell effect associated with teleportation every half-second. ...And remember, for all your SCUD needs, trust Acme Incorporated. Link to comment Share on other sites More sharing options...
chr0n0ss Posted February 10, 2004 Author Share Posted February 10, 2004 :lol: Uh, okay... a long variable doesn't need so much RAM... but thanks for your input. I've fixed some little issues with the scripts in the meantime and tested if it works, and it does (but Wile's plans never do :P). But I think you're right, it's a bit too cumbersome. Especially for performance reasons, because the surroundings where it would be working in will be well-loaded (many objects with small scripts on them). I'm gonna see. Thanks&Greetings... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.