]> icculus.org git repositories - divverent/nexuiz.git/blob - TeamNexuiz/game/gamec/tfq3fitems.c
Added a Game C folder
[divverent/nexuiz.git] / TeamNexuiz / game / gamec / tfq3fitems.c
1 /*\r
2 =============\r
3         XavioR's Q3F/ETF Entity recognition\r
4                                                         ==============\r
5 */\r
6 // q3f_forts seems to work almost perfectly --\r
7 //any other map will probably need a small to large amount of entity editing;\r
8 //still, this code does do a lot of work for you so give it a look :)\r
9 .string groupname;\r
10 //.string allowteams;\r
11 .string give;\r
12 .string active_all_sound;\r
13 .string carried_message;\r
14 .string active_all_message;\r
15 .string carried_sound;\r
16 .string holding;\r
17 .float gameindex;\r
18 .float teamscore;\r
19 .float floating;\r
20 //.vector orig_origin;\r
21 \r
22 // Q3F/ETF Maps dont have info_tfdetects, so this calls it.\r
23 void () DoTFDetect =\r
24 {\r
25         if (q3fdetect == 1)\r
26                 return;\r
27 self.display_item_status1 = 1;\r
28 self.n_s_c = "ÅÎÅÍÙ flag: carried by";\r
29 self.display_item_status2 = 2;\r
30 self.impulse = 64;\r
31 //self.classname = "info_tfdetect";\r
32 self.b_n = "\n";\r
33 self.t_s_h = "ÙÏÕÒ flag: base.";\r
34 //self.origin = '-80 -60 108';\r
35 self.t_s_c = "ÙÏÕÒ flag: carried by";\r
36 self.n_s_h = "ÅÎÅÍÙ flag: base.";\r
37 self.b_t = "Amnesia\n\9d\9e\9f CHOOSE YOUR TEAM \9d\9e\9f\n\n\90..\85 BLUE TEAM\n\90..\85 ÒÅÄ TEAM \n\n\90\97.\85 AUTO TEAM\n";\r
38 self.b_b = "TeamFortress";\r
39 self.n_s_m = "ÅÎÅÍÙ flag: down.";\r
40 self.t_s_m = "ÙÏÕÒ flag: down.";\r
41 q3fdetect = 1;\r
42 info_tfdetect();\r
43 };\r
44 \r
45 void () PossiblyDoTFDetect =\r
46 {\r
47         if (q3fdetect != 1)\r
48         {\r
49                 newmis = spawn();\r
50                 newmis.classname = "info_tfdetect";\r
51                 newmis.nextthink = time;\r
52                 newmis.think = DoTFDetect;\r
53         }\r
54 }\r
55 \r
56 //      Converts item to FLAG\r
57 void (float tno) ConvertToFlag =\r
58 {\r
59         PossiblyDoTFDetect();\r
60         local string droppedmsg;\r
61 \r
62         if (self.allowteams == "red")\r
63         {\r
64 //              if (redflagexists == 1)\r
65 //                      return;\r
66                 self.team_no = 2;\r
67                 self.owned_by = 1;\r
68                 self.n_b = " took the Blue Æìáç!\n";\r
69                 droppedmsg = " Dropped the Blue flag\n";\r
70                 self.netname = "Red Flag";\r
71                 redflagexists = 1;\r
72 \r
73                         if (!self.goal_no)\r
74                 self.goal_no = 200;             // Temp Goal Number, can be overridden by a "goal" def in the entity\r
75         }\r
76         if (self.allowteams == "blue")\r
77         {\r
78 //              if (blueflagexists == 1)\r
79 //                      return;\r
80                 self.team_no = 1;\r
81                 self.owned_by = 2;\r
82                 self.n_b = " took the Red Æìáç!\n";\r
83                 droppedmsg = " Dropped the Red flag\n";\r
84                 self.netname = "Blue Flag";\r
85                 blueflagexists = 1;\r
86 \r
87                         if (!self.goal_no)\r
88                 self.goal_no = 100;             // Temp Goal Number, can be overridden by a "goal" def in the entity\r
89         }\r
90         self.classname = "item_tfgoal";\r
91         self.message = self.carried_message;\r
92 \r
93         self.d_t = "the ÅÎÅÍÙ ìïóô your flag!\n";               // The enemy stole your flag msg\r
94         self.b_o = "Your flag has been stolen!\n";\r
95 \r
96         self.noise = self.carried_sound;\r
97 //      self.noise3 = self.inactive_all_message;\r
98         self.noise3 = "Your flag has returned to base!\n";\r
99 //      self.noise4 = self.inactive_all_message;\r
100         self.noise4 = "The enemy flag has returned to base!\n";\r
101 \r
102 //      self.impulse = 9;\r
103         self.items = 133701;\r
104 \r
105         self.mdl = self.model;\r
106 \r
107 //      self.mdl = "models/flag.md3";\r
108 \r
109         if (!self.delay)\r
110                 self.delay = self.wait;\r
111 \r
112         self.d_n_n = droppedmsg;\r
113         self.d_n_t = droppedmsg;\r
114 \r
115         self.g_a = 2741;\r
116         self.g_e = 17;\r
117 \r
118 \r
119         item_tfgoal();\r
120 };\r
121 \r
122 // Simulate animation for converted tfgoal backpack\r
123 // Very unorthodox -- i cant find out why self.owner.velocity has no effect\r
124 void () PackFloat =\r
125 {\r
126         self.owner.angles_y = self.owner.angles_y + 10;\r
127 \r
128         if (self.floating == -17)\r
129         {\r
130                 self.floating = 9;\r
131         }\r
132         if (self.floating == 0)\r
133         {\r
134                 self.floating = 9;\r
135         }\r
136         if (self.floating > 0)\r
137         {\r
138                 self.owner.origin_z = self.owner.origin_z + 3;\r
139                 self.floating = self.floating - 1;\r
140         }\r
141         if (self.floating == 0)\r
142         {\r
143                 self.floating = -9;\r
144         }\r
145         if (self.floating < 0)\r
146         {\r
147                 self.owner.origin_z = self.owner.origin_z - 3;\r
148                 self.floating = self.floating + 1;\r
149         }\r
150         self.owner.movetype = 9;\r
151 \r
152 //      self.nextthink = (time + 0.500000);\r
153         self.nextthink = time + 0.01;\r
154         self.think = PackFloat;\r
155 };\r
156 \r
157 // This is the function that will convert an item to a backpack\r
158 //(happens with any item that has a "give" value).\r
159 void () ConvertToBackPack =\r
160 {\r
161         PossiblyDoTFDetect();\r
162         if (self.give == "")\r
163                 return;\r
164 \r
165 //      self.classname = "i_t_g";\r
166         if (self.allowteams == "red")\r
167         {\r
168                 self.team_no = 2;\r
169                 self.owned_by = 2;\r
170         }\r
171         if (self.allowteams == "blue")\r
172         {\r
173                 self.team_no = 1;\r
174                 self.owned_by = 1;\r
175         }\r
176 \r
177         self.message = "Resupplied!\n";\r
178         if (self.carried_message != "")\r
179                 self.message = self.carried_message;\r
180         if (self.active_all_message != "")\r
181                 self.message = self.active_all_message;\r
182 \r
183         self.mdl = self.model;\r
184         self.noise = self.active_all_sound;\r
185         self.g_e = 1;\r
186         self.g_a = 1;\r
187 \r
188         self.flags = self.flags & FL_ITEM & FL_WEAPON; // makes it turn around -- much more bandwidth efficient\r
189 \r
190 /*      self.orig_origin = self.origin;         // old pack float code\r
191         newmis = spawn();                                       // thx savagex for making me aware of cl_itembobheight\r
192         newmis.floating = -17;\r
193         newmis.owner = self;\r
194         newmis.think = PackFloat;\r
195         newmis.nextthink = (time + 1.000000);*/\r
196 \r
197         // If no ammo amount is specified in the entity, it will default to these values.\r
198         // The reason for this is because q3f/etf uses "give" commands to add ammo, and I can't\r
199         //convert those easily :(\r
200         if (!(self.ammo_nails || self.ammo_cells || self.ammo_rockets || self.health))\r
201         {\r
202                 self.health = 50;\r
203                 self.ammo_nails = 50;\r
204                 self.ammo_nails = 100;\r
205                 self.ammo_rockets = 15;\r
206                 self.armorvalue = 100;\r
207                 self.no_grenades_1 = 2;\r
208         }\r
209         i_t_g ();\r
210 };\r
211 \r
212 // Converts Q3F/ETF Team Spawn points to tf-recognized ones.\r
213 /*void () info_player_start =\r
214 {\r
215         if (self.allowteams == "blue")\r
216                 self.team_no = 1;\r
217         if (self.allowteams == "red")\r
218                 self.team_no = 2;\r
219         i_p_t();\r
220 };*/\r
221 \r
222 void() info_notnull =\r
223 {\r
224         if (self.give != "")\r
225         {\r
226                 ConvertToBackPack ();\r
227         }\r
228         if (self.groupname == "blueflag")\r
229                 ConvertToFlag(1);\r
230         if (self.groupname == "redflag")\r
231                 ConvertToFlag(2);\r
232 };\r
233 \r
234 void() func_goalinfo =\r
235 {\r
236         if (self.give != "")\r
237         {\r
238                 ConvertToBackPack ();\r
239         }\r
240         if (self.groupname == "blueflag")\r
241                 ConvertToFlag(1);\r
242         if (self.groupname == "redflag")\r
243                 ConvertToFlag(2);\r
244 };\r
245 \r
246 void() func_goalitem =\r
247 {\r
248         if (self.give != "")\r
249         {\r
250                 ConvertToBackPack ();\r
251         }\r
252         if (self.groupname == "blueflag" && self.gameindex != 3) {\r
253                 ConvertToFlag(1);\r
254         }\r
255         if (self.groupname == "redflag" && self.gameindex != 3) {\r
256                 ConvertToFlag(2);\r
257         }\r
258 };\r
259 \r
260 // Converts trigger_multiples to Flag Goals (the point(s) where the flag is capped).\r
261 //This works for q3f_forts and machse and a couple other ones. \r
262 void(float tno) ConvertToGoal =\r
263 {\r
264         if (!self.teamscore)\r
265                 return;\r
266         if (tno == 1)\r
267         {\r
268                 self.team_no = 2;\r
269                 self.axhitme = 200;\r
270                 self.items_allowed = 200;\r
271         }\r
272         if (tno == 2)\r
273         {\r
274                 self.team_no = 1;\r
275                 self.axhitme = 100;\r
276                 self.items_allowed = 100;\r
277         }\r
278 \r
279         self.is_converted_goal = "yes"; // used with spawn point finder, no connnection with the actual conversion\r
280 \r
281         self.goal_result = 2;\r
282         self.noise = self.active_all_sound;\r
283         self.frags = self.teamscore;\r
284         self.count = self.teamscore;\r
285         self.classname = "i_t_g";\r
286 \r
287         self.g_a = 1;\r
288         self.g_e = 3;\r
289 \r
290         i_t_g();\r
291 };\r
292 \r
293 void() CheckIfQ3FTrigger =                      // Handles trigger_multiples from Q3F/ETF -- called from trigger_multiple\r
294 {\r
295         if (self.holding == "blueflag")\r
296                 ConvertToGoal (1);\r
297         if (self.holding == "redflag")\r
298                 ConvertToGoal (2);\r
299         if (self.holding == "oneflag" && self.allowteams == "blue")\r
300                 ConvertToGoal (1);\r
301         if (self.holding == "oneflag" && self.allowteams == "red")\r
302                 ConvertToGoal (2);\r
303 };\r