Forum

Teamspawns

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Teamspawns

Postby ceriux » Sun Nov 23, 2008 9:02 am

how would i code in two new map entities 1 being Info_team1_spawn and the 2nd being info_team2_spawn.

(i would also like to add classes to each team later on using a menu)
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby CocoT » Sun Nov 23, 2008 2:25 pm

Respawning is handled by entity() SelectSpawnPoint in client.qc
You'd need to create a spawn entity like the ones listed in "QUAKED FUNCTIONS" (look a little further ahead of entity() SelectSpawnPoint) and then make the appropriate changes in entity() SelectSpawnPoint (according to team number, for example). Now, you'll probably still want to keep some form of regular respawn point, though, so that players appear there first, then choose their team, then get respawned to the new spot.
Neurotic Conversions - New location: Update your bookmarks!
User avatar
CocoT
 
Posts: 695
Joined: Tue Dec 14, 2004 5:39 pm
Location: Belly-Gum

Postby ceriux » Sun Nov 23, 2008 7:11 pm

exactly what i want to do :D thanks ill check it out and see what i cant attempt :D
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby ceriux » Mon Nov 24, 2008 6:27 pm

so something like this?

Code: Select all
/*QUAKED Info_allied_spawn (1 0 1) (-16 -16 -24) (16 16 24)
potential spawning position for allied players
*/
void() Info_allied_spawn =
{
};

/*QUAKED Info_axis_spawn (1 0 1) (-16 -16 -24) (16 16 24)
potential spawning position for axis players
*/
void() Info_axis_spawn =
{
};
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby MauveBib » Mon Nov 24, 2008 9:37 pm

That will create the entities, yes, but now you need to alter the SelectSpawnPoint function to make the player actually spawn there.
Apathy Now!
User avatar
MauveBib
 
Posts: 634
Joined: Thu Nov 04, 2004 1:22 am

Postby ceriux » Mon Nov 24, 2008 10:04 pm

so would i edit like this? because.... im not exactly sure what id add... so i tried editing another qc file i found some where to work with this... but i doubt it will...

first in client.qc scroll down to where you find



void() PutClientInServer =
{
local entity spot;

spot = SelectSpawnPoint ();

self.classname = "player";


and under

self.classname = "player";

add

self.classname = "Allied";
self.classname = "Axis";


So that it looks like this


void() PutClientInServer =
{
local entity spot;

spot = SelectSpawnPoint ();

self.classname = "player";
self.classname = "Allied"; //new team 1
self.classname = "Axis"; //new team 2
self.health = 100;
self.takedamage = DAMAGE_AIM;
self.solid = SOLID_SLIDEBOX;
self.movetype = MOVETYPE_WALK;
self.show_hostile = 0;
self.max_health = 100;
self.flags = FL_CLIENT;
self.air_finished = time + 12;



after that scroll down to about line 426 and edit like so


}
else if (deathmatch)
{
lastspawn = find(lastspawn, classname, "info_player_allied");
if (lastspawn == world)
if !(Allied)
{
lastspawn = find (lastspawn, classname, "info_player_allied");
if (lastspawn == world)
lastspawn = find (lastspawn, classname, "info_player_allied");
}
else
{
while (lastspawn.team != self.team)
{
lastspawn = find(lastspawn, classname, "info_player_axis");
if (lastspawn == world)
lastspawn = find (lastspawn, classname, "info_player_axis");
}
}
if (lastspawn != world)
return lastspawn;
}
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Electro » Tue Nov 25, 2008 12:39 am

Everyone will be classname Axis with that code. You can't set classname 3 times there, it's just going to end up staying as the last one set.

Use that menu system you have setup to set peoples class ;)
Then you can just have the respawns base off that class. I'd avoid changing classname as other code ties into it. Instead just make a .string class, and search for that when selectspawnpoint is called. (so basically exactly what you have there already, just change the finds to search for class strings instead of classname, and make your menus set .class :)
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
Electro
 
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia

Postby ceriux » Tue Nov 25, 2008 12:51 am

hmm i want them to be assigned to specific teams though with each their own class... i wish i could get a look a teamfortress's system for it... so i can see how they set up teams with classes.

you know what :) i think im going to read this :D

http://inside3d.com/showtutorial.php?id=140
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Electro » Tue Nov 25, 2008 2:21 am

All you need is another menu. You can change your menu to include 2 different types of menus, first team, then class.
Then you have all the data you need from the player for where to spawn them. :)

The team fortress code is available, but you don't need to look at something that is so far developed, you just need the bare basics at this stage, and it's better to see why things work the way they do.

That tutorial you linked by Koolio would be a good start, definitely. :)
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
Electro
 
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia

Postby ceriux » Tue Nov 25, 2008 9:07 am

hmm... iv gotten this far...
http://inside3d.com/showtutorial.php?id=143

and it compiles and plays, but when i spawn as either team it aways repspawns me at the info_player_start which is required to play in any map...

edit: i also changed it to where it looks for info_player_allied/or axis
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Electro » Tue Nov 25, 2008 9:17 am

Need to see your function ;)
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
Electro
 
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia

Postby ceriux » Tue Nov 25, 2008 9:33 am

i believe this is it.

Code: Select all
if ((deathmatch) && (self.team == TERROR_TEAM)) // <-- changed that
   {
      spot = lastspawn;
      while (1)
      {
         spot = find(spot, classname, "info_player_allied");
         if (spot != world)
         {
            if (spot == lastspawn)
               return lastspawn;
            pcount = 0;
            thing = findradius(spot.origin, 32);
            while(thing)
            {
               if (thing.classname == "player")
                  pcount = pcount + 1;
               thing = thing.chain;
            }
            if (pcount == 0)
            {
               lastspawn = spot;
               return spot;
            }
         }
      }
   }
   else if ((deathmatch) && (self.team == COUNTER_TEAM)) // <-- changed that
   {
      spot = lastspawn;
      while (1)
      {
         spot = find(spot, classname, "info_player_axis");
         if (spot != world)
         {
            if (spot == lastspawn)
               return lastspawn;
            pcount = 0;
            thing = findradius(spot.origin, 32);
            while(thing)
            {
               if (thing.classname == "player")
                  pcount = pcount + 1;
               thing = thing.chain;
            }
            if (pcount == 0)
            {
               lastspawn = spot;
               return spot;
            }
         }
      }
   }

   if (serverflags)
   {   // return with a rune to start
      spot = find (world, classname, "info_player_start2");
      if (spot)
         return spot;
   }
   
   spot = find (world, classname, "info_player_start");
   if (!spot)
      error ("PutClientInServer: no info_player_start on level");
   
   return spot;
};
/*
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby ceriux » Tue Nov 25, 2008 8:17 pm

sorry for double post, but has anyone seen where i might have screw'd up? or if i even have? according to what iv read each team should spawn at its own spawn point and only spawn at the info_player_start if its on co-op mode when creating a server.

iv been hosting it to test using regular Deathmatch with no other options no ff ect. but aslong as its in deathmatch mode i should spawn to the corresponding player spawn.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby r00k » Tue Nov 25, 2008 8:28 pm

Code: Select all
entity(string cname) SelectSpawnPoint =
{
   local entity spot, e;
   local float f;

   spot = lastspawn;
      
   while (1)
   {      
      spot = find(spot, classname, cname);

      f = 0;      
      
      if (spot != world)
      {
         if (spot != self.trigger_field)
         {
            e = findradius (spot.origin, 32);         
            while (e)
            {
               if (e.classname == "player")
               {
                  e = world;
                  f = 1;
               }
               else
               {
                  e = e.chain;
               }
            }
         }
         else
         {
            f = 1;
         }
         
         if (f == 0)
         {
            lastspawn = spot;
            return (spot);
         }
      }      
   }   
   return (lastspawn);
};


then in PutClientInServer
Code: Select all
     if (self.team == TERROR_TEAM)
   spot = SelectSpawnPoint ("Info_axis_spawn");
     else
     if (self.team == COUNTER_TEAM)
   spot = SelectSpawnPoint ("Info_allied_spawn");


ect...


Note: You MUST have your spawn points ENTITIES added to the .bsp
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby Electro » Tue Nov 25, 2008 9:48 pm

...and need to make sure you have .team set to either one of those values.
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
Electro
 
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest