2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <sys/types.h>
32 #include "openal_wrapper.h"
35 #include "Animation.h"
40 // Added more evilness needed for MSVC
42 #define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
43 #define snprintf(buf, size, format, ...) _sprintf_p(buf, size, format)
47 extern float multiplier;
49 extern int environment;
50 extern float texscale;
51 extern Terrain terrain;
52 extern int channels[100];
53 extern int kTextureSize;
54 extern float screenwidth,screenheight;
57 extern float texdetail;
58 extern Objects objects;
60 extern float slomodelay;
61 extern bool floatjump;
64 extern float texdetail;
65 extern GLubyte bloodText[512*512*3];
66 extern GLubyte wolfbloodText[512*512*3];
67 extern float terraindetail;
68 extern float camerashake;
70 extern float blackout;
71 extern bool cellophane;
72 extern bool musictoggle;
73 extern int difficulty;
74 extern int bloodtoggle;
75 extern bool invertmouse;
77 extern float precipdelay;
78 extern XYZ viewerfacing;
79 extern bool ambientsound;
80 extern bool mousejump;
81 extern float viewdistance;
83 extern bool autoslomo;
84 extern bool keyboardfrozen;
85 extern int netdatanew;
86 extern bool loadingstuff;
87 extern char mapname[256];
88 extern XYZ windvector;
89 extern bool debugmode;
92 extern int oldmainmenu;
93 extern bool visibleloading;
94 extern int loadscreencolor;
95 extern float flashamount,flashr,flashg,flashb;
96 extern int flashdelay;
97 extern XYZ envsound[30];
98 extern float envsoundvol[30];
99 extern int numenvsounds;
100 extern float envsoundlife[30];
101 extern float usermousesensitivity;
102 extern bool ismotionblur;
104 extern bool trilinear;
105 extern bool damageeffects;
106 extern bool showpoints;
107 extern bool showdamagebar; // (des)activate the damage bar
108 extern bool texttoggle;
109 extern bool alwaysblur;
110 extern float gamespeed;
113 extern bool immediate;
114 extern bool velocityblur;
117 extern float bonusvalue;
118 extern float bonustotal;
119 extern float bonustime;
120 extern float startbonustotal;
121 extern float tintr,tintg,tintb;
122 extern float bonusnum[100];
123 extern bool skyboxtexture;
124 extern float skyboxr;
125 extern float skyboxg;
126 extern float skyboxb;
127 extern float skyboxlightr;
128 extern float skyboxlightg;
129 extern float skyboxlightb;
130 extern float fadestart;
131 extern float slomospeed;
132 extern float slomofreq;
133 extern int tutoriallevel;
134 extern float smoketex;
135 extern float tutorialstagetime;
136 extern int tutorialstage;
137 extern float tutorialmaxtime;
138 extern float tutorialsuccess;
139 extern bool againbonus;
140 extern bool reversaltrain;
141 extern bool canattack;
142 extern bool cananger;
143 extern float damagedealt;
145 extern int editoractive;
146 extern int editorpathtype;
148 extern float hostiletime;
150 extern bool gamestarted;
152 extern int numhotspots;
153 extern int winhotspot;
154 extern int windialogue;
155 extern int killhotspot;
156 extern XYZ hotspot[40];
157 extern int hotspottype[40];
158 extern float hotspotsize[40];
159 extern char hotspottext[40][256];
160 extern int currenthotspot;
162 extern int kBitsPerPixel;
165 extern bool stillloading;
166 extern bool winfreeze;
168 extern int numdialogues;
169 extern int numdialogueboxes[max_dialogues];
170 extern int dialoguetype[max_dialogues];
171 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
172 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
173 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
174 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
175 extern char dialoguename[max_dialogues][max_dialoguelength][64];
176 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
177 extern XYZ participantlocation[max_dialogues][10];
178 extern int participantfocus[max_dialogues][max_dialoguelength];
179 extern int participantaction[max_dialogues][max_dialoguelength];
180 extern float participantrotation[max_dialogues][10];
181 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
182 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
183 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
184 extern int indialogue;
185 extern int whichdialogue;
186 extern int directing;
187 extern float dialoguetime;
188 extern int dialoguegonethrough[20];
190 extern bool campaign;
192 extern float oldgamespeed;
194 static const char *rabbitskin[] = {
195 ":Data:Textures:Fur3.jpg",
196 ":Data:Textures:Fur.jpg",
197 ":Data:Textures:Fur2.jpg",
198 ":Data:Textures:Lynx.jpg",
199 ":Data:Textures:Otter.jpg",
200 ":Data:Textures:Opal.jpg",
201 ":Data:Textures:Sable.jpg",
202 ":Data:Textures:Chocolate.jpg",
203 ":Data:Textures:BW2.jpg",
204 ":Data:Textures:WB2.jpg"
207 static const char *wolfskin[] = {
208 ":Data:Textures:Wolf.jpg",
209 ":Data:Textures:Darkwolf.jpg",
210 ":Data:Textures:Snowwolf.jpg"
213 #define STATIC_ASSERT(x) extern int s_a_dummy[2 * (!!(x)) - 1];
214 STATIC_ASSERT (rabbittype == 0 && wolftype == 1)
216 static const char **creatureskin[] = {rabbitskin, wolfskin};
218 /* Return true if PFX is a prefix of STR (case-insensitive). */
219 static bool stripfx(const char *str, const char *pfx)
221 return !strncasecmp(str, pfx, strlen(pfx));
224 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
225 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
228 static const char *cmd_names[] = {
229 #define DECLARE_COMMAND(cmd) #cmd " ",
230 #include "ConsoleCmds.h"
231 #undef DECLARE_COMMAND
234 typedef void (*console_handler)(Game *game, const char *args);
236 #define DECLARE_COMMAND(cmd) static void ch_##cmd(Game *game, const char *args);
237 #include "ConsoleCmds.h"
238 #undef DECLARE_COMMAND
240 static console_handler cmd_handlers[] = {
241 #define DECLARE_COMMAND(cmd) ch_##cmd,
242 #include "ConsoleCmds.h"
243 #undef DECLARE_COMMAND
246 static void ch_quit(Game *game, const char *args)
251 static void ch_map(Game *game, const char *args)
254 snprintf(buf, 63, ":Data:Maps:%s", args);
255 game->Loadlevel(buf);
256 game->whichlevel = -2;
260 static void ch_save(Game *game, const char *args)
263 int i, j, k, l, m, templength;
264 float headprop, bodyprop, armprop, legprop;
265 snprintf(buf, 63, ":Data:Maps:%s", args);
271 tfile=fopen( ConvertFileName(buf), "wb" );
272 fpackf(tfile, "Bi", mapvers);
273 fpackf(tfile, "Bi", maptype);
274 fpackf(tfile, "Bi", hostile);
275 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
276 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
277 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
278 fpackf(tfile, "Bf Bf Bf Bf Bf Bi", player[0].coords.x, player[0].coords.y, player[0].coords.z, player[0].rotation, player[0].targetrotation, player[0].num_weapons);
279 if(player[0].num_weapons>0&&player[0].num_weapons<5)
280 for(j=0;j<player[0].num_weapons;j++){
281 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
284 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
285 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
286 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
287 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
289 fpackf(tfile, "Bi", player[0].numclothes);
291 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
293 fpackf(tfile, "Bi", numdialogues);
294 for(k=0;k<numdialogues;k++){
295 fpackf(tfile, "Bi", numdialogueboxes[k]);
296 fpackf(tfile, "Bi", dialoguetype[k]);
298 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
299 fpackf(tfile, "Bf", participantrotation[k][l]);
301 for(l=0;l<numdialogueboxes[k];l++){
302 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
303 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
304 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
305 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
306 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
308 templength=strlen(dialoguetext[k][l]);
309 fpackf(tfile, "Bi",(templength));
310 for(m=0;m<templength;m++){
311 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
312 if(dialoguetext[k][l][m]=='\0')break;
315 templength=strlen(dialoguename[k][l]);
316 fpackf(tfile, "Bi",templength);
317 for(m=0;m<templength;m++){
318 fpackf(tfile, "Bb", dialoguename[k][l][m]);
319 if(dialoguename[k][l][m]=='\0')break;
322 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
323 fpackf(tfile, "Bi", participantfocus[k][l]);
324 fpackf(tfile, "Bi", participantaction[k][l]);
327 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
329 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
333 for(k=0;k<player[0].numclothes;k++){
334 templength=strlen(player[0].clothes[k]);
335 fpackf(tfile, "Bi", templength);
336 for(l=0;l<templength;l++)
337 fpackf(tfile, "Bb", player[0].clothes[k][l]);
338 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
341 fpackf(tfile, "Bi", environment);
343 fpackf(tfile, "Bi", objects.numobjects);
345 for(k=0;k<objects.numobjects;k++){
346 fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", objects.type[k], objects.rotation[k], objects.rotation2[k], objects.position[k].x, objects.position[k].y, objects.position[k].z, objects.scale[k]);
349 fpackf(tfile, "Bi", numhotspots);
350 for(i=0;i<numhotspots;i++){
351 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
352 templength=strlen(hotspottext[i]);
353 fpackf(tfile, "Bi",templength);
354 for(l=0;l<templength;l++)
355 fpackf(tfile, "Bb", hotspottext[i][l]);
358 fpackf(tfile, "Bi", numplayers);
359 if(numplayers<maxplayers)
360 for(j=1;j<numplayers;j++){
361 fpackf(tfile, "Bi Bi Bf Bf Bf Bi Bi Bf Bb Bf", player[j].whichskin, player[j].creature, player[j].coords.x, player[j].coords.y, player[j].coords.z, player[j].num_weapons, player[j].howactive, player[j].scale, player[j].immobile, player[j].rotation);
362 if(player[j].num_weapons<5)
363 for(k=0;k<player[j].num_weapons;k++){
364 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
366 if(player[j].numwaypoints<30){
367 fpackf(tfile, "Bi", player[j].numwaypoints);
368 for(k=0;k<player[j].numwaypoints;k++){
369 fpackf(tfile, "Bf", player[j].waypoints[k].x);
370 fpackf(tfile, "Bf", player[j].waypoints[k].y);
371 fpackf(tfile, "Bf", player[j].waypoints[k].z);
372 fpackf(tfile, "Bi", player[j].waypointtype[k]);
374 fpackf(tfile, "Bi", player[j].waypoint);
376 player[j].numwaypoints=0;
377 player[j].waypoint=0;
378 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
381 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
382 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
383 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
384 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
386 if(player[j].creature==wolftype) {
387 headprop=player[j].proportionhead.x/1.1;
388 bodyprop=player[j].proportionbody.x/1.1;
389 armprop=player[j].proportionarms.x/1.1;
390 legprop=player[j].proportionlegs.x/1.1;
391 } else if(player[j].creature==rabbittype){
392 headprop=player[j].proportionhead.x/1.2;
393 bodyprop=player[j].proportionbody.x/1.05;
394 armprop=player[j].proportionarms.x/1.00;
395 legprop=player[j].proportionlegs.x/1.1;
398 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
400 fpackf(tfile, "Bi", player[j].numclothes);
401 if(player[j].numclothes)
402 for(k=0;k<player[j].numclothes;k++){
404 templength=strlen(player[j].clothes[k]);
405 fpackf(tfile, "Bi", templength);
406 for(l=0;l<templength;l++)
407 fpackf(tfile, "Bb", player[j].clothes[k][l]);
408 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
412 fpackf(tfile, "Bi", game->numpathpoints);
413 for(j=0;j<game->numpathpoints;j++){
414 fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]);
415 for(k=0;k<game->numpathpointconnect[j];k++){
416 fpackf(tfile, "Bi", game->pathpointconnect[j][k]);
420 fpackf(tfile, "Bf Bf Bf Bf", game->mapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius);
425 static void ch_cellar(Game *game, const char *args)
427 game->LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
430 static void ch_tint(Game *game, const char *args)
432 sscanf(args, "%f%f%f", &tintr, &tintg, &tintb);
435 static void ch_tintr(Game *game, const char *args)
440 static void ch_tintg(Game *game, const char *args)
445 static void ch_tintb(Game *game, const char *args)
450 static void ch_speed(Game *game, const char *args)
452 player[0].speedmult = atof(args);
455 static void ch_strength(Game *game, const char *args)
457 player[0].power = atof(args);
460 static void ch_power(Game *game, const char *args)
462 player[0].power = atof(args);
465 static void ch_size(Game *game, const char *args)
467 player[0].scale = atof(args) * .2;
470 static int find_closest()
473 float closestdist = 1.0/0.0;
475 for (int i = 1; i < numplayers; i++) {
477 distance = findDistancefast(&player[i].coords,&player[0].coords);
478 if (distance < closestdist) {
479 closestdist = distance;
486 static void ch_sizenear(Game *game, const char *args)
488 int closest = find_closest();
491 player[closest].scale = atof(args) * .2;
494 static void set_proportion(int pnum, const char *args)
496 float headprop,bodyprop,armprop,legprop;
498 sscanf(args, "%f%f%f%f", &headprop, &bodyprop, &armprop, &legprop);
500 if(player[pnum].creature==wolftype){
501 player[pnum].proportionhead=1.1*headprop;
502 player[pnum].proportionbody=1.1*bodyprop;
503 player[pnum].proportionarms=1.1*armprop;
504 player[pnum].proportionlegs=1.1*legprop;
505 } else if(player[pnum].creature==rabbittype){
506 player[pnum].proportionhead=1.2*headprop;
507 player[pnum].proportionbody=1.05*bodyprop;
508 player[pnum].proportionarms=1.00*armprop;
509 player[pnum].proportionlegs=1.1*legprop;
510 player[pnum].proportionlegs.y=1.05*legprop;
514 static void ch_proportion(Game *game, const char *args)
516 set_proportion(0, args);
519 static void ch_proportionnear(Game *game, const char *args)
521 int closest = find_closest();
523 set_proportion(closest, args);
526 static void set_protection(int pnum, const char *args)
528 float head, high, low;
529 sscanf(args, "%f%f%f", &head, &high, &low);
531 player[pnum].protectionhead = head;
532 player[pnum].protectionhigh = high;
533 player[pnum].protectionlow = low;
536 static void ch_protection(Game *game, const char *args)
538 set_protection(0, args);
541 static void ch_protectionnear(Game *game, const char *args)
543 int closest = find_closest();
545 set_protection(closest, args);
548 static void set_armor(int pnum, const char *args)
550 float head, high, low;
551 sscanf(args, "%f%f%f", &head, &high, &low);
553 player[pnum].armorhead = head;
554 player[pnum].armorhigh = high;
555 player[pnum].armorlow = low;
558 static void ch_armor(Game *game, const char *args)
563 static void ch_armornear(Game *game, const char *args)
565 int closest = find_closest();
567 set_armor(closest, args);
570 static void ch_protectionreset(Game *game, const char *args)
572 set_protection(0, "1 1 1");
573 set_armor(0, "1 1 1");
576 static void set_metal(int pnum, const char *args)
578 float head, high, low;
579 sscanf(args, "%f%f%f", &head, &high, &low);
581 player[pnum].metalhead = head;
582 player[pnum].metalhigh = high;
583 player[pnum].metallow = low;
586 static void ch_metal(Game *game, const char *args)
591 static void set_noclothes(int pnum, Game *game, const char *args)
593 player[pnum].numclothes = 0;
594 game->LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin],
595 &player[pnum].skeleton.drawmodel.textureptr,1,
596 &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize);
599 static void ch_noclothes(Game *game, const char *args)
601 set_noclothes(0, game, args);
604 static void ch_noclothesnear(Game *game, const char *args)
606 int closest = find_closest();
608 set_noclothes(closest, game, args);
612 static void set_clothes(int pnum, Game *game, const char *args)
615 snprintf(buf, 63, ":Data:Textures:%s.png", args);
617 if (!game->AddClothes(buf,0,1,&player[pnum].skeleton.skinText[pnum],&player[pnum].skeleton.skinsize))
620 player[pnum].DoMipmaps(5,0,0,player[pnum].skeleton.skinsize,player[pnum].skeleton.skinsize);
621 strcpy(player[pnum].clothes[player[pnum].numclothes],buf);
622 player[pnum].clothestintr[player[pnum].numclothes]=tintr;
623 player[pnum].clothestintg[player[pnum].numclothes]=tintg;
624 player[pnum].clothestintb[player[pnum].numclothes]=tintb;
625 player[pnum].numclothes++;
628 static void ch_clothes(Game *game, const char *args)
630 set_clothes(0, game, args);
633 static void ch_clothesnear(Game *game, const char *args)
635 int closest = find_closest();
637 set_clothes(closest, game, args);
640 static void ch_belt(Game *game, const char *args)
642 player[0].skeleton.clothes = !player[0].skeleton.clothes;
646 static void ch_cellophane(Game *game, const char *args)
648 cellophane = !cellophane;
649 float mul = cellophane ? 0 : 1;
651 for (int i = 0; i < numplayers; i++) {
652 player[i].proportionhead.z = player[i].proportionhead.x * mul;
653 player[i].proportionbody.z = player[i].proportionbody.x * mul;
654 player[i].proportionarms.z = player[i].proportionarms.x * mul;
655 player[i].proportionlegs.z = player[i].proportionlegs.x * mul;
659 static void ch_funnybunny(Game *game, const char *args)
661 player[0].skeleton.id=0;
662 player[0].skeleton.Load(":Data:Skeleton:Basic Figure",":Data:Skeleton:Basic Figurelow",
663 ":Data:Skeleton:Rabbitbelt",":Data:Models:Body.solid",
664 ":Data:Models:Body2.solid",":Data:Models:Body3.solid",
665 ":Data:Models:Body4.solid",":Data:Models:Body5.solid",
666 ":Data:Models:Body6.solid",":Data:Models:Body7.solid",
667 ":Data:Models:Bodylow.solid",":Data:Models:Belt.solid",1);
668 game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
669 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
670 player[0].creature=rabbittype;
672 player[0].headless=0;
673 player[0].damagetolerance=200;
674 set_proportion(0, "1 1 1 1");
677 static void ch_wolfie(Game *game, const char *args)
679 player[0].skeleton.id=0;
680 player[0].skeleton.Load(":Data:Skeleton:Basic Figure Wolf",":Data:Skeleton:Basic Figure Wolf Low",
681 ":Data:Skeleton:Rabbitbelt",":Data:Models:Wolf.solid",
682 ":Data:Models:Wolf2.solid",":Data:Models:Wolf3.solid",
683 ":Data:Models:Wolf4.solid",":Data:Models:Wolf5.solid",
684 ":Data:Models:Wolf6.solid",":Data:Models:Wolf7.solid",
685 ":Data:Models:Wolflow.solid",":Data:Models:Belt.solid",0);
686 game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
687 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
688 player[0].creature=wolftype;
689 player[0].damagetolerance=300;
690 set_proportion(0, "1 1 1 1");
693 static void ch_wolfieisgod(Game *game, const char *args)
695 ch_wolfie(game, args);
698 static void ch_wolf(Game *game, const char *args)
700 game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
701 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
704 static void ch_snowwolf(Game *game, const char *args)
706 game->LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
707 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
710 static void ch_darkwolf(Game *game, const char *args)
712 game->LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
713 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
716 static void ch_lizardwolf(Game *game, const char *args)
718 game->LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
719 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
722 static void ch_white(Game *game, const char *args)
724 game->LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,
725 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
728 static void ch_brown(Game *game, const char *args)
730 game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
731 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
734 static void ch_black(Game *game, const char *args)
736 game->LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,
737 &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
740 static void ch_sizemin(Game *game, const char *args)
743 for (i = 1; i < numplayers; i++)
744 if (player[i].scale < 0.8 * 0.2)
745 player[i].scale = 0.8 * 0.2;
748 static void ch_tutorial(Game *game, const char *args)
750 tutoriallevel = atoi(args);
753 static void ch_hostile(Game *game, const char *args)
755 hostile = atoi(args);
758 static void ch_indemo(Game *game, const char *args)
761 hotspot[numhotspots]=player[0].coords;
762 hotspotsize[numhotspots]=0;
763 hotspottype[numhotspots]=-111;
764 strcpy(hotspottext[numhotspots],"mapname");
768 static void ch_notindemo(Game *game, const char *args)
774 static void ch_type(Game *game, const char *args)
776 int i, n = sizeof(editortypenames) / sizeof(editortypenames[0]);
777 for (i = 0; i < n; i++)
778 if (stripfx(args, editortypenames[i])) {
784 static void ch_path(Game *game, const char *args)
786 int i, n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
787 for (i = 0; i < n; i++)
788 if (stripfx(args, pathtypenames[i])) {
794 static void ch_hs(Game *game, const char *args)
796 hotspot[numhotspots]=player[0].coords;
800 sscanf(args, "%f%d %n", &size, &type, &shift);
802 hotspotsize[numhotspots] = size;
803 hotspottype[numhotspots] = type;
805 strcpy(hotspottext[numhotspots], args + shift);
806 strcat(hotspottext[numhotspots], "\n");
811 static void ch_dialogue(Game *game, const char *args)
814 char buf1[32], buf2[64];
816 sscanf(args, "%d %31s", &dlg, buf1);
817 snprintf(buf2, 63, ":Data:Dialogues:%s.txt", buf1);
819 dialoguetype[numdialogues] = dlg;
821 memset(dialoguetext[numdialogues], 0, sizeof(dialoguetext[numdialogues]));
822 memset(dialoguename[numdialogues], 0, sizeof(dialoguename[numdialogues]));
824 ifstream ipstream(ConvertFileName(buf2));
825 ipstream.ignore(256,':');
826 ipstream >> numdialogueboxes[numdialogues];
827 for(i=0;i<numdialogueboxes[numdialogues];i++){
828 ipstream.ignore(256,':');
829 ipstream.ignore(256,':');
830 ipstream.ignore(256,' ');
831 ipstream >> dialogueboxlocation[numdialogues][i];
832 ipstream.ignore(256,':');
833 ipstream >> dialogueboxcolor[numdialogues][i][0];
834 ipstream >> dialogueboxcolor[numdialogues][i][1];
835 ipstream >> dialogueboxcolor[numdialogues][i][2];
836 ipstream.ignore(256,':');
837 ipstream.getline(dialoguename[numdialogues][i],64);
838 ipstream.ignore(256,':');
839 ipstream.ignore(256,' ');
840 ipstream.getline(dialoguetext[numdialogues][i],128);
842 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
844 ipstream.ignore(256,':');
845 ipstream >> dialogueboxsound[numdialogues][i];
848 for(i=0;i<numdialogueboxes[numdialogues];i++){
849 for(j=0;j<numplayers;j++){
850 participantfacing[numdialogues][i][j]=player[j].facing;
857 whichdialogue=numdialogues;
862 static void ch_fixdialogue(Game *game, const char *args)
864 char buf1[32], buf2[64];
867 sscanf(args, "%d %31s", &whichdi, buf1);
868 snprintf(buf2, 63, ":Data:Dialogues:%s.txt", buf1);
870 memset(dialoguetext[whichdi], 0, sizeof(dialoguetext[whichdi]));
871 memset(dialoguename[whichdi], 0, sizeof(dialoguename[whichdi]));
873 ifstream ipstream(ConvertFileName(buf2));
874 ipstream.ignore(256,':');
875 ipstream >> numdialogueboxes[whichdi];
876 for(i=0;i<numdialogueboxes[whichdi];i++){
877 ipstream.ignore(256,':');
878 ipstream.ignore(256,':');
879 ipstream.ignore(256,' ');
880 ipstream >> dialogueboxlocation[whichdi][i];
881 ipstream.ignore(256,':');
882 ipstream >> dialogueboxcolor[whichdi][i][0];
883 ipstream >> dialogueboxcolor[whichdi][i][1];
884 ipstream >> dialogueboxcolor[whichdi][i][2];
885 ipstream.ignore(256,':');
886 ipstream.getline(dialoguename[whichdi][i],64);
887 ipstream.ignore(256,':');
888 ipstream.ignore(256,' ');
889 ipstream.getline(dialoguetext[whichdi][i],128);
891 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
893 ipstream.ignore(256,':');
894 ipstream >> dialogueboxsound[whichdi][i];
900 static void ch_fixtype(Game *game, const char *args)
903 sscanf(args, "%d", &dlg);
904 dialoguetype[0] = dlg;
907 static void ch_fixrotation(Game *game, const char *args)
909 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
912 static void ch_ddialogue(Game *game, const char *args)
918 static void ch_dhs(Game *game, const char *args)
924 static void ch_immobile(Game *game, const char *args)
926 player[0].immobile = 1;
929 static void ch_allimmobile(Game *game, const char *args)
931 for (int i = 1; i < numplayers; i++)
932 player[i].immobile = 1;
935 static void ch_mobile(Game *game, const char *args)
937 player[0].immobile = 0;
940 static void ch_default(Game *game, const char *args)
942 player[0].armorhead=1;
943 player[0].armorhigh=1;
944 player[0].armorlow=1;
945 player[0].protectionhead=1;
946 player[0].protectionhigh=1;
947 player[0].protectionlow=1;
948 player[0].metalhead=1;
949 player[0].metalhigh=1;
950 player[0].metallow=1;
952 player[0].speedmult=1;
955 if(player[0].creature==wolftype){
956 player[0].proportionhead=1.1;
957 player[0].proportionbody=1.1;
958 player[0].proportionarms=1.1;
959 player[0].proportionlegs=1.1;
960 } else if(player[0].creature==rabbittype){
961 player[0].proportionhead=1.2;
962 player[0].proportionbody=1.05;
963 player[0].proportionarms=1.00;
964 player[0].proportionlegs=1.1;
965 player[0].proportionlegs.y=1.05;
968 player[0].numclothes=0;
969 game->LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin],
970 &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],
971 &player[0].skeleton.skinsize);
973 editoractive=typeactive;
974 player[0].immobile=0;
977 static void ch_play(Game *game, const char *args)
980 sscanf(args, "%d", &dlg);
983 if (whichdialogue >= numdialogues)
986 for(i=0;i<numdialogueboxes[whichdialogue];i++){
987 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
988 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
989 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
990 player[participantfocus[whichdialogue][i]].velocity=0;
991 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
992 player[participantfocus[whichdialogue][i]].targetframe=0;
1001 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
1002 temppos=temppos-viewer;
1003 Normalise(&temppos);
1013 whichsoundplay=rabbitchitter;
1014 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1015 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1016 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1017 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1018 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1019 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1020 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1021 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1022 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1023 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1024 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1025 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1026 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1027 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1028 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1029 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1030 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1031 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1032 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1033 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1034 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1035 OPENAL_SetVolume(channels[whichsoundplay], 256);
1036 OPENAL_SetPaused(channels[whichsoundplay], false);
1039 static void ch_mapkilleveryone(Game *game, const char *args)
1041 maptype = mapkilleveryone;
1044 static void ch_mapkillmost(Game *game, const char *args)
1046 maptype = mapkillmost;
1049 static void ch_mapkillsomeone(Game *game, const char *args)
1051 maptype = mapkillsomeone;
1054 static void ch_mapgosomewhere(Game *game, const char *args)
1056 maptype = mapgosomewhere;
1059 static void ch_viewdistance(Game *game, const char *args)
1061 viewdistance = atof(args)*100;
1064 static void ch_fadestart(Game *game, const char *args)
1066 fadestart = atof(args);
1069 static void ch_slomo(Game *game, const char *args)
1071 slomospeed = atof(args);
1076 static void ch_slofreq(Game *game, const char *args)
1078 slomofreq = atof(args);
1081 static void ch_skytint(Game *game, const char *args)
1083 sscanf(args, "%f%f%f", &skyboxr, &skyboxg, &skyboxb);
1085 skyboxlightr=skyboxr;
1086 skyboxlightg=skyboxg;
1087 skyboxlightb=skyboxb;
1089 game->SetUpLighting();
1091 terrain.DoShadows();
1092 objects.DoShadows();
1095 static void ch_skylight(Game *game, const char *args)
1097 sscanf(args, "%f%f%f", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1099 game->SetUpLighting();
1101 terrain.DoShadows();
1102 objects.DoShadows();
1105 static void ch_skybox(Game *game, const char *args)
1107 skyboxtexture = !skyboxtexture;
1109 game->SetUpLighting();
1111 terrain.DoShadows();
1112 objects.DoShadows();
1115 static void cmd_dispatch(Game *game, const char *cmd)
1117 int i, n_cmds = sizeof(cmd_names) / sizeof(cmd_names[0]);
1119 for (i = 0; i < n_cmds; i++)
1120 if (stripfx(cmd, cmd_names[i]))
1122 cmd_handlers[i](game, cmd + strlen(cmd_names[i]));
1127 PlaySoundEx(consolesuccesssound, samp[consolesuccesssound], NULL, true);
1128 OPENAL_SetVolume(channels[consolesuccesssound], 256);
1129 OPENAL_SetPaused(channels[consolesuccesssound], false);
1133 PlaySoundEx(consolefailsound, samp[consolefailsound], NULL, true);
1134 OPENAL_SetVolume(channels[consolefailsound], 256);
1135 OPENAL_SetPaused(channels[consolefailsound], false);
1139 /********************> Tick() <*****/
1140 extern bool save_image(const char * fname);
1141 void Screenshot (void)
1144 time_t t = time(NULL);
1145 struct tm *tme = localtime(&t);
1146 sprintf(temp, "Screenshots/Screenshot_%04d_%02d_%02d--%02d_%02d_%02d.png", tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec);
1149 mkdir("Screenshots");
1151 mkdir("Screenshots", S_IRWXU);
1159 void Game::SetUpLighting(){
1160 if(environment==snowyenvironment){
1164 light.ambient[0]=.4;
1165 light.ambient[1]=.4;
1166 light.ambient[2]=.44;
1168 if(environment==desertenvironment){
1172 light.ambient[0]=.4;
1173 light.ambient[1]=.35;
1174 light.ambient[2]=.3;
1177 if(environment==grassyenvironment){
1181 light.ambient[0]=.4;
1182 light.ambient[1]=.4;
1183 light.ambient[2]=.44;
1189 light.ambient[0]=.4;
1190 light.ambient[1]=.4;
1191 light.ambient[2]=.4;
1194 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
1195 light.color[0]*=(skyboxlightr+average)/2;
1196 light.color[1]*=(skyboxlightg+average)/2;
1197 light.color[2]*=(skyboxlightb+average)/2;
1198 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
1199 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
1200 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
1204 light.ambient[2]=0; */
1207 int Game::findPathDist(int start,int end){
1208 int i,j,k,smallestcount,count,connected;
1209 int last,last2,last3,last4;
1219 while(last!=end&&count<30){
1221 for(j=0;j<numpathpoints;j++){
1222 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
1225 if(numpathpointconnect[j])
1226 for(k=0;k<numpathpointconnect[j];k++){
1227 if(pathpointconnect[j][k]==last)connected=1;
1230 if(numpathpointconnect[last])
1231 for(k=0;k<numpathpointconnect[last];k++){
1232 if(pathpointconnect[last][k]==j)connected=1;
1235 if(closest==-1||Random()%2==0){
1246 if(count<smallestcount)smallestcount=count;
1248 return smallestcount;
1251 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
1252 static XYZ colpoint,colviewer,coltarget;
1253 static float minx,minz,maxx,maxz,miny,maxy;
1262 if(minx>endpoint.x)minx=endpoint.x;
1264 if(miny>endpoint.y)miny=endpoint.y;
1266 if(minz>endpoint.z)minz=endpoint.z;
1269 if(maxx<endpoint.x)maxx=endpoint.x;
1271 if(maxy<endpoint.y)maxy=endpoint.y;
1273 if(maxz<endpoint.z)maxz=endpoint.z;
1282 for(i=0;i<objects.numobjects;i++){
1283 if(objects.position[i].x>minx-objects.model[i].boundingsphereradius&&objects.position[i].x<maxx+objects.model[i].boundingsphereradius&&objects.position[i].y>miny-objects.model[i].boundingsphereradius&&objects.position[i].y<maxy+objects.model[i].boundingsphereradius&&objects.position[i].z>minz-objects.model[i].boundingsphereradius&&objects.position[i].z<maxz+objects.model[i].boundingsphereradius){
1284 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
1285 colviewer=startpoint;
1287 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
1292 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
1297 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
1298 static XYZ colpoint,colviewer,coltarget;
1299 static float minx,minz,maxx,maxz,miny,maxy;
1308 if(minx>endpoint.x)minx=endpoint.x;
1310 if(miny>endpoint.y)miny=endpoint.y;
1312 if(minz>endpoint.z)minz=endpoint.z;
1315 if(maxx<endpoint.x)maxx=endpoint.x;
1317 if(maxy<endpoint.y)maxy=endpoint.y;
1319 if(maxz<endpoint.z)maxz=endpoint.z;
1329 if(objects.position[what].x>minx-objects.model[what].boundingsphereradius&&objects.position[what].x<maxx+objects.model[what].boundingsphereradius&&objects.position[what].y>miny-objects.model[what].boundingsphereradius&&objects.position[what].y<maxy+objects.model[what].boundingsphereradius&&objects.position[what].z>minz-objects.model[what].boundingsphereradius&&objects.position[what].z<maxz+objects.model[what].boundingsphereradius){
1330 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
1331 colviewer=startpoint;
1333 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
1338 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
1343 void Game::Setenvironment(int which)
1347 LOG(" Setting environment...");
1349 float temptexdetail;
1352 OPENAL_SetPaused(channels[music1snow], true);
1353 OPENAL_SetPaused(channels[music1grass], true);
1354 OPENAL_SetPaused(channels[music1desert], true);
1355 OPENAL_SetPaused(channels[wind], true);
1356 OPENAL_SetPaused(channels[desertambient], true);
1358 OPENAL_SetPaused(channels[stream_music1snow], true);
1359 OPENAL_SetPaused(channels[stream_music1grass], true);
1360 OPENAL_SetPaused(channels[stream_music1desert], true);
1361 OPENAL_SetPaused(channels[stream_wind], true);
1362 OPENAL_SetPaused(channels[stream_desertambient], true);
1365 if(environment==snowyenvironment){
1369 //PlaySoundEx( wind, samp[wind], NULL, true);
1370 PlayStreamEx(stream_wind, samp[stream_wind], 0, true);
1371 OPENAL_SetPaused(channels[stream_wind], false);
1372 OPENAL_SetVolume(channels[stream_wind], 256);
1375 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
1376 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
1377 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
1378 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
1380 footstepsound = footstepsn1;
1381 footstepsound2 = footstepsn2;
1382 footstepsound3 = footstepst1;
1383 footstepsound4 = footstepst2;
1385 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
1387 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
1389 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
1394 temptexdetail=texdetail;
1395 if(texdetail>1)texdetail=4;
1396 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
1397 ":Data:Textures:Skybox(snow):Left.jpg",
1398 ":Data:Textures:Skybox(snow):Back.jpg",
1399 ":Data:Textures:Skybox(snow):Right.jpg",
1400 ":Data:Textures:Skybox(snow):Up.jpg",
1401 ":Data:Textures:Skybox(snow):Down.jpg",
1402 ":Data:Textures:Skybox(snow):Cloud.jpg",
1403 ":Data:Textures:Skybox(snow):Reflect.jpg");
1408 texdetail=temptexdetail;
1410 if(environment==desertenvironment){
1413 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
1414 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
1415 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
1416 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
1420 //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
1421 PlayStreamEx( stream_desertambient, samp[stream_desertambient], NULL, true);
1422 OPENAL_SetPaused(channels[stream_desertambient], false);
1423 OPENAL_SetVolume(channels[stream_desertambient], 256);
1426 footstepsound = footstepsn1;
1427 footstepsound2 = footstepsn2;
1428 footstepsound3 = footstepsn1;
1429 footstepsound4 = footstepsn2;
1431 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
1433 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
1435 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
1439 temptexdetail=texdetail;
1440 if(texdetail>1)texdetail=4;
1441 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
1442 ":Data:Textures:Skybox(sand):Left.jpg",
1443 ":Data:Textures:Skybox(sand):Back.jpg",
1444 ":Data:Textures:Skybox(sand):Right.jpg",
1445 ":Data:Textures:Skybox(sand):Up.jpg",
1446 ":Data:Textures:Skybox(sand):Down.jpg",
1447 ":Data:Textures:Skybox(sand):Cloud.jpg",
1448 ":Data:Textures:Skybox(sand):Reflect.jpg");
1453 texdetail=temptexdetail;
1455 if(environment==grassyenvironment){
1458 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
1459 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
1460 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
1461 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
1464 PlayStreamEx( stream_wind, samp[stream_wind], NULL, true);
1465 OPENAL_SetPaused(channels[stream_wind], false);
1466 OPENAL_SetVolume(channels[stream_wind], 100);
1469 footstepsound = footstepgr1;
1470 footstepsound2 = footstepgr2;
1471 footstepsound3 = footstepst1;
1472 footstepsound4 = footstepst2;
1474 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
1476 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
1478 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
1482 temptexdetail=texdetail;
1483 if(texdetail>1)texdetail=4;
1484 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
1485 ":Data:Textures:Skybox(grass):Left.jpg",
1486 ":Data:Textures:Skybox(grass):Back.jpg",
1487 ":Data:Textures:Skybox(grass):Right.jpg",
1488 ":Data:Textures:Skybox(grass):Up.jpg",
1489 ":Data:Textures:Skybox(grass):Down.jpg",
1490 ":Data:Textures:Skybox(grass):Cloud.jpg",
1491 ":Data:Textures:Skybox(grass):Reflect.jpg");
1495 texdetail=temptexdetail;
1497 temptexdetail=texdetail;
1499 terrain.load(":Data:Textures:heightmap.png");
1501 texdetail=temptexdetail;
1505 void Game::Loadlevel(int which){
1508 if(which==0)Loadlevel((char *)":Data:Maps:map1");
1509 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
1510 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
1511 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
1512 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
1513 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
1514 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
1515 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
1516 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
1517 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
1518 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
1519 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
1520 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
1521 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
1522 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
1523 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
1524 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
1525 else Loadlevel((char *)":Data:Maps:mapsave");
1530 void Game::Loadlevel(char *name){
1532 static int oldlevel;
1537 float headprop,legprop,armprop,bodyprop;
1541 LOG(std::string("Loading level...") + name);
1543 if(!gameon)visibleloading=1;
1545 if(stealthloading)visibleloading=0;
1547 if(!stillloading)loadtime=0;
1552 if(tutoriallevel!=-1)tutoriallevel=0;
1553 else tutoriallevel=1;
1555 if(tutoriallevel==1)tutorialstage=0;
1556 if(tutorialstage==0){
1557 tutorialstagetime=0;
1564 OPENAL_SetPaused(channels[whooshsound], true);
1565 OPENAL_SetPaused(channels[stream_firesound], true);
1567 // Change the map filename into something that is os specific
1568 char *FixedFN = ConvertFileName(name);
1572 tfile=fopen( FixedFN, "rb" );
1575 OPENAL_SetPaused(channels[stream_firesound], true);
1586 animation[bounceidleanim].Load((char *)"Idle",middleheight,neutral);
1592 dialoguegonethrough[i]=0;
1601 if(accountactive)difficulty=accountactive->getDifficulty();
1603 if(difficulty!=2)minimap=1;
1640 bonustotal=startbonustotal;
1646 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1647 OPENAL_SetVolume(channels[consolesuccesssound], 256);
1648 OPENAL_SetPaused(channels[consolesuccesssound], false);
1655 terrain.numdecals=0;
1656 Sprite::deleteSprites();
1657 for(i=0;i<objects.numobjects;i++)
1659 objects.model[i].numdecals=0;
1662 j=objects.numobjects;
1665 objects.DeleteObject(0);
1666 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1669 for(i=0;i<subdivision;i++)
1671 for(j=0;j<subdivision;j++)
1673 terrain.patchobjectnum[i][j]=0;
1676 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1679 weapons.numweapons=0;
1681 funpackf(tfile, "Bi", &mapvers);
1682 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
1684 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
1685 else maptype=mapkilleveryone;
1686 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1688 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1694 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1702 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1705 skyboxlightr=skyboxr;
1706 skyboxlightg=skyboxg;
1707 skyboxlightb=skyboxb;
1709 if(!stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].rotation,&player[0].targetrotation, &player[0].num_weapons);
1710 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1711 player[0].originalcoords=player[0].coords;
1712 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1714 for(j=0;j<player[0].num_weapons;j++)
1716 player[0].weaponids[j]=weapons.numweapons;
1717 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1718 weapons.owner[weapons.numweapons]=0;
1719 weapons.numweapons++;
1723 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1725 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1726 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1727 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1728 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1730 funpackf(tfile, "Bi", &player[0].numclothes);
1734 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1738 player[0].whichskin=0;
1739 player[0].creature=rabbittype;
1742 for(i=0;i<max_dialogues;i++)
1744 for(j=0;j<max_dialoguelength;j++)
1748 dialoguetext[i][j][k]='\0';
1752 dialoguename[i][j][k]='\0';
1757 player[0].lastattack=-1;
1758 player[0].lastattack2=-1;
1759 player[0].lastattack3=-1;
1763 funpackf(tfile, "Bi", &numdialogues);
1766 for(k=0;k<numdialogues;k++)
1768 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1769 funpackf(tfile, "Bi", &dialoguetype[k]);
1772 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1773 funpackf(tfile, "Bf", &participantrotation[k][l]);
1775 if(numdialogueboxes)
1777 for(l=0;l<numdialogueboxes[k];l++)
1779 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1780 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1781 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1782 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1783 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1787 funpackf(tfile, "Bi",&templength);
1788 if(templength>128||templength<=0)templength=128;
1789 for(m=0;m<templength;m++){
1790 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1791 if(dialoguetext[k][l][m]=='\0')break;
1794 funpackf(tfile, "Bi",&templength);
1795 if(templength>64||templength<=0)templength=64;
1796 for(m=0;m<templength;m++){
1797 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1798 if(dialoguename[k][l][m]=='\0'){
1802 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1803 funpackf(tfile, "Bi", &participantfocus[k][l]);
1804 funpackf(tfile, "Bi", &participantaction[k][l]);
1807 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1809 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1815 else numdialogues=0;
1817 if(player[0].numclothes)
1819 for(k=0;k<player[0].numclothes;k++)
1821 funpackf(tfile, "Bi", &templength);
1822 for(l=0;l<templength;l++)
1823 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1824 player[0].clothes[k][templength]='\0';
1825 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1829 funpackf(tfile, "Bi", &environment);
1831 funpackf(tfile, "Bi", &objects.numobjects);
1832 if(objects.numobjects)
1834 for(i=0;i<objects.numobjects;i++)
1836 funpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", &objects.type[i],&objects.rotation[i],&objects.rotation2[i], &objects.position[i].x, &objects.position[i].y, &objects.position[i].z,&objects.scale[i]);
1837 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1843 funpackf(tfile, "Bi", &numhotspots);
1846 for(i=0;i<numhotspots;i++)
1848 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1849 funpackf(tfile, "Bi", &templength);
1851 for(l=0;l<templength;l++)
1852 funpackf(tfile, "Bb", &hotspottext[i][l]);
1853 hotspottext[i][templength]='\0';
1854 if(hotspottype[i]==-111)indemo=1;
1860 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1865 for(i=0;i<objects.numobjects;i++)
1867 objects.center+=objects.position[i];
1869 objects.center/=objects.numobjects;
1872 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1874 float maxdistance=0;
1877 for(i=0;i<objects.numobjects;i++)
1879 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1880 if(tempdist>maxdistance)
1883 maxdistance=tempdist;
1886 objects.radius=fast_sqrt(maxdistance);
1889 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1890 //mapcenter=objects.center;
1891 //mapradius=objects.radius;
1893 funpackf(tfile, "Bi", &numplayers);
1894 int howmanyremoved=0;
1895 bool removeanother=0;
1896 if(numplayers>1&&numplayers<maxplayers)
1898 for(i=1;i<numplayers;i++)
1900 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1903 funpackf(tfile, "Bi Bi Bf Bf Bf Bi",&player[i-howmanyremoved].whichskin,&player[i-howmanyremoved].creature, &player[i-howmanyremoved].coords.x,&player[i-howmanyremoved].coords.y,&player[i-howmanyremoved].coords.z,&player[i-howmanyremoved].num_weapons);
1904 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1905 else player[i-howmanyremoved].howactive=typeactive;
1906 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1907 else player[i-howmanyremoved].scale=-1;
1908 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1909 else player[i-howmanyremoved].immobile=0;
1910 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1911 else player[i-howmanyremoved].rotation=0;
1912 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1913 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1919 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1921 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1923 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1924 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1925 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1926 weapons.numweapons++;
1929 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1930 //player[i-howmanyremoved].numwaypoints=10;
1931 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1933 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1934 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1935 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1936 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1937 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1940 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1941 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1943 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1944 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1945 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1946 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1948 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1956 if(player[i-howmanyremoved].creature==wolftype)
1958 player[i-howmanyremoved].proportionhead=1.1*headprop;
1959 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1960 player[i-howmanyremoved].proportionarms=1.1*armprop;
1961 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1964 if(player[i-howmanyremoved].creature==rabbittype)
1966 player[i-howmanyremoved].proportionhead=1.2*headprop;
1967 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1968 player[i-howmanyremoved].proportionarms=1.00*armprop;
1969 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1970 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1973 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1974 if(player[i-howmanyremoved].numclothes)
1976 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1979 funpackf(tfile, "Bi", &templength);
1980 for(l=0;l<templength;l++)
1981 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1982 player[i-howmanyremoved].clothes[k][templength]='\0';
1983 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1989 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1991 numplayers-=howmanyremoved;
1992 funpackf(tfile, "Bi", &numpathpoints);
1993 if(numpathpoints>30||numpathpoints<0)
1997 for(j=0;j<numpathpoints;j++)
1999 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
2000 for(k=0;k<numpathpointconnect[j];k++){
2001 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
2005 if(visibleloading){loadscreencolor=4; LoadingScreen();}
2007 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
2010 if(environment!=oldenvironment)Setenvironment(environment);
2011 oldenvironment=environment;
2015 j=objects.numobjects;
2016 objects.numobjects=0;
2019 //if(objects.type[i]!=spiketype)
2020 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
2021 if(visibleloading){loadscreencolor=4; LoadingScreen();}
2024 //if(skyboxtexture){
2025 terrain.DoShadows();
2026 if(visibleloading){loadscreencolor=4; LoadingScreen();}
2027 objects.DoShadows();
2028 if(visibleloading){loadscreencolor=4; LoadingScreen();}
2030 else terrain.DoLighting();
2036 oldlevel=whichlevel;
2039 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
2040 for(i=0;i<numplayers;i++)
2042 if(visibleloading){loadscreencolor=4; LoadingScreen();}
2046 if(i==0||player[i].scale<0)player[i].scale=.2;
2047 player[i].skeleton.free=0;
2048 player[i].skeleton.id=i;
2049 //if(Random()%2==0)player[i].creature=wolftype;
2050 //else player[i].creature=rabbittype;
2051 if(i==0&&mapvers<9)player[i].creature=rabbittype;
2052 if(player[i].creature!=wolftype)player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",0);
2055 if(player[i].creature!=wolftype){
2056 player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
2057 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
2059 if(player[i].creature==wolftype){
2060 player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
2066 texsize=512*512*3/texdetail/texdetail;
2067 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
2068 //player[i].skeleton.skinText.resize(texsize);
2070 LoadTextureSave(creatureskin[player[i].creature][player[i].whichskin],&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
2072 if(player[i].numclothes)
2074 for(j=0;j<player[i].numclothes;j++)
2076 tintr=player[i].clothestintr[j];
2077 tintg=player[i].clothestintg[j];
2078 tintb=player[i].clothestintb[j];
2079 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
2081 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
2084 player[i].currentanimation=bounceidleanim;
2085 player[i].targetanimation=bounceidleanim;
2086 player[i].currentframe=0;
2087 player[i].targetframe=1;
2089 player[i].speed=1+(float)(Random()%100)/1000;
2090 if(difficulty==0)player[i].speed-=.2;
2091 if(difficulty==1)player[i].speed-=.1;
2093 player[i].velocity=0;
2094 player[i].oldcoords=player[i].coords;
2095 player[i].realoldcoords=player[i].coords;
2098 player[i].skeleton.id=i;
2099 player[i].updatedelay=0;
2100 player[i].normalsupdatedelay=0;
2102 player[i].aitype=passivetype;
2103 player[i].aitarget=0;
2104 player[i].madskills=0;
2108 player[i].proportionhead=1.2;
2109 player[i].proportionbody=1.05;
2110 player[i].proportionarms=1.00;
2111 player[i].proportionlegs=1.1;
2112 player[i].proportionlegs.y=1.05;
2114 player[i].headless=0;
2115 player[i].currentoffset=0;
2116 player[i].targetoffset=0;
2117 /*player[i].armorhead=1;
2118 player[i].armorhigh=1;
2119 player[i].armorlow=1;
2120 player[i].protectionhead=1;
2121 player[i].protectionhigh=1;
2122 player[i].protectionlow=1;
2123 player[i].metalhead=1;
2124 player[i].metalhigh=1;
2125 player[i].metallow=1;
2127 player[i].speedmult=1;*/
2129 player[i].damagetolerance=200;
2131 if(player[i].creature==wolftype)
2133 /*player[i].proportionhead=1.1;
2134 player[i].proportionbody=1.1;
2135 player[i].proportionarms=1.1;
2136 player[i].proportionlegs=1.1;
2137 player[i].proportionlegs.y=1.1;*/
2138 if(i==0||player[i].scale<0)player[i].scale=.23;
2140 player[i].damagetolerance=300;
2143 if(visibleloading){loadscreencolor=4; LoadingScreen();}
2146 player[i].proportionhead.z=0;
2147 player[i].proportionbody.z=0;
2148 player[i].proportionarms.z=0;
2149 player[i].proportionlegs.z=0;
2152 player[i].tempanimation.Load((char *)"Tempanim",0,0);
2154 player[i].headmorphness=0;
2155 player[i].targetheadmorphness=1;
2156 player[i].headmorphstart=0;
2157 player[i].headmorphend=0;
2159 player[i].pausetime=0;
2162 player[i].jumppower=5;
2164 player[i].permanentdamage=0;
2165 player[i].superpermanentdamage=0;
2167 player[i].forwardkeydown=0;
2168 player[i].leftkeydown=0;
2169 player[i].backkeydown=0;
2170 player[i].rightkeydown=0;
2171 player[i].jumpkeydown=0;
2172 player[i].crouchkeydown=0;
2173 player[i].throwkeydown=0;
2175 player[i].collided=-10;
2177 player[i].bloodloss=0;
2178 player[i].weaponactive=-1;
2179 player[i].weaponstuck=-1;
2180 player[i].bleeding=0;
2181 player[i].deathbleeding=0;
2182 player[i].stunned=0;
2183 player[i].hasvictim=0;
2184 player[i].wentforweapon=0;
2187 player[0].aitype=playercontrolled;
2188 player[0].weaponactive=-1;
2192 //player[0].speedmult=1/.9;
2193 player[0].power=1/.9;
2198 //player[0].speedmult=1/.8;
2199 player[0].power=1/.8;
2202 //player[0].weaponstuck=1;
2204 if(difficulty==1)player[0].damagetolerance=250;
2205 if(difficulty==0)player[0].damagetolerance=300;
2206 if(difficulty==0)player[0].armorhead*=1.5;
2207 if(difficulty==0)player[0].armorhigh*=1.5;
2208 if(difficulty==0)player[0].armorlow*=1.5;
2209 cameraloc=player[0].coords;
2211 rotation=player[0].rotation;
2213 hawkcoords=player[0].coords;
2216 if(visibleloading){loadscreencolor=4; LoadingScreen();}
2217 //weapons.numweapons=numplayers;
2218 for(i=0;i<weapons.numweapons;i++)
2220 weapons.bloody[i]=0;
2221 weapons.blooddrip[i]=0;
2222 weapons.blooddripdelay[i]=0;
2223 weapons.onfire[i]=0;
2224 weapons.flamedelay[i]=0;
2225 weapons.damage[i]=0;
2226 //weapons.type[i]=sword;
2227 if(weapons.type[i]==sword){
2228 weapons.mass[i]=1.5;
2229 weapons.tipmass[i]=1;
2230 weapons.length[i]=.8;
2232 if(weapons.type[i]==staff){
2234 weapons.tipmass[i]=1;
2235 weapons.length[i]=1.5;
2237 if(weapons.type[i]==knife){
2239 weapons.tipmass[i]=1.2;
2240 weapons.length[i]=.25;
2242 weapons.position[i]=-1000;
2243 weapons.tippoint[i]=-1000;
2246 LOG("Starting background music...");
2248 OPENAL_StopSound(OPENAL_ALL);
2249 if(environment==snowyenvironment)
2253 PlayStreamEx(stream_wind, samp[stream_wind], NULL, true);
2254 OPENAL_SetPaused(channels[stream_wind], false);
2255 OPENAL_SetVolume(channels[stream_wind], 256);
2258 else if(environment==desertenvironment)
2262 //PlaySoundEx(desertambient,
2263 // samp[desertambient], NULL, true);
2264 PlayStreamEx(stream_desertambient,
2265 samp[stream_desertambient], NULL, true);
2266 OPENAL_SetPaused(channels[stream_desertambient], false);
2267 OPENAL_SetVolume(channels[stream_desertambient], 256);
2270 else if(environment==grassyenvironment)
2274 //PlaySoundEx(wind, samp[wind], NULL, true);
2275 PlayStreamEx(stream_wind, samp[stream_wind], NULL, true);
2276 OPENAL_SetPaused(channels[stream_wind], false);
2277 OPENAL_SetVolume(channels[stream_wind], 100);
2280 oldmusicvolume[0]=0;
2281 oldmusicvolume[1]=0;
2282 oldmusicvolume[2]=0;
2283 oldmusicvolume[3]=0;
2297 static int i,k,j,l,m;
2298 static XYZ facing,flatfacing,absflatfacing;
2299 static XYZ rotatetarget;
2301 static float oldtargetrotation;
2302 static int target, numgood;
2303 static XYZ tempcoords1,tempcoords2;
2306 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
2307 static int whichhit;
2308 static bool oldjumpkeydown;
2312 float headprop,bodyprop,armprop,legprop;
2315 displaytime[i]+=multiplier;
2320 if (Input::isKeyDown(SDLK_F6) && !freezetogglekeydown) {
2321 if (Input::isKeyDown(SDLK_LSHIFT)) {
2324 stereoreverse=false;
2327 if (stereoreverse) {
2328 printf("Stereo reversed\n");
2330 printf("Stereo unreversed\n");
2332 freezetogglekeydown=1;
2335 if (Input::isKeyDown(SDLK_F7)) {
2336 if (Input::isKeyDown(SDLK_LSHIFT)) {
2337 stereoseparation -= 0.001;
2339 stereoseparation -= 0.010;
2342 printf("Stereo decreased increased to %f\n", stereoseparation);
2345 if (Input::isKeyDown(SDLK_F8)) {
2346 if (Input::isKeyDown(SDLK_LSHIFT)) {
2347 stereoseparation += 0.001;
2349 stereoseparation += 0.010;
2352 printf("Stereo separation increased to %f\n", stereoseparation);
2357 if(mainmenu&&endgame==1)mainmenu=10;
2358 if( (Input::isKeyDown(SDLK_ESCAPE)||(mainmenu==0&&((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))
2359 && !mainmenutogglekeydown
2360 && (!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==10)
2363 if(mainmenu==1||mainmenu==2||mainmenu==0){
2364 if(mainmenu==0&&!winfreeze)mainmenu=2;
2365 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
2366 else if(mainmenu==0&&winfreeze){
2369 else if(mainmenu==1||mainmenu==2)mainmenu=0;
2370 if(mainmenu&&musictoggle){
2371 if(mainmenu==1||mainmenu==2||mainmenu==100){
2372 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
2373 PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
2374 OPENAL_SetPaused(channels[stream_music3], false);
2375 OPENAL_SetVolume(channels[stream_music3], 256);
2376 OPENAL_SetPaused(channels[music1], true);
2380 OPENAL_SetPaused(channels[stream_music3], true);
2381 OPENAL_SetPaused(channels[music1], false);
2389 if(newdetail>2)newdetail=detail;
2390 if(newdetail<0)newdetail=detail;
2391 if(newscreenwidth<0)newscreenwidth=screenwidth;
2392 if(newscreenheight<0)newscreenheight=screenheight;
2394 SaveSettings(*this);
2396 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==10||mainmenu==100){
2401 if(mainmenu==3&&gameon)mainmenu=2;
2402 if(mainmenu==3&&!gameon)mainmenu=1;
2403 if(mainmenu==5&&gameon)mainmenu=2;
2404 if(mainmenu==5&&!gameon)mainmenu=1;
2405 if(mainmenu==4)mainmenu=3;
2406 if(mainmenu==6)mainmenu=5;
2407 if(mainmenu==7)mainmenu=1;
2408 if(mainmenu==9)mainmenu=5;
2409 if(mainmenu==10)mainmenu=5;
2415 mainmenutogglekeydown=1;
2417 if(!Input::isKeyDown(SDLK_ESCAPE)){
2418 mainmenutogglekeydown=0;
2422 static bool minimaptogglekeydown;
2423 if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown&&tutoriallevel){
2424 if(tutorialstage!=51)
2425 tutorialstagetime=tutorialmaxtime;
2426 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
2427 OPENAL_SetVolume(channels[consolefailsound], 128);
2428 OPENAL_SetPaused(channels[consolefailsound], false);
2429 minimaptogglekeydown=1;
2431 if(!Input::isKeyDown(SDLK_TAB)){
2432 minimaptogglekeydown=0;
2437 if(mainmenu==1||mainmenu==2){
2438 if(Input::Button()&&!oldbutton&&selected==1){
2440 fireSound(firestartsound);
2456 OPENAL_SetPaused(channels[stream_music3], true);
2457 OPENAL_SetPaused(channels[music1], false);
2461 if(Input::Button()&&!oldbutton&&selected==2){
2470 if(newdetail>2)newdetail=detail;
2471 if(newdetail<0)newdetail=detail;
2472 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2473 if(newscreenwidth<0)newscreenwidth=screenwidth;
2474 if(newscreenheight>3000)newscreenheight=screenheight;
2475 if(newscreenheight<0)newscreenheight=screenheight;
2478 if(Input::Button()&&!oldbutton&&selected==3){
2486 OPENAL_SetPaused(channels[stream_music3], true);
2496 if(Input::Button()&&!oldbutton&&selected!=-1){
2499 if(Input::Button()&&!oldbutton&&selected==0){
2501 extern SDL_Rect **resolutions;
2502 bool isCustomResolution = true;
2504 for (int i = 0; (!found) && (resolutions[i]); i++)
2506 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2507 isCustomResolution = false;
2509 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2512 if (resolutions[i] != NULL)
2514 newscreenwidth = (int) resolutions[i]->w;
2515 newscreenheight = (int) resolutions[i]->h;
2517 else if (isCustomResolution)
2519 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2521 newscreenwidth = (int) resolutions[0]->w;
2522 newscreenheight = (int) resolutions[0]->h;
2526 newscreenwidth = screenwidth;
2527 newscreenheight = screenheight;
2532 newscreenwidth = (int) resolutions[0]->w;
2533 newscreenheight = (int) resolutions[0]->h;
2541 newscreenwidth = (int) resolutions[0]->w;
2542 newscreenheight = (int) resolutions[0]->h;
2547 if(Input::Button()&&!oldbutton&&selected==1){
2549 if(newdetail>2)newdetail=0;
2551 if(Input::Button()&&!oldbutton&&selected==2){
2553 if(bloodtoggle>2)bloodtoggle=0;
2555 if(Input::Button()&&!oldbutton&&selected==3){
2557 if(difficulty>2)difficulty=0;
2559 if(Input::Button()&&!oldbutton&&selected==4){
2560 ismotionblur=1-ismotionblur;
2562 if(Input::Button()&&!oldbutton&&selected==5){
2565 if(Input::Button()&&!oldbutton&&selected==6){
2566 musictoggle=1-musictoggle;
2569 OPENAL_SetPaused(channels[music1], true);
2570 OPENAL_SetPaused(channels[stream_music2], true);
2571 OPENAL_SetPaused(channels[stream_music3], true);
2574 oldmusicvolume[i]=0;
2580 PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
2581 OPENAL_SetPaused(channels[stream_music3], false);
2582 OPENAL_SetVolume(channels[stream_music3], 256);
2585 if(Input::Button()&&!oldbutton&&selected==9){
2586 invertmouse=1-invertmouse;
2588 if(Input::Button()&&!oldbutton&&selected==10){
2589 usermousesensitivity+=.2;
2590 if(usermousesensitivity>2)usermousesensitivity=.2;
2592 if(Input::Button()&&!oldbutton&&selected==11){
2594 if(volume>1.0001f)volume=0;
2595 OPENAL_SetSFXMasterVolume((int)(volume*255));
2597 if(Input::Button()&&!oldbutton&&selected==7){
2608 if(Input::Button() && !oldbutton && selected == 12) {
2611 newstereomode = stereomode;
2615 if(Input::Button() && !oldbutton && selected == 13) {
2616 showdamagebar=!showdamagebar;
2618 if(Input::Button()&&!oldbutton&&selected==8){
2623 if(newdetail>2)newdetail=detail;
2624 if(newdetail<0)newdetail=detail;
2625 if(newscreenwidth<0)newscreenwidth=screenwidth;
2626 if(newscreenheight<0)newscreenheight=screenheight;
2629 SaveSettings(*this);
2630 if(mainmenu==3&&gameon)mainmenu=2;
2631 if(mainmenu==3&&!gameon)mainmenu=1;
2635 if(Input::Button()&&!oldbutton&&selected!=-1&&!waiting){
2637 if(selected<9&&keyselect==-1)
2646 if(newdetail>2)newdetail=detail;
2647 if(newdetail<0)newdetail=detail;
2648 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2649 if(newscreenwidth<0)newscreenwidth=screenwidth;
2650 if(newscreenheight>3000)newscreenheight=screenheight;
2651 if(newscreenheight<0)newscreenheight=screenheight;
2659 accountactive->endGame();
2663 if(Input::Button()&&!oldbutton&&selected==1){
2673 if(firstload)TickOnceAfter();
2674 if(!firstload)LoadStuff();
2681 OPENAL_SetPaused(channels[stream_music3], true);
2683 if(Input::Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){
2693 if(firstload) TickOnceAfter();
2709 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountactive->getCampaignChoicesMade()]]);
2710 whichchoice=selected-7-accountactive->getCampaignChoicesMade();
2714 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2718 OPENAL_SetPaused(channels[stream_music3], true);
2720 if(Input::Button()&&!oldbutton&&selected==4){
2725 if(mainmenu==5&&gameon)mainmenu=2;
2726 if(mainmenu==5&&!gameon)mainmenu=1;
2728 if(Input::Button()&&!oldbutton&&selected==5){
2735 if(Input::Button()&&!oldbutton&&selected==3){
2742 if(Input::Button()&&!oldbutton&&selected==2){
2750 else if(mainmenu==9){
2751 if(Input::Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountactive->getProgress()){
2760 targetlevel=selected;
2761 if(firstload)TickOnceAfter();
2762 if(!firstload)LoadStuff();
2764 Loadlevel(selected);
2770 OPENAL_SetPaused(channels[stream_music3], true);
2772 if(Input::Button()&&!oldbutton&&selected==numchallengelevels){
2782 if(Input::Button()&&!oldbutton&&selected==3){
2792 if(Input::Button()&&!oldbutton) {
2797 accountactive = Account::destroy(accountactive);
2799 } else if(selected==2) {
2807 if(Input::Button()&&!oldbutton) {
2810 if(selected==0&&Account::getNbAccounts()<8){
2812 } else if (selected<Account::getNbAccounts()+1) {
2813 accountactive=Account::get(selected-1);
2816 } else if (selected==Account::getNbAccounts()+1) {
2822 displaytext[0][j]=' ';
2832 if(Input::Button()&&!oldbutton&&selected>-1){
2836 accountactive->setDifficulty(selected);
2845 if(Input::Button()&&!oldbutton&&selected==0) {
2846 newstereomode = (StereoMode)(newstereomode + 1);
2847 while(!CanInitStereo(newstereomode)) {
2848 printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode), newstereomode);
2849 newstereomode = (StereoMode)(newstereomode + 1);
2850 if ( newstereomode >= stereoCount ) {
2851 newstereomode = stereoNone;
2856 if(Input::isKeyDown(MOUSEBUTTON1)&&!oldbutton&&selected==1) {
2857 stereoseparation+=0.001;
2859 if(Input::isKeyDown(MOUSEBUTTON2)&&!oldbutton&&selected==1) {
2860 stereoseparation-=0.001;
2863 if(Input::Button()&&!oldbutton&&selected==2) {
2864 stereoreverse =! stereoreverse;
2867 if(Input::Button()&&!oldbutton&&selected==3) {
2870 stereomode = newstereomode;
2871 InitStereo(stereomode);
2878 if(Input::Button()||Input::isKeyDown(MOUSEBUTTON2))oldbutton=1;
2881 if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){
2884 if(newdetail>2)newdetail=detail;
2885 if(newdetail<0)newdetail=detail;
2886 if(newscreenwidth<0)newscreenwidth=screenwidth;
2887 if(newscreenheight<0)newscreenheight=screenheight;
2889 SaveSettings(*this);
2893 if(mainmenu==1||mainmenu==2){
2894 if(loaddistrib>4)transition+=multiplier/8;
2902 OPENAL_SetFrequency(channels[stream_music3], 22050);
2905 inputText(displaytext[0],&displayselected,&displaychars[0]);
2906 if(!waiting) { // the input as finished
2907 if(displaychars[0]){ // with enter
2908 accountactive = Account::add(string(displaytext[0]));
2914 fireSound(firestartsound);
2917 displaytext[0][i]=' ';
2922 } else { // with escape or empty
2923 mainmenutogglekeydown=1;
2928 displayblinkdelay-=multiplier;
2929 if(displayblinkdelay<=0){
2930 displayblinkdelay=.3;
2931 displayblink=1-displayblink;
2937 if(hostile==1)hostiletime+=multiplier;
2939 if(!winfreeze)leveltime+=multiplier;
2940 if(Input::isKeyDown(SDLK_ESCAPE)){
2947 if(Input::isKeyDown(chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
2949 chattogglekeydown=1;
2952 if(!Input::isKeyDown(chatkey)){
2953 chattogglekeydown=0;
2957 inputText(displaytext[0],&displayselected,&displaychars[0]);
2959 if(displaychars[0]){
2960 for(int j=0;j<255;j++){
2961 displaytext[0][j]=' ';
2969 displayblinkdelay-=multiplier;
2970 if(displayblinkdelay<=0){
2971 displayblinkdelay=.3;
2972 displayblink=1-displayblink;
2976 if(chatting)keyboardfrozen=1;
2978 if(Input::isKeyDown(SDLK_v)&&!freezetogglekeydown&&debugmode){
2981 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
2983 freezetogglekeydown=1;
2986 if(!Input::isKeyDown(SDLK_v)&&!Input::isKeyDown(SDLK_F1)){
2987 freezetogglekeydown=0;
2990 if(Input::isKeyDown(SDLK_BACKQUOTE)&&!consoletogglekeydown&&debugmode){
2993 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
2998 consoletogglekeydown=1;
3001 if(!Input::isKeyDown(SDLK_BACKQUOTE)){
3002 consoletogglekeydown=0;
3005 if(console)freeze=1;
3007 if(console&&!Input::isKeyDown(SDLK_LMETA)){
3008 inputText(consoletext[0],&consoleselected,&consolechars[0]);
3011 cmd_dispatch(this, consoletext[0]);
3012 if(consolechars[0]>0){
3016 consoletext[k][j]=consoletext[k-1][j];
3018 consolechars[k]=consolechars[k-1];
3021 consoletext[0][j]=' ';
3028 consoleblinkdelay-=multiplier;
3029 if(consoleblinkdelay<=0){
3030 consoleblinkdelay=.3;
3031 consoleblink=1-consoleblink;
3035 if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){
3038 if(newdetail>2)newdetail=detail;
3039 if(newdetail<0)newdetail=detail;
3040 if(newscreenwidth<0)newscreenwidth=screenwidth;
3041 if(newscreenheight<0)newscreenheight=screenheight;
3043 SaveSettings(*this);
3047 static int oldwinfreeze;
3048 if(winfreeze&&!oldwinfreeze){
3049 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3050 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3051 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3052 OPENAL_SetPaused(channels[consolesuccesssound], false);
3054 if(winfreeze==0)oldwinfreeze=winfreeze;
3055 else oldwinfreeze++;
3057 if((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE))&&!oldjumpkeydown&&!campaign){
3058 if(winfreeze)winfreeze=0;
3061 if((Input::isKeyDown(SDLK_ESCAPE))&&!campaign&&gameon){
3067 if((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE))){
3070 if(!Input::isKeyDown(jumpkey)&&!Input::isKeyDown(SDLK_SPACE))oldjumpkeydown=0;
3072 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
3074 static bool oldbuttondialogue;
3076 if(indialogue!=-1)talkdelay=1;
3077 talkdelay-=multiplier;
3080 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
3081 for(i=0;i<numdialogues;i++){
3082 int realdialoguetype;
3084 if(dialoguetype[i]>49){
3085 realdialoguetype=dialoguetype[i]-50;
3088 else if(dialoguetype[i]>39){
3089 realdialoguetype=dialoguetype[i]-40;
3092 else if(dialoguetype[i]>29){
3093 realdialoguetype=dialoguetype[i]-30;
3096 else if(dialoguetype[i]>19){
3097 realdialoguetype=dialoguetype[i]-20;
3100 else if(dialoguetype[i]>9){
3101 realdialoguetype=dialoguetype[i]-10;
3105 realdialoguetype=dialoguetype[i];
3108 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(Input::isKeyDown(attackkey)&&!oldbuttondialogue))){
3109 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
3111 for(j=0;j<numdialogueboxes[whichdialogue];j++){
3112 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
3113 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
3114 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
3115 player[participantfocus[whichdialogue][j]].velocity=0;
3116 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
3117 player[participantfocus[whichdialogue][j]].targetframe=0;
3122 dialoguegonethrough[i]++;
3123 if(dialogueboxsound[whichdialogue][indialogue]!=0){
3124 static float gLoc[3];
3125 static float vel[3];
3127 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
3128 temppos=temppos-viewer;
3129 Normalise(&temppos);
3134 gLoc[2]=temppos.z;vel[0]=0;
3138 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
3139 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
3140 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
3141 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
3142 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
3143 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
3144 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
3145 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
3146 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
3147 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
3148 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
3149 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
3150 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
3151 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
3152 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
3153 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
3154 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
3155 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
3156 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
3157 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
3158 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
3159 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
3160 OPENAL_SetVolume(channels[whichsoundplay], 256);
3161 OPENAL_SetPaused(channels[whichsoundplay], false);
3163 if(Input::isKeyDown(attackkey))oldbuttondialogue=1;
3168 windvar+=multiplier;
3169 smoketex+=multiplier;
3170 tutorialstagetime+=multiplier;
3172 static float hotspotvisual[40];
3176 for(i=0;i<numhotspots;i++)
3177 hotspotvisual[i]-=multiplier/320;
3179 for(i=0;i<numhotspots;i++){
3180 //if(hotspottype[i]<=10)
3181 while(hotspotvisual[i]<0){
3183 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
3184 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
3185 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
3186 hotspotsprite+=hotspot[i];
3187 Sprite::MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
3188 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
3192 for(i=0;i<numhotspots;i++){
3193 if(hotspottype[i]<=10&&hotspottype[i]>0){
3194 hotspot[i]=player[hotspottype[i]].coords;
3200 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
3203 if(tutorialstage<=1){
3208 if(tutorialstage==1){
3210 } else if(tutorialstage==2){
3212 } else if(tutorialstage==3){
3213 tutorialmaxtime=600;
3214 } else if(tutorialstage==4){
3215 tutorialmaxtime=1000;
3216 } else if(tutorialstage==5){
3217 tutorialmaxtime=600;
3218 } else if(tutorialstage==6){
3219 tutorialmaxtime=600;
3220 } else if(tutorialstage==7){
3221 tutorialmaxtime=600;
3222 } else if(tutorialstage==8){
3223 tutorialmaxtime=600;
3224 } else if(tutorialstage==9){
3225 tutorialmaxtime=600;
3226 } else if(tutorialstage==10){
3228 } else if(tutorialstage==11){
3229 tutorialmaxtime=1000;
3230 } else if(tutorialstage==12){
3231 tutorialmaxtime=1000;
3232 } else if(tutorialstage==13){
3234 } else if(tutorialstage==14){
3246 player[1].coords=(temp+temp2)/2;
3250 gLoc[0]=player[1].coords.x;
3251 gLoc[1]=player[1].coords.y;
3252 gLoc[2]=player[1].coords.z;
3256 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
3257 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
3258 OPENAL_SetVolume(channels[fireendsound], 256);
3259 OPENAL_SetPaused(channels[fireendsound], false);
3261 for(i=0;i<player[1].skeleton.num_joints;i++){
3263 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
3264 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
3265 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
3266 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
3267 Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
3271 } else if(tutorialstage==15){
3272 tutorialmaxtime=500;
3273 } else if(tutorialstage==16){
3274 tutorialmaxtime=500;
3275 } else if(tutorialstage==17){
3276 tutorialmaxtime=500;
3277 } else if(tutorialstage==18){
3278 tutorialmaxtime=500;
3279 } else if(tutorialstage==19){
3281 //tutorialmaxtime=500;
3282 } else if(tutorialstage==20){
3283 tutorialmaxtime=500;
3284 } else if(tutorialstage==21){
3285 tutorialmaxtime=500;
3291 } else if(tutorialstage==22){
3292 tutorialmaxtime=500;
3293 } else if(tutorialstage==23){
3294 tutorialmaxtime=500;
3295 } else if(tutorialstage==24){
3296 tutorialmaxtime=500;
3297 } else if(tutorialstage==25){
3298 tutorialmaxtime=500;
3299 } else if(tutorialstage==26){
3301 } else if(tutorialstage==27){
3305 player[1].aitype=attacktypecutoff;
3306 } else if(tutorialstage==28){
3307 tutorialmaxtime=400;
3308 } else if(tutorialstage==29){
3309 tutorialmaxtime=400;
3310 player[0].escapednum=0;
3311 } else if(tutorialstage==30){
3315 player[1].aitype=passivetype;
3316 } else if(tutorialstage==31){
3318 } else if(tutorialstage==32){
3320 } else if(tutorialstage==33){
3321 tutorialmaxtime=400;
3324 player[1].aitype=attacktypecutoff;
3325 } else if(tutorialstage==34){
3326 tutorialmaxtime=400;
3327 } else if(tutorialstage==35){
3328 tutorialmaxtime=400;
3329 } else if(tutorialstage==36){
3333 player[1].aitype=passivetype;
3334 } else if(tutorialstage==37){
3340 player[1].aitype=attacktypecutoff;
3341 } else if(tutorialstage==38){
3345 player[1].aitype=passivetype;
3346 } else if(tutorialstage==39){
3357 weapons.owner[weapons.numweapons]=-1;
3358 weapons.type[weapons.numweapons]=knife;
3359 weapons.damage[weapons.numweapons]=0;
3360 weapons.mass[weapons.numweapons]=1;
3361 weapons.tipmass[weapons.numweapons]=1.2;
3362 weapons.length[weapons.numweapons]=.25;
3363 weapons.position[weapons.numweapons]=(temp+temp2)/2;
3364 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
3366 weapons.velocity[weapons.numweapons]=0.1;
3367 weapons.tipvelocity[weapons.numweapons]=0.1;
3368 weapons.missed[weapons.numweapons]=1;
3369 weapons.hitsomething[weapons.numweapons]=0;
3370 weapons.freetime[weapons.numweapons]=0;
3371 weapons.firstfree[weapons.numweapons]=1;
3372 weapons.physics[weapons.numweapons]=1;
3374 weapons.numweapons++;
3375 } else if(tutorialstage==40){
3376 tutorialmaxtime=300;
3377 } else if(tutorialstage==41){
3378 tutorialmaxtime=300;
3379 } else if(tutorialstage==42){
3381 } else if(tutorialstage==43){
3382 tutorialmaxtime=300;
3383 } else if(tutorialstage==44){
3385 player[0].weaponactive=-1;
3386 player[0].num_weapons=0;
3387 player[1].weaponactive=0;
3388 player[1].num_weapons=1;
3389 player[1].weaponids[0]=0;
3393 player[1].aitype=attacktypecutoff;
3395 tutorialmaxtime=300;
3396 } else if(tutorialstage==45){
3398 player[0].weaponactive=-1;
3399 player[0].num_weapons=0;
3400 player[1].weaponactive=0;
3401 player[1].num_weapons=1;
3402 player[1].weaponids[0]=0;
3404 tutorialmaxtime=300;
3405 } else if(tutorialstage==46){
3407 player[0].weaponactive=-1;
3408 player[0].num_weapons=0;
3409 player[1].weaponactive=0;
3410 player[1].num_weapons=1;
3411 player[1].weaponids[0]=0;
3413 weapons.type[0]=sword;
3415 tutorialmaxtime=300;
3416 } else if(tutorialstage==47){
3428 weapons.owner[weapons.numweapons]=-1;
3429 weapons.type[weapons.numweapons]=sword;
3430 weapons.damage[weapons.numweapons]=0;
3431 weapons.mass[weapons.numweapons]=1;
3432 weapons.tipmass[weapons.numweapons]=1.2;
3433 weapons.length[weapons.numweapons]=.25;
3434 weapons.position[weapons.numweapons]=(temp+temp2)/2;
3435 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
3437 weapons.velocity[weapons.numweapons]=0.1;
3438 weapons.tipvelocity[weapons.numweapons]=0.1;
3439 weapons.missed[weapons.numweapons]=1;
3440 weapons.hitsomething[weapons.numweapons]=0;
3441 weapons.freetime[weapons.numweapons]=0;
3442 weapons.firstfree[weapons.numweapons]=1;
3443 weapons.physics[weapons.numweapons]=1;
3447 player[0].weaponactive=0;
3448 player[0].num_weapons=1;
3449 player[0].weaponids[0]=1;
3450 player[1].weaponactive=0;
3451 player[1].num_weapons=1;
3452 player[1].weaponids[0]=0;
3454 weapons.numweapons++;
3455 } else if(tutorialstage==48){
3458 player[1].aitype=passivetype;
3464 player[0].weaponactive=0;
3465 player[0].num_weapons=1;
3466 player[0].weaponids[0]=1;
3467 player[1].weaponactive=0;
3468 player[1].num_weapons=1;
3469 player[1].weaponids[0]=0;
3471 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
3472 else weapons.type[0]=staff;
3474 weapons.numweapons++;
3475 } else if(tutorialstage==49){
3478 player[1].aitype=passivetype;
3480 tutorialmaxtime=200;
3482 weapons.position[1]=1000;
3483 weapons.tippoint[1]=1000;
3485 weapons.numweapons=1;
3487 player[1].weaponactive=-1;
3488 player[1].num_weapons=0;
3489 player[0].weaponactive=0;
3490 player[0].num_weapons=1;
3491 player[0].weaponids[0]=0;
3493 weapons.type[0]=knife;
3495 weapons.numweapons++;
3496 } else if(tutorialstage==50){
3502 gLoc[0]=player[1].coords.x;
3503 gLoc[1]=player[1].coords.y;
3504 gLoc[2]=player[1].coords.z;
3508 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
3509 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
3510 OPENAL_SetVolume(channels[fireendsound], 256);
3511 OPENAL_SetPaused(channels[fireendsound], false);
3513 for(i=0;i<player[1].skeleton.num_joints;i++){
3515 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
3516 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
3517 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
3518 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
3519 Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
3523 player[1].num_weapons=0;
3524 player[1].weaponstuck=-1;
3525 player[1].weaponactive=-1;
3527 weapons.numweapons=0;
3529 weapons.owner[0]=-1;
3530 weapons.velocity[0]=0.1;
3531 weapons.tipvelocity[0]=-0.1;
3532 weapons.missed[0]=1;
3533 weapons.hitsomething[0]=0;
3534 weapons.freetime[0]=0;
3535 weapons.firstfree[0]=1;
3536 weapons.physics[0]=1;
3537 } else if(tutorialstage==51){
3538 tutorialmaxtime=80000;
3540 if(tutorialstage<=51)tutorialstagetime=0;
3544 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
3545 if(tutorialstage==3){
3546 if(deltah||deltav)tutorialsuccess+=multiplier;
3548 if(tutorialstage==4){
3549 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
3551 if(tutorialstage==5){
3552 if(player[0].jumpkeydown)tutorialsuccess=1;
3554 if(tutorialstage==6){
3555 if(player[0].isCrouch())tutorialsuccess=1;
3557 if(tutorialstage==7){
3558 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
3560 if(tutorialstage==8){
3561 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
3563 if(tutorialstage==9){
3564 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
3566 if(tutorialstage==11){
3567 if(player[0].isWallJump())tutorialsuccess=1;
3569 if(tutorialstage==12){
3570 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
3572 if(tutorialstage==15){
3573 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
3575 if(tutorialstage==16){
3576 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
3578 if(tutorialstage==17){
3579 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
3581 if(tutorialstage==18){
3582 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
3584 if(tutorialstage==19){
3585 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
3587 if(tutorialstage==20){
3588 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
3590 if(tutorialstage==21){
3591 if(bonus==cannon)tutorialsuccess=1;
3593 if(tutorialstage==22){
3594 if(bonus==spinecrusher)tutorialsuccess=1;
3596 if(tutorialstage==23){
3597 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
3599 if(tutorialstage==24){
3600 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
3602 if(tutorialstage==25){
3603 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
3605 if(tutorialstage==28){
3606 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
3608 if(tutorialstage==29){
3609 if(player[0].escapednum==2){
3613 player[1].aitype=passivetype;
3616 if(tutorialstage==33){
3617 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
3619 if(tutorialstage==34){
3620 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
3622 if(tutorialstage==35){
3623 if(animation[player[0].targetanimation].attack==reversal){
3627 player[1].aitype=passivetype;
3630 if(tutorialstage==40){
3631 if(player[0].num_weapons>0)tutorialsuccess=1;
3633 if(tutorialstage==41){
3634 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
3636 if(tutorialstage==43){
3637 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
3639 if(tutorialstage==44){
3640 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
3642 if(tutorialstage==45){
3643 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
3645 if(tutorialstage==46){
3646 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
3648 if(tutorialstage==49){
3649 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
3651 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
3654 if(tutorialstagetime==tutorialmaxtime-3){
3655 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3656 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3657 OPENAL_SetPaused(channels[consolesuccesssound], false);
3660 if(tutorialsuccess>=1){
3661 if(tutorialstage==34||tutorialstage==35)
3662 tutorialstagetime=tutorialmaxtime-1;
3667 if(tutorialstage<14||tutorialstage>=50){
3668 player[1].coords.y=300;
3669 player[1].velocity=0;
3673 if(tutoriallevel!=1){
3674 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
3675 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3676 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3677 OPENAL_SetPaused(channels[consolesuccesssound], false);
3682 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
3683 OPENAL_SetVolume(channels[fireendsound], 256);
3684 OPENAL_SetPaused(channels[fireendsound], false);
3687 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
3688 else bonusnum[bonus]+=0.15;
3689 if(tutoriallevel)bonusvalue=0;
3690 bonusvalue/=bonusnum[bonus];
3691 bonustotal+=bonusvalue;
3693 bonustime+=multiplier;
3695 if(environment==snowyenvironment){
3696 precipdelay-=multiplier;
3697 while(precipdelay<0){
3699 if(!detail)precipdelay+=.04;
3700 XYZ footvel,footpoint;
3703 footpoint=viewer+viewerfacing*6;
3704 footpoint.y+=((float)abs(Random()%1200))/100-6;
3705 footpoint.x+=((float)abs(Random()%1200))/100-6;
3706 footpoint.z+=((float)abs(Random()%1200))/100-6;
3707 Sprite::MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
3710 for(k=0;k<numplayers;k++){
3711 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
3712 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
3714 if((player[k].isRun()&&((player[k].targetrotation!=rabbitrunninganim&&player[k].targetrotation!=wolfrunninganim)||player[k].targetframe==4))||player[k].targetanimation==removeknifeanim||player[k].targetanimation==crouchremoveknifeanim||player[k].targetanimation==flipanim||player[k].targetanimation==fightsidestep||player[k].targetanimation==walkanim){
3715 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
3716 else if(player[k].rotation>player[k].targetrotation){
3717 player[k].rotation-=multiplier*player[k].turnspeed;
3719 else if(player[k].rotation<player[k].targetrotation){
3720 player[k].rotation+=multiplier*player[k].turnspeed;
3725 if(player[k].isStop()||player[k].isLanding()||player[k].targetanimation==staggerbackhighanim||(player[k].targetanimation==sneakanim&&player[k].currentanimation==sneakanim)||player[k].targetanimation==staggerbackhardanim||player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim||player[k].targetanimation==rollanim||(animation[player[k].targetanimation].attack&&player[k].targetanimation!=rabbitkickanim&&(player[k].targetanimation!=crouchstabanim||player[k].hasvictim)&&(player[k].targetanimation!=swordgroundstabanim||player[k].hasvictim))){
3726 player[k].turnspeed*=2;
3727 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
3728 else if(player[k].rotation>player[k].targetrotation){
3729 player[k].rotation-=multiplier*player[k].turnspeed;
3731 else if(player[k].rotation<player[k].targetrotation){
3732 player[k].rotation+=multiplier*player[k].turnspeed;
3734 player[k].turnspeed/=2;
3737 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
3738 player[k].turnspeed*=4;
3739 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
3740 else if(player[k].rotation>player[k].targetrotation){
3741 player[k].rotation-=multiplier*player[k].turnspeed;
3743 else if(player[k].rotation<player[k].targetrotation){
3744 player[k].rotation+=multiplier*player[k].turnspeed;
3746 player[k].turnspeed/=4;
3749 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
3750 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
3752 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
3753 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
3756 if(player[k].collide<-.3)player[k].collide=-.3;
3757 if(player[k].collide>1)player[k].collide=1;
3758 player[k].collide-=multiplier*30;
3760 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
3761 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
3763 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
3764 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
3765 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
3766 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
3767 lowpoint=player[k].coords;
3768 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
3769 else lowpoint.y+=1.3;
3770 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)&&player[k].coords.y>terrain.getHeight(player[k].coords.x,player[k].coords.z)-.1){
3771 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
3773 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
3774 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
3776 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
3777 flatfacing=lowpoint-player[k].coords;
3778 player[k].coords=lowpoint;
3779 player[k].coords.y-=1.3;
3780 player[k].collide=1;
3782 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
3783 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
3784 tempcoords1=lowpoint;
3785 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
3786 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
3788 player[k].targetanimation=walljumpleftanim;
3789 player[k].targetframe=0;
3792 gLoc[0]=player[k].coords.x;
3793 gLoc[1]=player[k].coords.y;
3794 gLoc[2]=player[k].coords.z;
3798 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
3799 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
3800 OPENAL_SetVolume(channels[movewhooshsound], 256);
3801 OPENAL_SetPaused(channels[movewhooshsound], false);
3802 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
3804 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
3805 player[k].rotation=-asin(0-lowpointtarget.x);
3806 player[k].rotation*=360/6.28;
3807 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
3808 player[k].targetrotation=player[k].rotation;
3809 player[k].lowrotation=player[k].rotation;
3810 if(k==0)numwallflipped++;
3814 lowpoint=tempcoords1;
3815 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
3816 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
3817 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
3819 player[k].targetanimation=walljumprightanim;
3820 player[k].targetframe=0;
3823 gLoc[0]=player[k].coords.x;
3824 gLoc[1]=player[k].coords.y;
3825 gLoc[2]=player[k].coords.z;
3829 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
3830 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
3831 OPENAL_SetVolume(channels[movewhooshsound], 256);
3832 OPENAL_SetPaused(channels[movewhooshsound], false);
3833 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
3835 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
3836 player[k].rotation=-asin(0-lowpointtarget.x);
3837 player[k].rotation*=360/6.28;
3838 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
3839 player[k].targetrotation=player[k].rotation;
3840 player[k].lowrotation=player[k].rotation;
3841 if(k==0)numwallflipped++;
3845 lowpoint=tempcoords1;
3846 lowpointtarget=lowpoint+player[k].facing*2;
3847 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
3848 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
3850 player[k].targetanimation=walljumpbackanim;
3851 player[k].targetframe=0;
3854 gLoc[0]=player[k].coords.x;
3855 gLoc[1]=player[k].coords.y;
3856 gLoc[2]=player[k].coords.z;
3860 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
3861 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
3862 OPENAL_SetVolume(channels[movewhooshsound], 256);
3863 OPENAL_SetPaused(channels[movewhooshsound], false);
3864 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
3866 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
3867 player[k].rotation=-asin(0-lowpointtarget.x);
3868 player[k].rotation*=360/6.28;
3869 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
3870 player[k].targetrotation=player[k].rotation;
3871 player[k].lowrotation=player[k].rotation;
3872 if(k==0)numwallflipped++;
3876 lowpoint=tempcoords1;
3877 lowpointtarget=lowpoint-player[k].facing*2;
3878 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
3879 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
3881 player[k].targetanimation=walljumpfrontanim;
3882 player[k].targetframe=0;
3885 gLoc[0]=player[k].coords.x;
3886 gLoc[1]=player[k].coords.y;
3887 gLoc[2]=player[k].coords.z;
3891 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
3892 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
3893 OPENAL_SetVolume(channels[movewhooshsound], 256);
3894 OPENAL_SetPaused(channels[movewhooshsound], false);
3895 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
3897 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
3898 player[k].rotation=-asin(0-lowpointtarget.x);
3899 player[k].rotation*=360/6.28;
3900 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
3901 player[k].rotation+=180;
3902 player[k].targetrotation=player[k].rotation;
3903 player[k].lowrotation=player[k].rotation;
3904 if(k==0)numwallflipped++;
3912 else if(objects.type[i]==rocktype){
3913 lowpoint2=player[k].coords;
3914 lowpoint=player[k].coords;
3916 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
3917 player[k].coords=colpoint;
3918 player[k].collide=1;
3921 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
3922 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
3924 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
3926 player[k].targetframe=0;
3927 player[k].onterrain=1;
3929 if(player[k].id==0){
3930 OPENAL_SetPaused(channels[whooshsound], true);
3931 OPENAL_SetVolume(channels[whooshsound], 0);
3934 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
3935 if(player[k].isFlip())player[k].jumppower=-4;
3936 player[k].targetanimation=player[k].getLanding();
3939 gLoc[0]=player[k].coords.x;
3940 gLoc[1]=player[k].coords.y;
3941 gLoc[2]=player[k].coords.z;
3942 vel[0]=player[k].velocity.x;
3943 vel[1]=player[k].velocity.y;
3944 vel[2]=player[k].velocity.z;
3945 PlaySoundEx( landsound, samp[landsound], NULL, true);
3946 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
3947 OPENAL_SetVolume(channels[landsound], 128);
3948 OPENAL_SetPaused(channels[landsound], false);
3950 envsound[numenvsounds]=player[k].coords;
3951 envsoundvol[numenvsounds]=16;
3952 envsoundlife[numenvsounds]=.4;
3961 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
3962 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
3963 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
3964 lowpoint=player[k].coords;
3966 if(objects.type[i]!=rocktype)
3967 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
3968 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
3969 player[k].coords=lowpoint;
3970 player[k].coords.y-=1.35;
3971 player[k].collide=1;
3973 if((player[k].grabdelay<=0||player[k].aitype!=playercontrolled)&&((/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)&&*/player[k].currentanimation!=climbanim&&player[k].currentanimation!=hanganim&&!player[k].isWallJump())||player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
3974 lowpoint=player[k].coords;
3975 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
3976 lowpoint=player[k].coords;
3980 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
3981 lowpointtarget=lowpoint+facing*1.4;
3982 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
3984 lowpoint=player[k].coords;
3986 lowpointtarget=lowpoint+facing*1.4;
3988 lowpointtarget2=lowpointtarget;
3990 lowpointtarget3=lowpointtarget;
3992 lowpointtarget4=lowpointtarget;
3994 lowpointtarget5=lowpointtarget;
3996 lowpointtarget6=lowpointtarget;
3998 lowpointtarget7=lowpoint;
4000 lowpointtarget2.x+=.1;
4002 lowpointtarget3.z+=.1;
4004 lowpointtarget4.x-=.1;
4006 lowpointtarget5.z-=.1;
4008 lowpointtarget6.y+=45/13;
4009 lowpointtarget6+=facing*.6;
4010 lowpointtarget7.y+=90/13;
4011 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
4012 if(objects.friction[i]>.5)
4015 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
4016 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
4017 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
4018 if(objects.model[i].LineCheckPossible(&lowpoint2,&lowpointtarget2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1&&objects.model[i].LineCheckPossible(&lowpoint3,&lowpointtarget3,&colpoint,&objects.position[i],&objects.rotation[i])!=-1&&objects.model[i].LineCheckPossible(&lowpoint4,&lowpointtarget4,&colpoint,&objects.position[i],&objects.rotation[i])!=-1&&objects.model[i].LineCheckPossible(&lowpoint5,&lowpointtarget5,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)
4020 lowpoint=player[k].coords;
4021 lowpoint.y+=(float)j/13;
4022 lowpointtarget=lowpoint+facing*1.4;
4023 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
4027 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
4030 if(j<=25&&player[k].targetanimation==jumpdownanim){
4033 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
4034 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
4035 if(1==1/*dotproduct(&player[k].velocity,&lowpoint)>0||player[k].aitype!=playercontrolled||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim||player[k].targetanimation==jumpupanim)*/){
4036 lowpoint=player[k].coords;
4037 lowpoint.y+=(float)j/13;
4038 lowpointtarget=lowpoint+facing*1.3;
4039 flatfacing=player[k].coords;
4040 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
4041 player[k].coords.y=lowpointtarget.y-.07;
4042 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
4044 if(j>10||!player[k].isRun()){
4045 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
4046 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
4050 gLoc[0]=player[k].coords.x;
4051 gLoc[1]=player[k].coords.y;
4052 gLoc[2]=player[k].coords.z;
4053 vel[0]=player[k].velocity.x;
4054 vel[1]=player[k].velocity.y;
4055 vel[2]=player[k].velocity.z;
4056 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
4057 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
4058 OPENAL_SetVolume(channels[jumpsound], 128);
4059 OPENAL_SetPaused(channels[jumpsound], false);
4061 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
4062 player[k].rotation=-asin(0-lowpointtarget.x);
4063 player[k].rotation*=360/6.28;
4064 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
4065 player[k].targetrotation=player[k].rotation;
4066 player[k].lowrotation=player[k].rotation;
4068 //player[k].velocity=lowpointtarget*.03;
4069 player[k].velocity=0;
4071 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
4072 //player[k].currentanimation=climbanim;
4073 player[k].targetanimation=climbanim;
4074 player[k].jumppower=0;
4075 player[k].jumpclimb=1;
4077 player[k].transspeed=6;
4080 //player[k].currentframe=1;
4081 player[k].targetframe=1;
4083 //player[k].currentframe=0;
4084 player[k].targetframe=0;
4085 //player[k].currentanimation=hanganim;
4086 player[k].targetanimation=hanganim;
4087 player[k].jumppower=0;
4101 if(player[k].collide<=0){
4102 if(!player[k].onterrain&&player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim&&!player[k].isWallJump()&&!player[k].isFlip()){
4103 if(player[k].currentanimation!=climbanim&&player[k].currentanimation!=tempanim&&player[k].targetanimation!=backhandspringanim&&(player[k].targetanimation!=rollanim||player[k].targetframe<2||player[k].targetframe>6)){
4104 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
4105 player[k].targetanimation=jumpdownanim;
4106 player[k].targetframe=0;
4111 gLoc[0]=player[k].coords.x;
4112 gLoc[1]=player[k].coords.y;
4113 gLoc[2]=player[k].coords.z;
4114 vel[0]=player[k].velocity.x;
4115 vel[1]=player[k].velocity.y;
4116 vel[2]=player[k].velocity.z;
4118 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
4119 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4120 OPENAL_SetVolume(channels[whooshsound], 128);
4121 OPENAL_SetPaused(channels[whooshsound], false);
4124 player[k].velocity.y+=gravity;
4129 player[k].realoldcoords=player[k].coords;
4132 static XYZ oldviewer;
4135 player[0].forwardkeydown=Input::isKeyDown(forwardkey);
4136 player[0].leftkeydown=Input::isKeyDown(leftkey);
4137 player[0].backkeydown=Input::isKeyDown(backkey);
4138 player[0].rightkeydown=Input::isKeyDown(rightkey);
4139 player[0].jumpkeydown=Input::isKeyDown(jumpkey);
4140 player[0].crouchkeydown=Input::isKeyDown(crouchkey);
4141 player[0].drawkeydown=Input::isKeyDown(drawkey);
4142 player[0].throwkeydown=Input::isKeyDown(throwkey);
4146 player[0].forwardkeydown=0;
4147 player[0].leftkeydown=0;
4148 player[0].backkeydown=0;
4149 player[0].rightkeydown=0;
4150 player[0].jumpkeydown=0;
4151 player[0].crouchkeydown=0;
4152 player[0].drawkeydown=0;
4153 player[0].throwkeydown=0;
4156 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
4159 static bool endkeydown;
4166 facing=DoRotation(facing,-rotation2,0,0);
4167 facing=DoRotation(facing,0,0-rotation,0);
4172 flatfacing=DoRotation(flatfacing,0,-rotation,0);
4174 if(Input::isKeyDown(forwardkey))viewer+=facing*multiplier*4;
4175 if(Input::isKeyDown(backkey))viewer-=facing*multiplier*4;
4176 if(Input::isKeyDown(leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
4177 if(Input::isKeyDown(rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
4178 if(Input::isKeyDown(jumpkey))viewer.y+=multiplier*4;
4179 if(Input::isKeyDown(crouchkey))viewer.y-=multiplier*4;
4180 if(!endkeydown&&(Input::isKeyDown(SDLK_1)||Input::isKeyDown(SDLK_2)||Input::isKeyDown(SDLK_3)||Input::isKeyDown(SDLK_4)||Input::isKeyDown(SDLK_5)
4181 ||Input::isKeyDown(SDLK_6)||Input::isKeyDown(SDLK_7)||Input::isKeyDown(SDLK_8)||Input::isKeyDown(SDLK_9)||Input::isKeyDown(SDLK_0)
4182 ||Input::isKeyDown(SDLK_MINUS))){
4184 if(Input::isKeyDown(SDLK_1))whichend=1;
4185 if(Input::isKeyDown(SDLK_2))whichend=2;
4186 if(Input::isKeyDown(SDLK_3))whichend=3;
4187 if(Input::isKeyDown(SDLK_4))whichend=4;
4188 if(Input::isKeyDown(SDLK_5))whichend=5;
4189 if(Input::isKeyDown(SDLK_6))whichend=6;
4190 if(Input::isKeyDown(SDLK_7))whichend=7;
4191 if(Input::isKeyDown(SDLK_8))whichend=8;
4192 if(Input::isKeyDown(SDLK_9))whichend=9;
4193 if(Input::isKeyDown(SDLK_0))whichend=0;
4194 if(Input::isKeyDown(SDLK_MINUS))whichend=-1;
4196 participantfocus[whichdialogue][indialogue]=whichend;
4197 participantlocation[whichdialogue][whichend]=player[whichend].coords;
4198 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
4201 participantfocus[whichdialogue][indialogue]=-1;
4203 if(player[participantfocus[whichdialogue][indialogue]].dead){
4208 dialoguecamera[whichdialogue][indialogue]=viewer;
4209 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
4210 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
4212 if(indialogue<numdialogueboxes[whichdialogue]){
4213 if(dialogueboxsound[whichdialogue][indialogue]!=0){
4214 static float gLoc[3];
4215 static float vel[3];
4217 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4218 temppos=temppos-viewer;
4219 Normalise(&temppos);
4224 gLoc[2]=temppos.z;vel[0]=0;
4228 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
4229 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4230 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4231 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4232 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4233 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4234 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4235 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4236 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4237 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4238 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4239 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4240 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4241 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4242 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4243 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4244 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4245 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4246 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4247 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4248 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4249 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4250 OPENAL_SetVolume(channels[whichsoundplay], 256);
4251 OPENAL_SetPaused(channels[whichsoundplay], false);
4255 for(j=0;j<numplayers;j++){
4256 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
4261 if((Input::isKeyDown(SDLK_KP1)||Input::isKeyDown(SDLK_KP2)||Input::isKeyDown(SDLK_KP3)||Input::isKeyDown(SDLK_KP4)||Input::isKeyDown(SDLK_KP5)
4262 ||Input::isKeyDown(SDLK_KP6)||Input::isKeyDown(SDLK_KP7)||Input::isKeyDown(SDLK_KP8)||Input::isKeyDown(SDLK_KP9)||Input::isKeyDown(SDLK_KP0)
4265 if(Input::isKeyDown(SDLK_KP1))whichend=1;
4266 if(Input::isKeyDown(SDLK_KP2))whichend=2;
4267 if(Input::isKeyDown(SDLK_KP3))whichend=3;
4268 if(Input::isKeyDown(SDLK_KP4))whichend=4;
4269 if(Input::isKeyDown(SDLK_KP5))whichend=5;
4270 if(Input::isKeyDown(SDLK_KP6))whichend=6;
4271 if(Input::isKeyDown(SDLK_KP7))whichend=7;
4272 if(Input::isKeyDown(SDLK_KP8))whichend=8;
4273 if(Input::isKeyDown(SDLK_KP9))whichend=9;
4274 if(Input::isKeyDown(SDLK_KP0))whichend=0;
4275 participantfacing[whichdialogue][indialogue][whichend]=facing;
4277 if(!Input::isKeyDown(SDLK_1)&&!Input::isKeyDown(SDLK_2)&&!Input::isKeyDown(SDLK_3)&&!Input::isKeyDown(SDLK_4)&&!Input::isKeyDown(SDLK_5)
4278 &&!Input::isKeyDown(SDLK_6)&&!Input::isKeyDown(SDLK_7)&&!Input::isKeyDown(SDLK_8)&&!Input::isKeyDown(SDLK_9)&&!Input::isKeyDown(SDLK_0)
4279 &&!Input::isKeyDown(SDLK_MINUS)){
4282 if(indialogue>=numdialogueboxes[whichdialogue]){
4289 OPENAL_SetPaused(channels[whooshsound], true);
4290 viewer=dialoguecamera[whichdialogue][indialogue];
4291 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
4292 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
4294 rotation=dialoguecamerarotation[whichdialogue][indialogue];
4295 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
4296 if(dialoguetime>0.5)
4297 if((!endkeydown&&(Input::isKeyDown(SDLK_1)||Input::isKeyDown(SDLK_2)||Input::isKeyDown(SDLK_3)||Input::isKeyDown(SDLK_4)||Input::isKeyDown(SDLK_5)
4298 ||Input::isKeyDown(SDLK_6)||Input::isKeyDown(SDLK_7)||Input::isKeyDown(SDLK_8)||Input::isKeyDown(SDLK_9)||Input::isKeyDown(SDLK_0)
4299 ||Input::isKeyDown(SDLK_MINUS)))||(Input::isKeyDown(attackkey)&&!oldbuttondialogue)){
4302 if(indialogue<numdialogueboxes[whichdialogue]){
4303 if(dialogueboxsound[whichdialogue][indialogue]!=0){
4304 static float gLoc[3];
4305 static float vel[3];
4307 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4308 temppos=temppos-viewer;
4309 Normalise(&temppos);
4314 gLoc[2]=temppos.z;vel[0]=0;
4318 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
4319 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4320 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4321 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4322 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4323 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4324 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4325 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4326 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4327 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4328 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4329 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4330 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4331 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4332 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4333 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4334 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4335 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4336 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4337 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4338 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
4339 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
4340 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4341 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4342 OPENAL_SetVolume(channels[whichsoundplay], 256);
4343 OPENAL_SetPaused(channels[whichsoundplay], false);
4345 if(dialogueboxsound[whichdialogue][indialogue]==-5){
4346 hotspot[numhotspots]=player[0].coords;
4347 hotspotsize[numhotspots]=10;
4348 hotspottype[numhotspots]=-1;
4352 if(dialogueboxsound[whichdialogue][indialogue]==-6){
4356 if(player[participantfocus[whichdialogue][indialogue]].dead){
4364 if(!Input::isKeyDown(SDLK_1)&&!Input::isKeyDown(SDLK_2)&&!Input::isKeyDown(SDLK_3)&&!Input::isKeyDown(SDLK_4)&&!Input::isKeyDown(SDLK_5)
4365 &&!Input::isKeyDown(SDLK_6)&&!Input::isKeyDown(SDLK_7)&&!Input::isKeyDown(SDLK_8)&&!Input::isKeyDown(SDLK_9)&&!Input::isKeyDown(SDLK_0)
4366 &&!Input::isKeyDown(SDLK_MINUS)){
4369 if(indialogue>=numdialogueboxes[whichdialogue]){
4373 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
4376 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
4379 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
4381 for(i=1;i<numplayers;i++){
4382 player[i].aitype = attacktypecutoff;
4389 if(!Input::isKeyDown(attackkey))oldbuttondialogue=0;
4390 else oldbuttondialogue=1;
4392 static float keyrefreshdelay=0,bigrefreshdelay=0;
4394 if(!player[0].jumpkeydown){
4395 player[0].jumptogglekeydown=0;
4397 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
4400 dialoguetime+=multiplier;
4401 skybox.cloudmove+=multiplier;
4402 hawkrotation+=multiplier*25;
4404 realhawkcoords.x=25;
4405 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
4406 hawkcalldelay-=multiplier/2;
4408 if(hawkcalldelay<=0)
4410 static float gLoc[3];
4411 static float vel[3];
4412 gLoc[0]=realhawkcoords.x;
4413 gLoc[1]=realhawkcoords.y;
4414 gLoc[2]=realhawkcoords.z;
4418 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
4419 OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
4420 OPENAL_SetVolume(channels[hawksound], 128);
4421 OPENAL_SetPaused(channels[hawksound], false);
4423 hawkcalldelay=16+abs(Random()%8);
4425 static float temptexdetail;
4428 if(Input::isKeyDown(SDLK_h)&&debugmode){
4429 player[0].damagetolerance=200000;
4432 player[0].permanentdamage=0;
4433 player[0].superpermanentdamage=0;
4436 if(Input::isKeyDown(SDLK_j)&&!envtogglekeydown&&debugmode){
4438 if(environment>2)environment=0;
4439 Setenvironment(environment);
4445 if(!Input::isKeyDown(SDLK_j)){
4449 if(Input::isKeyDown(SDLK_c)&&!cameratogglekeydown&&debugmode){
4450 cameramode=1-cameramode;
4451 cameratogglekeydown=1;
4454 if(!Input::isKeyDown(SDLK_c)){
4455 cameratogglekeydown=0;
4458 if(Input::isKeyDown(SDLK_x)&&!Input::isKeyDown(SDLK_LSHIFT)&&!detailtogglekeydown&&debugmode){
4459 if(player[0].num_weapons>0){
4460 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
4461 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
4462 else weapons.type[player[0].weaponids[0]]=sword;
4463 if(weapons.type[player[0].weaponids[0]]==sword){
4464 weapons.mass[player[0].weaponids[0]]=1.5;
4465 weapons.tipmass[player[0].weaponids[0]]=1;
4466 weapons.length[player[0].weaponids[0]]=.8;
4468 if(weapons.type[player[0].weaponids[0]]==staff){
4469 weapons.mass[player[0].weaponids[0]]=2;
4470 weapons.tipmass[player[0].weaponids[0]]=1;
4471 weapons.length[player[0].weaponids[0]]=1.5;
4474 if(weapons.type[player[0].weaponids[0]]==knife){
4475 weapons.mass[player[0].weaponids[0]]=1;
4476 weapons.tipmass[player[0].weaponids[0]]=1.2;
4477 weapons.length[player[0].weaponids[0]]=.25;
4480 detailtogglekeydown=1;
4483 if(Input::isKeyDown(SDLK_x)&&Input::isKeyDown(SDLK_LSHIFT)&&!detailtogglekeydown&&debugmode){
4485 float closestdist=-1;
4488 for(i=1;i<numplayers;i++){
4489 distance=findDistancefast(&player[i].coords,&player[0].coords);
4490 if(closestdist==-1||distance<closestdist){
4491 closestdist=distance;
4496 if(player[closest].num_weapons)
4498 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
4499 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
4500 else weapons.type[player[closest].weaponids[0]]=sword;
4501 if(weapons.type[player[closest].weaponids[0]]==sword){
4502 weapons.mass[player[closest].weaponids[0]]=1.5;
4503 weapons.tipmass[player[closest].weaponids[0]]=1;
4504 weapons.length[player[closest].weaponids[0]]=.8;
4506 if(weapons.type[player[0].weaponids[0]]==staff){
4507 weapons.mass[player[0].weaponids[0]]=2;
4508 weapons.tipmass[player[0].weaponids[0]]=1;
4509 weapons.length[player[0].weaponids[0]]=1.5;
4511 if(weapons.type[player[closest].weaponids[0]]==knife){
4512 weapons.mass[player[closest].weaponids[0]]=1;
4513 weapons.tipmass[player[closest].weaponids[0]]=1.2;
4514 weapons.length[player[closest].weaponids[0]]=.25;
4517 if(!player[closest].num_weapons)
4519 player[closest].weaponids[0]=weapons.numweapons;
4520 weapons.owner[weapons.numweapons]=closest;
4521 weapons.type[weapons.numweapons]=knife;
4522 weapons.damage[weapons.numweapons]=0;
4523 weapons.numweapons++;
4524 player[closest].num_weapons=1;
4525 if(weapons.type[player[closest].weaponids[0]]==sword){
4526 weapons.mass[player[closest].weaponids[0]]=1.5;
4527 weapons.tipmass[player[closest].weaponids[0]]=1;
4528 weapons.length[player[closest].weaponids[0]]=.8;
4530 if(weapons.type[player[closest].weaponids[0]]==knife){
4531 weapons.mass[player[closest].weaponids[0]]=1;
4532 weapons.tipmass[player[closest].weaponids[0]]=1.2;
4533 weapons.length[player[closest].weaponids[0]]=.25;
4537 detailtogglekeydown=1;
4540 if(Input::isKeyDown(SDLK_u)&&debugmode){
4542 float closestdist=-1;
4545 for(i=1;i<numplayers;i++){
4546 distance=findDistancefast(&player[i].coords,&player[0].coords);
4547 if(closestdist==-1||distance<closestdist){
4548 closestdist=distance;
4553 player[closest].rotation+=multiplier*50;
4554 player[closest].targetrotation=player[closest].rotation;
4558 if(Input::isKeyDown(SDLK_o)&&!Input::isKeyDown(SDLK_LSHIFT)&&debugmode){
4560 float closestdist=-1;
4563 for(i=1;i<numplayers;i++){
4564 distance=findDistancefast(&player[i].coords,&player[0].coords);
4565 if(closestdist==-1||distance<closestdist){
4566 closestdist=distance;
4570 if(Input::isKeyDown(SDLK_LCTRL))closest=0;
4573 player[closest].whichskin++;
4574 if(player[closest].whichskin>9)player[closest].whichskin=0;
4575 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
4577 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
4578 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
4581 if(player[closest].numclothes){
4582 for(i=0;i<player[closest].numclothes;i++){
4583 tintr=player[closest].clothestintr[i];
4584 tintg=player[closest].clothestintg[i];
4585 tintb=player[closest].clothestintb[i];
4586 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
4588 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
4591 detailtogglekeydown=1;
4594 if(Input::isKeyDown(SDLK_o)&&Input::isKeyDown(SDLK_LSHIFT)&&debugmode){
4596 float closestdist=-1;
4599 for(i=1;i<numplayers;i++){
4600 distance=findDistancefast(&player[i].coords,&player[0].coords);
4601 if(closestdist==-1||distance<closestdist){
4602 closestdist=distance;
4607 if(player[closest].creature==wolftype){
4608 headprop=player[closest].proportionhead.x/1.1;
4609 bodyprop=player[closest].proportionbody.x/1.1;
4610 armprop=player[closest].proportionarms.x/1.1;
4611 legprop=player[closest].proportionlegs.x/1.1;
4614 if(player[closest].creature==rabbittype){
4615 headprop=player[closest].proportionhead.x/1.2;
4616 bodyprop=player[closest].proportionbody.x/1.05;
4617 armprop=player[closest].proportionarms.x/1.00;
4618 legprop=player[closest].proportionlegs.x/1.1;
4622 if(player[closest].creature==rabbittype){
4623 player[closest].skeleton.id=closest;
4624 player[closest].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
4625 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
4626 player[closest].whichskin=0;
4627 player[closest].creature=wolftype;
4629 player[closest].proportionhead=1.1;
4630 player[closest].proportionbody=1.1;
4631 player[closest].proportionarms=1.1;
4632 player[closest].proportionlegs=1.1;
4633 player[closest].proportionlegs.y=1.1;
4634 player[closest].scale=.23*5*player[0].scale;
4636 player[closest].damagetolerance=300;
4640 player[closest].skeleton.id=closest;
4641 player[closest].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
4642 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
4643 player[closest].whichskin=0;
4644 player[closest].creature=rabbittype;
4646 player[closest].proportionhead=1.2;
4647 player[closest].proportionbody=1.05;
4648 player[closest].proportionarms=1.00;
4649 player[closest].proportionlegs=1.1;
4650 player[closest].proportionlegs.y=1.05;
4651 player[closest].scale=.2*5*player[0].scale;
4653 player[closest].damagetolerance=200;
4656 if(player[closest].creature==wolftype){
4657 player[closest].proportionhead=1.1*headprop;
4658 player[closest].proportionbody=1.1*bodyprop;
4659 player[closest].proportionarms=1.1*armprop;
4660 player[closest].proportionlegs=1.1*legprop;
4663 if(player[closest].creature==rabbittype){
4664 player[closest].proportionhead=1.2*headprop;
4665 player[closest].proportionbody=1.05*bodyprop;
4666 player[closest].proportionarms=1.00*armprop;
4667 player[closest].proportionlegs=1.1*legprop;
4668 player[closest].proportionlegs.y=1.05*legprop;
4672 detailtogglekeydown=1;
4675 if(!Input::isKeyDown(SDLK_x)){
4676 detailtogglekeydown=0;
4679 if(Input::isKeyDown(SDLK_b)&&!slomotogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)&&debugmode){
4682 slomotogglekeydown=1;
4686 if(((Input::isKeyDown(SDLK_i)&&!Input::isKeyDown(SDLK_LSHIFT)))&&!explodetogglekeydown&&debugmode){
4688 float closestdist=-1;
4690 XYZ flatfacing2,flatvelocity2;
4693 for(i=1;i<numplayers;i++){
4694 distance=findDistancefast(&player[i].coords,&player[0].coords);
4695 if(distance<144&&!player[i].headless)
4696 if(closestdist==-1||distance<closestdist){
4697 closestdist=distance;
4699 blah = player[i].coords;
4704 XYZ headspurtdirection;
4705 int i = player[closest].skeleton.jointlabels[head];
4706 for(k=0;k<player[closest].skeleton.num_joints; k++){
4707 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
4708 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
4709 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
4710 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
4711 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
4712 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
4713 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
4714 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
4715 Normalise(&headspurtdirection);
4716 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
4717 flatvelocity2+=headspurtdirection*8;
4718 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
4720 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
4730 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
4731 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
4732 OPENAL_SetVolume(channels[splattersound], 256);
4733 OPENAL_SetPaused(channels[splattersound], false);
4735 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
4736 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
4737 OPENAL_SetVolume(channels[breaksound2], 100);
4738 OPENAL_SetPaused(channels[breaksound2], false);
4740 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
4741 player[closest].RagDoll(0);
4742 player[closest].dead=2;
4743 player[closest].headless=1;
4744 player[closest].DoBloodBig(3,165);
4749 explodetogglekeydown=1;
4752 if(((Input::isKeyDown(SDLK_i)&&Input::isKeyDown(SDLK_LSHIFT)))&&!explodetogglekeydown&&debugmode){
4754 float closestdist=-1;
4756 XYZ flatfacing2,flatvelocity2;
4759 for(i=1;i<numplayers;i++){
4760 distance=findDistancefast(&player[i].coords,&player[0].coords);
4762 if(closestdist==-1||distance<closestdist){
4763 closestdist=distance;
4765 blah=player[i].coords;
4779 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
4780 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
4781 OPENAL_SetVolume(channels[splattersound], 256);
4782 OPENAL_SetPaused(channels[splattersound], false);
4784 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
4785 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
4786 OPENAL_SetVolume(channels[breaksound2], 600);
4787 OPENAL_SetPaused(channels[breaksound2], false);
4789 for(i=0;i<player[closest].skeleton.num_joints; i++){
4790 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
4791 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
4792 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
4793 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
4794 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
4795 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
4796 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
4797 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
4798 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
4799 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
4802 for(i=0;i<player[closest].skeleton.num_joints; i++){
4803 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
4804 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
4805 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
4806 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
4807 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
4808 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
4809 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
4810 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
4811 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
4814 for(i=0;i<player[closest].skeleton.num_joints; i++){
4815 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
4816 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
4817 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
4818 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
4819 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
4820 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
4821 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
4822 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
4823 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
4826 for(i=0;i<player[closest].skeleton.num_joints; i++){
4827 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
4828 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
4829 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
4830 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
4831 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
4832 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
4833 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
4834 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
4835 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
4839 for(j=0;j<numplayers; j++){
4841 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
4842 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
4843 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
4844 player[j].skeleton.longdead=0;
4845 player[j].RagDoll(0);
4846 for(i=0;i<player[j].skeleton.num_joints; i++){
4847 temppos=player[j].skeleton.joints[i].position+player[j].coords;
4848 if(findDistancefast(&temppos,&player[closest].coords)<25){
4849 flatvelocity2=temppos-player[closest].coords;
4850 Normalise(&flatvelocity2);
4851 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
4858 player[closest].DoDamage(10000);
4859 player[closest].RagDoll(0);
4860 player[closest].dead=2;
4861 player[closest].coords=20;
4862 player[closest].skeleton.free=2;
4868 explodetogglekeydown=1;
4871 if(!Input::isKeyDown(SDLK_i)){
4872 explodetogglekeydown=0;
4875 if(!Input::isKeyDown(SDLK_b)&&!Input::isKeyDown(SDLK_f)&&!Input::isKeyDown(SDLK_k)&&!Input::isKeyDown(SDLK_s)){
4876 slomotogglekeydown=0;
4880 if(Input::isKeyDown(SDLK_f)&&!slomotogglekeydown&&debugmode){
4881 player[0].onfire=1-player[0].onfire;
4882 if(player[0].onfire){
4883 player[0].CatchFire();
4885 if(!player[0].onfire){
4888 gLoc[0]=player[0].coords.x;
4889 gLoc[1]=player[0].coords.y;
4890 gLoc[2]=player[0].coords.z;
4894 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
4895 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
4896 OPENAL_SetVolume(channels[fireendsound], 256);
4897 OPENAL_SetPaused(channels[fireendsound], false);
4898 OPENAL_SetPaused(channels[stream_firesound], true);
4900 slomotogglekeydown=1;
4903 if(Input::isKeyDown(SDLK_DELETE)&&editorenabled&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LSHIFT)){
4905 float closestdist=-1;
4908 for(i=1;i<numplayers;i++){
4909 distance=findDistancefast(&player[i].coords,&player[0].coords);
4910 if(closestdist==-1||distance<closestdist){
4911 closestdist=distance;
4915 if(closestdist>0&&closest>=0){
4916 //player[closest]=player[numplayers-1];
4917 //player[closest].skeleton=player[numplayers-1].skeleton;
4920 drawmodetogglekeydown=1;
4923 if(Input::isKeyDown(SDLK_DELETE)&&editorenabled&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LCTRL)){
4925 float closestdist=-1;
4928 for(i=1;i<max_objects;i++){
4929 distance=findDistancefast(&objects.position[i],&player[0].coords);
4930 if(closestdist==-1||distance<closestdist){
4931 closestdist=distance;
4935 if(closestdist>0&&closest>=0){
4936 objects.position[closest].y-=500;
4938 drawmodetogglekeydown=1;
4941 if(Input::isKeyDown(SDLK_m)&&!drawmodetogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)&&editorenabled&&debugmode){
4943 //if(drawmode>2)drawmode=0;
4944 if(objects.numobjects<max_objects-1){
4946 boxcoords.x=player[0].coords.x;
4947 boxcoords.z=player[0].coords.z;
4948 boxcoords.y=player[0].coords.y-3;
4949 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
4950 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
4951 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
4952 float temprotat,temprotat2;
4953 temprotat=editorrotation;
4954 temprotat2=editorrotation2;
4955 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
4956 if(temprotat2<0)temprotat2=Random()%360;
4958 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
4959 if(editortype==treetrunktype)
4960 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
4963 drawmodetogglekeydown=1;
4966 if(Input::isKeyDown(SDLK_p)&&!drawmodetogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)&&editorenabled){
4967 if(numplayers<maxplayers-1){
4968 player[numplayers].scale=.2*5*player[0].scale;
4969 player[numplayers].creature=rabbittype;
4970 player[numplayers].howactive=editoractive;
4971 player[numplayers].skeleton.id=numplayers;
4972 player[numplayers].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
4974 //texsize=512*512*3/texdetail/texdetail;
4975 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
4976 //player[numplayers].skeleton.skinText.resize(texsize);
4978 k=abs(Random()%2)+1;
4980 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
4981 player[numplayers].whichskin=0;
4984 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
4985 player[numplayers].whichskin=1;
4988 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
4989 player[numplayers].whichskin=2;
4992 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
4993 player[numplayers].power=1;
4994 player[numplayers].speedmult=1;
4995 player[numplayers].currentanimation=bounceidleanim;
4996 player[numplayers].targetanimation=bounceidleanim;
4997 player[numplayers].currentframe=0;
4998 player[numplayers].targetframe=1;
4999 player[numplayers].target=0;
5000 player[numplayers].bled=0;
5001 player[numplayers].speed=1+(float)(Random()%100)/1000;
5003 player[numplayers].targetrotation=player[0].targetrotation;
5004 player[numplayers].rotation=player[0].rotation;
5006 player[numplayers].velocity=0;
5007 player[numplayers].coords=player[0].coords;
5008 player[numplayers].oldcoords=player[numplayers].coords;
5009 player[numplayers].realoldcoords=player[numplayers].coords;
5011 player[numplayers].id=numplayers;
5012 player[numplayers].skeleton.id=numplayers;
5013 player[numplayers].updatedelay=0;
5014 player[numplayers].normalsupdatedelay=0;
5016 player[numplayers].aitype=passivetype;
5017 player[numplayers].aitarget=0;
5019 if(player[0].creature==wolftype){
5020 headprop=player[0].proportionhead.x/1.1;
5021 bodyprop=player[0].proportionbody.x/1.1;
5022 armprop=player[0].proportionarms.x/1.1;
5023 legprop=player[0].proportionlegs.x/1.1;
5026 if(player[0].creature==rabbittype){
5027 headprop=player[0].proportionhead.x/1.2;
5028 bodyprop=player[0].proportionbody.x/1.05;
5029 armprop=player[0].proportionarms.x/1.00;
5030 legprop=player[0].proportionlegs.x/1.1;
5033 if(player[numplayers].creature==wolftype){
5034 player[numplayers].proportionhead=1.1*headprop;
5035 player[numplayers].proportionbody=1.1*bodyprop;
5036 player[numplayers].proportionarms=1.1*armprop;
5037 player[numplayers].proportionlegs=1.1*legprop;
5040 if(player[numplayers].creature==rabbittype){
5041 player[numplayers].proportionhead=1.2*headprop;
5042 player[numplayers].proportionbody=1.05*bodyprop;
5043 player[numplayers].proportionarms=1.00*armprop;
5044 player[numplayers].proportionlegs=1.1*legprop;
5045 player[numplayers].proportionlegs.y=1.05*legprop;
5048 player[numplayers].headless=0;
5049 player[numplayers].onfire=0;
5052 player[numplayers].proportionhead.z=0;
5053 player[numplayers].proportionbody.z=0;
5054 player[numplayers].proportionarms.z=0;
5055 player[numplayers].proportionlegs.z=0;
5058 player[numplayers].tempanimation.Load((char *)"Tempanim",0,0);
5060 player[numplayers].damagetolerance=200;
5062 player[numplayers].protectionhead=player[0].protectionhead;
5063 player[numplayers].protectionhigh=player[0].protectionhigh;
5064 player[numplayers].protectionlow=player[0].protectionlow;
5065 player[numplayers].armorhead=player[0].armorhead;
5066 player[numplayers].armorhigh=player[0].armorhigh;
5067 player[numplayers].armorlow=player[0].armorlow;
5068 player[numplayers].metalhead=player[0].metalhead;
5069 player[numplayers].metalhigh=player[0].metalhigh;
5070 player[numplayers].metallow=player[0].metallow;
5072 player[numplayers].immobile=player[0].immobile;
5074 player[numplayers].numclothes=player[0].numclothes;
5075 if(player[numplayers].numclothes)
5076 for(i=0;i<player[numplayers].numclothes;i++){
5077 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
5078 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
5079 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
5080 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
5081 tintr=player[numplayers].clothestintr[i];
5082 tintg=player[numplayers].clothestintg[i];
5083 tintb=player[numplayers].clothestintb[i];
5084 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
5086 if(player[numplayers].numclothes){
5087 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
5090 player[numplayers].power=player[0].power;
5091 player[numplayers].speedmult=player[0].speedmult;
5093 player[numplayers].damage=0;
5094 player[numplayers].permanentdamage=0;
5095 player[numplayers].superpermanentdamage=0;
5096 player[numplayers].deathbleeding=0;
5097 player[numplayers].bleeding=0;
5098 player[numplayers].numwaypoints=0;
5099 player[numplayers].waypoint=0;
5100 player[numplayers].jumppath=0;
5101 player[numplayers].weaponstuck=-1;
5102 player[numplayers].weaponactive=-1;
5103 player[numplayers].num_weapons=0;
5104 player[numplayers].bloodloss=0;
5105 player[numplayers].dead=0;
5107 player[numplayers].loaded=1;
5111 drawmodetogglekeydown=1;
5114 if(Input::isKeyDown(SDLK_p)&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LSHIFT)&&editorenabled){
5115 if(player[numplayers-1].numwaypoints<90){
5116 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
5117 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
5118 player[numplayers-1].numwaypoints++;
5120 drawmodetogglekeydown=1;
5123 if(Input::isKeyDown(SDLK_p)&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LCTRL)&&editorenabled){
5124 if(numpathpoints<30){
5125 bool connected,alreadyconnected;
5128 for(i=0;i<numpathpoints;i++){
5129 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
5131 for(j=0;j<numpathpointconnect[pathpointselected];j++){
5132 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
5134 if(!alreadyconnected){
5135 numpathpointconnect[pathpointselected]++;
5137 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
5143 pathpoint[numpathpoints-1]=player[0].coords;
5144 numpathpointconnect[numpathpoints-1]=0;
5145 if(numpathpoints>1&&pathpointselected!=-1){
5146 numpathpointconnect[pathpointselected]++;
5147 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
5149 pathpointselected=numpathpoints-1;
5152 drawmodetogglekeydown=1;
5155 if(Input::isKeyDown(SDLK_PERIOD)&&!drawmodetogglekeydown&&editorenabled){
5156 pathpointselected++;
5157 if(pathpointselected>=numpathpoints)pathpointselected=-1;
5158 drawmodetogglekeydown=1;
5160 if(Input::isKeyDown(SDLK_COMMA)&&!Input::isKeyDown(SDLK_LSHIFT)&&!drawmodetogglekeydown&&editorenabled){
5161 pathpointselected--;
5162 if(pathpointselected<=-2)
5163 pathpointselected=numpathpoints-1;
5164 drawmodetogglekeydown=1;
5166 if(Input::isKeyDown(SDLK_COMMA)&&Input::isKeyDown(SDLK_LSHIFT)&&!drawmodetogglekeydown&&editorenabled){
5167 if(pathpointselected!=-1){
5169 pathpoint[pathpointselected]=pathpoint[numpathpoints];
5170 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
5171 for(i=0;i<numpathpointconnect[pathpointselected];i++){
5172 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
5174 for(i=0;i<numpathpoints;i++){
5175 for(j=0;j<numpathpointconnect[i];j++){
5176 if(pathpointconnect[i][j]==pathpointselected){
5177 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
5178 numpathpointconnect[i]--;
5180 if(pathpointconnect[i][j]==numpathpoints){
5181 pathpointconnect[i][j]=pathpointselected;
5185 pathpointselected=numpathpoints-1;
5187 drawmodetogglekeydown=1;
5190 if(Input::isKeyDown(SDLK_m)&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LSHIFT)&&debugmode){
5191 editorenabled=1-editorenabled;
5193 player[0].damagetolerance=100000;
5195 player[0].damagetolerance=200;
5197 player[0].damage=0; // these lines were in both if and else, but I think they would better fit in the if
5198 player[0].permanentdamage=0;
5199 player[0].superpermanentdamage=0;
5200 player[0].bloodloss=0;
5201 player[0].deathbleeding=0;
5202 drawmodetogglekeydown=1;
5205 if(Input::isKeyDown(SDLK_LEFT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
5207 if(editortype==treeleavestype||editortype==10)editortype--;
5208 if(editortype<0)editortype=firetype;
5209 drawmodetogglekeydown=1;
5212 if(Input::isKeyDown(SDLK_RIGHT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
5214 if(editortype==treeleavestype||editortype==10)editortype++;
5215 if(editortype>firetype)editortype=0;
5216 drawmodetogglekeydown=1;
5219 if(Input::isKeyDown(SDLK_LEFT)&&editorenabled&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
5220 editorrotation-=multiplier*100;
5221 if(editorrotation<-.01)editorrotation=-.01;
5222 drawmodetogglekeydown=1;
5225 if(Input::isKeyDown(SDLK_RIGHT)&&editorenabled&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
5226 editorrotation+=multiplier*100;
5227 drawmodetogglekeydown=1;
5230 if(Input::isKeyDown(SDLK_UP)&&editorenabled&&!Input::isKeyDown(SDLK_LCTRL)){
5231 editorsize+=multiplier;
5232 drawmodetogglekeydown=1;
5235 if(Input::isKeyDown(SDLK_DOWN)&&editorenabled&&!Input::isKeyDown(SDLK_LCTRL)){
5236 editorsize-=multiplier;
5237 if(editorsize<.1)editorsize=.1;
5238 drawmodetogglekeydown=1;
5242 if(Input::isKeyDown(SDLK_LEFT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&Input::isKeyDown(SDLK_LCTRL)){
5243 mapradius-=multiplier*10;
5246 if(Input::isKeyDown(SDLK_RIGHT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&Input::isKeyDown(SDLK_LCTRL)){
5247 mapradius+=multiplier*10;
5249 if(Input::isKeyDown(SDLK_UP)&&editorenabled&&Input::isKeyDown(SDLK_LCTRL)){
5250 editorrotation2+=multiplier*100;
5253 if(Input::isKeyDown(SDLK_DOWN)&&editorenabled&&Input::isKeyDown(SDLK_LCTRL)){
5254 editorrotation2-=multiplier*100;
5255 if(editorrotation2<-.01)editorrotation2=-.01;
5257 if(Input::isKeyDown(SDLK_DELETE)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)){
5259 float closestdist=-1;
5261 for(i=0;i<objects.numobjects;i++){
5262 distance=findDistancefast(&objects.position[i],&player[0].coords);
5263 if(closestdist==-1||distance<closestdist){
5264 closestdist=distance;
5268 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
5269 drawmodetogglekeydown=1;
5273 if(!Input::isKeyDown(SDLK_m)&&!Input::isKeyDown(SDLK_LEFT)&&!Input::isKeyDown(SDLK_COMMA)&&!Input::isKeyDown(SDLK_PERIOD)&&!Input::isKeyDown(SDLK_RIGHT)&&!Input::isKeyDown(SDLK_DELETE)&&!Input::isKeyDown(SDLK_p)){
5274 drawmodetogglekeydown=0;
5277 if(Input::isKeyDown(SDLK_n)&&!Input::isKeyDown(SDLK_LCTRL)&&!texturesizetogglekeydown&&debugmode){
5278 //if(!player[0].skeleton.free)player[0].damage+=500;
5279 player[0].RagDoll(0);
5280 //player[0].spurt=1;
5281 //player[0].DoDamage(1000);
5285 gLoc[0]=player[0].coords.x;
5286 gLoc[1]=player[0].coords.y;
5287 gLoc[2]=player[0].coords.z;
5288 vel[0]=player[0].velocity.x;
5289 vel[1]=player[0].velocity.y;
5290 vel[2]=player[0].velocity.z;
5291 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
5292 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
5293 OPENAL_SetVolume(channels[whooshsound], 128);
5294 OPENAL_SetPaused(channels[whooshsound], false);
5295 //OPENAL_SetPaused(channels[whooshsound], true);
5297 texturesizetogglekeydown=1;
5300 if(Input::isKeyDown(SDLK_n)&&Input::isKeyDown(SDLK_LCTRL)&&!texturesizetogglekeydown&&debugmode){
5303 float closestdist=-1;
5305 for(i=0;i<objects.numobjects;i++){
5306 if(objects.type[i]==treeleavestype){
5307 objects.scale[i]*=.9;
5310 texturesizetogglekeydown=1;
5313 static XYZ relative;
5314 static int randattack;
5316 static bool playerrealattackkeydown=0;
5318 if(!Input::isKeyDown(MOUSEBUTTON1)&&!Input::isKeyDown(MOUSEBUTTON2))oldbutton=0;
5319 if(!Input::isKeyDown(attackkey))oldattackkey=0;
5320 if(oldattackkey)player[0].attackkeydown=0;
5321 if(oldattackkey)playerrealattackkeydown=0;
5322 if(!oldattackkey)playerrealattackkeydown=Input::isKeyDown(attackkey);
5323 if((player[0].parriedrecently<=0||player[0].weaponactive==-1)&&(!oldattackkey||(realthreat&&player[0].lastattack!=swordslashanim&&player[0].lastattack!=knifeslashstartanim&&player[0].lastattack!=staffhitanim&&player[0].lastattack!=staffspinhitanim)))player[0].attackkeydown=Input::isKeyDown(attackkey);
5324 if(Input::isKeyDown(attackkey)&&!oldattackkey&&!player[0].backkeydown){
5325 for(k=0;k<numplayers;k++){
5326 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
5327 player[k].Reverse();
5331 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
5333 for(k=0;k<numplayers;k++){
5334 if(indialogue!=-1)player[k].attackkeydown=0;
5335 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
5336 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
5337 if(player[k].attackkeydown&&player[k].jumppower<=1&&player[k].backkeydown&&player[k].targetanimation!=backhandspringanim&&(player[k].isIdle()||player[k].isStop()||player[k].isRun()||player[k].targetanimation==walkanim)){
5338 player[k].jumppower-=2;
5340 if(player[k].attackkeydown&&player[k].jumppower>1&&player[k].backkeydown&&player[k].targetanimation!=backhandspringanim&&(player[k].isIdle()||player[k].isStop()||player[k].isRun()||player[k].targetanimation==walkanim)){
5341 for(i=0;i<numplayers;i++){
5343 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
5344 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
5345 player[k].targetanimation=dodgebackanim;
5347 player[k].targetframe=0;
5348 rotatetarget=player[i].coords-player[k].coords;
5349 Normalise(&rotatetarget);
5350 player[k].targetrotation=-asin(0-rotatetarget.x);
5351 player[k].targetrotation*=360/6.28;
5352 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
5354 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
5357 if(player[k].targetanimation!=dodgebackanim){
5358 if(k==0)numflipped++;
5359 player[k].targetanimation=backhandspringanim;
5361 player[k].targetframe=0;
5362 player[k].targetrotation=-rotation+180;
5363 if(player[k].leftkeydown)player[k].targetrotation-=45;
5364 if(player[k].rightkeydown)player[k].targetrotation+=45;
5365 player[k].rotation=player[k].targetrotation;
5366 player[k].jumppower-=2;
5369 if(player[k].attackkeydown&&!animation[player[k].targetanimation].attack&&!player[k].backkeydown&&(player[k].isIdle()||player[k].isRun()||player[k].targetanimation==walkanim||player[k].targetanimation==sneakanim||player[k].isCrouch())){
5370 player[k].hasvictim=0;
5372 for(i=0;i<numplayers;i++){
5374 if(!player[k].hasvictim)
5375 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
5376 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5&&!player[i].skeleton.free&&player[i].howactive<typedead1&&player[i].targetanimation!=jumpreversedanim&&player[i].targetanimation!=rabbitkickreversedanim&&player[i].targetanimation!=rabbitkickanim&&player[k].targetanimation!=rabbitkickanim&&player[i].targetanimation!=getupfrombackanim&&(player[i].targetanimation!=staggerbackhighanim&&(player[i].targetanimation!=staggerbackhardanim||animation[staggerbackhardanim].label[player[i].targetframe]==6))&&player[i].targetanimation!=jumpdownanim&&player[i].targetanimation!=jumpupanim&&player[i].targetanimation!=getupfromfrontanim){
5377 player[k].victim=&player[i];
5378 player[k].hasvictim=1;
5379 if(player[k].aitype==playercontrolled){
5380 if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&player[k].crouchkeydown&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
5381 else if(findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive==-1&&!reversaltrain)player[k].targetanimation=winduppunchanim;
5382 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
5383 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&player[k].weaponactive!=-1&&player[i].staggerdelay>0&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&player[i].bloodloss>player[i].damagetolerance/2)player[k].targetanimation=knifefollowanim;
5384 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&player[k].weaponmissdelay<=0)player[k].targetanimation=knifeslashstartanim;
5385 else if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword&&player[k].weaponmissdelay<=0)player[k].targetanimation=swordslashanim;
5386 else if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff&&player[k].weaponmissdelay<=0&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].forwardkeydown)player[k].targetanimation=staffhitanim;
5387 else if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff&&player[k].weaponmissdelay<=0)player[k].targetanimation=staffspinhitanim;
5388 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
5389 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height==lowheight&&animation[player[k].targetanimation].attack!=normalattack)player[k].targetanimation=lowkickanim;
5392 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
5393 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
5394 else randattack=abs(Random()%5);
5395 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
5396 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
5397 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
5398 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
5399 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
5401 if(player[k].weaponactive!=-1){
5402 if((tutoriallevel!=1||player[k].weaponactive==-1)&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
5403 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)/*&&animation[player[i].targetanimation].height!=lowheight*/&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&player[k].weaponmissdelay<=0)player[k].targetanimation=knifeslashstartanim;
5404 //else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5&&player[k].weaponactive!=-1&&player[i].staggerdelay>0&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)player[k].targetanimation=knifefollowanim;
5405 else if(!(player[0].victim==&player[i]&&player[0].hasvictim&&player[0].targetanimation==swordslashanim)&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword&&player[k].weaponmissdelay<=0)player[k].targetanimation=swordslashanim;
5406 else if(!(player[0].victim==&player[i]&&player[0].hasvictim&&player[0].targetanimation==swordslashanim)&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff&&player[k].weaponmissdelay<=0&&randattack<3)player[k].targetanimation=staffhitanim;
5407 else if(!(player[0].victim==&player[i]&&player[0].hasvictim&&player[0].targetanimation==swordslashanim)&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff&&player[k].weaponmissdelay<=0&&randattack>=3)player[k].targetanimation=staffspinhitanim;
5408 else if((tutoriallevel!=1||player[k].weaponactive==-1)&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&randattack==1&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
5409 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height==lowheight&&animation[player[k].targetanimation].attack!=normalattack)player[k].targetanimation=lowkickanim;
5413 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
5415 if((tutoriallevel!=1||tutorialstage==22)&&player[i].howactive<typedead1&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)&&!player[i].skeleton.free&&player[i].targetanimation!=getupfrombackanim&&player[i].targetanimation!=getupfromfrontanim&&(((player[i].stunned>0&&player[k].madskills)||(player[i].surprised>0)||player[i].aitype==passivetype)||(player[k].weaponactive!=-1&&player[i].stunned>0))&&normaldotproduct(player[i].facing,player[i].coords-player[k].coords)>0&&(k==0)){
5416 if(player[k].weaponactive==-1){
5417 player[i].targetanimation=sneakattackedanim;
5418 player[i].currentanimation=sneakattackedanim;
5419 player[k].currentanimation=sneakattackanim;
5420 player[k].targetanimation=sneakattackanim;
5421 player[k].oldcoords=player[k].coords;
5422 player[k].coords=player[i].coords;
5424 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
5425 player[i].targetanimation=knifesneakattackedanim;
5426 player[i].currentanimation=knifesneakattackedanim;
5427 player[k].currentanimation=knifesneakattackanim;
5428 player[k].targetanimation=knifesneakattackanim;
5429 player[i].oldcoords=player[i].coords;
5430 player[i].coords=player[k].coords;
5432 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
5433 player[i].targetanimation=swordsneakattackedanim;
5434 player[i].currentanimation=swordsneakattackedanim;
5435 player[k].currentanimation=swordsneakattackanim;
5436 player[k].targetanimation=swordsneakattackanim;
5437 player[i].oldcoords=player[i].coords;
5438 player[i].coords=player[k].coords;
5440 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
5441 player[k].victim=&player[i];
5442 player[k].hasvictim=1;
5443 player[i].targettilt2=0;
5444 player[i].targetframe=1;
5445 player[i].currentframe=0;
5447 player[i].velocity=0;
5448 player[k].targettilt2=player[i].targettilt2;
5449 player[k].currentframe=player[i].currentframe;
5450 player[k].targetframe=player[i].targetframe;
5451 player[k].target=player[i].target;
5452 player[k].velocity=0;
5453 player[k].targetrotation=player[i].rotation;
5454 player[k].rotation=player[i].rotation;
5455 player[i].targetrotation=player[i].rotation;
5458 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
5460 player[k].targetframe=0;
5462 //player[k].velocity=0;
5464 rotatetarget=player[i].coords-player[k].coords;
5465 Normalise(&rotatetarget);
5466 player[k].targetrotation=-asin(0-rotatetarget.x);
5467 player[k].targetrotation*=360/6.28;
5468 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
5470 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
5472 player[k].lastattack3=player[k].lastattack2;
5473 player[k].lastattack2=player[k].lastattack;
5474 player[k].lastattack=player[k].targetanimation;
5475 //player[k].targettilt2=0;
5479 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
5480 rotatetarget=player[i].coords-player[k].coords;
5481 Normalise(&rotatetarget);
5482 player[k].targetrotation=-asin(0-rotatetarget.x);
5483 player[k].targetrotation*=360/6.28;
5484 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
5485 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
5487 player[k].victim=&player[i];
5488 player[k].hasvictim=1;
5489 player[i].targetanimation=knifefollowedanim;
5490 player[i].currentanimation=knifefollowedanim;
5491 player[i].targettilt2=0;
5492 player[i].targettilt2=player[k].targettilt2;
5493 player[i].targetframe=1;
5494 player[i].currentframe=0;
5496 player[i].velocity=0;
5497 player[k].currentanimation=knifefollowanim;
5498 player[k].targetanimation=knifefollowanim;
5499 player[k].targettilt2=player[i].targettilt2;
5500 player[k].currentframe=player[i].currentframe;
5501 player[k].targetframe=player[i].targetframe;
5502 player[k].target=player[i].target;
5503 player[k].velocity=0;
5504 player[k].oldcoords=player[k].coords;
5505 player[i].coords=player[k].coords;
5506 player[i].targetrotation=player[k].targetrotation;
5507 player[i].rotation=player[k].targetrotation;
5508 player[k].rotation=player[k].targetrotation;
5509 player[i].rotation=player[k].targetrotation;
5514 if(player[k].weaponactive!=-1){
5515 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
5518 for(i=0;i<numplayers;i++){
5520 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
5521 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
5522 if(player[i].skeleton.free)
5523 if(findDistancefast(&player[k].coords,&player[i].coords)<3.5*(player[k].scale*5)*(player[k].scale*5)&&(player[i].dead||player[i].skeleton.longdead>1000||player[k].isRun()||(hasstaff)||(player[k].weaponactive!=-1&&player[i].skeleton.free&&(player[i].skeleton.longdead>2000||player[i].damage>player[i].damagetolerance/8||player[i].bloodloss>player[i].damagetolerance/2)&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)))){
5524 player[k].victim=&player[i];
5525 player[k].hasvictim=1;
5526 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
5527 if(player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5))player[k].targetanimation=crouchstabanim;
5528 if(player[k].crouchkeydown&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)/*&&player[i].dead!=2*/&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)player[k].targetanimation=swordgroundstabanim;
5529 if(/*(player[k].crouchkeydown||!player[i].dead)&&*/findDistancefast(&player[k].coords,&player[i].coords)<3.5*(player[k].scale*5)*(player[k].scale*5)/*&&player[i].dead!=2*/&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)player[k].targetanimation=staffgroundsmashanim;
5531 if(findDistancefast(&player[k].coords,&player[i].coords)<2.5&&player[k].crouchkeydown&&player[k].targetanimation!=crouchstabanim&&(player[k].weaponactive==-1)&&player[i].dead&&player[i].skeleton.free&&player[i].skeleton.longdead>1000){
5532 player[k].targetanimation=killanim;
5533 for(j=0;j<terrain.numdecals;j++){
5534 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
5535 terrain.DeleteDecal(j);
5538 for(l=0;l<objects.numobjects;l++){
5539 if(objects.model[l].type==decalstype)
5540 for(j=0;j<objects.model[l].numdecals;j++){
5541 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
5542 objects.model[l].DeleteDecal(j);
5547 if(!player[i].dead||musictype!=2)
5548 if(findDistancefast(&player[k].coords,&player[i].coords)<3.5&&(player[k].isRun()||(player[k].isIdle()&&player[k].attackkeydown))&&(player[k].staggerdelay<=0&&(player[i].dead||(player[i].skeleton.longdead<300&&player[k].lastattack!=spinkickanim&&player[i].skeleton.free)))&&(!player[i].dead||musictype!=stream_music2)){
5549 player[k].targetanimation=dropkickanim;
5550 for(j=0;j<terrain.numdecals;j++){
5551 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
5552 terrain.DeleteDecal(j);
5555 for(l=0;l<objects.numobjects;l++){
5556 if(objects.model[l].type==decalstype)
5557 for(j=0;j<objects.model[l].numdecals;j++){
5558 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
5559 objects.model[l].DeleteDecal(j);
5565 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free||player[k].targetanimation==killanim||player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim||player[k].targetanimation==dropkickanim)){
5567 player[k].targetframe=0;
5569 //player[k].velocity=0;
5571 rotatetarget=player[i].coords-player[k].coords;
5572 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
5573 rotatetarget=(player[i].coords+(player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position+player[i].skeleton.joints[player[i].skeleton.jointlabels[neck]].position)/2*player[i].scale)-player[k].coords;
5575 Normalise(&rotatetarget);
5576 player[k].targetrotation=-asin(0-rotatetarget.x);
5577 player[k].targetrotation*=360/6.28;
5578 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
5580 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
5581 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
5584 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
5585 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
5587 player[k].lastattack3=player[k].lastattack2;
5588 player[k].lastattack2=player[k].lastattack;
5589 player[k].lastattack=player[k].targetanimation;
5591 if(player[k].targetanimation==swordgroundstabanim){
5592 player[k].targetrotation+=30;
5594 //player[k].targettilt2=0;
5600 if(!player[k].hasvictim){
5601 for(i=0;i<numplayers;i++){
5602 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
5603 player[k].victim=&player[i];
5604 player[k].hasvictim=1;
5606 if(player[k].hasvictim&&!player[i].skeleton.free)
5607 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
5608 player[k].victim=&player[i];
5612 if(player[k].aitype==playercontrolled)
5613 if(player[k].attackkeydown&&(player[k].isRun())&&player[k].wasRun()&&((player[k].hasvictim&&findDistancefast(&player[k].coords,&player[k].victim->coords)<12*(player[k].scale*5)*(player[k].scale*5)&&findDistancefast(&player[k].coords,&player[k].victim->coords)>7*(player[k].scale*5)*(player[k].scale*5)&&!player[k].victim->skeleton.free&&player[k].victim->targetanimation!=getupfrombackanim&&player[k].victim->targetanimation!=getupfromfrontanim&&animation[player[k].victim->targetanimation].height!=lowheight&&player[k].aitype!=playercontrolled&&normaldotproduct(player[k].facing,player[k].victim->coords-player[k].coords)>0&&player[k].rabbitkickenabled)||player[k].jumpkeydown)){
5615 player[k].targetanimation=rabbitkickanim;
5616 player[k].targetframe=0;
5619 if(animation[player[k].targetanimation].attack&&k==0){
5622 if(player[k].weaponactive!=-1){
5623 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
5626 if(player[k].weaponactive!=-1){
5627 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
5630 if(player[k].weaponactive!=-1){
5631 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
5633 if(armedstaff)numstaffattack++;
5634 else if(armedsword)numswordattack++;
5635 else if(armedknife)numknifeattack++;
5636 else numunarmedattack++;
5643 static float collisionradius;
5645 for(k=0;k<numplayers;k++){
5646 for(i=k;i<numplayers;i++){
5649 if((animation[player[i].targetanimation].attack!=reversed&&animation[player[i].targetanimation].attack!=reversal&&animation[player[k].targetanimation].attack!=reversed&&animation[player[k].targetanimation].attack!=reversal)||(i!=0&&k!=0))
5650 if((animation[player[i].currentanimation].attack!=reversed&&animation[player[i].currentanimation].attack!=reversal&&animation[player[k].currentanimation].attack!=reversed&&animation[player[k].currentanimation].attack!=reversal)||(i!=0&&k!=0))
5651 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
5652 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
5653 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz&&player[k].skeleton.oldfree==player[k].skeleton.free&&player[i].skeleton.oldfree==player[i].skeleton.free&&player[i].targetanimation!=climbanim&&player[i].targetanimation!=hanganim&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim)
5654 if(player[i].coords.y>player[k].coords.y-3)
5655 if(player[i].coords.y<player[k].coords.y+3)
5656 if(player[i].coords.x>player[k].coords.x-3)
5657 if(player[i].coords.x<player[k].coords.x+3)
5658 if(player[i].coords.z>player[k].coords.z-3)
5659 if(player[i].coords.z<player[k].coords.z+3){
5660 if(findDistancefast(&player[i].coords,&player[k].coords)<3*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
5661 if(player[i].onfire||player[k].onfire){
5662 if(!player[i].onfire)player[i].CatchFire();
5663 if(!player[k].onfire)player[k].CatchFire();
5667 tempcoords1=player[i].coords;
5668 tempcoords2=player[k].coords;
5669 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
5670 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
5671 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
5672 if(player[0].hasvictim)
5673 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
5674 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
5676 if(player[k].targetanimation==jumpdownanim&&!player[k].skeleton.oldfree&&!player[k].skeleton.free&&player[i].skeleton.oldfree&&player[i].skeleton.free&&player[i].dead&&player[k].lastcollide<=0&&abs(player[i].coords.y-player[k].coords.y)<.2&&findDistancefast(&player[k].coords,&player[i].coords)<.7*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
5677 player[k].coords.y=player[i].coords.y;
5678 player[i].velocity=player[k].velocity;
5679 player[i].skeleton.free=0;
5680 player[i].rotation=0;
5681 player[i].RagDoll(0);
5682 player[i].DoDamage(20);
5683 if(k==0)camerashake+=.3;
5684 player[i].skeleton.longdead=0;
5685 player[k].lastcollide=1;
5688 if(player[i].targetanimation==jumpdownanim&&!player[i].skeleton.oldfree&&!player[i].skeleton.free&&player[k].skeleton.oldfree&&player[k].skeleton.free&&player[k].dead&&player[i].lastcollide<=0&&abs(player[i].coords.y-player[k].coords.y)<.2&&findDistancefast(&player[k].coords,&player[i].coords)<.7*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
5689 player[i].coords.y=player[k].coords.y;
5690 player[k].velocity=player[i].velocity;
5691 player[k].skeleton.free=0;
5692 player[k].rotation=0;
5693 player[k].RagDoll(0);
5694 player[k].DoDamage(20);
5695 if(i==0)camerashake+=.3;
5696 player[k].skeleton.longdead=0;
5697 player[i].lastcollide=1;
5700 if((player[i].skeleton.oldfree==1&&findLengthfast(&player[i].velocity)>1)||(player[k].skeleton.oldfree==1&&findLengthfast(&player[k].velocity)>1)||(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0)){
5701 rotatetarget=player[k].velocity-player[i].velocity;
5702 if(((player[i].targetanimation!=getupfrombackanim&&player[i].targetanimation!=getupfromfrontanim)||player[i].skeleton.free)&&((player[k].targetanimation!=getupfrombackanim&&player[k].targetanimation!=getupfromfrontanim)||player[k].skeleton.free))
5703 if(((((findLengthfast(&rotatetarget)>150&&(i!=0&&k!=0))||(findLengthfast(&rotatetarget)>50&&player[0].rabbitkickragdoll/*currentanimation==rabbitkickanim*/&&(i==0||k==0)))&&normaldotproduct(rotatetarget,player[k].coords-player[i].coords)>0)&&((i==0||k==0)||((player[i].skeleton.oldfree==1&&k!=0&&animation[player[k].currentanimation].attack==neutral)||(player[k].skeleton.oldfree==1&&i!=0&&animation[player[i].currentanimation].attack==neutral)||(player[i].isFlip()&&!player[i].skeleton.oldfree&&(i==0||k==0))||(player[k].isFlip()&&!player[k].skeleton.oldfree&&(i==0||k==0))||(i==0||k==0))))||((player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip())&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&(i==0||k==0)&&(!player[i].skeleton.oldfree&&!player[k].skeleton.oldfree))){
5705 if((i!=0||player[i].skeleton.free)&&(k!=0||player[k].skeleton.free)||(animation[player[i].targetanimation].height==highheight&&animation[player[k].targetanimation].height==highheight)){
5706 static float gLoc[3];
5707 static float vel[3];
5708 gLoc[0]=player[i].coords.x;
5709 gLoc[1]=player[i].coords.y;
5710 gLoc[2]=player[i].coords.z;
5711 vel[0]=player[i].velocity.x;
5712 vel[1]=player[i].velocity.y;
5713 vel[2]=player[i].velocity.z;
5714 if(tutoriallevel!=1){
5715 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
5716 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
5717 OPENAL_SetVolume(channels[heavyimpactsound], 256);
5718 OPENAL_SetPaused(channels[heavyimpactsound], false);
5720 //player[i].velocity=player[k].velocity;
5721 //player[k].velocity=player[i].velocity;
5723 player[i].RagDoll(0);
5724 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
5729 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
5730 player[k].RagDoll(0);
5731 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
5736 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
5738 //if(player[i].skeleton.oldfree){
5739 for(j=0;j<player[i].skeleton.num_joints;j++){
5740 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
5743 //if(player[k].skeleton.oldfree){
5744 for(j=0;j<player[k].skeleton.num_joints;j++){
5745 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
5751 if((animation[player[i].targetanimation].attack==neutral||animation[player[i].targetanimation].attack==normalattack)&&(animation[player[k].targetanimation].attack==neutral||animation[player[k].targetanimation].attack==normalattack)){
5753 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
5754 if(findDistancefast(&player[k].coords,&player[i].coords)<.5*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
5755 rotatetarget=player[k].coords-player[i].coords;
5756 Normalise(&rotatetarget);
5757 player[k].coords=(player[k].coords+player[i].coords)/2;
5758 player[i].coords=player[k].coords-rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
5759 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
5760 if(player[k].howactive==typeactive||hostile)
5761 if(player[k].isIdle()){
5762 if(player[k].howactive<typesleeping){
5763 player[k].targetanimation=player[k].getStop();
5764 player[k].targetframe=0;
5767 else if(player[k].howactive==typesleeping)
5769 player[k].targetanimation=getupfromfrontanim;
5770 player[k].targetframe=0;
5773 if(!editorenabled)player[k].howactive=typeactive;
5775 if(player[i].howactive==typeactive||hostile)
5776 if(player[i].isIdle()){
5777 if(player[i].howactive<typesleeping){
5778 player[i].targetanimation=player[i].getStop();
5779 player[i].targetframe=0;
5784 player[i].targetanimation=getupfromfrontanim;
5785 player[i].targetframe=0;
5788 if(!editorenabled)player[i].howactive=typeactive;
5792 if(k==0&&i!=0&&player[k].targetanimation==jumpdownanim&&!player[i].isCrouch()&&player[i].targetanimation!=rollanim&&!player[k].skeleton.oldfree&&!player[k].skeleton.free&&player[k].lastcollide<=0&&player[k].velocity.y<-10){
5793 player[i].velocity=player[k].velocity;
5794 player[k].velocity=player[k].velocity*-.5;
5795 //player[i].velocity.y-=10;
5796 player[k].velocity.y=player[i].velocity.y;
5797 player[i].DoDamage(20);
5798 player[i].RagDoll(0);
5799 player[k].lastcollide=1;
5806 if(i==0&&k!=0&&player[i].targetanimation==jumpdownanim&&!player[k].isCrouch()&&player[k].targetanimation!=rollanim&&!player[i].skeleton.oldfree&&!player[i].skeleton.free&&player[i].lastcollide<=0&&player[i].velocity.y<-10){
5807 player[k].velocity=player[i].velocity;
5808 player[i].velocity=player[i].velocity*-.3;
5809 //player[k].velocity.y-=10;
5810 player[i].velocity.y=player[k].velocity.y;
5811 player[k].DoDamage(20);
5812 player[k].RagDoll(0);
5813 player[i].lastcollide=1;
5824 player[i].CheckKick();
5825 player[k].CheckKick();
5831 for(k=0;k<numplayers;k++){
5832 for(i=k;i<numplayers;i++){
5834 if(i<numplayers&&i!=k&&player[k].skeleton.free==0&&player[i].skeleton.oldfree==0&&(player[i].targetanimation==jumpupanim||player[k].targetanimation==jumpupanim)&&(player[i].aitype==playercontrolled||player[k].aitype==playercontrolled)&&((player[i].aitype==attacktypecutoff&&player[i].stunned<=0)||(player[k].aitype==attacktypecutoff&&player[k].stunned<=0))){
5835 if(findDistancefast(&player[i].coords,&player[k].coords)<10*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)&&findDistancefastflat(&player[i].coords,&player[k].coords)<2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
5836 if(player[i].targetanimation==jumpupanim&&player[k].targetanimation!=getupfrombackanim&&player[k].targetanimation!=getupfromfrontanim&&animation[player[k].targetanimation].height==middleheight&&normaldotproduct(player[i].velocity,player[k].coords-player[i].coords)<0&&((player[k].aitype==playercontrolled&&player[k].attackkeydown)||player[k].aitype!=playercontrolled)){
5837 player[i].victim=&player[k];
5838 player[i].targetanimation=jumpreversedanim;
5839 player[i].currentanimation=jumpreversedanim;
5840 player[k].currentanimation=jumpreversalanim;
5841 player[k].targetanimation=jumpreversalanim;
5842 player[i].targettilt2=0;
5843 player[i].currentframe=0;
5844 player[i].targetframe=1;
5845 player[k].currentframe=0;
5846 player[k].targetframe=1;
5847 if(player[i].coords.y<player[k].coords.y+1){
5848 player[i].targetanimation=rabbitkickreversedanim;
5849 player[i].currentanimation=rabbitkickreversedanim;
5850 player[k].currentanimation=rabbitkickreversalanim;
5851 player[k].targetanimation=rabbitkickreversalanim;
5852 player[k].currentframe=1;
5853 player[k].targetframe=2;
5854 player[i].currentframe=1;
5855 player[i].targetframe=2;
5857 player[k].targettilt2=0;
5859 player[i].velocity=0;
5860 player[k].velocity=0;
5861 player[k].oldcoords=player[k].coords;
5862 player[i].coords=player[k].coords;
5863 player[k].targetrotation=player[i].targetrotation;
5864 player[k].rotation=player[i].targetrotation;
5865 player[k].victim=&player[i];
5866 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
5868 if(player[k].targetanimation==jumpupanim&&player[i].targetanimation!=getupfrombackanim&&player[i].targetanimation!=getupfromfrontanim&&animation[player[i].targetanimation].height==middleheight&&normaldotproduct(player[k].velocity,player[i].coords-player[k].coords)<0&&((player[i].aitype==playercontrolled&&player[i].attackkeydown)||player[i].aitype!=playercontrolled)){
5869 player[k].victim=&player[i];
5870 player[k].targetanimation=jumpreversedanim;
5871 player[k].currentanimation=jumpreversedanim;
5872 player[i].currentanimation=jumpreversalanim;
5873 player[i].targetanimation=jumpreversalanim;
5874 player[k].targettilt2=0;
5875 player[i].targettilt2=0;
5876 player[k].currentframe=0;
5877 player[k].targetframe=1;
5878 player[i].currentframe=0;
5879 player[i].targetframe=1;
5880 if(player[k].coords.y<player[i].coords.y+1){
5881 player[k].targetanimation=rabbitkickreversedanim;
5882 player[k].currentanimation=rabbitkickreversedanim;
5883 player[i].currentanimation=rabbitkickreversalanim;
5884 player[i].targetanimation=rabbitkickreversalanim;
5885 player[k].currentframe=1;
5886 player[k].targetframe=2;
5887 player[i].currentframe=1;
5888 player[i].targetframe=2;
5891 player[k].velocity=0;
5892 player[i].velocity=0;
5893 player[i].oldcoords=player[i].coords;
5894 player[k].coords=player[i].coords;
5895 player[i].targetrotation=player[k].targetrotation;
5896 player[i].rotation=player[k].targetrotation;
5897 player[i].victim=&player[k];
5898 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
5905 for(k=0;k<numplayers;k++)
5906 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
5910 if(!Input::isKeyDown(SDLK_n)){
5911 texturesizetogglekeydown=0;
5914 for(k=0;k<numplayers;k++){
5915 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
5916 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
5917 player[k].DoDamage(1000);
5922 static bool respawnkeydown;
5923 if(!editorenabled&&(whichlevel!=-2&&(Input::isKeyDown(SDLK_z)&&Input::isKeyDown(SDLK_LMETA)&&debugmode&&!editorenabled)||(Input::isKeyDown(jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
5924 targetlevel=whichlevel;
5928 if(!Input::isKeyDown(jumpkey))respawnkeydown=0;
5929 if(Input::isKeyDown(jumpkey))respawnkeydown=1;
5934 if(whichlevel!=-2&&Input::isKeyDown(SDLK_k)&&Input::isKeyDown(SDLK_LSHIFT)&&!slomotogglekeydown&&debugmode&&!editorenabled){
5936 if(targetlevel>numchallengelevels-1)targetlevel=0;
5939 slomotogglekeydown=1;
5941 static bool movekey;
5942 static bool connected;
5944 for(int i=0;i<numplayers;i++){
5945 if(!player[i].skeleton.free){
5946 oldtargetrotation=player[i].targetrotation;
5947 if(i==0&&indialogue==-1){
5948 if(!animation[player[0].targetanimation].attack&&player[0].targetanimation!=staggerbackhighanim&&player[0].targetanimation!=staggerbackhardanim&&player[0].targetanimation!=crouchremoveknifeanim&&player[0].targetanimation!=removeknifeanim&&player[0].targetanimation!=backhandspringanim&&player[0].targetanimation!=dodgebackanim&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
5949 if(!cameramode)player[0].targetrotation=-rotation+180;
5950 if(cameramode)player[0].targetrotation=0;
5956 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
5957 if(cameramode){facing=flatfacing;}
5959 facing=DoRotation(facing,-rotation2,0,0);
5960 facing=DoRotation(facing,0,0-rotation,0);
5963 player[0].lookrotation=-rotation;
5965 player[i].targetheadrotation=rotation;
5966 player[i].targetheadrotation2=rotation2;
5968 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
5969 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim&&player[i].targetanimation!=walljumprightkickanim&&player[i].targetanimation!=walljumpleftkickanim){
5970 player[i].targetrotation=-player[i].lookrotation+180;
5976 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
5978 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
5979 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
5981 player[i].targetheadrotation=player[i].lookrotation;
5982 player[i].targetheadrotation2=player[i].lookrotation2;
5985 rotatetarget=participantfacing[whichdialogue][indialogue][i];
5986 Normalise(&rotatetarget);
5987 player[i].targetheadrotation=-asin(0-rotatetarget.x);
5988 player[i].targetheadrotation*=360/6.28;
5989 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
5991 player[i].targetheadrotation*=-1;
5992 player[i].targetheadrotation+=180;
5993 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
6001 player[i].avoidsomething=0;
6003 for(j=0;j<objects.numobjects;j++){
6004 if(objects.onfire[j]){
6005 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
6007 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
6008 player[i].collided=0;
6009 player[i].avoidcollided=1;
6010 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
6011 player[i].avoidwhere=objects.position[j];
6017 //Add avoidwhere to players
6019 for(j=0;j<numplayers;j++){
6020 if(player[j].onfire){
6021 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
6023 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
6024 player[i].collided=0;
6025 player[i].avoidcollided=1;
6026 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
6027 player[i].avoidwhere=objects.position[j];
6033 if(player[i].collided>.8)player[i].avoidcollided=0;
6034 if(player[i].aitype!=playercontrolled&&indialogue==-1){
6035 player[i].jumpclimb=0;
6037 if(editorenabled)player[i].stunned=1;
6040 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
6041 if(findDistancefastflat(&player[0].coords,&player[i].coords)<30&&player[0].coords.y>player[i].coords.y+2&&!player[0].onterrain)player[i].pause=1;
6043 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
6044 player[i].forwardkeydown=0;
6045 player[i].leftkeydown=0;
6046 player[i].backkeydown=0;
6047 player[i].rightkeydown=0;
6048 player[i].crouchkeydown=0;
6049 player[i].attackkeydown=0;
6050 player[i].jumpkeydown=0;
6051 player[i].throwkeydown=0;
6054 if(player[i].aitype==pathfindtype){
6055 if(player[i].finalpathfindpoint==-1){
6056 float closestdistance;
6062 for(j=0;j<numpathpoints;j++){
6063 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
6064 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
6066 player[i].finaltarget=pathpoint[j];
6069 player[i].finalpathfindpoint=closest;
6070 for(j=0;j<numpathpoints;j++){
6071 if(numpathpointconnect[j])
6072 for(k=0;k<numpathpointconnect[j];k++){
6073 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
6074 if(tempdist*tempdist<closestdistance){
6075 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
6076 closestdistance=tempdist*tempdist;
6078 player[i].finaltarget=colpoint;
6083 player[i].finalpathfindpoint=closest;
6086 if(player[i].targetpathfindpoint==-1){
6087 float closestdistance;
6093 if(player[i].lastpathfindpoint==-1){
6094 for(j=0;j<numpathpoints;j++){
6095 if(j!=player[i].lastpathfindpoint)
6096 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
6097 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
6101 player[i].targetpathfindpoint=closest;
6102 for(j=0;j<numpathpoints;j++){
6103 if(j!=player[i].lastpathfindpoint)
6104 if(numpathpointconnect[j])
6105 for(k=0;k<numpathpointconnect[j];k++){
6106 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
6107 if(tempdist*tempdist<closestdistance){
6108 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
6109 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
6110 closestdistance=tempdist*tempdist;
6117 player[i].targetpathfindpoint=closest;
6121 for(j=0;j<numpathpoints;j++){
6122 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
6125 if(numpathpointconnect[j])
6126 for(k=0;k<numpathpointconnect[j];k++){
6127 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
6130 if(numpathpointconnect[player[i].lastpathfindpoint])
6131 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
6132 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
6135 tempdist=findPathDist(j,player[i].finalpathfindpoint);
6136 if(closest==-1||tempdist<closestdistance){
6137 closestdistance=tempdist;
6143 player[i].targetpathfindpoint=closest;
6146 player[i].losupdatedelay-=multiplier;
6148 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
6149 Normalise(&rotatetarget);
6150 player[i].targetrotation=-asin(0-rotatetarget.x);
6151 player[i].targetrotation*=360/6.28;
6152 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
6153 player[i].lookrotation=player[i].targetrotation;
6154 //player[i].aiupdatedelay=.05;
6156 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
6157 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
6158 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
6159 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
6160 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
6161 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
6162 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
6163 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
6164 player[i].targetpathfindpoint=-1;
6166 if(findDistancefastflat(&player[i].coords,&player[i].finalfinaltarget)<findDistancefastflat(&player[i].coords,&player[i].finaltarget)||findDistancefastflat(&player[i].coords,&player[i].finaltarget)<.6*(player[i].scale*5)*(player[i].scale*5)||player[i].lastpathfindpoint==player[i].finalpathfindpoint){
6167 player[i].aitype=passivetype;
6170 player[i].forwardkeydown=1;
6171 player[i].leftkeydown=0;
6172 player[i].backkeydown=0;
6173 player[i].rightkeydown=0;
6174 player[i].crouchkeydown=0;
6175 player[i].attackkeydown=0;
6176 player[i].throwkeydown=0;
6178 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
6180 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
6181 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
6183 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
6184 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled&&(player[0].coords.y<player[i].coords.y+5||player[0].onterrain))
6185 player[i].aitype=attacktypecutoff;
6186 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
6187 player[i].aitype=attacktypecutoff;
6189 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
6190 player[i].losupdatedelay=.2;
6191 for(j=0;j<numplayers;j++){
6192 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
6193 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
6194 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
6195 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
6196 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
6197 if((-1==checkcollide(DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords,DoRotation(player[j].skeleton.joints[player[j].skeleton.jointlabels[head]].position,0,player[j].rotation,0)*player[j].scale+player[j].coords)&&!player[j].isWallJump())||(player[j].targetanimation==hanganim&&normaldotproduct(player[j].facing,player[i].coords-player[j].coords)<0)){
6198 player[i].aitype=searchtype;
6199 player[i].lastchecktime=12;
6200 player[i].lastseen=player[j].coords;
6201 player[i].lastseentime=12;
6207 if(player[i].aitype==attacktypecutoff&&musictype!=2){
6208 if(player[i].creature!=wolftype){
6209 player[i].stunned=.6;
6210 player[i].surprised=.6;
6215 if(player[i].aitype!=passivetype&&leveltime>.5){
6216 player[i].howactive=typeactive;
6219 if(player[i].aitype==passivetype){
6220 player[i].aiupdatedelay-=multiplier;
6221 player[i].losupdatedelay-=multiplier;
6222 player[i].lastseentime+=multiplier;
6223 player[i].pausetime-=multiplier;
6224 if(player[i].lastseentime>1)player[i].lastseentime=1;
6226 if(player[i].aiupdatedelay<0){
6227 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
6228 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
6229 Normalise(&rotatetarget);
6230 player[i].targetrotation=-asin(0-rotatetarget.x);
6231 player[i].targetrotation*=360/6.28;
6232 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
6233 player[i].lookrotation=player[i].targetrotation;
6234 player[i].aiupdatedelay=.05;
6236 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
6237 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
6238 player[i].waypoint++;
6239 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
6244 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
6245 else player[i].forwardkeydown=0;
6246 player[i].leftkeydown=0;
6247 player[i].backkeydown=0;
6248 player[i].rightkeydown=0;
6249 player[i].crouchkeydown=0;
6250 player[i].attackkeydown=0;
6251 player[i].throwkeydown=0;
6253 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
6254 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
6256 XYZ leftpos,rightpos;
6257 float leftdist,rightdist;
6258 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
6259 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
6260 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
6261 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
6262 if(leftdist<rightdist)player[i].targetrotation+=90;
6263 else player[i].targetrotation-=90;
6267 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
6268 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
6272 if(player[i].howactive<typesleeping)
6273 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
6274 for(j=0;j<numenvsounds;j++){
6275 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
6276 player[i].aitype=attacktypecutoff;
6280 if(player[i].howactive==typesleeping)
6281 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
6282 for(j=0;j<numenvsounds;j++){
6283 if(envsoundvol[j]>14)
6284 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
6285 player[i].aitype=attacktypecutoff;
6289 if(player[i].aitype!=passivetype){
6290 if(player[i].howactive==typesleeping){
6291 player[i].targetanimation=getupfromfrontanim;
6292 player[i].targetframe=0;
6296 player[i].howactive=typeactive;
6300 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
6301 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
6302 player[i].aitype=attacktypecutoff;
6303 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
6304 player[i].aitype=attacktypecutoff;
6306 if(player[i].creature==wolftype){
6308 float smelldistance;
6310 for(j=0;j<numplayers;j++){
6311 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
6312 if(j==0&&player[j].num_weapons>0){
6313 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
6314 if(player[j].num_weapons==2)
6315 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
6320 windsmell=windvector;
6321 Normalise(&windsmell);
6322 windsmell=windsmell*2+player[j].coords;
6323 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
6324 player[i].aitype=attacktypecutoff;
6329 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
6330 player[i].losupdatedelay=.2;
6331 for(j=0;j<numplayers;j++){
6332 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
6333 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
6334 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
6335 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
6336 if((-1==checkcollide(DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords,DoRotation(player[j].skeleton.joints[player[j].skeleton.jointlabels[head]].position,0,player[j].rotation,0)*player[j].scale+player[j].coords)&&!player[j].isWallJump())||(player[j].targetanimation==hanganim&&normaldotproduct(player[j].facing,player[i].coords-player[j].coords)<0)){
6337 player[i].lastseentime-=.2;
6338 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
6339 else player[i].lastseentime-=.6;
6341 if(player[i].lastseentime<=0){
6342 player[i].aitype=searchtype;
6343 player[i].lastchecktime=12;
6344 player[i].lastseen=player[j].coords;
6345 player[i].lastseentime=12;
6351 if(player[i].aitype==attacktypecutoff&&musictype!=2){
6352 if(player[i].creature!=wolftype){
6353 player[i].stunned=.6;
6354 player[i].surprised=.6;
6356 if(player[i].creature==wolftype){
6357 player[i].stunned=.47;
6358 player[i].surprised=.47;
6364 if(player[i].aitype==searchtype){
6365 player[i].aiupdatedelay-=multiplier;
6366 player[i].losupdatedelay-=multiplier;
6367 if(!player[i].pause)player[i].lastseentime-=multiplier;
6368 player[i].lastchecktime-=multiplier;
6370 if(player[i].isRun()&&!player[i].onground){
6371 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
6372 test2=player[i].coords+player[i].facing;
6374 test=player[i].coords+player[i].facing;
6376 j=checkcollide(test2,test,player[i].laststanding);
6377 if(j==-1)j=checkcollide(test2,test);
6379 player[i].velocity=0;
6380 player[i].targetanimation=player[i].getStop();
6381 player[i].targetframe=0;
6383 player[i].targetrotation+=180;
6384 player[i].stunned=.5;
6385 //player[i].aitype=passivetype;
6386 player[i].aitype=pathfindtype;
6387 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
6388 player[i].finalpathfindpoint=-1;
6389 player[i].targetpathfindpoint=-1;
6390 player[i].lastpathfindpoint=-1;
6391 player[i].lastpathfindpoint2=-1;
6392 player[i].lastpathfindpoint3=-1;
6393 player[i].lastpathfindpoint4=-1;
6395 else player[i].laststanding=j;
6398 if(player[i].aiupdatedelay<0){
6399 rotatetarget=player[i].lastseen-player[i].coords;
6400 Normalise(&rotatetarget);
6401 player[i].targetrotation=-asin(0-rotatetarget.x);
6402 player[i].targetrotation*=360/6.28;
6403 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
6404 player[i].lookrotation=player[i].targetrotation;
6405 player[i].aiupdatedelay=.05;
6406 player[i].forwardkeydown=1;
6408 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
6409 player[i].forwardkeydown=0;
6410 player[i].aiupdatedelay=1;
6411 player[i].lastseen.x+=(float(Random()%100)-50)/25;
6412 player[i].lastseen.z+=(float(Random()%100)-50)/25;
6413 player[i].lastchecktime=3;
6416 player[i].leftkeydown=0;
6417 player[i].backkeydown=0;
6418 player[i].rightkeydown=0;
6419 player[i].crouchkeydown=0;
6420 player[i].attackkeydown=0;
6421 player[i].throwkeydown=0;
6423 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
6424 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
6426 XYZ leftpos,rightpos;
6427 float leftdist,rightdist;
6428 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
6429 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
6430 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
6431 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
6432 if(leftdist<rightdist)player[i].targetrotation+=90;
6433 else player[i].targetrotation-=90;
6437 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
6438 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
6440 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
6441 for(j=0;j<numenvsounds;j++){
6442 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
6443 player[i].aitype=attacktypecutoff;
6447 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
6448 player[i].losupdatedelay=.2;
6449 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
6450 {player[i].aitype=attacktypecutoff;
6451 player[i].lastseentime=1;}
6452 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
6453 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
6454 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
6455 if((-1==checkcollide(DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords,DoRotation(player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position,0,player[0].rotation,0)*player[0].scale+player[0].coords))||(player[j].targetanimation==hanganim&&normaldotproduct(player[j].facing,player[i].coords-player[j].coords)<0)){
6456 player[i].aitype=attacktypecutoff;
6457 player[i].lastseentime=1;
6460 if(player[i].lastseentime<0){
6461 //player[i].aitype=passivetype;
6463 player[i].aitype=pathfindtype;
6464 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
6465 player[i].finalpathfindpoint=-1;
6466 player[i].targetpathfindpoint=-1;
6467 player[i].lastpathfindpoint=-1;
6468 player[i].lastpathfindpoint2=-1;
6469 player[i].lastpathfindpoint3=-1;
6470 player[i].lastpathfindpoint4=-1;
6474 if(player[i].aitype!=gethelptype){
6475 player[i].runninghowlong=0;
6478 if(player[i].aitype==gethelptype){
6479 player[i].runninghowlong+=multiplier;
6480 player[i].aiupdatedelay-=multiplier;
6482 if(player[i].aiupdatedelay<0||player[i].ally==0){
6483 player[i].aiupdatedelay=.2;
6491 if(!player[i].ally){
6492 for(j=0;j<numplayers;j++){
6493 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
6494 distance=findDistancefast(&player[i].coords,&player[j].coords);
6495 if(closestdist==-1||distance<closestdist){
6496 closestdist=distance;
6502 if(closest!=-1)player[i].ally=closest;
6503 else player[i].ally=0;
6504 player[i].lastseen=player[0].coords;
6505 player[i].lastseentime=12;
6509 player[i].lastchecktime=12;
6510 //player[i].lastseentime-=.5;
6512 facing=player[i].coords;
6513 flatfacing=player[player[i].ally].coords;
6514 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
6515 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
6516 if(-1!=checkcollide(facing,flatfacing))
6517 player[i].lastseentime-=.1;
6519 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
6520 player[i].aitype=searchtype;
6521 player[i].lastseentime=12;
6524 if(player[i].ally>0){
6525 rotatetarget=player[player[i].ally].coords-player[i].coords;
6526 Normalise(&rotatetarget);
6527 player[i].targetrotation=-asin(0-rotatetarget.x);
6528 player[i].targetrotation*=360/6.28;
6529 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
6530 player[i].lookrotation=player[i].targetrotation;
6531 player[i].aiupdatedelay=.05;
6532 player[i].forwardkeydown=1;
6534 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
6535 player[i].aitype=searchtype;
6536 player[i].lastseentime=12;
6537 player[player[i].ally].aitype=searchtype;
6538 if(player[player[i].ally].lastseentime<player[i].lastseentime){
6539 player[player[i].ally].lastseen=player[i].lastseen;
6540 player[player[i].ally].lastseentime=player[i].lastseentime;
6541 player[player[i].ally].lastchecktime=player[i].lastchecktime;
6545 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
6546 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
6548 XYZ leftpos,rightpos;
6549 float leftdist,rightdist;
6550 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
6551 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
6552 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
6553 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
6554 if(leftdist<rightdist)player[i].targetrotation+=90;
6555 else player[i].targetrotation-=90;
6560 player[i].leftkeydown=0;
6561 player[i].backkeydown=0;
6562 player[i].rightkeydown=0;
6563 player[i].crouchkeydown=0;
6564 player[i].attackkeydown=0;
6566 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
6567 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
6570 if(player[i].aitype==getweapontype){
6571 player[i].aiupdatedelay-=multiplier;
6572 player[i].lastchecktime-=multiplier;
6574 if(player[i].aiupdatedelay<0){
6575 player[i].aiupdatedelay=.2;
6583 if(player[i].ally<0){
6584 for(j=0;j<weapons.numweapons;j++){
6585 if(weapons.owner[j]==-1){
6586 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
6587 if(closestdist==-1||distance<closestdist){
6588 closestdist=distance;
6594 if(closest!=-1)player[i].ally=closest;
6595 else player[i].ally=-1;
6598 player[i].lastseentime=12;
6600 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
6601 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
6602 player[i].aitype=attacktypecutoff;
6603 player[i].lastseentime=1;
6606 if(player[i].ally>=0){
6607 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
6608 player[i].aitype=attacktypecutoff;
6609 player[i].lastseentime=1;
6611 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
6612 Normalise(&rotatetarget);
6613 player[i].targetrotation=-asin(0-rotatetarget.x);
6614 player[i].targetrotation*=360/6.28;
6615 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
6616 player[i].lookrotation=player[i].targetrotation;
6617 player[i].aiupdatedelay=.05;
6618 player[i].forwardkeydown=1;
6621 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
6622 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
6624 XYZ leftpos,rightpos;
6625 float leftdist,rightdist;
6626 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
6627 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
6628 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
6629 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
6630 if(leftdist<rightdist)player[i].targetrotation+=90;
6631 else player[i].targetrotation-=90;
6636 player[i].leftkeydown=0;
6637 player[i].backkeydown=0;
6638 player[i].rightkeydown=0;
6639 player[i].attackkeydown=0;
6640 player[i].throwkeydown=1;
6641 player[i].crouchkeydown=0;
6642 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
6643 player[i].drawkeydown=0;
6645 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
6646 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
6649 if(player[i].aitype==attacktypecutoff){
6650 player[i].aiupdatedelay-=multiplier;
6651 if(player[i].damage<player[i].damagetolerance*2/3)
6652 if((player[0].targetanimation==rabbitkickanim||player[0].targetanimation==knifethrowanim||(player[0].isFlip()&&normaldotproduct(player[0].facing,player[0].coords-player[i].coords)<0))&&!player[0].skeleton.free&&(player[i].aiupdatedelay<.1)){
6653 player[i].attackkeydown=0;
6654 if(player[i].isIdle())player[i].crouchkeydown=1;
6655 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
6656 if(weapons.type[player[0].weaponids[0]]==knife){
6657 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
6658 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
6659 else player[i].targetanimation=rollanim;
6661 player[i].targetframe=0;
6662 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
6663 player[i].wentforweapon=0;
6665 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
6666 player[i].targetanimation=flipanim;
6668 player[i].targetframe=0;
6672 player[i].forwardkeydown=0;
6673 player[i].aiupdatedelay=.02;
6675 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
6676 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
6677 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
6679 if(player[i].wentforweapon<3)
6680 for(j=0;j<weapons.numweapons;j++){
6681 if(player[i].creature!=wolftype)
6682 if(player[i].num_weapons==0&&weapons.owner[j]==-1&&weapons.velocity[i].x==0&&weapons.velocity[i].z==0&&weapons.velocity[i].y==0){
6683 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
6684 player[i].wentforweapon++;
6685 player[i].lastchecktime=6;
6686 player[i].aitype=getweapontype;
6691 if(player[i].damage<player[i].damagetolerance/2)
6692 if(animation[player[i].targetanimation].height!=highheight)
6693 if(player[i].damage<player[i].damagetolerance*.5&&((player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)&&((player[i].aiupdatedelay<.15&&difficulty==2)||(player[i].aiupdatedelay<.08&&difficulty!=2)))){
6694 player[i].crouchkeydown=1;
6696 if(player[i].isRun()&&!player[i].onground){
6697 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
6698 test2=player[i].coords+player[i].facing;
6700 test=player[i].coords+player[i].facing;
6702 j=checkcollide(test2,test,player[i].laststanding);
6703 if(j==-1)j=checkcollide(test2,test);
6705 player[i].velocity=0;
6706 player[i].targetanimation=player[i].getStop();
6707 player[i].targetframe=0;
6709 player[i].targetrotation+=180;
6710 player[i].stunned=.5;
6711 //player[i].aitype=passivetype;
6712 player[i].aitype=pathfindtype;
6713 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
6714 player[i].finalpathfindpoint=-1;
6715 player[i].targetpathfindpoint=-1;
6716 player[i].lastpathfindpoint=-1;
6717 player[i].lastpathfindpoint2=-1;
6718 player[i].lastpathfindpoint3=-1;
6719 player[i].lastpathfindpoint4=-1;
6721 else player[i].laststanding=j;
6724 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
6725 player[i].aitype=pathfindtype;
6726 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
6727 player[i].finalpathfindpoint=-1;
6728 player[i].targetpathfindpoint=-1;
6729 player[i].lastpathfindpoint=-1;
6730 player[i].lastpathfindpoint2=-1;
6731 player[i].lastpathfindpoint3=-1;
6732 player[i].lastpathfindpoint4=-1;
6734 if(player[i].aiupdatedelay<0&&!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
6735 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
6736 else player[i].drawkeydown=0;
6737 player[i].rabbitkickenabled=Random()%2;
6738 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
6739 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
6740 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity*findDistance(&player[player[i].aitarget].coords,&player[i].coords)/findLength(&player[i].velocity)-player[i].coords;
6741 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
6742 Normalise(&rotatetarget);
6743 player[i].targetrotation=-asin(0-rotatetarget.x);
6744 player[i].targetrotation*=360/6.28;
6745 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
6746 player[i].lookrotation=player[i].targetrotation;
6747 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
6749 oldkey=player[i].forwardkeydown;
6750 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
6751 else if((findDistancefast(&player[i].coords,&player[0].coords)>16||findDistancefast(&player[i].coords,&player[0].coords)<9)&&player[0].weaponactive!=-1)player[i].forwardkeydown=1;
6752 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
6753 else player[i].forwardkeydown=0;
6755 player[i].forwardkeydown=0;
6756 if(Random()%10==0)player[i].forwardkeydown=1;
6757 if(Random()%100==0){
6758 player[i].aitype=pathfindtype;
6759 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
6760 player[i].finalpathfindpoint=-1;
6761 player[i].targetpathfindpoint=-1;
6762 player[i].lastpathfindpoint=-1;
6763 player[i].lastpathfindpoint2=-1;
6764 player[i].lastpathfindpoint3=-1;
6765 player[i].lastpathfindpoint4=-1;
6768 player[i].leftkeydown=0;
6769 player[i].backkeydown=0;
6770 player[i].rightkeydown=0;
6771 player[i].crouchkeydown=0;
6772 player[i].throwkeydown=0;
6774 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
6775 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
6776 else player[i].attackkeydown=0;
6777 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
6779 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
6781 for(j=0;j<numplayers;j++){
6782 if(j!=i&&!player[j].skeleton.free&&player[j].hasvictim&&((tutoriallevel==1&&reversaltrain)||(Random()%2==0&&difficulty==2)||(Random()%4==0&&difficulty==1)||(Random()%8==0&&difficulty==0)||(player[j].lastattack2==player[j].targetanimation&&player[j].lastattack3==player[j].targetanimation&&(Random()%2==0||difficulty==2))||((player[i].isIdle()||player[i].isRun())&&player[j].weaponactive!=-1)||(player[j].targetanimation==swordslashanim&&player[i].weaponactive!=-1)||player[j].targetanimation==staffhitanim||player[j].targetanimation==staffspinhitanim)){
6783 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<4&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim||player[j].targetanimation==spinkickanim||player[j].targetanimation==staffhitanim||player[j].targetanimation==staffspinhitanim||player[j].targetanimation==winduppunchanim||player[j].targetanimation==upunchanim||player[j].targetanimation==wolfslapanim||player[j].targetanimation==knifeslashstartanim||((player[j].targetanimation==swordslashanim)&&(findDistancefast(&player[j].coords,&player[i].coords)<2||(player[i].weaponactive!=-1))))){
6784 if(target>=0)target=-1;
6789 if(target>=0)player[target].Reverse();
6792 if(player[i].collided<1)player[i].jumpkeydown=0;
6793 if((player[i].collided>.8&&player[i].jumppower>=5)||(findDistancefast(&player[i].coords,&player[0].coords)>400&&player[i].onterrain&&player[i].creature==rabbittype))player[i].jumpkeydown=1;
6794 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
6795 player[0].jumpkeydown=0;
6796 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
6797 if(player[i].jumpkeydown)player[i].attackkeydown=0;
6798 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
6800 if(tutoriallevel==1){
6801 if(!canattack)player[i].attackkeydown=0;
6805 facing=player[i].coords;
6806 flatfacing=player[0].coords;
6807 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
6808 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
6809 if(player[i].occluded>=2)
6810 if(-1!=checkcollide(facing,flatfacing)){
6811 if(!player[i].pause)player[i].lastseentime-=.2;
6812 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
6813 player[i].aitype=searchtype;
6814 player[i].lastchecktime=12;
6815 player[i].lastseen=player[0].coords;
6816 player[i].lastseentime=12;
6819 else player[i].lastseentime=1;
6822 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
6823 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
6824 test=player[0].coords;
6826 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
6829 // NOTE: Ask about logic of this call : NOTE
6830 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
6831 player[i].stunned>0 ||
6832 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
6834 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
6835 player[i].targetrotation=player[i].rotation;
6836 player[i].forwardkeydown=0;
6837 player[i].leftkeydown=0;
6838 player[i].backkeydown=0;
6839 player[i].rightkeydown=0;
6840 player[i].jumpkeydown=0;
6841 player[i].attackkeydown=0;
6842 player[i].crouchkeydown=0;
6843 player[i].throwkeydown=0;
6850 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
6853 if(player[i].aitype==attacktypecutoff){
6854 rotatetarget=player[0].coords-player[i].coords;
6855 Normalise(&rotatetarget);
6856 player[i].targetheadrotation=-asin(0-rotatetarget.x);
6857 player[i].targetheadrotation*=360/6.28;
6858 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
6860 player[i].targetheadrotation*=-1;
6861 player[i].targetheadrotation+=180;
6862 //player[i].targetheadrotation2=0;
6863 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
6865 else if(player[i].howactive>=typesleeping){
6866 player[i].targetheadrotation=player[i].targetrotation;
6867 player[i].targetheadrotation2=0;
6870 if(player[i].interestdelay<=0){
6871 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
6872 player[i].headtarget=player[i].coords;
6873 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
6874 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
6875 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
6876 player[i].headtarget+=player[i].facing*1.5;
6878 rotatetarget=player[i].headtarget-player[i].coords;
6879 Normalise(&rotatetarget);
6880 player[i].targetheadrotation=-asin(0-rotatetarget.x);
6881 player[i].targetheadrotation*=360/6.28;
6882 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
6884 player[i].targetheadrotation*=-1;
6885 player[i].targetheadrotation+=180;
6886 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
6888 //if(whichlevel==2)player[i].jumpkeydown=0;
6890 if(animation[player[i].targetanimation].attack==reversed){
6891 //player[i].targetrotation=player[i].rotation;
6892 player[i].forwardkeydown=0;
6893 player[i].leftkeydown=0;
6894 player[i].backkeydown=0;
6895 player[i].rightkeydown=0;
6896 player[i].jumpkeydown=0;
6897 player[i].attackkeydown=0;
6898 //player[i].crouchkeydown=0;
6899 player[i].throwkeydown=0;
6903 player[i].forwardkeydown=0;
6904 player[i].leftkeydown=0;
6905 player[i].backkeydown=0;
6906 player[i].rightkeydown=0;
6907 player[i].jumpkeydown=0;
6908 player[i].crouchkeydown=0;
6909 player[i].drawkeydown=0;
6910 player[i].throwkeydown=0;
6913 if(player[i].collided<-.3)player[i].collided=-.3;
6914 if(player[i].collided>1)player[i].collided=1;
6915 player[i].collided-=multiplier*4;
6916 player[i].whichdirectiondelay-=multiplier;
6917 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
6918 player[i].avoidcollided=-.3;
6919 player[i].whichdirection=abs(Random()%2);
6920 player[i].whichdirectiondelay=.4;
6922 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
6923 player[i].avoidcollided-=multiplier/4;
6924 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
6925 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
6926 if(player[i].surprised<=0&&player[i].aitype==attacktypecutoff&&i!=0&&!player[i].dead&&!player[i].skeleton.free&&animation[player[i].targetanimation].attack==neutral)numresponded=1;
6928 if(!player[i].throwkeydown){
6929 player[i].throwtogglekeydown=0;
6931 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
6932 if(player[i].weaponactive==-1&&player[i].num_weapons<2&&(player[i].isIdle()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim||player[i].isFlip()||player[i].isFlip()||player[i].aitype!=playercontrolled)){
6933 for(j=0;j<weapons.numweapons;j++){
6934 if(((weapons.velocity[j].x==0&&weapons.velocity[j].y==0&&weapons.velocity[j].z==0)||player[i].aitype==playercontrolled)&&weapons.owner[j]==-1&&player[i].weaponactive==-1)
6935 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
6936 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
6937 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
6938 player[i].throwtogglekeydown=1;
6939 player[i].targetanimation=crouchremoveknifeanim;
6941 player[i].targetframe=0;
6942 rotatetarget=weapons.position[j]-player[i].coords;
6943 Normalise(&rotatetarget);
6944 player[i].targetrotation=-asin(0-rotatetarget.x);
6945 player[i].targetrotation*=360/6.28;
6946 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
6947 player[i].hasvictim=0;
6949 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
6950 player[i].throwtogglekeydown=1;
6951 player[i].hasvictim=0;
6953 //for(i=0;i<weapons.numweapons;i++){
6954 if((((weapons.velocity[j].x==0&&weapons.velocity[j].y==0&&weapons.velocity[j].z==0)||player[i].aitype==playercontrolled)&&weapons.owner[j]==-1)||(player[i].victim&&weapons.owner[j]==player[i].victim->id))
6955 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
6956 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
6959 gLoc[0]=player[i].coords.x;
6960 gLoc[1]=player[i].coords.y;
6961 gLoc[2]=player[i].coords.z;
6962 vel[0]=player[i].velocity.x;
6963 vel[1]=player[i].velocity.y;
6964 vel[2]=player[i].velocity.z;
6965 if(weapons.type[j]!=staff){
6966 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
6967 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
6968 OPENAL_SetVolume(channels[knifedrawsound], 128);
6969 OPENAL_SetPaused(channels[knifedrawsound], false);
6972 player[i].weaponactive=0;
6973 weapons.owner[j]=player[i].id;
6974 if(player[i].num_weapons>0){
6975 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
6977 player[i].num_weapons++;
6978 player[i].weaponids[0]=j;
6984 else if ((player[i].isIdle()||player[i].isFlip()||player[i].aitype!=playercontrolled)&&findDistancefast(&player[i].coords,&weapons.position[j])<5&&player[i].coords.y<weapons.position[j].y){
6985 if(!player[i].isFlip()){
6986 player[i].throwtogglekeydown=1;
6987 player[i].targetanimation=removeknifeanim;
6989 player[i].targetframe=0;
6990 rotatetarget=weapons.position[j]-player[i].coords;
6991 Normalise(&rotatetarget);
6992 player[i].targetrotation=-asin(0-rotatetarget.x);
6993 player[i].targetrotation*=360/6.28;
6994 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
6996 if(player[i].isFlip()){
6997 player[i].throwtogglekeydown=1;
6998 player[i].hasvictim=0;
7000 for(k=0;k<weapons.numweapons;k++){
7001 if(player[i].weaponactive==-1)
7002 if((((weapons.velocity[k].x==0&&weapons.velocity[k].y==0&&weapons.velocity[k].z==0)||player[i].aitype==playercontrolled)&&weapons.owner[k]==-1)||(player[i].victim&&weapons.owner[k]==player[i].victim->id))
7003 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
7006 gLoc[0]=player[i].coords.x;
7007 gLoc[1]=player[i].coords.y;
7008 gLoc[2]=player[i].coords.z;
7009 vel[0]=player[i].velocity.x;
7010 vel[1]=player[i].velocity.y;
7011 vel[2]=player[i].velocity.z;
7012 if(weapons.type[k]!=staff){
7013 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
7014 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
7015 OPENAL_SetVolume(channels[knifedrawsound], 128);
7016 OPENAL_SetPaused(channels[knifedrawsound], false);
7019 player[i].weaponactive=0;
7020 weapons.owner[k]=player[i].id;
7021 if(player[i].num_weapons>0){
7022 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
7024 player[i].num_weapons++;
7025 player[i].weaponids[0]=k;
7032 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
7034 for(j=0;j<numplayers;j++){
7035 if(player[i].weaponactive==-1)
7037 if(player[j].num_weapons&&player[j].skeleton.free&&findDistancefast(&player[i].coords,&player[j].coords)<2/*&&player[j].dead*/&&(((player[j].skeleton.forward.y<0&&player[j].weaponstuckwhere==0)||(player[j].skeleton.forward.y>0&&player[j].weaponstuckwhere==1))||player[j].weaponstuck==-1||player[j].num_weapons>1)){
7038 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
7039 player[i].throwtogglekeydown=1;
7040 player[i].victim=&player[j];
7041 player[i].hasvictim=1;
7042 player[i].targetanimation=crouchremoveknifeanim;
7044 player[i].targetframe=0;
7045 rotatetarget=player[j].coords-player[i].coords;
7046 Normalise(&rotatetarget);
7047 player[i].targetrotation=-asin(0-rotatetarget.x);
7048 player[i].targetrotation*=360/6.28;
7049 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
7051 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
7052 player[i].throwtogglekeydown=1;
7053 player[i].victim=&player[j];
7054 player[i].hasvictim=1;
7055 int k = player[j].weaponids[0];
7056 if(player[i].hasvictim){
7059 gLoc[0]=player[i].coords.x;
7060 gLoc[1]=player[i].coords.y;
7061 gLoc[2]=player[i].coords.z;
7062 vel[0]=player[i].velocity.x;
7063 vel[1]=player[i].velocity.y;
7064 vel[2]=player[i].velocity.z;
7067 if(player[i].victim->weaponstuck!=-1){
7068 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
7073 if(weapons.type[k]!=staff){
7074 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
7075 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
7076 OPENAL_SetVolume(channels[knifedrawsound], 128);
7077 OPENAL_SetPaused(channels[knifedrawsound], false);
7081 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
7082 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
7083 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
7084 OPENAL_SetPaused(channels[fleshstabremovesound], false);
7087 player[i].weaponactive=0;
7088 if(weapons.owner[k]!=-1){
7089 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
7090 else player[i].victim->num_weapons=1;
7092 player[i].victim->skeleton.longdead=0;
7093 player[i].victim->skeleton.free=1;
7094 player[i].victim->skeleton.broken=0;
7096 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
7097 player[i].victim->skeleton.joints[l].velchange=0;
7098 player[i].victim->skeleton.joints[l].locked=0;
7104 Normalise(&relative);
7105 XYZ footvel,footpoint;
7107 footpoint=weapons.position[k];
7108 if(player[i].victim->weaponstuck!=-1){
7109 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
7110 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
7111 weapons.bloody[k]=2;
7112 weapons.blooddrip[k]=5;
7113 player[i].victim->weaponstuck=-1;
7114 player[i].victim->bloodloss+=2000;
7115 player[i].victim->DoDamage(2000);
7118 if(player[i].victim->num_weapons>0){
7119 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
7120 if(player[i].victim->weaponids[0]==k)
7121 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
7124 player[i].victim->weaponactive=-1;
7126 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
7127 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
7128 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
7129 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
7132 if(player[i].num_weapons>0){
7133 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
7135 player[i].num_weapons++;
7136 player[i].weaponids[0]=k;
7143 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
7144 if(weapons.type[player[i].weaponids[0]]==knife){
7145 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
7147 for(j=0;j<numplayers;j++){
7149 if(tutoriallevel!=1||tutorialstage==49)
7151 if(normaldotproduct(player[i].facing,player[i].coords-player[j].coords)<0&&findDistancefast(&player[i].coords,&player[j].coords)<100&&findDistancefast(&player[i].coords,&player[j].coords)>1.5&&!player[j].skeleton.free&&-1==checkcollide(DoRotation(player[j].skeleton.joints[player[j].skeleton.jointlabels[head]].position,0,player[j].rotation,0)*player[j].scale+player[j].coords,DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords)){
7152 if(!player[i].isFlip()){
7153 player[i].throwtogglekeydown=1;
7154 player[i].victim=&player[j];
7155 player[i].targetanimation=knifethrowanim;
7157 player[i].targetframe=0;
7158 rotatetarget=player[j].coords-player[i].coords;
7159 Normalise(&rotatetarget);
7160 player[i].targetrotation=-asin(0-rotatetarget.x);
7161 player[i].targetrotation*=360/6.28;
7162 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
7164 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
7166 if(player[i].isFlip()){
7167 if(player[i].weaponactive!=-1){
7168 player[i].throwtogglekeydown=1;
7169 player[i].victim=&player[j];
7171 weapons.owner[player[i].weaponids[0]]=-1;
7172 aim=player[i].victim->coords+DoRotation(player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].position,0,player[i].victim->rotation,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[righthand]].position,0,player[i].rotation,0)*player[i].scale);
7175 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
7177 weapons.velocity[player[i].weaponids[0]]=aim*50;
7178 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
7179 weapons.missed[player[i].weaponids[0]]=0;
7180 weapons.freetime[player[i].weaponids[0]]=0;
7181 weapons.firstfree[player[i].weaponids[0]]=1;
7182 weapons.physics[player[i].weaponids[0]]=0;
7183 player[i].num_weapons--;
7184 if(player[i].num_weapons){
7185 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
7187 player[i].weaponactive=-1;
7194 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
7195 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
7197 player[i].throwtogglekeydown=1;
7198 weapons.owner[player[i].weaponids[0]]=-1;
7199 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
7200 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
7201 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
7202 weapons.missed[player[i].weaponids[0]]=1;
7203 weapons.freetime[player[i].weaponids[0]]=0;
7204 weapons.firstfree[player[i].weaponids[0]]=1;
7205 weapons.physics[player[i].weaponids[0]]=1;
7206 player[i].num_weapons--;
7207 if(player[i].num_weapons){
7208 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
7209 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
7212 player[i].weaponactive=-1;
7213 for(j=0;j<numplayers;j++){
7214 player[j].wentforweapon=0;
7221 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
7222 if((player[i].drawkeydown&&!player[i].drawtogglekeydown)||(player[i].num_weapons==2&&player[i].weaponactive==-1&&player[i].isIdle())||(player[0].dead&&player[i].weaponactive!=-1&&i!=0)){
7223 //Setenvironment(1-environment);
7226 if(player[i].weaponactive!=-1){
7227 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
7229 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
7230 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
7231 player[i].targetanimation=drawrightanim;
7232 player[i].targetframe=0;
7234 player[i].drawtogglekeydown=1;
7236 if((player[i].isIdle()||(player[i].aitype!=playercontrolled&&player[0].weaponactive!=-1&&player[i].isRun()))&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==sword){
7237 player[i].targetanimation=drawleftanim;
7238 player[i].targetframe=0;
7240 player[i].drawtogglekeydown=1;
7242 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
7243 player[i].targetanimation=crouchdrawrightanim;
7244 player[i].targetframe=0;
7246 player[i].drawtogglekeydown=1;
7250 if(player[i].isCrouch()&&weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&bloodtoggle&&player[i].onterrain&&player[i].num_weapons&&player[i].weaponactive!=-1&&player[i].attackkeydown){
7251 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
7252 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
7253 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
7254 player[i].targetframe=0;
7256 player[i].hasvictim=0;
7257 //player[i].attacktogglekeydown=1;
7261 if(!player[i].drawkeydown){
7262 player[i].drawtogglekeydown=0;
7269 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
7271 else absflatfacing=flatfacing;
7274 player[i].forwardkeydown=0;
7275 player[i].leftkeydown=0;
7276 player[i].backkeydown=0;
7277 player[i].rightkeydown=0;
7278 player[i].jumpkeydown=0;
7279 player[i].crouchkeydown=0;
7280 player[i].drawkeydown=0;
7281 player[i].throwkeydown=0;
7285 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
7286 if(!player[i].forwardkeydown){
7287 player[i].forwardstogglekeydown=0;
7289 if(player[i].crouchkeydown){
7293 player[i].superruntoggle=1;
7295 for(j=0;j<numplayers;j++){
7296 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
7297 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
7298 player[i].superruntoggle=0;
7305 for(j=0;j<numplayers;j++){
7306 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
7307 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim||player[j].targetanimation==upunchanim||player[j].targetanimation==wolfslapanim||((player[j].targetanimation==swordslashanim||player[j].targetanimation==knifeslashstartanim||player[j].targetanimation==staffhitanim||player[j].targetanimation==staffspinhitanim)&&findDistancefast(&player[j].coords,&player[i].coords)<2))){
7308 if(target>=0)target=-1;
7313 if(target>=0)player[target].Reverse();
7314 player[i].lowreversaldelay=.5;
7316 if(player[i].isIdle()){
7317 player[i].targetanimation=player[i].getCrouch();
7319 player[i].targetframe=0;
7320 player[i].transspeed=10;
7322 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
7323 player[i].targetanimation=rollanim;
7325 player[i].targetframe=0;
7326 player[i].transspeed=20;
7329 if(!player[i].crouchkeydown){
7331 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
7333 if(player[i].isCrouch()){
7335 for(j=0;j<numplayers;j++){
7336 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
7337 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
7338 if(target>=0)target=-1;
7343 if(target>=0)player[target].Reverse();
7344 player[i].highreversaldelay=.5;
7346 if(player[i].isCrouch()){
7347 if(!player[i].wasCrouch()){
7348 player[i].currentanimation=player[i].getCrouch();
7349 player[i].currentframe=0;
7352 player[i].targetanimation=player[i].getIdle();
7353 player[i].targetframe=0;
7354 player[i].transspeed=10;
7357 if(player[i].targetanimation==sneakanim){
7358 player[i].targetanimation=player[i].getIdle();
7360 player[i].targetframe=0;
7361 player[i].transspeed=10;
7364 if(player[i].forwardkeydown){
7365 if(player[i].isIdle()||(player[i].isStop()&&player[i].targetrotation==player[i].rotation)||(player[i].isLanding()&&player[i].targetframe>0&&!player[i].jumpkeydown)||(player[i].isLandhard()&&player[i].targetframe>0&&!player[i].jumpkeydown&&player[i].crouchkeydown)){
7366 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
7367 else player[i].targetanimation=player[i].getRun();
7369 player[i].targetframe=0;
7371 if(player[i].isCrouch()){
7372 player[i].targetanimation=sneakanim;
7373 if(player[i].wasCrouch())player[i].target=0;
7374 player[i].targetframe=0;
7376 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
7377 player[i].targetanimation=climbanim;
7379 player[i].targetframe=1;
7380 player[i].jumpclimb=1;
7382 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
7383 player[i].velocity+=absflatfacing*5*multiplier;
7385 player[i].forwardstogglekeydown=1;
7388 if (player[i].rightkeydown){
7389 if(player[i].isIdle()||(player[i].isStop()&&player[i].targetrotation==player[i].rotation)||(player[i].isLanding()&&player[i].targetframe>0&&!player[i].jumpkeydown)||(player[i].isLandhard()&&player[i].targetframe>0&&!player[i].jumpkeydown&&player[i].crouchkeydown)){
7390 player[i].targetanimation=player[i].getRun();
7392 player[i].targetframe=0;
7394 if(player[i].isCrouch()){
7395 player[i].targetanimation=sneakanim;
7396 if(player[i].wasCrouch()) player[i].target=0;
7397 player[i].targetframe=0;
7399 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
7400 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
7402 player[i].targetrotation-=90;
7403 if(player[i].forwardkeydown)player[i].targetrotation+=45;
7404 if(player[i].backkeydown)player[i].targetrotation-=45;
7407 if ( player[i].leftkeydown){
7408 if(player[i].isIdle()||(player[i].isStop()&&player[i].targetrotation==player[i].rotation)||(player[i].isLanding()&&player[i].targetframe>0&&!player[i].jumpkeydown)||(player[i].isLandhard()&&player[i].targetframe>0&&!player[i].jumpkeydown&&player[i].crouchkeydown)){
7409 player[i].targetanimation=player[i].getRun();
7411 player[i].targetframe=0;
7413 if(player[i].isCrouch()){
7414 player[i].targetanimation=sneakanim;
7415 if(player[i].wasCrouch())player[i].target=0;
7416 player[i].targetframe=0;
7418 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
7419 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
7421 player[i].targetrotation+=90;
7422 if(player[i].forwardkeydown)player[i].targetrotation-=45;
7423 if(player[i].backkeydown)player[i].targetrotation+=45;
7426 if(player[i].backkeydown){
7427 if(player[i].isIdle()||(player[i].isStop()&&player[i].targetrotation==player[i].rotation)||(player[i].isLanding()&&player[i].targetframe>0&&!player[i].jumpkeydown)||(player[i].isLandhard()&&player[i].targetframe>0&&!player[i].jumpkeydown&&player[i].crouchkeydown)){
7428 player[i].targetanimation=player[i].getRun();
7430 player[i].targetframe=0;
7432 if(player[i].isCrouch()){
7433 player[i].targetanimation=sneakanim;
7434 if(player[i].wasCrouch())player[i].target=0;
7435 player[i].targetframe=0;
7437 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
7438 player[i].velocity-=absflatfacing*5*multiplier;
7440 if(player[i].targetanimation==hanganim){
7441 player[i].currentanimation=jumpdownanim;
7442 player[i].targetanimation=jumpdownanim;
7444 player[i].currentframe=0;
7445 player[i].targetframe=1;
7446 player[i].velocity=0;
7447 player[i].velocity.y+=gravity;
7448 player[i].coords.y-=1.4;
7449 player[i].grabdelay=1;
7451 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
7452 player[i].targetrotation+=180;
7455 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
7456 if((((player[i].isLanding()&&player[i].targetframe>=3)||player[i].isRun()||player[i].targetanimation==walkanim||player[i].isCrouch()||player[i].targetanimation==sneakanim)&&player[i].jumppower>1)&&((player[i].targetanimation!=rabbitrunninganim&&player[i].targetanimation!=wolfrunninganim)||i!=0)){
7457 player[i].jumpstart=0;
7458 player[i].targetanimation=jumpupanim;
7460 player[i].targetframe=0;
7461 player[i].rotation=player[i].targetrotation;
7462 player[i].transspeed=20;
7463 player[i].FootLand(0,1);
7464 player[i].FootLand(1,1);
7468 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
7470 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
7471 if(!movekey)player[i].velocity=0;
7476 for(j=0;j<numplayers;j++){
7477 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
7478 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
7479 if(target>=0)target=-1;
7484 if(target>=0)player[i].velocity.y=1;
7485 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
7486 player[i].velocity.y=7;
7487 player[i].crouchtogglekeydown=1;
7489 else player[i].velocity.y=5;
7491 if(mousejump&&i==0&&debugmode){
7492 if(!player[i].isLanding())player[i].tempdeltav=deltav;
7493 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
7496 player[i].coords.y+=.2;
7497 player[i].jumppower-=1;
7499 static float gLoc[3];
7500 static float vel[3];
7501 gLoc[0]=player[i].coords.x;
7502 gLoc[1]=player[i].coords.y;
7503 gLoc[2]=player[i].coords.z;
7504 vel[0]=player[i].velocity.x;
7505 vel[1]=player[i].velocity.y;
7506 vel[2]=player[i].velocity.z;
7509 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
7510 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
7511 OPENAL_SetVolume(channels[whooshsound], 128);
7512 OPENAL_SetPaused(channels[whooshsound], false);
7515 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
7516 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
7517 OPENAL_SetVolume(channels[jumpsound], 128);
7518 OPENAL_SetPaused(channels[jumpsound], false);
7520 if((player[i].isIdle())&&player[i].jumppower>1){
7521 player[i].targetanimation=player[i].getLanding();
7522 player[i].landhard=0;
7524 player[i].targetframe=2;
7525 player[i].jumpstart=1;
7526 player[i].tempdeltav=deltav;
7528 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
7529 if(player[i].jumppower>multiplier*6){
7530 player[i].velocity.y+=multiplier*6;
7531 player[i].jumppower-=multiplier*6;
7533 if(player[i].jumppower<=multiplier*6){
7534 player[i].velocity.y+=player[i].jumppower;
7535 player[i].jumppower=0;
7538 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
7542 if(player[i].isRun()||player[i].targetanimation==walkanim){
7543 player[i].targetanimation=player[i].getStop();
7545 player[i].targetframe=0;
7547 if(player[i].targetanimation==sneakanim){
7548 player[i].targetanimation=player[i].getCrouch();
7549 if(player[i].currentanimation==sneakanim)player[i].target=0;
7550 player[i].targetframe=0;
7553 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
7554 player[i].targetanimation=player[i].getStop();
7556 player[i].targetframe=0;
7558 if(player[i].isRun()&&(player[i].aitype==passivetype)){
7559 player[i].targetanimation=player[i].getStop();
7561 player[i].targetframe=0;
7565 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
7569 for(k=0;k<numplayers;k++){
7570 if(abs(player[k].rotation-player[k].targetrotation)>180){
7571 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
7572 else player[k].rotation+=360;
7575 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
7576 player[k].targetanimation=player[k].getStop();
7577 player[k].targetframe=0;
7581 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
7582 player[k].targettilt=0;
7584 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
7585 player[k].targettilt=0;
7586 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
7587 player[k].jumppower+=multiplier*7;
7588 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
7589 //*(1-(player[k].damage/player[k].damagetolerance))
7590 if(player[k].jumppower>5)player[k].jumppower=5;
7593 if(player[k].isRun()){
7594 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
7597 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
7598 else if(player[k].tilt>player[k].targettilt){
7599 player[k].tilt-=multiplier*150;
7601 else if(player[k].tilt<player[k].targettilt){
7602 player[k].tilt+=multiplier*150;
7605 player[k].grabdelay-=multiplier;
7608 for(k=0;k<numplayers;k++){
7609 player[k].DoAnimations();
7610 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
7611 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
7616 for(j=numenvsounds-1;j>=0;j--){
7617 envsoundlife[j]-=multiplier;
7618 if(envsoundlife[j]<0){
7620 envsoundlife[j]=envsoundlife[numenvsounds];
7621 envsound[j]=envsound[numenvsounds];
7624 if(slomo) OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
7625 else OPENAL_SetFrequency(OPENAL_ALL, 22050);
7627 if(tutoriallevel==1){
7644 if(tutorialstage>=51)
7645 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
7646 OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
7647 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
7649 PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
7650 OPENAL_SetPaused(channels[stream_music3], false);
7651 OPENAL_SetVolume(channels[stream_music3], 256);
7660 if(tutorialstage<51)
7661 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
7664 gLoc[0]=player[0].coords.x;
7665 gLoc[1]=player[0].coords.y;
7666 gLoc[2]=player[0].coords.z;
7670 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7671 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7672 OPENAL_SetVolume(channels[fireendsound], 256);
7673 OPENAL_SetPaused(channels[fireendsound], false);
7675 player[0].coords=(oldtemp+oldtemp2)/2;
7679 if(tutorialstage>=14&&tutorialstage<50)
7680 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
7683 gLoc[0]=player[1].coords.x;
7684 gLoc[1]=player[1].coords.y;
7685 gLoc[2]=player[1].coords.z;
7689 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7690 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7691 OPENAL_SetVolume(channels[fireendsound], 256);
7692 OPENAL_SetPaused(channels[fireendsound], false);
7694 for(int i=0;i<player[1].skeleton.num_joints;i++){
7696 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
7697 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
7698 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
7699 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
7700 Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
7704 player[1].coords=(oldtemp+oldtemp2)/2;
7705 for(int i=0;i<player[1].skeleton.num_joints;i++){
7706 player[1].skeleton.joints[i].velocity=0;
7708 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
7709 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
7710 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
7711 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
7712 Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
7720 static float gLoc[3];
7724 static float vel[3];
7725 vel[0]=(viewer.x-oldviewer.x)/multiplier;
7726 vel[1]=(viewer.y-oldviewer.y)/multiplier;
7727 vel[2]=(viewer.z-oldviewer.z)/multiplier;
7729 //Set orientation with forward and up vectors
7730 static XYZ upvector;
7734 upvector=DoRotation(upvector,-rotation2+90,0,0);
7735 upvector=DoRotation(upvector,0,0-rotation,0);
7740 facing=DoRotation(facing,-rotation2,0,0);
7741 facing=DoRotation(facing,0,0-rotation,0);
7744 static float ori[6];
7748 ori[3] = -upvector.x;
7749 ori[4] = upvector.y;
7750 ori[5] = -upvector.z;
7752 OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
7759 if(Input::isKeyDown(SDLK_F1)&&!freezetogglekeydown){
7761 freezetogglekeydown=1;
7765 void Game::TickOnce(){
7767 rotation+=multiplier*5;
7769 if(directing||indialogue==-1) {
7770 rotation+=deltah*.7;
7771 if(!invertmouse)rotation2+=deltav*.7;
7772 if(invertmouse)rotation2-=deltav*.7;
7773 if(rotation2>90)rotation2=90;
7774 if(rotation2<-70)rotation2=-70;
7778 void Game::TickOnceAfter(){
7779 static XYZ colviewer;
7780 static XYZ coltarget;
7783 static float brotate;
7786 static float changedelay;
7787 static bool alldead;
7788 static float unseendelay;
7789 static float cameraspeed;
7793 if(environment==snowyenvironment)music1=stream_music1snow;
7794 if(environment==grassyenvironment)music1=stream_music1grass;
7795 if(environment==desertenvironment)music1=stream_music1desert;
7800 for(i=0;i<numplayers;i++){
7801 if((player[i].aitype==attacktypecutoff||player[i].aitype==getweapontype||player[i].aitype==gethelptype||player[i].aitype==searchtype)&&!player[i].dead/*&&player[i].surprised<=0*/&&(player[i].targetanimation!=sneakattackedanim&&player[i].targetanimation!=knifesneakattackedanim&&player[i].targetanimation!=swordsneakattackedanim)){
7802 musictype=stream_music2;
7806 if(player[0].dead)musictype=stream_music3;
7809 if(musictype==stream_music2){
7813 if(oldmusictype==stream_music2&&musictype!=stream_music2){
7814 unseendelay-=multiplier;
7816 musictype=stream_music2;
7822 musictype=stream_music3;
7830 if(musictype!=oldmusictype&&musictype==stream_music2){
7831 static float gLoc[3];
7832 static float vel[3];
7833 gLoc[0]=cameraloc.x;
7834 gLoc[1]=cameraloc.y;
7835 gLoc[2]=cameraloc.z;
7839 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
7840 OPENAL_SetVolume(channels[alarmsound], 512);
7841 OPENAL_SetPaused(channels[alarmsound], false);
7845 musicselected=musictype;
7847 if(musicselected==music1)musicvolume[0]+=multiplier*450;
7848 else musicvolume[0]-=multiplier*450;
7849 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
7850 else musicvolume[1]-=multiplier*450;
7851 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
7852 else musicvolume[2]-=multiplier*450;
7855 if(musicvolume[i]<0)musicvolume[i]=0;
7856 if(musicvolume[i]>512)musicvolume[i]=512;
7859 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
7862 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
7863 PlayStreamEx( music1, samp[music1], NULL, true);
7864 OPENAL_SetPaused(channels[music1], false);
7866 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
7867 PlayStreamEx( stream_music2, samp[stream_music2], NULL, true);
7868 OPENAL_SetPaused(channels[stream_music2], false);
7870 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
7871 PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
7872 OPENAL_SetPaused(channels[stream_music3], false);
7874 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
7875 OPENAL_SetPaused(channels[music1], true);
7877 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
7878 OPENAL_SetPaused(channels[stream_music2], true);
7880 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
7881 OPENAL_SetPaused(channels[stream_music3], true);
7884 if(musicvolume[0]!=oldmusicvolume[0]){
7885 OPENAL_SetVolume(channels[music1], musicvolume[0]);
7887 if(musicvolume[1]!=oldmusicvolume[1]){
7888 OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
7890 if(musicvolume[2]!=oldmusicvolume[2]){
7891 OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
7895 oldmusicvolume[i]=musicvolume[i];
7898 OPENAL_SetPaused(channels[music1], true);
7899 OPENAL_SetPaused(channels[stream_music2], true);
7900 OPENAL_SetPaused(channels[stream_music3], true);
7903 oldmusicvolume[i]=0;
7909 for(i=0;i<numhotspots;i++){
7910 if(hotspottype[i]>10&&hotspottype[i]<20){
7911 if(player[hotspottype[i]-10].dead==0){
7914 else if(killhotspot==2)
7918 if(killhotspot==2)killhotspot=0;
7922 for(i=0;i<numhotspots;i++){
7923 if(hotspottype[i]==-1){
7924 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
7930 for(i=1;i<numplayers;i++){
7931 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
7933 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
7935 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
7936 if(player[0].dead&&changedelay<=0){
7938 targetlevel=whichlevel;
7941 for(i=1;i<numplayers;i++){
7942 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
7946 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
7948 targetlevel=whichlevel+1;
7949 if(targetlevel>numchallengelevels-1)targetlevel=0;
7951 if(winhotspot||windialogue){
7953 targetlevel=whichlevel+1;
7954 if(targetlevel>numchallengelevels-1)targetlevel=0;
7960 targetlevel=whichlevel+1;
7961 if(targetlevel>numchallengelevels-1)targetlevel=0;
7964 if(changedelay>0&&!player[0].dead&&!won){
7965 //high scores, awards, win
7967 accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime);
7972 accountactive->winLevel(whichlevel,bonustotal-startbonustotal,leveltime);
7988 if(!editorenabled&&gameon&&!mainmenu){
7989 if(changedelay!=-999)changedelay-=multiplier/7;
7990 if(player[0].dead)targetlevel=whichlevel;
7991 if(loading==2&&!campaign){
7994 fireSound(firestartsound);
7996 if(!player[0].dead&&targetlevel!=whichlevel){
7997 startbonustotal=bonustotal;
7999 if(player[0].dead) Loadlevel(whichlevel);
8000 else Loadlevel(targetlevel);
8006 if(loading==2&&targetlevel==whichlevel){
8010 fireSound(firestartsound);
8026 strcat(mapname,campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]);//[campaignchoicewhich[whichchoice]]);
8033 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
8034 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
8036 if(whichlevel!=-2&&!loading&&!player[0].dead){
8040 if(player[0].dead)loading=1;
8046 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
8047 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
8051 else if(mainmenu==0&&winfreeze){
8052 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
8054 else stealthloading=0;
8056 if(!stealthloading){
8057 float gLoc[3]={0,0,0};
8058 float vel[3]={0,0,0};
8059 fireSound(firestartsound);
8066 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
8067 ipstream.ignore(256,':');
8068 ipstream >> campaignnumlevels;
8069 for(i=0;i<campaignnumlevels;i++){
8070 ipstream.ignore(256,':');
8071 ipstream.ignore(256,':');
8072 ipstream.ignore(256,' ');
8073 ipstream >> campaignmapname[i];
8074 ipstream.ignore(256,':');
8075 ipstream >> campaigndescription[i];
8077 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
8079 ipstream.ignore(256,':');
8080 ipstream >> campaignchoosenext[i];
8081 ipstream.ignore(256,':');
8082 ipstream >> campaignnumnext[i];
8083 for(j=0;j<campaignnumnext[i];j++){
8084 ipstream.ignore(256,':');
8085 ipstream >> campaignnextlevel[i][j];
8086 campaignnextlevel[i][j]-=1;
8088 ipstream.ignore(256,':');
8089 ipstream >> campaignlocationx[i];
8090 ipstream.ignore(256,':');
8091 ipstream >> campaignlocationy[i];
8095 for(i=0;i<campaignnumlevels;i++){
8097 levelhighlight[i]=0;
8101 for(i=0;i<campaignnumlevels;i++){
8103 levelhighlight[i]=0;
8108 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
8109 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
8110 levelvisible[levelorder[i+1]]=1;
8112 int whichlevelstart;
8113 whichlevelstart=accountactive->getCampaignChoicesMade()-1;
8114 if(whichlevelstart<0){
8115 campaignchoicenum=1;
8116 campaignchoicewhich[0]=0;
8120 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
8121 for(i=0;i<campaignchoicenum;i++){
8122 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
8123 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
8124 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
8131 //if(firstload)TickOnceAfter();
8132 if(!firstload)LoadStuff();
8149 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
8157 OPENAL_SetPaused(channels[stream_music3], true);
8162 if(loading==3)loading=0;
8166 oldmusictype=musictype;
8172 facing=DoRotation(facing,-rotation2,0,0);
8173 facing=DoRotation(facing,0,0-rotation,0);
8174 viewerfacing=facing;
8178 if((animation[player[0].targetanimation].attack!=3&&animation[player[0].currentanimation].attack!=3)||player[0].skeleton.free)target=player[0].coords+player[0].currentoffset*(1-player[0].target)*player[0].scale+player[0].targetoffset*player[0].target*player[0].scale-player[0].facing*.05;
8179 else target=player[0].oldcoords+player[0].currentoffset*(1-player[0].target)*player[0].scale+player[0].targetoffset*player[0].target*player[0].scale-player[0].facing*.05;
8181 if(player[0].skeleton.free){
8182 for(i=0;i<player[0].skeleton.num_joints;i++){
8183 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
8184 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
8188 if(player[0].skeleton.free!=2&&!autocam){
8190 if(findLengthfast(&player[0].velocity)>400){
8191 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
8193 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
8194 coltarget=target-cameraloc;
8195 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
8197 Normalise(&coltarget);
8198 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
8199 else cameraloc=cameraloc+coltarget*multiplier*8;
8201 if(editorenabled)cameraloc=target;
8202 cameradist+=multiplier*5;
8203 if(cameradist>2.3)cameradist=2.3;
8204 viewer=cameraloc-facing*cameradist;
8206 coltarget=cameraloc;
8207 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
8208 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
8209 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
8210 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
8212 coltarget=cameraloc;
8213 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
8215 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
8216 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
8217 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
8219 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
8223 cameradist=findDistance(&viewer,&target);
8224 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
8225 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
8227 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
8228 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
8231 if(player[0].skeleton.free!=2&&autocam){
8233 if(findLengthfast(&player[0].velocity)>400){
8234 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
8236 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
8237 cameradist+=multiplier*5;
8238 if(cameradist>3.3)cameradist=3.3;
8239 coltarget=target-cameraloc;
8240 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
8241 else if(findLengthfast(&coltarget)>1)
8243 Normalise(&coltarget);
8244 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
8245 else cameraloc=cameraloc+coltarget*multiplier*8;
8247 if(editorenabled)cameraloc=target;
8250 coltarget=cameraloc;
8251 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
8252 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
8253 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
8254 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
8256 coltarget=cameraloc;
8257 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
8259 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
8260 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
8261 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
8263 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
8267 cameradist=findDistance(&viewer,&target);
8268 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
8269 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
8271 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
8272 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
8275 if(camerashake>.8)camerashake=.8;
8276 //if(woozy>10)woozy=10;
8277 //woozy+=multiplier;
8279 if(player[0].dead)camerashake=0;
8280 if(player[0].dead)woozy=0;
8281 camerashake-=multiplier*2;
8282 blackout-=multiplier*2;
8283 //if(player[0].isCrouch())woozy-=multiplier*8;
8284 if(camerashake<0)camerashake=0;
8285 if(blackout<0)blackout=0;
8286 //if(woozy<0)woozy=0;
8288 viewer.x+=(float)(Random()%100)*.0005*camerashake;
8289 viewer.y+=(float)(Random()%100)*.0005*camerashake;
8290 viewer.z+=(float)(Random()%100)*.0005*camerashake;