1 // --------------------------------------------------------------------------
\r
2 // BEGIN REQUIRED CSQC FUNCTIONS
\r
6 void() menu_show_error =
\r
8 drawstring('0 200', "ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!", '8 8 0', '1 0 0', 1, 0);
\r
11 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
\r
12 // Useful for precaching things
\r
14 void() menu_sub_null =
\r
18 void CSQC_Init(void)
\r
20 menu_visible = FALSE;
\r
21 menu_show = menu_show_error;
\r
22 menu_action = menu_sub_null;
\r
24 localcmd("alias order \"cmd order $*\"");
\r
25 //registercmd("ctf_menu");
\r
26 registercmd("ons_map");
\r
27 //registercmd("menu_action");
\r
33 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
\r
34 void CSQC_Shutdown(void)
\r
38 // CSQC_ConsoleCommand : Used to parse commands in the console that have been registered with the "registercmd" function
\r
39 // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
\r
40 float CSQC_ConsoleCommand(string strMessage)
\r
42 local float nReturn;
\r
46 tokenize(strMessage);
\r
49 local string strCmd;
\r
52 /*if(strCmd == "ctf_menu") {
\r
56 if(strCmd == "ons_map") {
\r
63 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
\r
64 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
\r
65 // All keys are in ascii.
\r
66 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
\r
67 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
\r
68 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
\r
69 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
\r
71 local float bSkipKey;
\r
74 if(menu_action(bInputType, nPrimary, nSecondary))
\r
79 // END REQUIRED CSQC FUNCTIONS
\r
80 // --------------------------------------------------------------------------
\r
82 // --------------------------------------------------------------------------
\r
83 // BEGIN OPTIONAL CSQC FUNCTIONS
\r
85 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
\r
86 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
\r
87 void(float bIsNewEntity) CSQC_Ent_Update =
\r
89 self.enttype = ReadByte();
\r
91 /*if (self.enttype == ENT_CLIENT)
\r
93 setmodelindex(self, ReadShort());
\r
94 self.origin_x = ReadCoord();
\r
95 self.origin_y = ReadCoord();
\r
96 self.origin_z = ReadCoord();
\r
97 self.angles_x = ReadCoord();
\r
98 self.angles_y = ReadCoord();
\r
99 self.angles_z = ReadCoord();
\r
100 self.velocity_x = ReadCoord();
\r
101 self.velocity_y = ReadCoord();
\r
102 self.velocity_z = ReadCoord();
\r
103 pmove_org = self.origin;
\r
104 pmove_vel = self.velocity;
\r
105 self.avelocity_x = ReadCoord();
\r
106 self.avelocity_y = ReadCoord();
\r
107 self.avelocity_z = ReadCoord();
\r
108 self.movetype = ReadShort();
\r
109 self.frame = ReadShort();
\r
110 self.flags = ReadShort();
\r
111 self.colormap = ReadShort();
\r
112 setorigin(self, self.origin); // relink
\r
115 setsize(self, '0 0 0', '0 0 0');
\r
116 self.drawmask = MASK_NORMAL;
\r
117 //self.think = Client_Think;
\r
118 //self.nextthink = time;
\r
120 self.ctf_state = ReadByte();
\r
122 if(self.enttype == ENT_CLIENT_ENTCS)
\r
124 self.sv_entnum = ReadByte();
\r
125 self.origin_x = ReadCoord();
\r
126 self.origin_y = ReadCoord();
\r
127 self.angles_y = ReadCoord();
\r
128 self.origin_z = self.angles_x = self.angles_z = 0;
\r
132 //print(strcat("Adding entity: ", ftos(self.sv_entnum), "\n"));
\r
133 self.chain = gps_start;
\r
138 error("unknown entity type in CSQC_Ent_Update\n");
\r
141 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
\r
142 void CSQC_Ent_Remove()
\r
144 if(self.enttype == ENT_CLIENT_ENTCS)
\r
146 if(gps_start == self)
\r
147 gps_start = self.chain;
\r
153 while(ent.chain != self && ent.chain != world)
\r
155 if(ent.chain == self)
\r
156 ent.chain = self.chain;
\r
162 void Gamemode_Init()
\r
164 local string mapinfo, infoline;
\r
167 local vector mi_min, mi_max;
\r
169 gametype = cvar("gametype");
\r
170 if(gametype == GAME_ONSLAUGHT) {
\r
171 if(!strcasecmp(substring(mapname, 0, 5), "maps/"))
\r
172 minimapname = substring(mapname, 5, 999);
\r
174 minimapname = mapname;
\r
175 len = strlen(minimapname);
\r
176 if(!strcasecmp(substring(minimapname, len-4, 4), ".bsp"))
\r
177 minimapname = substring(minimapname, 0, len-4);
\r
179 mapinfo = strcat("maps/", minimapname, ".info");
\r
180 minimapname = strzone(strcat("gfx/", minimapname, "_mini.tga"));
\r
182 mi_min = world.mins;
\r
183 mi_max = world.maxs;
\r
185 file = fopen(mapinfo, FILE_READ);
\r
187 while((infoline = fgets(file))) {
\r
188 if(!strncasecmp(infoline, "mins", 4)) {
\r
189 mi_min = stov(substring(infoline, 5, 999));
\r
190 } else if(!strncasecmp(infoline, "maxs", 4)) {
\r
191 mi_max = stov(substring(infoline, 5, 999));
\r
192 } else if(strncasecmp(infoline, "//", 2)) { // don't print comment-style lines
\r
193 print(strcat("mapinfo: ", infoline, "\n"));
\r
197 print(strcat("^1Error: ^7Mapinfo file '", mapinfo, "' missing! Minimap will be screwed.\n"));
\r
201 print(strcat("Mins: ", vtos(mi_min), " Maxs: ", vtos(mi_max), "\n"));
\r
203 mi_center = (mi_min + mi_max) * 0.5;
\r
204 mi_scale = mi_max - mi_min;
\r
207 print(strcat("Using ", minimapname, " as minimap.\n"));
\r
208 precache_pic(minimapname);
\r
209 precache_pic("gfx/ons-cp-neutral.tga");
\r
210 precache_pic("gfx/ons-cp-red.tga");
\r
211 precache_pic("gfx/ons-cp-blue.tga");
\r
212 precache_pic("gfx/ons-frame.tga");
\r
213 precache_pic("gfx/ons-frame-team.tga");
\r
216 // CSQC_Parse_StuffCmd : Provides the stuffcmd string in the first parameter that the server provided. To execute standard behavior, simply execute localcmd with the string.
\r
217 void CSQC_Parse_StuffCmd(string strMessage)
\r
219 localcmd(strMessage);
\r
220 // watch for gametype changes!
\r
221 if(gametype != cvar("gametype"))
\r
226 // CSQC_Parse_Print : Provides the print string in the first parameter that the server provided. To execute standard behavior, simply execute print with the string.
\r
227 void CSQC_Parse_Print(string strMessage)
\r
231 // CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided. To execute standard behavior, simply execute cprint with the string.
\r
232 void CSQC_Parse_CenterPrint(string strMessage)
\r
234 cprint(strMessage);
\r
236 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
\r
237 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
\r
238 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
\r
239 float CSQC_Parse_TempEntity()
\r
241 local float bHandled;
\r
245 nTEID = ReadByte();
\r
250 // Do something cool with TE_GUNSHOT!
\r
253 // No special logic for this temporary entity; return 0 so the engine can handle it
\r