Security Camera

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » April 1st, 2006, 12:59 am

Pedsdude wrote:EDIT: I loaded the map in CoD and the camera appeared, but it didnt move and didn't have any textures.
It doesnt move because you need to script it :P

Textures are missing because you havent extracted the files correctly (skins?)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » April 1st, 2006, 7:56 pm

Ah I think I know what I've done wrong... will report back soon ;)

EDIT:
It now works fine, moves etc with textures on, although whenever I go in the trigger area it comes up with the message saying I've been spotted, rather than when I'm actually in the line of sight of the camera. Also, how would I make it so that it slowly hurts you when you are in the line of sight of the camera?
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » April 1st, 2006, 8:57 pm

Drofder2004 wrote:triggers cannot be moved, but there are easy ways of detection (im guessing the trigger multiple doe the detection?

Anyway. This is my way of doing it...

Make the trigger multiple fill the entire area where the camera can see.
Then make a box out of texture "no_draw_non_solid" (found in common).
Then make the box a script_brushmodel.
Now use that brush as the detector.

Now in the scripting do...

Code: Select all

if(self isTouching(trigger) && self isTouching(brush))
self iprintln("you were spotted by camera");
That will make the camera detect you.

:)

(Nice work btw)
Peds ^^
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » April 1st, 2006, 10:36 pm

Cameras that can hurt? That would be crazy
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » April 1st, 2006, 10:39 pm

Nightmare wrote:Cameras that can hurt? That would be crazy
Lasers!!!
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » April 2nd, 2006, 1:34 pm

Drofder2004 wrote:
Drofder2004 wrote:triggers cannot be moved, but there are easy ways of detection (im guessing the trigger multiple doe the detection?

Anyway. This is my way of doing it...

Make the trigger multiple fill the entire area where the camera can see.
Then make a box out of texture "no_draw_non_solid" (found in common).
Then make the box a script_brushmodel.
Now use that brush as the detector.

Now in the scripting do...

Code: Select all

if(self isTouching(trigger) && self isTouching(brush))
self iprintln("you were spotted by camera");
That will make the camera detect you.

:)

(Nice work btw)
Peds ^^
Aha, should have looked ;) What about making it hurt you slowly?
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » April 2nd, 2006, 5:00 pm

Pedsdude wrote:Aha, should have looked ;) What about making it hurt you slowly?
Just testing my code... if it works, then i'll post it.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » April 2nd, 2006, 6:16 pm

Ok, you need to make a trigger. The trigger, needs to be somewhere where it is guarenteed to be touched (doorway/spawn/etc).

Give that a targetname of start.

Now, you need to make a brushmodel that is going to act as the camera spotter. The brush only need to be 1 unit high, but it must touch the floor. You are going to be moving the brush around the floor as the camera moves (imagine this as a spotlight, that only detects people feet :P)
Give the entire brush the texture called (nodraw_notsolid).

Now for the script.

Code: Select all

main()
{
thread start();
}

Code: Select all

start()
{
start = getent("start","targetname");
brush = getent("brush","targetname");
brush thread move();

start waittill("trigger",user);
user thread hurt();
}

Code: Select all

hurt()
{
brush = getent("brush","targetname");

while(1)
{
if(self.health > 0 && self isTouching(brush))
{	
	if(self.health > 0)
		self.health--;
		
	wait 0.05;
}
else if(self.health < 1)
{
	self suicide();
	break;
}
else
	break;	
}
wait 0.1;
}

Code: Select all

move()
{
//Movements
}
in the move() thread, you do not need getent or "brush", use the word "self" when referring to the brush.

Tell me of any problems... (this is only partially tested and may be faulty :P)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » April 2nd, 2006, 6:18 pm

OK, so what's the point of the nodraw brush coming from the camera then?
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » April 2nd, 2006, 6:21 pm

Pedsdude wrote:OK, so what's the point of the nodraw brush coming from the camera then?
scrap it.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » April 2nd, 2006, 6:24 pm

So I should delete the current nodraw and trigger covering the whole area, then add a brushmodel with nodraw and a trigger which starts when they enter?
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » April 2nd, 2006, 6:30 pm

Pedsdude wrote:So I should delete the current nodraw and trigger covering the whole area, then add a brushmodel with nodraw and a trigger which starts when they enter?
You only need the 2 things I said...

1 trigger_multiple. This is used for grabbing a single player and running the camera thread on that player.
1 script_brushmodel. This is used as the spotlight area for the camera.

Nothing else is needed.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » April 2nd, 2006, 6:37 pm

Hmm sorry to be so much hassle, but I'm confused. I have the following code:

Code: Select all

main()
{
	ambientPlay("ambient_mp_harbor");

	maps\mp\_load::main();
	
	game["allies"] = "american";
	game["axis"] = "german";

	game["american_soldiertype"] = "airborne";
	game["american_soldiervariation"] = "normal";
	game["german_soldiertype"] = "fallschirmjagergrey";
	game["german_soldiervariation"] = "normal";

	game["attackers"] = "allies";
	game["defenders"] = "axis";
	
	thread Camera();	
	thread Camera_scope();
	thread cam_trigger();
}





Camera()
{
	move_camera_01 = getentarray("camera_01","targetname");

	if(isdefined(move_camera_01))
		{
		for(i=0;i<move_camera_01.size;i++)
			{
			move_camera_01[i] thread do_move_camera_01();
			}
		}
}

Camera_scope()
{
	move_camera__scope_01 = getentarray("camera_trigger_01","targetname");

	if(isdefined(move_camera__scope_01))
		{
		for(i=0;i<move_camera__scope_01.size;i++)
			{
			move_camera__scope_01[i] thread do_move_camera_01();
			}
		}
}

do_move_camera_01()
{
	while(true)
		{
		self rotateyaw (25, 5);		//Rotate the camera to the left, with a speed of 5
		self waittill ("rotatedone");	//wait untill the rotate is done, els it doesn't work
		self rotateyaw (-25, 5);		//Rotate the camera to the right
		self waittill ("rotatedone");
		self rotateyaw (-25, 5);		//Rotate the camera to the right
		self waittill ("rotatedone");
		self rotateyaw (25, 5);		//Rotate the camera to the start position
		self waittill ("rotatedone");
		}
}

cam_trigger()
{
	cam_trig_area_01 = getent ("camera_trigger_area_01","targetname");
	move_camera__scope_01 = getent("camera_trigger_01","targetname");
	
	while(1)
		{
			cam_trig_area_01 waittill ("trigger",user);

			if (user istouching(move_camera__scope_01))
				{	
				user thread Camera_action();
				}
	wait .5;
		}
}

Camera_action()
{
			self iprintlnbold (self.name + " ^1the camera has spotted you!");				
}
Seeing you asked me to delete the brushes and triggers that I didn't need in the .map file, I'm not sure which ones of those to keep and which to get rid of.

I have created a trigger_multiple with targetname 'start', and a brushmodel with nodraw texture and targetname 'spotter'. What should the .gsc look like?
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » April 3rd, 2006, 10:55 am

Code: Select all

main()
{
   ambientPlay("ambient_mp_harbor");

   maps\mp\_load::main();
   
   game["allies"] = "american";
   game["axis"] = "german";

   game["american_soldiertype"] = "airborne";
   game["american_soldiervariation"] = "normal";
   game["german_soldiertype"] = "fallschirmjagergrey";
   game["german_soldiervariation"] = "normal";

   game["attackers"] = "allies";
   game["defenders"] = "axis";
   
   thread camera_think();
   thread spotter_think();
   thread start();
}

Code: Select all

camera_think()
{
   move_camera = getentarray("camera","targetname");

   if(isdefined(move_camera))
      {
      for(i=0;i<move_camera.size;i++)
         {
         move_camera[i] thread do_move_camera();
         }
      }
}

Code: Select all

do_move_camera();
{
while(1)
      {
      self rotateyaw (25, 5);
      self waittill ("rotatedone");
      self rotateyaw (-25, 5);
      self waittill ("rotatedone");
      self rotateyaw (-25, 5);
      self waittill ("rotatedone");
      self rotateyaw (25, 5);
      self waittill ("rotatedone");
      }
}

Code: Select all

spotter_think();
{
   spotter = getentarray("spotter","targetname");

   if(isdefined(spotter))
      {
      for(i=0;i<spottera.size;i++)
         {
         spotter[i] thread do_move_spotter();
         }
      }
}

Code: Select all

do_move_spotter()
{
while(1)
{
//Move Spotter (You will have to work this out)
}
}

Code: Select all

start()
{
start = getent("start","targetname");
while(1)
{
start waittill ("trigger",user);
user spotter(); //May or may not need to be threaded
}
}

Code: Select all

spotter()
{
spotter = getent("spotter","targetname");

while(1)
{

/*********************
if(self.health > 0 && self isTouching(spotter))
{   
   if(self.health > 0)
      self.health--;
      
   wait 0.05;
}
else if(self.health < 1)
{
   self suicide();
   break;
}
else
   break;
*********************/

self iprintlnbold("Spotted"); // for testing purposes...
}
wait 0.1;
}
Ok, a few problems that maybe leveller can help with...
I am unsure of using an array (getentarray) for the last thread because of the "self isTouching(spotter)".
So the above code, is only currently available for one single spotter.

Other things to point out are the change of entity names...

Code: Select all

move_camera = getentarray("camera","targetname");
Name all of your cameras, "camera".

The last thread has been mostly edited out, because you need to test to see if the threads work properly. Once you know the thread works, you can remove the comments ("/*" and "*/") to test the hurt code.

Try that... (its untested and mostly written off the top of my head)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

leveller
CJ Fan
CJ Fan
Posts: 156
Joined: June 25th, 2005, 12:24 pm

Post by leveller » April 3rd, 2006, 4:02 pm

I'm a bit confused why you want to rewrite the whole script again, its working good as it is.
the only thing that deeds to be edited = the last thread, "Camera_action()".

anyway, this is what i think you want(need).

Code: Select all

spotter_think();
{
   spotter = getentarray("spotter","targetname");

   if(isdefined(spotter))
      {
      for(i=0;i<spottera.size;i++)
         {
         spotter[i] thread do_move_camera();
         }
      }
}

Code: Select all

start()
{
start = getent("start","targetname");
spotter = getent("spotter","targetname");
while(1)
{
start waittill ("trigger",user);
if (user istouching(spotter))
user thread spotter();
}
}

Code: Select all

spotter()
{
while(1)
{
   if(self.health > 0)
      self.health--;
      
   wait 0.05;
}

else if(self.health < 1)
{
   self suicide();
   break;
}
// else  //<---Why is that?
// break; //<--And thins one.

self iprintlnbold("Spotted"); // for testing purposes...
}
wait 0.1;
}
Ok, a few problems that maybe leveller can help with...
I am unsure of using an array (getentarray) for the last thread because of the "self isTouching(spotter)".
So the above code, is only currently available for one single spotter.
cant remember exactly but i believe a getentarray didn't work or only partial worked.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests