]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/arena.c
Removed friction on downstepping
[divverent/nexuiz.git] / data / qcsrc / server / gamec / arena.c
1 float maxspawned;
2 float numspawned;
3 float arena_roundbased;
4 .float spawned;
5 .entity spawnqueue_next;
6 .entity spawnqueue_prev;
7 .float spawnqueue_in;
8 entity spawnqueue_first;
9 entity spawnqueue_last;
10 entity champion;
11 .float arena_warmup_end;
12
13 void PutObserverInServer();
14 void PutClientInServer();
15 void(entity e) DropFlag;
16 void(entity e) ReturnFlag;
17 void(entity e) removedecor;
18
19 void reset_map()
20 {
21         float warmup;
22         
23         champion = world;
24         self = nextent(world);
25
26         warmup = cvar("g_arena_warmup");
27         
28         while(self)
29         {
30                 if(self.classname == "droppedweapon"            // cleanup
31                                 || self.classname == "gib"
32                                 || self.classname == "body")
33                 {
34                         remove(self);
35                 }
36                 else if(self.flags & FL_ITEM)                   // reset items
37                 {
38                         self.model = self.mdl;
39                         self.solid = SOLID_TRIGGER;
40                         setorigin (self, self.origin);
41                         self.think = SUB_Null;
42                         self.nextthink = 0;
43                         self.effects = self.effects - (self.effects & EF_STARDUST);
44                 }
45                 else if(self.flags & FL_PROJECTILE)             // remove any projectiles left
46                 {
47                         sound(self, CHAN_BODY, "misc/null.wav", 1, ATTN_NORM);
48                         remove(self);
49                 }
50                 else if(self.isdecor)
51                 {
52                         removedecor(self);                      
53                 }
54                 else if(self.flags & FL_CLIENT)                 // reset all players
55                 {
56                         if(self.spawned)
57                         {
58                                 if(self.classname == "player" && !self.deadflag)
59                                         champion = self;
60
61                                 self.classname = "player";
62
63                                 if(warmup)
64                                         self.arena_warmup_end = time + warmup;
65                         }
66                         else
67                         {
68                                 self.classname = "observer";
69                         }
70                         PutClientInServer();
71
72                 }
73                 self = nextent(self);
74         }
75
76         if(champion)
77                 champion.frags += 1;
78 }
79
80 void Spawnqueue_Insert(entity e)
81 {
82         if(e.spawnqueue_in)
83                 return;
84         dprint(strcat("Into queue: ", e.netname, "\n"));
85         e.spawnqueue_in = TRUE;
86         e.spawnqueue_prev = spawnqueue_last;
87         e.spawnqueue_next = world;
88         if(spawnqueue_last)
89                 spawnqueue_last.spawnqueue_next = e;
90         spawnqueue_last = e;
91         if(!spawnqueue_first)
92                 spawnqueue_first = e;
93 }
94
95 void Spawnqueue_Remove(entity e)
96 {
97         if(!e.spawnqueue_in)
98                 return;
99         dprint(strcat("Out of queue: ", e.netname, "\n"));
100         e.spawnqueue_in = FALSE;
101         if(e == spawnqueue_first)
102                 spawnqueue_first = e.spawnqueue_next;
103         if(e == spawnqueue_last)
104                 spawnqueue_last = e.spawnqueue_prev;
105         if(e.spawnqueue_prev)
106                 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
107         if(e.spawnqueue_next)
108                 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
109         e.spawnqueue_next = world;
110         e.spawnqueue_prev = world;
111 }
112
113 void Spawnqueue_Unmark(entity e)
114 {
115         if(!e.spawned)
116                 return;
117         e.spawned = FALSE;
118         numspawned = numspawned - 1;
119 }
120
121 void Spawnqueue_Mark(entity e)
122 {
123         if(e.spawned)
124                 return;
125         e.spawned = TRUE;
126         numspawned = numspawned + 1;
127 }
128
129 void Arena_Warmup()
130 {
131         string msg;
132
133         if(!arena_roundbased)
134                 return;
135
136         msg = newlines;
137         if(time < self.arena_warmup_end)
138         {
139                 float f;
140                 f = rint(self.arena_warmup_end - time);
141                 
142                 if(champion)
143                         msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
144                 
145                 if(f)
146                         msg = strcat(msg, "Round will start in ", ftos(rint(self.arena_warmup_end - time)));
147                 else
148                 {
149                         if(self.spawned)
150                                 msg = strcat(msg, "^1Fight!");
151                 }
152
153                 centerprint(self, msg);
154                 
155                 if(self.spawned)
156                         self.movetype = MOVETYPE_NONE;
157         }
158         else if(self.movetype == MOVETYPE_NONE)
159         {
160                 self.movetype = MOVETYPE_WALK;
161                 centerprint(self, "\n");
162         }
163         
164 }
165
166 float next_round;
167 void Spawnqueue_Check()
168 {
169         if(!next_round)
170         if(numspawned < 2)
171                 next_round = time + 3;
172
173         if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
174         {
175                 next_round = 0;
176                 while(numspawned < maxspawned && spawnqueue_first)
177                 {
178                         self = spawnqueue_first;
179
180                         bprint (strcat("^4", self.netname, "^4 is the next challenger\n"));
181
182                         Spawnqueue_Remove(self);
183                         Spawnqueue_Mark(self);
184                         if(!arena_roundbased)
185                         {
186                                 self.classname = "player";
187                                 PutClientInServer();
188                         }
189                 }
190                 if(arena_roundbased)
191                         reset_map();
192         }
193 }