Jump to content
The Dark Mod Forums

Recommended Posts

Posted (edited)

Ambient light setup

It took me a while to figure this out, so I'm documenting it here.
If there is a faster way to set the worldspawn lightgem_adjust arg per location than this or a technical mistake, please let me know.

What this does:
The location system allows to setup locations (areas), which enables each location to have unique settings like ambient sound, ambient light, etc. This setup here ensures that the ambient light for each location is adjustable and that the lightgem_adjust modifier of the global worldspawn gets adjusted for each area, instead of only setting this just once on map load. This solves a problem where guards in dark indoor areas don't recognize the player at normal distance and recognize the player far too soon when stepping outside in a moonlit street while the player is still in a "not active lit" place.

It looks like a long act, but it doesn't take long and as soon as it is set up, the mapping for a new location is fast, as it is only setting up a few new entities and spawnargs/targets.

########

Definitions/needed objects, location system of TDM, this consists of:

  • one atdm:location_settings entity (containing some definitions)
  • several info_location entites (one in each location)
  • several info_locationseparator entities (each sitting in the middle of a Visportal, so that all visportals which split off a location from another have one. Visportals within a location not leading to another location don't need this entity.)

 

########

I'm listing every property here, so some have just descriptive values.

Worldspawn:
Add the spawnarg

  • lightgem_adjust: 0

to one brush (as usual, any worldbrush will then have it).

----

Create the ambient light by making a light entity (one per map).
The _color (=intensity) gets set to zero. My ambient_light and ambient_light_dynamic definitions in the info_location entities otherwise would make the light far too bright (seems to get multiplied) and I define the light values solely with the info_location entities.
Additionally this gives a nice effect at map startup, where the ambient is black first and then rises to the level of the current location, like as if the eyes are slowly adapting to the darkness.

Entity Light:

  • classname: light
  • name: ambient_world
  • _color: 0 0 0
  • light_center: 0 0 0
  • light_radius: scale, to cover your whole map
  • nodiffuse: 0
  • noshadows: 0
  • nospecular: 0
  • origin: place, where you like
  • parallel: 0
  • texture: lights/ambientlightnfo

----

Create the atdm:location_settings entity (one per map).
You can define the sound definitions (property and value) as you like.

Entity location_settings:

  • classname: atdm:location_settings
  • name: atdm:location_settings
  • ambient_light_dist_scale: 1.0
  • ambient_light_dynamic_cap: 0.1 0.1 0.1
  • ambient_light_fade_time: 7
    this is the it takes the ambient light to adjust when traversing to a new location and at map startup
  • ambient_light_falloff: 1
  • origin:
    where you want to place it
  • s_shader: silence
  • snd_cellar: phantoms
  • snd_inside: mansion_tense01a
  • snd_outside: city_sleeps01
  • snd_placeholder1: desolation_loop
  • snd_upstairs: derelict01

... and so on with the sound definitions

----

In the middle of all Visportals, sealing one location from another, put a info_locationseparator entity.

Entity info_locationseparator:

  • classname: info_locationseparator
  • name: info_locationseparator
    ..._1, ..._2, iterate, doesn't matter
  • origin:
    middle of the according Visportal

----

Inside each location, put one info_location entity.

Entity info_location:

  • classname: info_location
  • name: info_location
    ..._1, ..._2, iterate, doesn't matter
  • ambient: snd_inside
    use a sound property-field defined in the adtm:location_settings entity
  • ambient_light: 0.027 0.027 0.027
    this is an example, use whatever light level you want to define for this location. 0.027 equals a light level of 7. Note, that if you use the color picker - red/green/blue of this field, the value might be automatically reduced each time you deselect/reselect, don't know if this is bug, so recheck the values.
  • ambient_light_dynamic: 0 0 0
    with an ambient_light of 7 = 0.027 this ambient_light_dynamic value of 0 gives a good shop indoor brightneess, if you set ambient_light_dynamic to 0.002 0.002 0.002 with ambient_light 7, this gives a much brighter moonlit street look, but you can also leave ambient_light_dynamic at 0 and just increase ambient_light.
  • origin:
    in your location area
  • volume: 0
    loudest ambient sound
  • call_on_entry: adjustlightgem
    the function name in yourmapname.script
  • lightgemmodifier: -1
    a custom spawnarg, read by the function adjustlightgem in yourmissionname.script

For valid values for lightgemmodifier see this wiki page:
https://wiki.thedarkmod.com/index.php?title=Virtual_Darkness

For example an ambient_light value of 7 (with ambient_light_dynamic value 0) should have a lightgemmodifier of -1.

 

ambient_light.jpg

 

----

Create a textfile (replace yourmissionname everywhere):
TDM/fms/yourmissionname/maps/yourmissionname.script
with the content:

#include "script/yourmissionname.script"

 

----

Create the folder:
TDM/fms/yourmissionname/script

And create the file (this looks a bit redundant here, but you can include several script files in the first file and reference them):
TDM/fms/yourmissionname/script/yourmissionname.script
and insert the content (extend as you like):
 

void adjustlightgem(entity location)
  {
  string location_name = location.getName();
  float lightgemmodifier = location.getFloatKey("lightgemmodifier");
  
  // console debugging
  // sys.print ("Entering location: " + location_name + "\n");
  // sys.print ("lightgemmodifier: " + lightgemmodifier + "\n");
  
  $player1.setLightgemModifier("worldspawn", lightgemmodifier);
  }

 

----

Result:
The ambient light transitions from location to location and the worldspawn lightgem_adjust arg gets set accordingly, and you have a nice effect at map startup.

 

 

 

Edited by OGDA
  • Like 3
Posted
3 hours ago, OGDA said:

If there is a faster way to set the worldspawn lightgem_adjust arg per location than this or a technical mistake, please let me know.

If you wan't to adjust the lightgem modifier (or any other value) via the locations system, you should use the locations system. Modify the script to do what you desire and use an additional spawnarg on the location entities to specify the lightgem modifier for the respective location.

  • Like 2

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Posted

You seemed to have misunderstood me. I was talking about adjusting the location_settings script object used by the location entities that gets shipped with the mod. This would completely neglect the need to call a seperate script function for each location. Instead, the only thing the mapper would have to do is to specify the lightgem adjust value one the location entity.

Script functions placed in the mission script are normally only suitable for one time instances specific for the respective mission, like initiating a scripted sequence or event, something story-related, a custom objective or whatever. For reoccuring stuff that is intented to be reused in other missions setups as the above should be avoided, as they are hard to adjust, most often more time consuming to setup and much more sensitive to errors, not to mention the amount of time it takes to find and fix said errors.

I would advise that you familiarize yourself with scriptobjects as well as entity definitions.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Posted (edited)

I've only started getting into TDM scripting, so I'm not completely sure where to find that. Wouldn't that mean I would have to ship a script that overrides a default TDM function with the map? If that's the case, I would prefer the current way with a custom script and only one additional call (for future update security). If you mean something different, do you perhaps have an example in one of your maps where you've done something like that, I can look at?

Edited by OGDA
Posted

Well, you can either override the scriptobject file in your fm or you store it under a different name and use that modified version in your fm. Either way, script objects don't altered all too often for compatibility sake. Worst case scenario when overriding the stock file is that the new line added would have to be added to the updated file. An example were I modify the location system is the hitman style script iirc. You can find the file and a description in my mapping thread as well as in one of my wiki articles. See my signature.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • snatcher

      Author of the Visible Player Hands mod: please come forth and collect a round of applause!
      · 2 replies
    • nbohr1more

      Holiday TDM Moddb article is now up: https://www.moddb.com/mods/the-dark-mod/news/happy-holidays-from-the-dark-mod
      · 0 replies
    • nbohr1more

      Cool thing: Thanksgiving break means I don't have to get my son up before dawn

      Not cool thing: My son stays up all night on my PC so I don't get much TDM time...
      · 3 replies
    • datiswous

      Does anyone know if the mission/map in this video posted by @Springheel can still be found somewhere and played? Looks like fun.
       
      · 2 replies
    • taffernicus

      I'm curious about doom and thief multiplayer netcode 😂 or how these games handle networking for multiplayer in general
      a youtube channel called battle(non)sense sometimes posts about netcode analysis
      · 2 replies
×
×
  • Create New...