Forum

Coding new entities in Quake using QuakeC

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Coding new entities in Quake using QuakeC

Postby timbobsteve » Mon Oct 10, 2005 1:08 pm

Hello all,

I am trying to start a mod for the original quake engine and I am having some trouble with quakeC. I have only just started learning it, but I have had some past coding experience.

What I am trying to do is setup a camera system like in the Alone in the Dark games, where the camera changes depending on where the player is in the room.

I have written a custom entity called trigger_camera() and I can compile my code and it does not spit out any errors. But when I run a test map it errors and says something along the lines of the following:

Host_Error:PR_ExecuteProgram: Null Function


the entity is one that is made in the code. I will include the code (but i dont necessarily want people to make it work for me... I would prefer to learn what my mistake was and how to fix it)

I hope this isn't all too confusing. It is a little late here and I should really be asleep

My Code: (All in one file called Camera.QC)
Code: Select all
void() Switch_Camera =
{
   local entity camera;

   camera = find(world,targetname,self.target);

   // Switch view to camera
   msg_entity = self.enemy;
   WriteByte(MSG_ONE, 5);
   WriteEntity(MSG_ONE, camera);
   msg_entity.player_cam = camera;
   msg_entity.angles = camera.angles;
};

void() trigger_camera_trigger =
{
   if(self.nextthink > time) return; //Already triggered

   self.takedamage = DAMAGE_NO;

   activator = find(world,classname,"player");

   Switch_Camera();

   //self.touch = SUB_Null;
   self.nextthink = time + 0.1;
};

void() trigger_camera_touch =
{
   if(other.classname != "player") return;

   self.enemy = other;
   trigger_camera_trigger();
};

void() trigger_camera =
{
   if(!self.wait)
      self.wait = 0.2;

   InitTrigger();

   if (!self.spawnflags)
   {
      self.touch = trigger_camera_touch;
   }
};

void() info_camera =
{
   local entity cam;
   
   cam = spawn();
   cam.classname = "info_camera";
   cam.origin = self.origin;
   cam.angles = self.angles;
};
timbobsteve
 
Posts: 15
Joined: Mon Oct 10, 2005 12:56 pm

Postby Spike » Mon Oct 10, 2005 5:44 pm

You're setting a nextthink time but no think function.
Which means the engine tries calling the think function, which is null.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby timbobsteve » Mon Oct 10, 2005 10:23 pm

Thanks Spike... that fixed it. I can't believe I missed that.
Now I can focus on making it work how I want it to.
;)
timbobsteve
 
Posts: 15
Joined: Mon Oct 10, 2005 12:56 pm

Postby timbobsteve » Tue Oct 11, 2005 6:05 am

OK.... I finaly got the players view to change to my camera entity... but now I can't make it so the players controls only affect the player model and not the camera.... i.e. when I use the mouse to look around it moves the camera.... I would prefer to have the camera stationary and always facing the initial camera.angles value.... but I have no idea how to do this.

Thanks again.
timbobsteve
 
Posts: 15
Joined: Mon Oct 10, 2005 12:56 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest