View previous topic :: View next topic |
Author |
Message |
timbobsteve
Joined: 10 Oct 2005 Posts: 15
|
Posted: Mon Oct 10, 2005 1:08 pm Post subject: Coding new entities in Quake using QuakeC |
|
|
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:
Quote: | 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: |
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;
}; |
|
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Mon Oct 10, 2005 5:44 pm Post subject: |
|
|
You're setting a nextthink time but no think function.
Which means the engine tries calling the think function, which is null. |
|
Back to top |
|
 |
timbobsteve
Joined: 10 Oct 2005 Posts: 15
|
Posted: Mon Oct 10, 2005 10:23 pm Post subject: |
|
|
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.
 |
|
Back to top |
|
 |
timbobsteve
Joined: 10 Oct 2005 Posts: 15
|
Posted: Tue Oct 11, 2005 6:05 am Post subject: |
|
|
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. |
|
Back to top |
|
 |
|