Call of Duty 4: Switches Primary Light: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
(New page: Image:Nutshell.png This tutorial explains how to create a switcheable Primary Light as seen in Steamlab Create a new script _lights.gsc in ''/raw/maps/mp/'' <pre> main() { precacheM...)
 
mNo edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Image:Nutshell.png]] This tutorial explains how to create a switcheable Primary Light as seen in Steamlab
{{Warning_advanced}}
{{Note|This tutorial explains how to create a switcheable Primary Light as seen in Steamlab}}


Create a new script _lights.gsc in ''/raw/maps/mp/''
The technique used below is to move a ShadowCaster Brush [[Image:Shadow 1.jpg|32px]] over the actual Light Entity.


<pre>
Create a new script called '''_lights.gsc''' in <code>/raw/maps/mp/</code>
 
<syntaxhighlight lang="cpp">
main()
main()
{
{
Line 15: Line 18:


if ( isdefined(spotlight) )
if ( isdefined(spotlight) )
for ( i = 0 ; i < spotlight.size ; i++ )
for ( i = 0 ; i < spotlight.size ; i++ )
spotlight[i] thread lights_off();
spotlight[i] thread lights_off();
}
}


Line 22: Line 25:
{
{
while (1)
while (1)
{
{
speed = .01; // speed for moving on Z axis
speed = .01; // speed for moving on Z axis
height = -36; // high in units to move on Z axis
height = -36; // high in units to move on Z axis


spotlight_hide = getent("spotlight_hide", "targetname"); // get script_brushmodel(s) in level
spotlight_hide = getent("spotlight_hide", "targetname"); // get script_brushmodel(s) in level
spotlight_model = getent( "spotlight_model", "targetname" ); // get xmodel _on
spotlight_model = getent( "spotlight_model", "targetname" ); // get xmodel _on


self waittill("trigger");
self waittill("trigger");
spotlight_hide movez (height, speed); // Move script_brushmodel(s) on Z axis
spotlight_hide movez (height, speed); // Move script_brushmodel(s) on Z axis
spotlight_model setmodel( "com_studiolight_hanging_off" );      // swap xmodel by _off
spotlight_model setmodel( "com_studiolight_hanging_off" );      // swap xmodel by _off
self playsound("light_switch_off");
self playsound("light_switch_off");
spotlight_hide waittill ("movedone");
spotlight_hide waittill ("movedone");


self waittill("trigger");
self waittill("trigger");
spotlight_hide movez (height - (height * 2), speed);
spotlight_hide movez (height - (height * 2), speed);
spotlight_model setmodel( "com_studiolight_hanging_on" ); // switch back to _on Xmodel
spotlight_model setmodel( "com_studiolight_hanging_on" ); // switch back to _on Xmodel
self playsound("light_switch_on");
self playsound("light_switch_on");
spotlight_hide waittill ("movedone");
spotlight_hide waittill ("movedone");
}
}
}</pre>
}
</syntaxhighlight>


In your Map GSC file (/raw/maps/mp/mp_yourmap.gsc) add this after ''maps\mp\_load::main()'';
In your Map GSC file (<code>/raw/maps/mp/mp_yourmap.gsc</code>) add this after <code>maps\mp\_load::main();</code>


<pre>maps\mp\_lights::main();</pre>
<syntaxhighlight lang="cpp">
maps\mp\_lights::main();
</syntaxhighlight>


Add the _off model to your Zone File, in my example:
Add the _off model to your Zone File, in my example:


<pre>xmodel,com_studiolight_hanging_off</pre>
<syntaxhighlight lang="cpp">xmodel,com_studiolight_hanging_off</syntaxhighlight>


In Radiant (minus the com_studiolight_hanging_on model):
In Radiant (minus the com_studiolight_hanging_on model):
Line 56: Line 62:
[[Image:light_switch.jpg]]
[[Image:light_switch.jpg]]


The trigger is a trigger_usetouch and has targetname = switch ;
<pre>The trigger is a trigger_usetouch and has targetname = switch ;
The ShadowCaster script_brushmodel is solid and has targetname = spotlight_hide ;
The ShadowCaster script_brushmodel is solid and has targetname = spotlight_hide ;
Trigger is connected/link to ShawdowCaster script_brushmodel ;
Trigger is connected/link to ShawdowCaster script_brushmodel ;
spotlight model (not on pic) would be a script_model and have targetname = spotlight_model ;
spotlight model (not on pic) would be a script_model and have targetname = spotlight_model ;</pre>


Sounds in the script are custom - you can use "metal_click" also (stock)
Sounds in the script are custom - you can use "metal_click" also (stock)
{{Warning|The Light Switch will not work if the ''Shadow'' option is turned off in GFX settings of the Game!}}


--[[User:Zeroy|Zeroy.]] 19:40, 19 October 2008 (UTC)
--[[User:Zeroy|Zeroy.]] 19:40, 19 October 2008 (UTC)
[[Category:Call of Duty 4]]
[[Category:Radiant]]
[[Category:Scripting]]
[[Category:Lighting]]

Latest revision as of 13:58, 23 February 2012

This tutorial explains how to create a switcheable Primary Light as seen in Steamlab

The technique used below is to move a ShadowCaster Brush over the actual Light Entity.

Create a new script called _lights.gsc in /raw/maps/mp/

main()
{
	precacheModel("com_studiolight_hanging_off"); // precache selected model
	thread switch_start();
}

switch_start()
{
	spotlight = getentarray( "switch", "targetname" ); // get triggers

	if ( isdefined(spotlight) )
		for ( i = 0 ; i < spotlight.size ; i++ )
			spotlight[i] thread lights_off();
}

lights_off()
{
	while (1)
	{
		speed = .01; // speed for moving on Z axis
		height = -36; // high in units to move on Z axis

		spotlight_hide = getent("spotlight_hide", "targetname"); // get script_brushmodel(s) in level
		spotlight_model = getent( "spotlight_model", "targetname" ); // get xmodel _on

		self waittill("trigger");
		spotlight_hide movez (height, speed); // Move script_brushmodel(s) on Z axis
		spotlight_model setmodel( "com_studiolight_hanging_off" );       // swap xmodel by _off
		self playsound("light_switch_off");
		spotlight_hide waittill ("movedone");

		self waittill("trigger");
		spotlight_hide movez (height - (height * 2), speed);
		spotlight_model setmodel( "com_studiolight_hanging_on" ); // switch back to _on Xmodel
		self playsound("light_switch_on");
		spotlight_hide waittill ("movedone");
	}
}

In your Map GSC file (/raw/maps/mp/mp_yourmap.gsc) add this after maps\mp\_load::main();

maps\mp\_lights::main();

Add the _off model to your Zone File, in my example:

xmodel,com_studiolight_hanging_off

In Radiant (minus the com_studiolight_hanging_on model):


The trigger is a trigger_usetouch and has targetname = switch ;
The ShadowCaster script_brushmodel is solid and has targetname = spotlight_hide ;
Trigger is connected/link to ShawdowCaster script_brushmodel ;
spotlight model (not on pic) would be a script_model and have targetname = spotlight_model ;

Sounds in the script are custom - you can use "metal_click" also (stock)

The Light Switch will not work if the Shadow option is turned off in GFX settings of the Game!

--Zeroy. 19:40, 19 October 2008 (UTC)