    What's New in ZRP 1.09?

Specific changes are noted below.

This first 1.09 release is experimental, very experimental. 
A lot of changes under the covers were made to streamline the 
loading of the game, the game saves and the alife processing. 
Some of these changes are so extensive that mods added to 
this code base will likely need extensive tweaking to work 
with it. Some backward compatibility is left in the code, but 
many functions don't even take the same arguments, and a few 
assumptions have been made for efficiency as noted below.

In many cases the "constant" variables are replaced with the 
numbers they represent. For example, modules.stype_stalker is 
replaced with 0.

Engine constants are especially "heavy"; they take a long time 
to be fetched during script execution. In some cases they are 
now loaded as early as possible (CLSIDs can change with engine 
versions and modifications, and they are not valid constants 
at game start). 

The references to db.actor are being converted to just actor. 
This global variable will contain the same reference as 
db.actor. In instances where the actor is passed as a function 
parameter in the original game, it may be removed here. Some 
files/functions will be left as is if not used often in the 
game.

One constant that will be replaced over time is the value 
returned by db.actor:id(), which is always 0 in vanilla.

Currently, these changes will be accompanied by the original 
code in a comment. For readability, these comments should not 
be removed from the context if you edit the files.

One unexpected "feature" of faster processing is the exposure 
of race conditions. An example is the way the gulags change 
state. A camp (example: the AW mercs) can switch states from 
"camping" to "attacking" a neighboring enemy (example: the AW 
loner campsite). This is done by changing a number at one 
level (from 0 to 1 or 2 or 3, say) because conditions are right 
for the change (like the number of enemy being large enough). 
At lower levels this can trigger a "defend the camp" task for 
the loner camp, as well as throw every gulag member merc off 
his camping job and then assigning him a new "attack the 
loners" job. The problem here is that the check for "job done" 
is a simple "Is the number of attackers zero?" which said yes 
because the reassignment of attacking jobs wasn't fast enough 
after the merc campers were released from camping.

(In the future I'll consider some sort of immediate transition 
to a different job instead of firing then rehiring in the next 
event loop cycle. --Or even several cycles!)

Previous ZRP optimization occurred mainly at the local code 
level. This version of ZRP is being heavily optimizing at the 
first level above that, looking at reducing system memory usage 
and code execution times. The next major ZRP revision will 
examine and possibly rewrite entire systems. (See the example 
above.)

This version is much lighter in code execution loops and in 
actual game data created. For instance, physical objects that 
don't have an ini function associated with them are no longer 
bound ("binded") by bind_physic_object.script. This keeps 40% 
of physical objects in the Bar level from being stuffed in 
db.storage and updated via update().

And se_zones.script no longer processes anomalies for SANB 
unless they are on the same level. It was checking the entire 
game's 1344 anomalies then rechecking the anomalies for the 
level. It now checks less than a tenth that, even none for a 
couple of levels.

Event loop processing is sped up by avoiding the creation of 
unused debug tables and eliminating irrelevant data from tables 
that are used. So update() functions iterate through smaller 
lists.

Faster initialization of entities also occurs by avoiding 
repetitive checks of the same data. Fetching data from the .ltx 
files originally involved checking if the section was valid and 
if it existed in the .ltx file each time for every related 
field fetched for that section. Now it is validated only once 
for high-usage functions like NPC schemes. See modules.script 
for details on what schemes are used where.

Features are subject to change, based in part on testing and 
feedback.

Changed files are noted in square brackets.  Scripts are in the 
gamedata\scripts\ subdirectory.  You should also review the 
earlier ZRP documentation in the docs\ subdirectory, including 
other ZRP_Changes_*.txt files.



=====================================
Changes in 1.09 XR1 over ZRP 1.07 R5 RC
=====================================
ZRP 1.09 XR1 changes (NatVac and others as noted):

** Bug Fixes:
* Deferred deletion of ammo on NPCs at death to eliminate those 
  NOTFOUND and ge_destroy() log entries in 1.0006. This also 
  prevents the e_parent && e_entity crashes if NPC is reloading 
  when he dies. [death_manager.script]
* Corrected global var of motivation_action_manager() 
  invoked on each evaluator_state_mgr_idle_alife:evaluate() 
  call. (from Alundaio remark) [state_mgr.script]
* Gave player credit for trying if mutants killed Bullet's 
  friend AND the bandits escorting him. [xr_effects.script]
* Changed requirement for adding Yantar->AW level changer; must 
  have Scorcher task first. (Just in case you visit AW first.)
  [zlc.script]
* Removed ZRP legacy reference to the artifact swap program in 
  Skinflint's starting dialog. 
  [config\text\eng\stable_dialogs_military.xml]
* Fixed one more typo in the English localization. (More to 
  come from MrSeyker.) [text\eng\stable_task_manager.xml]
* Added activation of AW bloodsucker respawner after completing 
  Skinflint's bloodsucker task if you first talked to Skinflint
  before talking to Murk. [config\gameplay\dialogs_military.xml]
* Fixed Rostok helicopter explosion sound location.
  [bind_heli.script]
* Removed Murk spot if you killed the bloodsuckers before 
  talking to him after assigned the task by Skinflint.
  [mil_tasks.script]
* Adapted Shadows' outfit workaround so that you are always 
  properly dressed at death or in third-person view, unless 
  you are not to begin with (i.e., not wearing outfit).
  [bind_stalker.script, optional\*\bind_stalker.script]
* Adjusted code to properly handle mobile (mutant) death from 
  unknown causes. [mob_death.script, xr_conditions.script]
* Re-enabled remove_from_ranking() for those newly-dead NPCs 
  that have an assigned story_id (i.e., permabodies).
  [xr_motivator.script, optional\*\xr_motivator.script]
* Made the "rain sound on level change" fix the default. 
  [bind_stalker.script, optional\*\bind_stalker.script]
* Changed type to t_type. (AMK Team via castl)
  [xr_sound.script]
* Fixed wrong default_state_moving state assignments. (castl)
  [move_mgr.script]
* Corrected wrong logic branch references. (castl)
  [config\misc\gulag_escape.ltx]
* Added crash protection if no MM spawn_spots exist for level.
  (Actually didn't crash but corrupted subsequent saves, which 
  pops up a "corrupt save" dialog warning to load earlier save.)
  [_custom_ext_zrp_mm.script]
* Forced accelerated mental deterioration near Red Forest to 
  Pripyat level changer if the scorcher is not disabled. 
  While this transition-without-disabling-scorcher should be 
  allowed, players wouldn't see loner group in Pripyat but task 
  to follow them would still be given. [sr_psy_antenna.script]
* Added a couple of safeguards if insufficient progress 
  attained for an attempted fast-travel. You can no longer jump 
  beyond a closed Garbage Duty blockpost gate, and you are no 
  longer allowed to quick-jump to Pripyat level changer in 
  Red Forest if psy emissions are still present, which would 
  kill you as of this release. [ui_level_zip_dialog.script]
* Added a precautionary Esc J jump to Arnie if post-arena-match 
  timer somehow fails. [ui_level_zip_dialog.script]
* Checked for invalid game_vertex_id which might be one cause 
  of "there is no specified level in the game graph" errors. 
  This test may need to be deployed in other locations; please 
  report if you still get the error. [smart_terrain.script]
* Added a missing alarm state to val_lager_bandit kamp3. 
  [gulag_dark_valley.script]

** Tweaks:
* Changed use of engine clsid table to speed up functions that 
  use it. Modified other scripts to use the new global vars.
  [_g.script, anomaly_holder.script, bind_monster.script, 
  death_manager.script, gulag_dark_valley.script, 
  gulag_pripyat.script, smart_terrain.script, 
  task_manager.script, xr_conditions.script, xr_gulag.script, 
  xr_logic.script, z.script, zx.script, et alia]
* Moved "is this dead body new" check from death_manager.script 
  to xr_motivator.script to eliminate unneeded instances of the 
  drop manager. [death_manager.script, xr_motivator.script]
* Revised medkit drop (to heal NPCs) to use simpler medkit 
  release code in _dev.script. Also prevented the act of 
  storing medkits on bodies from healing nearby NPCs. 
  [_dev.script, _z.script]
* Adjusted NPC healing on master difficulty in dialog-based 
  normal medkit transfer; was only 60%, now 100%.
  [xr_wounded.script]
* Simplified level_tasks.proceed() to only call proceed() 
  function for current level. [level_tasks.script]
* The PDA has been updated a bit, although it is still a work 
  in progress. (MrSeyker, NatVac) [config\ui\*.xml]
* More optimizations and general clean-up.
  [xr_logic.script, most xr_*.script files, state_mgr_*.script]
* Removed zombie combat support for non-zombie NPCs. This could 
  break some zombifying mods; remove conditional check for 
  zombied to reenable support if needed. [xr_combat.script]
* Adjusted stealth tweak for neutrals and friends. If you kill 
  one silently but you are seen doing it or are within a 
  certain distance of his associate, you are still marked as 
  his cold-blooded killer. [xr_death.script]
* Tweaked the secrets text. [text\eng\stable_task_manager.xml]
* Added ZaGaR's fonts.ltx for better widescreen support.
  Optional; see Modifier changes. [config\fonts.ltx]
* Weakened MonoMartyrs a bit. [config\creatures\m_stalker.ltx]
* Commented out more loaded but unused code.
  [dialogs_military.script, se_stalker.script, utils.script]
* Made the attachment of grenade launcher and scope to the 
  G36/GP37 optional, non-default. See Modifier changes below.
  [config\weapons\w_g36.ltx]
* Moved db.sound table to xr_sound.db_sound for faster access 
  by the only script that really uses it.
  [sound_theme.script, xr_sound.script]
* Removed more unused sound themes from the theme table. 
  Streamlined sound loading. [sound_theme.script]
* Disabled loaded but unused TalesManager class. 
  [xr_patrol.script]
* Commented out unused stories and legends and reactions. 
  [config\misc\script_sound.ltx, optional\script_sound.ltx.ncc]
* Reworked xr_info.script to avoid creating and populating new 
  encyclopedia/story tables for each NPC. [xr_info.script]
* Stopped se_zones.script from processing all anomalies for 
  SANB, now just processes those for the current level if any. 
  Eliminated need for anomaly_holder.script. [se_zones.script, 
  anomaly_evader.script, anomaly_holder.script]
* Disabled config file processing by se_zones.script. The 
  update() functions are never called, so the loaded values 
  were never used. There are debug statements in the update() 
  code that will tell you if it starts working. (Yes, this 
  means artifact spawning occurs only at new game creation -- 
  it's an engine problem.) [se_zones.script]
* Tightened up code, eliminated unnecessary parameter passing, 
  absorbed functions into other scripts where practical.
  [mob_*.script, ph_*.script, sr_*.script, xr_*.script, etc.]
* Removed ten more unused or obsolete schemes, reworked code 
  to avoid loading otherwise-useless schemes. 
  [modules.script, above *.script]
* Reduced use of tables in db.script that were apparently 
  meant for debugging. Moved other tables to the only users. 
  [db.script, bind_physic_object.script, xr_sound.script]
* Changed add_to_binder() functions to add_to_binder_q() with 
  three fewer parameters since they were unused in all schemes. 
  NOTE that this change makes many AI mods incompatible with 
  the new approach until they are likewise adapted.
  [mob_*.script, ph_*.script, sr_*.script, xr_*.script, some
  optional\ scripts including xrs_*.script files]
* Set global 'actor' variable to db.actor value when defined. 
  Changed a lot of files to use it already. (Don't change 
  db.actor_proxy users.) [*.script]
* Made xr_spawner.script obsolete. Its check_spawn() was 
  rewritten and moved into the only two users of the function. 
  [se_car.script, se_monster.script, xr_spawner.script]
* Eliminated a populated but unused table in se_item.script.
  [se_item.script]
* Eliminated the loading of an otherwise-unused class set 
  (ce_switcher, se_switcher). This does change the numbering 
  of the CLSIDs, which is not a problem in vanilla/ZRP. 
  [class_registrator.script]
* Added a new support function for those who repeatedly start 
  new games to permit them to configure that new game somewhat 
  one the fly. See _custom_ext.script's new_game_tweaks()
  function. [bind_stalker.script, _custom_ext.script]

Modifier configuration changes (MrSeyker and NatVac):
* NPC Death Crash fix can be disabled/enabled.
  [modcfg\Experimental.cfg]
* G36/GP37 attachments can be enabled/disabled, its time_to_aim 
  can be adjusted. [modcfg\Weapons.cfg]
* Ft-200m/FN F2000 can have silencer with choice of silenced 
  shot sounds and its time_to_aim can be adjusted.
  [modcfg\Weapons.cfg]
* The "tagging" feature of binoculars can be disabled/enabled.
  [modcfg\_ZRP.cfg]
* Unique weapons can drop in perfect condition. Same tweak, 
  it just uses a different way to do it under the covers.
  [modcfg\_ZRP.cfg]
* The bleeding reduction provided by medkits can be tweaked.
  [modcfg\Tweaks.cfg]
* ZaGaR's fonts.ltx can be disabled for that vanilla 
  unreadability. [modcfg\Vanilla.cfg]
* Added movement dispersion adjustment to the actor difficulty 
  settings. [modcfg\Actor.cfg, Actor.cfg.txt]
* Added note on "bullet sponges". [FirstPersonShooter.cfg.txt]
* Updated Experimental AI configuration to accommodate changes 
  in AI scripts. [modcfg\Experimental_AI.cfg]
* Updated Sound Management configuration to accommodate changes 
  in sound table initialization. Removed simple NCC version; 
  use either NCC or vanilla sound. [modcfg\SoundManagement.cfg]
* New marking script: Mark Local. Works the same as Mark by 
  Partial Name except it only marks entities on the same level. 
  It also detects and removes objects with bad game vertex ids. 
  ["Mark NPCs and Items" entry for modcfg\SupportUtilities.cfg]

Debug changes (NatVac):
* Macro processing can now take place while debug information 
  like coordinate data or variable watch is actively displayed. 
  This permits the direct removal of the variable watch via 
  macro hotkey and better supports debugging functions.
  [_z.script, ui_main_menu.script]
* As part of the change above, the debugging information is now 
  toggled on or off via Esc D D. [_z.script]
* The z.jump(distance,height) function now uses the y component 
  of device().cam_dir as the default height adjustment if no 
  height is provided. The value of device().cam_pos.y is added 
  to cam_dir.y * distance to adjust for the height of your eyes 
  from the ground. So you can now jump to that roof in the 
  distance by turning on crosshairs, enabling "show distance" 
  in Options, then look exactly where you want to go, note the 
  distance, and without moving press Esc Z X and click in the 
  edit box. Then type "z.jump(the_distance)" (without quotes, 
  replacing the_distance with the distance you noted) and press 
  Enter to instantly teleport there. Requires ZSU enabled and 
  Execute Script Command installed. [z.script]
* A missing or invalid modules.script or scheme script file no 
  longer quits to desktop requiring the user to look at the 
  log file. It now reports the problem on the lower left of 
  the main menu and shows more info when you quit, just like a 
  bad/missing _z.script did. This will help you debug schemes. 
  [_g.script, modules.script, ui_main_menu.script]
* The zx.grab_remote_body_property() function now also works 
  in the same way as a direct search by checking for any info 
  on the body. The "smart heal" routine is a little smarter. 
  [zx.script]
* Added debug function to detect and remove entities with bad 
  game vertex values like left-over m_phantom ghosts in Red 
  Forest. [z_mark_local.script; see Modifier changes.]
* Updated some z.script functions to perform faster. You can 
  now use one of the z.this_*() functions in Variable Watch 
  with very little impact on framerate. [z.script]

All.spawn changes/fixes since R5RC -- these require a new 
game, but are not critical so existing saves are okay:
* Delayed the first bandit replacements for the Cordon auto 
  park until after you help Fox or go to the Garbage.
  [alife_l01_escape.ltx]
* Renamed Garbage's gar_zone_mincer to gar_zone_mincer_weak to 
  avoid name conflict with Pripyat's gar_zone_mincer in the 
  stadium. [alife_l02_garbage.ltx]
* Separated two metal cases that occupied the same space near 
  Chef. Moved one to the floor nearby. [alife_l07_military.ltx]
* Reworked Chef's freezer to keep it from moving and moved the 
  freezer and cans of Tourist Delight, etc. back into the SW 
  corner. [alife_l07_military.ltx]
* Locked the X18 refrigerator down. These chillers should not 
  "walk" when you open them. [alife_l04u_labx18.ltx]
* Fixed missing gunfire sr_sound in Duty vs. Freedom battle 
  after X19 in Red Forest. [alife_l10_radar.ltx]
