User:Thebigh/Sandbox: Difference between revisions
more |
more |
||
Line 1: | Line 1: | ||
Deciding on the best level of [[Ambient Light]] can be tricky. If you make it too bright, the mission can take on a flat, washed-out feel and useful shadows can be difficult to distinguish from their surroundings. Too dark, and it is often hard to see your immediate vicinity. The '''dark vision''' technique allows you to light up nearby objects while leaving distant areas dark | Deciding on the best level of [[Ambient Light]] can be tricky. If you make it too bright, the mission can take on a flat, washed-out feel and useful shadows can be difficult to distinguish from their surroundings. Too dark, and it is often hard to see your immediate vicinity. The '''dark vision''' technique allows you to light up nearby objects while leaving distant areas dark. | ||
Essentially, we are going to attach a point light to the thief's head and have it follow him around like a faint lantern. | Essentially, we are going to attach a point light to the thief's head and have it follow him around like a faint lantern. | ||
Line 5: | Line 5: | ||
==The light== | ==The light== | ||
Put a light anywhere, | Put a light anywhere. This will be the dark vision light itself. Later we will use a script to attach it to the player's head, but for now place it in your "blue room". | ||
* Give it a modest radius; I find 300 to 500 units gives good results (7 - 11.5 m). | |||
* Name it "<tt>darkvision</tt>" | |||
* Give it a fairly low brightness; again, I have got good results with rgb(10,10,10). It should be neutral in colour though. | |||
* Set its <tt>ai_see</tt> spawnarg to 0. This will prevent it from affecting your light gem. | |||
* Set its <tt>noshadows</tt> spawnarg to 1. That will improve performance slightly as well as stopping the darkvision light from casting shadows; see what happens if you leave it out and then lean around a corner to understand why this matters. | |||
==The trigger timer== | |||
Place a <tt>trigger_timer</tt> entity somewhere in your blue room. This object repeatedly triggers whatever its target is, over and over and over. We'll use this to continually activate the script that positions the light. | |||
* Give it a <tt>target</tt> spawnarg called "<tt>update_darkvision</tt>". | |||
* Give it a <tt>wait</tt> spawnarg of 0.1. This means the position of the darkvision will be updated ten times a second. | |||
* Give it a <tt>start_on</tt> spawnarg of 1. | |||
==The callscriptfunction entity== | |||
Put a <tt>atdm:target_callscriptfunction</tt> entity somewhere near the trigger timer. This object has one purpose: to run a specified script whenever something triggers it. In this case it will be activated by the trigger timer at regular intervals and run the script that actually moves the light. | |||
* Name it "<tt>update_darkvision</tt>" so the trigger timer knows what to trigger. | |||
* Give it a <tt>call</tt> spawnarg of <tt>update_darkvision_function</tt>. This is going to be the name of the script. | |||
==The script== | |||
Outside DarkRadiant, go into the folder containing your mission and navigate to the maps folder. Start a new text file called mapname.script, where "mapname" is the name of your mission. Add the following code to this new file: | |||
void update_darkvision_function() { | |||
vector player_head; | |||
player_head = $player1.getOrigin() + '0 0 64'; | |||
$darkvision.setOrigin( player_head ); | |||
return; | |||
} |
Revision as of 12:07, 2 June 2021
Deciding on the best level of Ambient Light can be tricky. If you make it too bright, the mission can take on a flat, washed-out feel and useful shadows can be difficult to distinguish from their surroundings. Too dark, and it is often hard to see your immediate vicinity. The dark vision technique allows you to light up nearby objects while leaving distant areas dark.
Essentially, we are going to attach a point light to the thief's head and have it follow him around like a faint lantern.
The light
Put a light anywhere. This will be the dark vision light itself. Later we will use a script to attach it to the player's head, but for now place it in your "blue room".
- Give it a modest radius; I find 300 to 500 units gives good results (7 - 11.5 m).
- Name it "darkvision"
- Give it a fairly low brightness; again, I have got good results with rgb(10,10,10). It should be neutral in colour though.
- Set its ai_see spawnarg to 0. This will prevent it from affecting your light gem.
- Set its noshadows spawnarg to 1. That will improve performance slightly as well as stopping the darkvision light from casting shadows; see what happens if you leave it out and then lean around a corner to understand why this matters.
The trigger timer
Place a trigger_timer entity somewhere in your blue room. This object repeatedly triggers whatever its target is, over and over and over. We'll use this to continually activate the script that positions the light.
- Give it a target spawnarg called "update_darkvision".
- Give it a wait spawnarg of 0.1. This means the position of the darkvision will be updated ten times a second.
- Give it a start_on spawnarg of 1.
The callscriptfunction entity
Put a atdm:target_callscriptfunction entity somewhere near the trigger timer. This object has one purpose: to run a specified script whenever something triggers it. In this case it will be activated by the trigger timer at regular intervals and run the script that actually moves the light.
- Name it "update_darkvision" so the trigger timer knows what to trigger.
- Give it a call spawnarg of update_darkvision_function. This is going to be the name of the script.
The script
Outside DarkRadiant, go into the folder containing your mission and navigate to the maps folder. Start a new text file called mapname.script, where "mapname" is the name of your mission. Add the following code to this new file:
void update_darkvision_function() { vector player_head; player_head = $player1.getOrigin() + '0 0 64'; $darkvision.setOrigin( player_head ); return; }