how to activate a light (rotate, beams on) and vice versa


(GRouZER) #1

This is my plan:

  1. Allies destroy doors
  2. Alarm goes off at the same time else where an red light is on which is rotating and has beams.
  3. Allies of Axis can turn on/off the alarm by pressing a button, when the alarm is off the red light (rotate, beams) must also be off.

What is the best way to achive this?

I have a func_explosive linked to a target_script_trigger and that is linked to the “light_on” brush, and i have a func_invisible_user linked to the “light_on” brush also, but it does not really work :stuck_out_tongue:

I played with the script a bit but i can’t get it to work:


game_manager
{
    spawn
    {
    }
}

siren_off_script
{
    spawn
      {
      trigger self startup
      }
    
    trigger startup
      {
      setstate siren_on          invisible
      setstate siren_off         default
      }
}

siren_on_script
{
    spawn
      {
      trigger self startup
      }

    trigger startup
      {
      setstate siren_off         invisible
      setstate siren_on          default
      }
    
}

(GRouZER) #2

kick


(Moonkey) #3

It would help if you could post the relevant parts of your .map file because it’s hard to know how you have things set up.

What types of entites are you using for your light beams?


(GRouZER) #4

What i now have (brushes, entities) doen’t work so i would like someone to tell me what entities, script commands to use etc.

I want the doors as a func_explosive so when it explodes, the "alarm goes off (i think i can fix that) and the “red light” goes on, but i don’t know where to link it to, and how to activate the scipt which causes the red light to go on (other texture -> light on texture) and which has red light beams.

And i want you to be able to turn on/off the “red light” by pressing the alarm button.

My idea was that i could use setstate invis and default for the on/off effect of the “red light”, like in the script example.

i am using a beam texture as beams i think if you use entities for beams it can’t rotate??


(GRouZER) #5

I might solve this by myselve but i can’t find a good list of tutorial which explanes what commands mean and what commands you can use in a script, and also for entities.


(Moonkey) #6

A good place to look for scripting definitions is the LDR (check in your radiant/docs directory).

As for this setup, there’s a few ways you could approach it, but here’s how I would do it.

Have your func_explosive target a target_script trigger. Give this target_script_trigger a scriptname of something like “door_script” and a target of “activate”.

For the button, have a func_invisible_user targetting a target_script_trigger. give this one a scriptname of “button_script” and target “activate”.

You could try a few ways of doing the lights, but I would use a script_mover. give it a scriptname and targetname of something like “rotating_light”.

Set up your target_speakers with looped_off checked, and a targetname of “alarm_sound”. You could use the ingame speaker editor too but you’ll need to change the script commands from alertentity to togglespeaker.

Set up your script something like this.



door_script
{
    trigger activate
    {
        trigger rotating_light on
    }
}        

button_script
{
    trigger activate
    {
        trigger rotating_light on
        trigger rotating_light off
    }
}        

rotating_light
{
    spawn
    {
        accum 1 set 0 // 0 = alarm is off
    }
    trigger on
    {
        accum 1 abort_if_not_equal 0
        resetscript

        alertentity alarm_sound // play speakers
        setrotation 0 90 0 // start rotating

        accum 1 set 1 //alarm is now on
    }
    trigger off
    {
        accum 1 abort_if_not_equal 1
        resetscript

        alertentity alarm_sound // turn speakers off
        setrotation 0 0 0 // stop rotating

        accum 1 set 0 //alarm is now off
    }
}

You could add some extra stuff if you wanted a moving button.

ps. I haven’t tested this but I think it should work :o

Hope that helps :slight_smile:


(GRouZER) #7

Thanx man it works, but i also wanted when the alarm is off you don’t see the light beams, and when turned on the light beams are on.
I have used setstate for the beams but that doen’t have a good result, how do i fix that, or do i make it to complicated :stuck_out_tongue: ?

And anther thing is i have customized the sfx/beam_1 texture, into a red color, and changed the shader script for beam_1 but it’s not transparant.

  • It’s a jpg file just as the original beam.
  • I have put the custom texture in the right folder (textures/op_complex)
  • I have added op_complex to the shaderlist
  • The file name (beam_red) is correct

original shader script:

textures/sfx/beam_dusty2
{
	qer_editorimage textures/sfx/beam_1.tga
	cull none
	nocompress
	surfaceparm nomarks
	surfaceparm nonsolid
	surfaceparm pointlight
	surfaceparm trans
	{
		map textures/sfx/beam_1.tga
		blendFunc add
	}
}

my custom shader script:

textures/op_complex/beam_dusty3
{
	qer_editorimage textures/op_complex/beam_red.tga
	cull none
	nocompress
	surfaceparm nomarks
	surfaceparm nonsolid
	surfaceparm pointlight
	surfaceparm trans
	{
		map textures/op_complex/beam_red.tga
		blendFunc add
	}
}

(Moonkey) #8

Oops yeah, I forgot to include the setstate parts :twak:

One thing to remember when using setstate is that it takes a little while at the start of the map for the entities to properly load, so make sure you put a wait of 50 or so before you make it insivible in the spawn section of the script.

Not sure about the texture sorry, everything looks right to me.


(GRouZER) #9

Sorry, but i can’t figure out where to put the setstate line i have just added the line to trigger on and off and that doen’t work.

do you know where i can download a model of a good alarm light, in that way i only need the beams to rotate.


(Moonkey) #10

The setstates should go here


rotating_light 
{ 
    spawn 
    { 
        accum 1 set 0
        wait 50 // new
        setstate rotating_light invisible // new
    } 
    trigger on 
    { 
        accum 1 abort_if_not_equal 0 
        resetscript 

        alertentity alarm_sound
        setrotation 0 90 0
        setstate rotating_light default // new

        accum 1 set 1
    } 
    trigger off 
    { 
        accum 1 abort_if_not_equal 1 
        resetscript 

        alertentity alarm_sound
        setrotation 0 0 0
        setstate rotating_light invisible // new

        accum 1 set 0    } 
} 


(GRouZER) #11

Thanks!

This part of the script doesn’t work (the script_movers (alarm_light_on/off) have the correct target names):

trigger on
    {
         setstate alarm_light_on         default
         setstate alarm_light_off        invisible
         setstate alarm_light_entity     default
    }
    trigger off
    {
        setstate alarm_light_on          invisible
        setstate alarm_light_off         default
        setstate alarm_light_entity      invisible   
    }

And also when nothing is triggered yet, i can see a red glow that goes on and off in the corners of the room where the shadows are.
I have also put a light in the map which has a targetname of alarm_light_entity which should be on when the lights are turned on, but it doesn’t.

light keys and values:

{
"classname" "light"
"origin" "-16 -32 200"
"light" "300"
"_color" "1.000000 0.000000 0.000000"
"targetname" "alarm_light_entity"
"scriptname" "alarm_light_script"
}
game_manager
{
    spawn
    {
    }
}


doors_script 
{ 
    trigger activate 
    { 
        trigger rotating_light on 
    } 
}        

button_script 
{ 
    trigger activate 
    { 
        trigger rotating_light on 
        trigger rotating_light off
        trigger alarm_light_script on
        trigger alarm_light_script off
    } 
}        

alarm_light_script
{
    spawn
    {
        wait 50
        setstate alarm_light_on          invisible
        setstate alarm_light_off         default
        setstate alarm_light_entity      invisible
    }
    trigger on
    {
         setstate alarm_light_on         default
         setstate alarm_light_off        invisible
         setstate alarm_light_entity     default
    }
    trigger off
    {
        setstate alarm_light_on          invisible
        setstate alarm_light_off         default
        setstate alarm_light_entity      invisible   
    }
}
    

rotating_light 
{ 
    spawn 
    { 
        wait 50
        accum 1 set 0                     // 0 = alarm is off
        setstate light_beams             invisible
    } 
    trigger on 
    {
        accum 1 abort_if_not_equal 0 
        resetscript 

        alertentity alarm_sound           // play speakers 
        setrotation 0 90 0                // start rotating
        setstate light_beams             default

        accum 1 set 1                     //alarm is now on 
    } 
    trigger off 
    { 
        accum 1 abort_if_not_equal 1 
        resetscript 

        alertentity alarm_sound           // turn speakers off 
        setrotation 0 0 0                 // stop rotating
        setstate light_beams             invisible

        accum 1 set 0                     //alarm is now off 
    } 
}

(GRouZER) #12
  • kick *

(Moonkey) #13

As far as I know, if you want a light to be able to be turned off/on, it has to be a dlight. I’ve never used one before but from what I gather they need some light in the area already to work.

The flashing red glow I’m not sure about. Maybe an effect of your script_mover turning and lighting up the wall, even though it’s invisible?
Or maybe someone planted some dynamite when you weren’t looking :banana: