Skip to content

Mod adaptation

PRXPHET edited this page May 27, 2025 · 1 revision

Here are the main problems that can be encountered when adapting mods, as well as the edits that need to be made for various elements to work.

Scripts

  • You have to replace it in the scripts:
_g -> _G -- This ingenious way of accessing global space you can find, for example, in some AMK scripts. It is not excluded that somewhere else. It should not be done this way at all, because when accessing _g, _g.script was loaded again, which is not known what could lead to. We have removed this, because the global space should be initiated by the engine only once after the start of Lua. If you try to access _g, it will crash.

4294967296 -> 4294967295 -- invalid vertex_id/story_id, maybe something else. I have no idea why 4294967296 is used, but it was like that in a bunch of scripts.
255 -- NO_ACTIVE_SLOT for :activate_slot(...) and other methods accepting slot number. These methods used to accept u32 (so 4294967295), now they accept u8. Also, -1 should not be passed there either. It is 255.
  • Sometimes in scripts clsid is directly compared to numbers. This won't work here.

Here is a simple example of code that won't work correctly:

function get_anoms(npc, radius) 
 local anoms = {} 
 local pos = npc:position() 
 for i= 1, 65534 do 
  local obj = level.object_by_id(i) 
  if obj ~= nil and obj:clsid() >= 168 and obj:clsid() <= 181 then 
   local dist = pos:distance_to(obj:position()) 
   if dist < radius then 
    table.insert(anoms, obj) 
   end 
  end 
 end 
 return anoms 
end

And this is the correct code:

function get_anoms(npc, radius) 
 local anomaly_classes = {
  [clsid.zone_acid_fog] = true,
  [clsid.zone_bfuzz] = true,
  [clsid.zone_bfuzz_s] = true,
  [clsid.zone_dead] = true,
  [clsid.zone_galant_s] = true,
  [clsid.zone_galantine] = true,
  [clsid.zone_mbald_s] = true,
  [clsid.zone_mincer] = true,
  [clsid.zone_mincer_s] = true,
  [clsid.zone_mosquito_bald] = true,
  [clsid.ameba_zone] = true,
  [clsid.zone_rusty_hair] = true,
  [clsid.torrid_zone] = true,
  [clsid.zone_radioactive] = true
 }

 local anoms = {} 
 local pos = npc:position() 
 for i= 1, 65534 do 
  local obj = level.object_by_id(i) 
  if obj and anomaly_classes[obj:clsid()] then 
   local dist = pos:distance_to(obj:position()) 
   if dist < radius then 
    table.insert(anoms, obj) 
   end 
  end 
 end 
 return anoms 
end

Controller aura

Add to the controller's config:

;------------------------------------------------------------------------
; Influences
;------------------------------------------------------------------------
psy_linear_factor        =    1.0 ;1.5
psy_quadratic_factor    =    0
psy_max_distance        =    25 ;33.0
psy_max_power            =    6.4
psy_sound                =    monsters\controller\controller_presence_l
psy_pp_effector_name    =     postprocess_psi_aura ;psy_antenna
psy_pp_highest_at        =     0.05

[postprocess_psi_aura]
pp_eff_name        = radiation.ppe
pp_eff_cyclic    = 1
pp_eff_overlap  = true
radius_min        = 0.5
radius_max        = 1.1

The chimera doesn't attack, it just jumps around

Try these settings:

jump_min_distance                = 0.5
jump_max_distance                = 15.0
jump_max_angle                    = 3.14
jump_max_height                    = 3.5 

Car doesn't go/glitching out

Scripted vehicles that are supposed to go on tracks glitching out/don't go.

Replace in ph_car.script in two places:

local curVel = self.car:CurrentVel():magnitude()

to

local Vel = self.car:CurrentVel()
local curVel = math.sqrt(Vel.x * Vel.x + Vel.y * Vel.y)

Screen Space Shaders

To enable grass response to anomalies, add settings to the anomaly configs. As an example, the original settings from the addon:

;Fruit punch
bend_grass_blowout = true
bend_grass_blowout_speed = 3.0
bend_grass_blowout_radius = 3.0
;----------------------------------
;Vortex
bend_grass_idle_anim = 3
bend_grass_idle_radius = 4.0
bend_grass_idle_str = 2.0
bend_grass_idle_speed = 1.5

bend_grass_whenactive_str = 3.0
bend_grass_whenactive_speed = 3.0

bend_grass_blowout = true
bend_grass_blowout_duration = 2500
bend_grass_blowout_speed = 6.0
bend_grass_blowout_radius = 20.0
;----------------------------------
;Whirligig
bend_grass_idle_anim = 2
bend_grass_idle_radius = 4.0
bend_grass_idle_speed = 1.3

bend_grass_whenactive_anim = 3
bend_grass_whenactive_str = 3.5
bend_grass_whenactive_speed = 4.5

bend_grass_blowout = true
bend_grass_blowout_duration = 5500
bend_grass_blowout_speed = 5.0
bend_grass_blowout_radius = 20.0
;----------------------------------
;Springboard
bend_grass_idle_anim = 3
bend_grass_idle_radius = 4.0
bend_grass_idle_str = 2.0
bend_grass_idle_speed = 1.5

bend_grass_whenactive_str = 3.0
bend_grass_whenactive_speed = 3.0

bend_grass_blowout = true
bend_grass_blowout_duration = 2500
bend_grass_blowout_speed = 6.0
bend_grass_blowout_radius = 20.0
;----------------------------------
;Electro
bend_grass_blowout = true
bend_grass_blowout_speed = 4.0
bend_grass_blowout_radius = 5.0
;----------------------------------
;Burner
bend_grass_idle_radius = 3.5

bend_grass_whenactive_anim = 4
bend_grass_whenactive_str = 2.0
bend_grass_whenactive_speed = 3.5

bend_grass_blowout = true
bend_grass_blowout_duration = 2500
bend_grass_blowout_speed = 3.0
bend_grass_blowout_radius = 5.0

Shader-based NVG/Heatvision

You can use these commands to change NVG/Heatvision settings.

r_pnv_mode -- Mode (1 - NVG, 2 - Color Heatvision, 3 - Black n White Heatvision)
r_pnv_noise -- Noise
r_pnv_position -- The position of the mask to create the effect of putting the NV/thermal imager on your head.
r_pnv_radius -- The radius of the NV. 
r_pnv_num_tubes -- Number of NV tubes.
r_pnv_gain_current -- The brightness/power of the NV.
r_pnv_washout_thresh -- Threshold for blurring light sources.
r_pnv_glitch -- Glitch effect.
r_pnv_size_vignet -- The size of the vignette.
r_pnv_alfa_vignete -- Vignette edge transparency.

Other

  • Remove multiplayer code from menu scripts, since there is no multiplayer in this engine.
  • It is recommended to use the menu scripts that come with the engine, because they corrected memory leaks, removed freezes, added options for new graphics settings and more.
  • If functions/callbacks etc. from X-Ray Extensions are used, they will have to be adapted/replaced with analogs from that engine. You can find a lot of examples here and here.
  • Beginning from 2.1.414 version we are recommending to use COP weather, this for example or any other. SoC weather will work, but its correct display on the new shaders is not guaranteed.
Clone this wiki locally