MSFD Доступные и недоступные объекты
Enable
Disable
"ObjectID"->enable
GetDisabled (returns Boolean/short)
If ( GetDisabled == 1 )
Return
Endif
Функция Disable заставляет объект полностью исчезнуть из игрового мира, т.е. он не рисуется на экране и не обрабатывается (присоединенные скрипты, тем не менее, продолжают работать). Функция Enable делает отключенный (disabled) объект видимым и заставляет его обрабатываться вновь.
GetDisabled (возвращает 1, если объект отключен) может использоваться для выяснения текущего статуса объекта.
Эти функции обладают большими возможностями и могут использоваться, например, для переключения моделей статики (обычный дом заменяется домом, вкопанным в землю, и т.д.) В игре они используются для строительства крепостей.
Пример:
Пример из игры SlaveScript, который заставляет освобожденных рабов исчезать, как только игрок покидает ячейку:
begin slaveScript
short slaveStatus
short doOnce
short NoLore
[другие проверки статуса рабов – смотри оригинальный скрипт!]
if ( slaveStatus == 3 )
if ( GetCurrentAIPackage == 3 )
AIWander 512 0 0 0 0 0 0 0 0 0 0 0
endif
if ( GetItemCount Slave_Bracer_Left > 0 )
Drop Slave_Bracer_Left 1
endif
if ( GetItemCount Slave_Bracer_Right > 0 )
Drop Slave_Bracer_Right 1
endif
if ( CellChanged == 1 )
Disable ;****** Застав.рабов исчезать, когда они свободны и игрок уходит
endif
endif
end slaveScript
Внимание: отключение света
Это, похоже, особенность движка игры с отключением света — актеры и некоторые типы объектов будут продолжать освещаться, тогда как мир вокруг - нет.
Я не особо тестировал, можно ли избежать этого, но подходящее решение — физически перемещать свет в удаленное место (например, на несколько метров ниже пола) вместо его отключения. Другой вариант от Indigo: Если вы включите свет, который поставлен в "negative" (т.е. излучает темноту вместо света) после выключения нормального света, проблемы освещения исчезают.
Note:
When you are in an exterior cell (haven't checked with interiors, but presumably it applies in interiors as well) any object you disable in the loaded cells while you are in that cell will retain its collision properties in the game world until the next time that exterior cell is loaded - i.e. you disable a fence piece through a script where that fence piece is in the same exterior cell as your PC. You still can't walk through the area where the fence piece is disabled until you exit and reenter that exterior cell. Similarly, you subsequently reenable that fence piece that was disabled when your PC entered that exterior cell. You can walk right through that fence piece until the next time that exterior cell is reloaded by the game.
To fix this use the "FixMe" command in your script after you disable or enable a game object that exhibits collision. You should check that you are in the same exterior cell as the game object before you execute the FixMe command - if you aren't you don't need FixMe. This is useful in global scripts that enable or disable objects with references persist so you could be in any cell when the object is enabled or disabled. Using FixMe will cause your PC to also move 128 game units (hardly noticeable in most cases other than as a "stutter") when it executes but since there is no other script command that reloads a cell that is something you will have to live with. Using FixMe will cause the collision to be reset for the cell FixMe reloads so is a way to immediately fix collision on script enabled/disabled objects. (Forum info / Rougetet)