Tutorial: Team Specific Door

 

 

Level: Easy

 

I was looking at Weapon Factory one day & thought it would be great to make doors that only opens for a certain team. This would be a great strategic advantage for CTF type of games with two forts. Lets say you are in the RED team, & there is only one room with ammo & health paks on each fort that has a team secured door on it. If you are in the blue teams fort and you run out of ammo, your a dead duck unless you go back to your fort and replenish with ammo & health.

So... Let's get started.

 

Note:

q      I'll be quoting things that have to do with the quake level editor QOOLE (which is where the image above comes from), but I think it should work with any level editor.

q      I'm using CTF source code (if not how the hell were going to know what team your on).

 

Each door is an entity in the level. If you look at the image you'll see that every door has a message field. We will use this field to determine what team is authorized to open it.

Ok, first open g_func.c & go to the door_use() function an add the following:

 

void door_use (edict_t *self, edict_t *other, edict_t *activator)

{

edict_t *ent;

// *********************************

// * JMR: Modified for team Doors

// *********************************

       if (strcmp (self->message, CTFTeamName(other->client->resp.ctf_team)) != 0)

       {

          gi.centerprintf (other, "Entrance Not Autorized!!");

          gi.sound (other, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0);

          return;

       }

// ********************************

       if (self->flags & FL_TEAMSLAVE)

             return;

       if (self->spawnflags & DOOR_TOGGLE)

 

 

 

First we compared the two strings. self->message contains whatever is in the message field for the door (in this case "RED"). The other part of the if is a funcion that gives us the color of the team the player is on. If the player isn't on the same team color as the doors message ("RED"), we let the player know, we send a sound & we leave the function, thus not opening the door.

Next, in the same file we go to the door_touch() funtion & comment out the following:

 

 

void door_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)

{

       if (!other->client)

             return;

 

       if (level.time < self->touch_debounce_time)

             return;

 

       self->touch_debounce_time = level.time + 5.0;

 

       // **********************************************

       // * JMR: Commented out for team doors

       // **********************************************

       // gi.centerprintf (other, "%s", self->message);

       // gi.sound (other, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0);

       // **********************************************

}

 

 

Normaly, each time we touch a door, this function displays on screen whatever is in the Message field. So, we comment this out so we dont see the message "RED" showing up every time we try to enter that door. And thats it. The only problem is that all doors work the same so if you leave the message field blank or enter another message thats not "RED" or "BLUE", no one can open it. This can be solved if you put the following if statement before both changes:

 

      if ((strcmp (self-message, "RED") == 0) || (strcmp (self->message, "BLUE") == 0)

      {

         // the code goes here

      }

 

This way you can make team specific door & normal doors in your levels.

Final remarks:I

If your trying to make a CLASS type Mod you can change the code so that only certain Classes can go through the doors.

Hope it's of any use and if anyone know how to create a (new field) so we don't have to use the message field, let me know.

Cya