X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=3522f20d6194b8d55ba8e524b1053f08a2b972aa;hb=26debbd380c6922e5a0b60d99567c6374a4fef9a;hp=5b58c1c81b954bde07eb81d58699aa00488d8381;hpb=bb61e3fc1a36858b603d3a3fc2058f7c63f081c5;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 5b58c1c..3522f20 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -29,16 +29,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +#include #include "Game.h" #include "openal_wrapper.h" #include "Settings.h" #include "Input.h" #include "Animation.h" #include "Awards.h" +#include "Menu.h" #include using namespace std; +using namespace Game; // Added more evilness needed for MSVC #ifdef _MSC_VER @@ -82,6 +85,7 @@ extern XYZ windvector; extern bool debugmode; static int leveltheme; extern int mainmenu; +extern int oldmainmenu; extern bool visibleloading; extern XYZ envsound[30]; extern float envsoundvol[30]; @@ -116,6 +120,7 @@ extern float damagedealt; extern int maptype; extern int editoractive; extern int editorpathtype; +extern TGAImageRec texture; extern float hostiletime; @@ -136,6 +141,95 @@ extern bool winfreeze; extern bool campaign; + + +void Loadlevel(int which); +void Loadlevel(const char *name); + + + +class CampaignLevel { +private: + int width; + struct Position { int x,y; }; +public: + std::string mapname; + std::string description; + int choosenext; + /* + 0 = Immediately load next level at the end of this one. + 1 = Go back to the world map. + 2 = Don't bring up the Fiery loading screen. Maybe other things, I've not investigated. + */ + //int numnext; // 0 on final level. As David said: he meant to add story branching, but he eventually hadn't. + std::vector nextlevel; + Position location; + CampaignLevel() : width(10) { + choosenext = 1; + location.x = 0; + location.y = 0; + } + int getStartX() { return 30+120+location.x*400/512; } + int getStartY() { return 30+30+(512-location.y)*400/512; } + int getEndX() { return getStartX()+width; } + int getEndY() { return getStartY()+width; } + XYZ getCenter() { + XYZ center; + center.x=getStartX()+width/2; + center.y=getStartY()+width/2; + return center; + } + int getWidth() { return width; } + istream& operator<< (istream& is) { + is.ignore(256,':'); + is.ignore(256,':'); + is.ignore(256,' '); + is >> mapname; + is.ignore(256,':'); + is >> description; + for(int pos = description.find('_');pos!=string::npos;pos = description.find('_',pos)) { + description.replace(pos,1,1,' '); + } + is.ignore(256,':'); + is >> choosenext; + is.ignore(256,':'); + int numnext,next; + is >> numnext; + for(int j=0;j> next; + nextlevel.push_back(next-1); + } + is.ignore(256,':'); + is >> location.x; + is.ignore(256,':'); + is >> location.y; + return is; + } + friend istream& operator>> (istream& is, CampaignLevel& cl) { + return cl << is; + } +}; + +int indemo = 0; +bool won = false; +int entername = 0; +vector campaignlevels; +int whichchoice = 0; +int actuallevel = 0; +bool winhotspot = false; +bool windialogue = false; +bool realthreat = 0; +XYZ cameraloc; +float cameradist = 0; +bool oldattackkey = 0; +int whichlevel = 0; +float musicvolume[4] = {}; +float oldmusicvolume[4] = {}; +int musicselected = 0; + + + static const char *rabbitskin[] = { ":Data:Textures:Fur3.jpg", ":Data:Textures:Fur.jpg", @@ -172,9 +266,9 @@ static const char *cmd_names[] = { #undef DECLARE_COMMAND }; -typedef void (*console_handler)(Game *game, const char *args); +typedef void (*console_handler)(const char *args); -#define DECLARE_COMMAND(cmd) static void ch_##cmd(Game *game, const char *args); +#define DECLARE_COMMAND(cmd) static void ch_##cmd(const char *args); #include "ConsoleCmds.h" #undef DECLARE_COMMAND @@ -186,10 +280,9 @@ static console_handler cmd_handlers[] = { -// added utility functions -sf17k ============================================================= +// utility functions -//TODO: this is incorrect but I'm afraid to change it and break something, -//probably causes quirky behavior that I might want to preserve +// TODO: this is slightly incorrect inline float roughDirection(XYZ vec){ Normalise(&vec); float angle=-asin(-vec.x)*180/M_PI; @@ -200,18 +293,14 @@ inline float roughDirection(XYZ vec){ inline float roughDirectionTo(XYZ start, XYZ end){ return roughDirection(end-start); } - -//TODO: gotta be a better way -inline float pitch(XYZ vec){ +inline float pitchOf(XYZ vec){ Normalise(&vec); return -asin(vec.y)*180/M_PI; } inline float pitchTo(XYZ start, XYZ end){ - return pitch(end-start); + return pitchOf(end-start); } - inline float sq(float n) { return n*n; } - inline float stepTowardf(float from, float to, float by){ if(fabs(from-to)to) return from-by; @@ -254,23 +343,63 @@ void playdialogueboxsound(){ emit_sound_at(sound, temppos); } -// end added utility functions ================================================================ +// ================================================================ + +bool AddClothes(const char *fileName, GLubyte *array) { + LOGFUNC; + //Load Image + unsigned char fileNamep[256]; + CopyCStringToPascal(fileName,fileNamep); + bool opened; + opened=upload_image( fileNamep ,1); + + float alphanum; + //Is it valid? + if(opened){ + if(tintr>1)tintr=1; + if(tintg>1)tintg=1; + if(tintb>1)tintb=1; + + if(tintr<0)tintr=0; + if(tintg<0)tintg=0; + if(tintb<0)tintb=0; + + int bytesPerPixel=texture.bpp/8; + + int tempnum=0; + alphanum=255; + for(int i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){ + if(bytesPerPixel==3)alphanum=255; + else if((i+1)%4==0)alphanum=texture.data[i]; + //alphanum/=2; + if((i+1)%4||bytesPerPixel==3){ + if((i%4)==0)texture.data[i]*=tintr; + if((i%4)==1)texture.data[i]*=tintg; + if((i%4)==2)texture.data[i]*=tintb; + array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255); + tempnum++; + } + } + } + else return 0; + return 1; +} -static void ch_quit(Game *game, const char *args) +static void ch_quit(const char *args) { - game->tryquit = 1; + tryquit = 1; } -static void ch_map(Game *game, const char *args) +static void ch_map(const char *args) { - game->Loadlevel(args); - game->whichlevel = -2; + Loadlevel(args); + whichlevel = -2; campaign = 0; } -static void ch_save(Game *game, const char *args){ +static void ch_save(const char *args){ char buf[64]; snprintf(buf, 63, ":Data:Maps:%s", args); @@ -285,7 +414,7 @@ static void ch_save(Game *game, const char *args){ fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb); fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb); 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); + player[0].yaw, player[0].targetyaw, player[0].num_weapons); if(player[0].num_weapons>0&&player[0].num_weapons<5) for(int j=0;jnumpathpoints); - for(int j=0;jnumpathpoints;j++){ - fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]); - for(int k=0;knumpathpointconnect[j];k++) - fpackf(tfile, "Bi", game->pathpointconnect[j][k]); + fpackf(tfile, "Bi", numpathpoints); + for(int j=0;jmapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius); + fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius); fclose(tfile); } -static void ch_cellar(Game *game, const char *args) +static void ch_cellar(const char *args) { - game->LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:Furdarko.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_tint(Game *game, const char *args) +static void ch_tint(const char *args) { sscanf(args, "%f%f%f", &tintr, &tintg, &tintb); } -static void ch_tintr(Game *game, const char *args) +static void ch_tintr(const char *args) { tintr = atof(args); } -static void ch_tintg(Game *game, const char *args) +static void ch_tintg(const char *args) { tintg = atof(args); } -static void ch_tintb(Game *game, const char *args) +static void ch_tintb(const char *args) { tintb = atof(args); } -static void ch_speed(Game *game, const char *args) +static void ch_speed(const char *args) { player[0].speedmult = atof(args); } -static void ch_strength(Game *game, const char *args) +static void ch_strength(const char *args) { player[0].power = atof(args); } -static void ch_power(Game *game, const char *args) +static void ch_power(const char *args) { player[0].power = atof(args); } -static void ch_size(Game *game, const char *args) +static void ch_size(const char *args) { player[0].scale = atof(args) * .2; } -static int find_closest() -{ - int closest = 0; - float closestdist = std::numeric_limits::max(); - - for (int i = 1; i < numplayers; i++) { - float distance; - distance = findDistancefast(&player[i].coords,&player[0].coords); - if (distance < closestdist) { - closestdist = distance; - closest = i; +static int findClosestPlayer(){ + int closest = -1; + float closestdist = std::numeric_limits::max(); + + for(int i=1; i::max(); - if (closest) + for(int i=0; i=0) player[closest].scale = atof(args) * .2; } @@ -524,15 +664,15 @@ static void set_proportion(int pnum, const char *args) } } -static void ch_proportion(Game *game, const char *args) +static void ch_proportion(const char *args) { set_proportion(0, args); } -static void ch_proportionnear(Game *game, const char *args) +static void ch_proportionnear(const char *args) { - int closest = find_closest(); - if (closest) + int closest = findClosestPlayer(); + if(closest>=0) set_proportion(closest, args); } @@ -546,15 +686,15 @@ static void set_protection(int pnum, const char *args) player[pnum].protectionlow = low; } -static void ch_protection(Game *game, const char *args) +static void ch_protection(const char *args) { set_protection(0, args); } -static void ch_protectionnear(Game *game, const char *args) +static void ch_protectionnear(const char *args) { - int closest = find_closest(); - if (closest) + int closest = findClosestPlayer(); + if(closest>=0) set_protection(closest, args); } @@ -568,19 +708,19 @@ static void set_armor(int pnum, const char *args) player[pnum].armorlow = low; } -static void ch_armor(Game *game, const char *args) +static void ch_armor(const char *args) { set_armor(0, args); } -static void ch_armornear(Game *game, const char *args) +static void ch_armornear(const char *args) { - int closest = find_closest(); - if (closest) + int closest = findClosestPlayer(); + if(closest>=0) set_armor(closest, args); } -static void ch_protectionreset(Game *game, const char *args) +static void ch_protectionreset(const char *args) { set_protection(0, "1 1 1"); set_armor(0, "1 1 1"); @@ -596,38 +736,38 @@ static void set_metal(int pnum, const char *args) player[pnum].metallow = low; } -static void ch_metal(Game *game, const char *args) +static void ch_metal(const char *args) { set_metal(0, args); } -static void set_noclothes(int pnum, Game *game, const char *args) +static void set_noclothes(int pnum, const char *args) { player[pnum].numclothes = 0; - game->LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin], - &player[pnum].skeleton.drawmodel.textureptr,1, - &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize); + player[pnum].skeleton.drawmodel.textureptr.load( + creatureskin[player[pnum].creature][player[pnum].whichskin],1, + &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize); } -static void ch_noclothes(Game *game, const char *args) +static void ch_noclothes(const char *args) { - set_noclothes(0, game, args); + set_noclothes(0, args); } -static void ch_noclothesnear(Game *game, const char *args) +static void ch_noclothesnear(const char *args) { - int closest = find_closest(); - if (closest) - set_noclothes(closest, game, args); + int closest = findClosestPlayer(); + if(closest>=0) + set_noclothes(closest, args); } -static void set_clothes(int pnum, Game *game, const char *args) +static void set_clothes(int pnum, const char *args) { char buf[64]; snprintf(buf, 63, ":Data:Textures:%s.png", args); - if (!game->AddClothes(buf,&player[pnum].skeleton.skinText[pnum])) + if (!AddClothes(buf,&player[pnum].skeleton.skinText[pnum])) return; player[pnum].DoMipmaps(); @@ -638,25 +778,25 @@ static void set_clothes(int pnum, Game *game, const char *args) player[pnum].numclothes++; } -static void ch_clothes(Game *game, const char *args) +static void ch_clothes(const char *args) { - set_clothes(0, game, args); + set_clothes(0, args); } -static void ch_clothesnear(Game *game, const char *args) +static void ch_clothesnear(const char *args) { - int closest = find_closest(); - if (closest) - set_clothes(closest, game, args); + int closest = findClosestPlayer(); + if(closest>=0) + set_clothes(closest, args); } -static void ch_belt(Game *game, const char *args) +static void ch_belt(const char *args) { player[0].skeleton.clothes = !player[0].skeleton.clothes; } -static void ch_cellophane(Game *game, const char *args) +static void ch_cellophane(const char *args) { cellophane = !cellophane; float mul = cellophane ? 0 : 1; @@ -669,7 +809,7 @@ static void ch_cellophane(Game *game, const char *args) } } -static void ch_funnybunny(Game *game, const char *args) +static void ch_funnybunny(const char *args) { player[0].skeleton.id=0; player[0].skeleton.Load(":Data:Skeleton:Basic Figure",":Data:Skeleton:Basic Figurelow", @@ -678,8 +818,7 @@ static void ch_funnybunny(Game *game, const char *args) ":Data:Models:Body4.solid",":Data:Models:Body5.solid", ":Data:Models:Body6.solid",":Data:Models:Body7.solid", ":Data:Models:Bodylow.solid",":Data:Models:Belt.solid",1); - game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:fur3.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); player[0].creature=rabbittype; player[0].scale=.2; player[0].headless=0; @@ -687,7 +826,7 @@ static void ch_funnybunny(Game *game, const char *args) set_proportion(0, "1 1 1 1"); } -static void ch_wolfie(Game *game, const char *args) +static void ch_wolfie(const char *args) { player[0].skeleton.id=0; player[0].skeleton.Load(":Data:Skeleton:Basic Figure Wolf",":Data:Skeleton:Basic Figure Wolf Low", @@ -696,80 +835,72 @@ static void ch_wolfie(Game *game, const char *args) ":Data:Models:Wolf4.solid",":Data:Models:Wolf5.solid", ":Data:Models:Wolf6.solid",":Data:Models:Wolf7.solid", ":Data:Models:Wolflow.solid",":Data:Models:Belt.solid",0); - game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); player[0].creature=wolftype; player[0].damagetolerance=300; set_proportion(0, "1 1 1 1"); } -static void ch_wolfieisgod(Game *game, const char *args) +static void ch_wolfieisgod(const char *args) { - ch_wolfie(game, args); + ch_wolfie(args); } -static void ch_wolf(Game *game, const char *args) +static void ch_wolf(const char *args) { - game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_snowwolf(Game *game, const char *args) +static void ch_snowwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:SnowWolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_darkwolf(Game *game, const char *args) +static void ch_darkwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:DarkWolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_lizardwolf(Game *game, const char *args) +static void ch_lizardwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:Lizardwolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_white(Game *game, const char *args) +static void ch_white(const char *args) { - game->LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:fur.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_brown(Game *game, const char *args) +static void ch_brown(const char *args) { - game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:fur3.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_black(Game *game, const char *args) +static void ch_black(const char *args) { - game->LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1, - &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:fur2.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_sizemin(Game *game, const char *args) +static void ch_sizemin(const char *args) { for (int i = 1; i < numplayers; i++) if (player[i].scale < 0.8 * 0.2) player[i].scale = 0.8 * 0.2; } -static void ch_tutorial(Game *game, const char *args) +static void ch_tutorial(const char *args) { tutoriallevel = atoi(args); } -static void ch_hostile(Game *game, const char *args) +static void ch_hostile(const char *args) { hostile = atoi(args); } -static void ch_indemo(Game *game, const char *args) +static void ch_indemo(const char *args) { - game->indemo=1; + indemo=1; hotspot[numhotspots]=player[0].coords; hotspotsize[numhotspots]=0; hotspottype[numhotspots]=-111; @@ -777,13 +908,13 @@ static void ch_indemo(Game *game, const char *args) numhotspots++; } -static void ch_notindemo(Game *game, const char *args) +static void ch_notindemo(const char *args) { - game->indemo=0; + indemo=0; numhotspots--; } -static void ch_type(Game *game, const char *args) +static void ch_type(const char *args) { int n = sizeof(editortypenames) / sizeof(editortypenames[0]); for (int i = 0; i < n; i++) @@ -793,7 +924,7 @@ static void ch_type(Game *game, const char *args) } } -static void ch_path(Game *game, const char *args) +static void ch_path(const char *args) { int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]); for (int i = 0; i < n; i++) @@ -803,7 +934,7 @@ static void ch_path(Game *game, const char *args) } } -static void ch_hs(Game *game, const char *args) +static void ch_hs(const char *args) { hotspot[numhotspots]=player[0].coords; @@ -820,7 +951,7 @@ static void ch_hs(Game *game, const char *args) numhotspots++; } -static void ch_dialogue(Game *game, const char *args) +static void ch_dialogue(const char *args) { int dlg; char buf1[32], buf2[64]; @@ -871,7 +1002,7 @@ static void ch_dialogue(Game *game, const char *args) numdialogues++; } -static void ch_fixdialogue(Game *game, const char *args) +static void ch_fixdialogue(const char *args) { char buf1[32], buf2[64]; int whichdi; @@ -909,47 +1040,47 @@ static void ch_fixdialogue(Game *game, const char *args) ipstream.close(); } -static void ch_fixtype(Game *game, const char *args) +static void ch_fixtype(const char *args) { int dlg; sscanf(args, "%d", &dlg); dialoguetype[0] = dlg; } -static void ch_fixrotation(Game *game, const char *args) +static void ch_fixrotation(const char *args) { - participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation; + participantyaw[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].yaw; } -static void ch_ddialogue(Game *game, const char *args) +static void ch_ddialogue(const char *args) { if (numdialogues) numdialogues--; } -static void ch_dhs(Game *game, const char *args) +static void ch_dhs(const char *args) { if (numhotspots) numhotspots--; } -static void ch_immobile(Game *game, const char *args) +static void ch_immobile(const char *args) { player[0].immobile = 1; } -static void ch_allimmobile(Game *game, const char *args) +static void ch_allimmobile(const char *args) { for (int i = 1; i < numplayers; i++) player[i].immobile = 1; } -static void ch_mobile(Game *game, const char *args) +static void ch_mobile(const char *args) { player[0].immobile = 0; } -static void ch_default(Game *game, const char *args) +static void ch_default(const char *args) { player[0].armorhead=1; player[0].armorhigh=1; @@ -978,15 +1109,15 @@ static void ch_default(Game *game, const char *args) } player[0].numclothes=0; - game->LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin], - &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0], - &player[0].skeleton.skinsize); + player[0].skeleton.drawmodel.textureptr.load( + creatureskin[player[0].creature][player[0].whichskin],1, + &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); editoractive=typeactive; player[0].immobile=0; } -static void ch_play(Game *game, const char *args) +static void ch_play(const char *args) { int dlg; sscanf(args, "%d", &dlg); @@ -997,8 +1128,8 @@ static void ch_play(Game *game, const char *args) for(int i=0;iSetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void ch_skylight(Game *game, const char *args) +static void ch_skylight(const char *args) { sscanf(args, "%f%f%f", &skyboxlightr, &skyboxlightg, &skyboxlightb); - game->SetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void ch_skybox(Game *game, const char *args) +static void ch_skybox(const char *args) { skyboxtexture = !skyboxtexture; - game->SetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void cmd_dispatch(Game *game, const string cmd) +static void cmd_dispatch(const string cmd) { int i, n_cmds = sizeof(cmd_names) / sizeof(cmd_names[0]); @@ -1094,7 +1225,7 @@ static void cmd_dispatch(Game *game, const string cmd) if (cmd.substr(0,cmd.find(' '))==string(cmd_names[i])) { cout << "|" << cmd.substr(cmd.find(' ')+1) << "|" << endl; - cmd_handlers[i](game, cmd.substr(cmd.find(' ')+1).c_str()); + cmd_handlers[i](cmd.substr(cmd.find(' ')+1).c_str()); break; } emit_sound_np(i < n_cmds ? consolesuccesssound : consolefailsound); @@ -1137,7 +1268,7 @@ void Game::SetUpLighting(){ light.ambient[2]*=(skyboxlightb+average)/2; } -int Game::findPathDist(int start,int end){ +int findPathDist(int start,int end){ int smallestcount,count,connected; int last,last2,last3,last4; int closest; @@ -1204,7 +1335,7 @@ int Game::checkcollide(XYZ startpoint,XYZ endpoint){ objects.type[i]!=firetype){ colviewer=startpoint; coltarget=endpoint; - if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i; + if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.yaw[i])!=-1)return i; } } } @@ -1239,7 +1370,7 @@ int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){ colviewer=startpoint; coltarget=endpoint; //FIXME: i/what - if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i; + if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.yaw[what])!=-1)return i; } } } @@ -1249,7 +1380,7 @@ int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){ return -1; } -void Game::Setenvironment(int which) +void Setenvironment(int which) { LOGFUNC; @@ -1271,19 +1402,18 @@ void Game::Setenvironment(int which) if(ambientsound) emit_stream_np(stream_wind); - LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1); - LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1); - LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0); - LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0); + objects.treetextureptr.load(":Data:Textures:snowtree.png",0,1); + objects.bushtextureptr.load(":Data:Textures:bushsnow.png",0,1); + objects.rocktextureptr.load(":Data:Textures:bouldersnow.jpg",1,0); + objects.boxtextureptr.load(":Data:Textures:snowbox.jpg",1,0); footstepsound = footstepsn1; footstepsound2 = footstepsn2; footstepsound3 = footstepst1; footstepsound4 = footstepst2; - LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0); - - LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0); + terraintexture.load(":Data:Textures:snow.jpg",1,0); + terraintexture2.load(":Data:Textures:rock.jpg",1,0); //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1); @@ -1292,7 +1422,7 @@ void Game::Setenvironment(int which) temptexdetail=texdetail; if(texdetail>1)texdetail=4; - skybox.load( ":Data:Textures:Skybox(snow):Front.jpg", + skybox->load( ":Data:Textures:Skybox(snow):Front.jpg", ":Data:Textures:Skybox(snow):Left.jpg", ":Data:Textures:Skybox(snow):Back.jpg", ":Data:Textures:Skybox(snow):Right.jpg", @@ -1306,10 +1436,10 @@ void Game::Setenvironment(int which) } else if(environment==desertenvironment){ windvector=0; windvector.z=2; - LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1); - LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1); - LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0); - LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0); + objects.treetextureptr.load(":Data:Textures:deserttree.png",0,1); + objects.bushtextureptr.load(":Data:Textures:bushdesert.png",0,1); + objects.rocktextureptr.load(":Data:Textures:boulderdesert.jpg",1,0); + objects.boxtextureptr.load(":Data:Textures:desertbox.jpg",1,0); if(ambientsound) @@ -1320,9 +1450,8 @@ void Game::Setenvironment(int which) footstepsound3 = footstepsn1; footstepsound4 = footstepsn2; - LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0); - - LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0); + terraintexture.load(":Data:Textures:sand.jpg",1,0); + terraintexture2.load(":Data:Textures:sandslope.jpg",1,0); //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1); @@ -1330,7 +1459,7 @@ void Game::Setenvironment(int which) temptexdetail=texdetail; if(texdetail>1)texdetail=4; - skybox.load( ":Data:Textures:Skybox(sand):Front.jpg", + skybox->load( ":Data:Textures:Skybox(sand):Front.jpg", ":Data:Textures:Skybox(sand):Left.jpg", ":Data:Textures:Skybox(sand):Back.jpg", ":Data:Textures:Skybox(sand):Right.jpg", @@ -1344,10 +1473,10 @@ void Game::Setenvironment(int which) } else if(environment==grassyenvironment){ windvector=0; windvector.z=2; - LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1); - LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1); - LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0); - LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0); + objects.treetextureptr.load(":Data:Textures:tree.png",0,1); + objects.bushtextureptr.load(":Data:Textures:bush.png",0,1); + objects.rocktextureptr.load(":Data:Textures:boulder.jpg",1,0); + objects.boxtextureptr.load(":Data:Textures:grassbox.jpg",1,0); if(ambientsound) emit_stream_np(stream_wind, 100.); @@ -1357,9 +1486,8 @@ void Game::Setenvironment(int which) footstepsound3 = footstepst1; footstepsound4 = footstepst2; - LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0); - - LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0); + terraintexture.load(":Data:Textures:grassdirt.jpg",1,0); + terraintexture2.load(":Data:Textures:mossrock.jpg",1,0); //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1); @@ -1367,7 +1495,7 @@ void Game::Setenvironment(int which) temptexdetail=texdetail; if(texdetail>1)texdetail=4; - skybox.load( ":Data:Textures:Skybox(grass):Front.jpg", + skybox->load( ":Data:Textures:Skybox(grass):Front.jpg", ":Data:Textures:Skybox(grass):Left.jpg", ":Data:Textures:Skybox(grass):Back.jpg", ":Data:Textures:Skybox(grass):Right.jpg", @@ -1385,7 +1513,56 @@ void Game::Setenvironment(int which) texdetail=temptexdetail; } -void Game::Loadlevel(int which) { +void LoadCampaign() { + if(!accountactive) + return; + ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str())); + ipstream.ignore(256,':'); + int numlevels; + ipstream >> numlevels; + campaignlevels.clear(); + for(int i=0;i> cl; + campaignlevels.push_back(cl); + } + ipstream.close(); + + ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str())); + if(test.good()) { + Mainmenuitems[7].load((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),0,0); + } else { + Mainmenuitems[7].load(":Data:Textures:World.png",0,0); + } + + if(accountactive->getCampaignChoicesMade()==0) { + accountactive->setCampaignScore(0); + accountactive->resetFasttime(); + } +} + +vector ListCampaigns() { + DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns")); + struct dirent *campaign = NULL; + if(!campaigns) { + perror("Problem while loading campaigns"); + cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl; + exit(EXIT_FAILURE); + } + vector campaignNames; + while ((campaign = readdir(campaigns)) != NULL) { + string name(campaign->d_name); + if(name.length()<5) + continue; + if(!name.compare(name.length()-4,4,".txt")) { + campaignNames.push_back(name.substr(0,name.length()-4)); + } + } + closedir(campaigns); + return campaignNames; +} + +void Loadlevel(int which) { stealthloading=0; whichlevel=which; @@ -1400,7 +1577,7 @@ void Game::Loadlevel(int which) { Loadlevel("mapsave"); } -void Game::Loadlevel(const char *name) { +void Loadlevel(const char *name) { int templength; float lamefloat; static const char *pfx = ":Data:Maps:"; @@ -1471,11 +1648,6 @@ void Game::Loadlevel(const char *name) { if(accountactive) difficulty=accountactive->getDifficulty(); - if(difficulty!=2) - minimap=1; - else - minimap=0; - numhotspots=0; currenthotspot=-1; bonustime=1; @@ -1575,7 +1747,7 @@ void Game::Loadlevel(const char *name) { skyboxlightb=skyboxb; } 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); + funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].yaw,&player[0].targetyaw, &player[0].num_weapons); if(stealthloading) funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons); player[0].originalcoords=player[0].coords; @@ -1616,7 +1788,7 @@ void Game::Loadlevel(const char *name) { funpackf(tfile, "Bi", &dialoguetype[k]); for(int l=0;l<10;l++){ funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z); - funpackf(tfile, "Bf", &participantrotation[k][l]); + funpackf(tfile, "Bf", &participantyaw[k][l]); } for(int l=0;l=12) - funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation); + funpackf(tfile, "Bf",&player[i-howmanyremoved].yaw); else - player[i-howmanyremoved].rotation=0; - player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation; + player[i-howmanyremoved].yaw=0; + player[i-howmanyremoved].targetyaw=player[i-howmanyremoved].yaw; if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){ removeanother=1; howmanyremoved++; @@ -1845,7 +2017,7 @@ void Game::Loadlevel(const char *name) { int j=objects.numobjects; objects.numobjects=0; for(int i=0;itutorialmaxtime){ tutorialstage++; tutorialsuccess=0; @@ -2139,7 +2311,7 @@ void Game::doTutorial(){ if(Random()%2==0){ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2; if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2; - 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; + 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].yaw,0)*player[1].scale+player[1].coords; if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords; Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1); } @@ -2370,7 +2542,7 @@ void Game::doTutorial(){ if(Random()%2==0){ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2; if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2; - 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; + 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].yaw,0)*player[1].scale+player[1].coords; if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords; Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1); } @@ -2457,7 +2629,7 @@ void Game::doTutorial(){ } } -void Game::doDebugKeys(){ +void doDebugKeys(){ float headprop,bodyprop,armprop,legprop; if(debugmode){ if(Input::isKeyPressed(SDLK_h)){ @@ -2491,18 +2663,8 @@ void Game::doDebugKeys(){ } if(Input::isKeyPressed(SDLK_x)&&Input::isKeyDown(SDLK_LSHIFT)){ - int closest=-1; - float closestdist=-1; - float distance; - if(numplayers>1) - for(int i=1;i=0){ if(player[closest].num_weapons){ if(weapons[player[closest].weaponids[0]].getType()==sword) weapons[player[closest].weaponids[0]].setType(staff); @@ -2522,45 +2684,28 @@ void Game::doDebugKeys(){ } if(Input::isKeyDown(SDLK_u)){ - int closest=-1; - float closestdist=-1; - float distance; - if(numplayers>1) - for(int i=1;i=0){ + player[closest].yaw+=multiplier*50; + player[closest].targetyaw=player[closest].yaw; + } } if(Input::isKeyPressed(SDLK_o)&&!Input::isKeyDown(SDLK_LSHIFT)){ - int closest=-1; - float closestdist=-1; - float distance; - if(numplayers>1) - for(int i=1;i=0){ player[closest].whichskin++; if(player[closest].whichskin>9) player[closest].whichskin=0; if(player[closest].whichskin>2&&player[closest].creature==wolftype) player[closest].whichskin=0; - LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin], - &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize); + player[closest].skeleton.drawmodel.textureptr.load(creatureskin[player[closest].creature][player[closest].whichskin],1, + &player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize); } if(player[closest].numclothes){ @@ -2575,18 +2720,8 @@ void Game::doDebugKeys(){ } if(Input::isKeyPressed(SDLK_o)&&Input::isKeyDown(SDLK_LSHIFT)){ - int closest=-1; - float closestdist=-1; - float distance; - if(numplayers>1) - for(int i=1;i=0){ if(player[closest].creature==wolftype){ headprop=player[closest].proportionhead.x/1.1; bodyprop=player[closest].proportionbody.x/1.1; @@ -2605,7 +2740,7 @@ void Game::doDebugKeys(){ if(player[closest].creature==rabbittype){ player[closest].skeleton.id=closest; 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); - LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize); + player[closest].skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg",1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize); player[closest].whichskin=0; player[closest].creature=wolftype; @@ -2622,7 +2757,7 @@ void Game::doDebugKeys(){ { player[closest].skeleton.id=closest; 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); - LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize); + player[closest].skeleton.drawmodel.textureptr.load(":Data:Textures:Fur3.jpg",1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize); player[closest].whichskin=0; player[closest].creature=rabbittype; @@ -2661,23 +2796,22 @@ void Game::doDebugKeys(){ if(((Input::isKeyPressed(SDLK_i)&&!Input::isKeyDown(SDLK_LSHIFT)))){ - int closest=-1; - float closestdist=-1; - float distance; + int closest = -1; + float closestdist = std::numeric_limits::max(); + + for(int i=1; i1) - for(int i=1;i1) - for(int i=1;i=0 && findDistancefast(&player[closest].coords,&player[0].coords)<144){ + blah=player[closest].coords; emit_sound_at(splattersound, blah); - emit_sound_at(breaksound2, blah); for(int i=0;i1) - for(int i=1;i0&&closest>=0){ + int closest=findClosestPlayer(); + if(closest>=0){ //player[closest]=player[numplayers-1]; //player[closest].skeleton=player[numplayers-1].skeleton; numplayers--; @@ -2889,20 +3000,9 @@ void Game::doDebugKeys(){ } if(Input::isKeyPressed(SDLK_DELETE)&&Input::isKeyDown(SDLK_LCTRL)){ - int closest=-1; - float closestdist=-1; - float distance; - if(max_objects>1) - for(int i=1;i0&&closest>=0){ + int closest=findClosestObject(); + if(closest>=0) objects.position[closest].y-=500; - } } if(Input::isKeyPressed(SDLK_m)&&Input::isKeyDown(SDLK_LSHIFT)){ @@ -2917,14 +3017,14 @@ void Game::doDebugKeys(){ if(editortype==firetype)boxcoords.y=player[0].coords.y-.5; //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360); float temprotat,temprotat2; - temprotat=editorrotation; - temprotat2=editorrotation2; + temprotat=editoryaw; + temprotat2=editorpitch; if(temprotat<0||editortype==bushtype)temprotat=Random()%360; if(temprotat2<0)temprotat2=Random()%360; objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize); if(editortype==treetrunktype) - objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize); + objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editoryaw-((int)editoryaw)%30,editorpitch,editorsize); } } @@ -2942,19 +3042,19 @@ void Game::doDebugKeys(){ int k=abs(Random()%2)+1; if(k==0){ - LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize); + player[numplayers].skeleton.drawmodel.textureptr.load(":Data:Textures:Fur3.jpg",1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize); player[numplayers].whichskin=0; } else if(k==1){ - LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize); + player[numplayers].skeleton.drawmodel.textureptr.load(":Data:Textures:Fur.jpg",1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize); player[numplayers].whichskin=1; } else { - LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize); + player[numplayers].skeleton.drawmodel.textureptr.load(":Data:Textures:Fur2.jpg",1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize); player[numplayers].whichskin=2; } - LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1); + player[numplayers].skeleton.drawmodelclothes.textureptr.load(":Data:Textures:Belt.png",1,1); player[numplayers].power=1; player[numplayers].speedmult=1; player[numplayers].currentanimation=bounceidleanim; @@ -2965,8 +3065,8 @@ void Game::doDebugKeys(){ player[numplayers].bled=0; player[numplayers].speed=1+(float)(Random()%100)/1000; - player[numplayers].targetrotation=player[0].targetrotation; - player[numplayers].rotation=player[0].rotation; + player[numplayers].targetyaw=player[0].targetyaw; + player[numplayers].yaw=player[0].yaw; player[numplayers].velocity=0; player[numplayers].coords=player[0].coords; @@ -3159,12 +3259,12 @@ void Game::doDebugKeys(){ } if(Input::isKeyDown(SDLK_LEFT)&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){ - editorrotation-=multiplier*100; - if(editorrotation<-.01)editorrotation=-.01; + editoryaw-=multiplier*100; + if(editoryaw<-.01)editoryaw=-.01; } if(Input::isKeyDown(SDLK_RIGHT)&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){ - editorrotation+=multiplier*100; + editoryaw+=multiplier*100; } if(Input::isKeyDown(SDLK_UP)&&!Input::isKeyDown(SDLK_LCTRL)){ @@ -3185,31 +3285,23 @@ void Game::doDebugKeys(){ mapradius+=multiplier*10; } if(Input::isKeyDown(SDLK_UP)&&Input::isKeyDown(SDLK_LCTRL)){ - editorrotation2+=multiplier*100; + editorpitch+=multiplier*100; } if(Input::isKeyDown(SDLK_DOWN)&&Input::isKeyDown(SDLK_LCTRL)){ - editorrotation2-=multiplier*100; - if(editorrotation2<-.01)editorrotation2=-.01; + editorpitch-=multiplier*100; + if(editorpitch<-.01)editorpitch=-.01; } if(Input::isKeyPressed(SDLK_DELETE)&&objects.numobjects&&Input::isKeyDown(SDLK_LSHIFT)){ - int closest=-1; - float closestdist=-1; - float distance; - for(int i=0;i0&&closest>=0)objects.DeleteObject(closest); + int closest=findClosestObject(); + if(closest>=0) + objects.DeleteObject(closest); } } } } -void Game::doJumpReversals(){ +void doJumpReversals(){ for(int k=0;kterrain.getHeight(player[k].coords.x,player[k].coords.z)-.1) player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z); - if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){ + if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.yaw[i], &objects.model[i])!=-1){ flatfacing=lowpoint-player[k].coords; player[k].coords=lowpoint; player[k].coords.y-=1.3; @@ -3398,19 +3490,19 @@ void Game::doAerialAcrobatics(){ player[k].jumpkeydown){ lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5; XYZ tempcoords1=lowpoint; - whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1&&fabs(objects.model[i].facenormals[whichhit].y)<.3){ player[k].setAnimation(walljumpleftanim); emit_sound_at(movewhooshsound, player[k].coords); if(k==0) pause_sound(whooshsound); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; if(lowpointtarget.z<0) - player[k].rotation=180-player[k].rotation; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + player[k].yaw=180-player[k].yaw; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; if(k==0) numwallflipped++; } @@ -3418,52 +3510,52 @@ void Game::doAerialAcrobatics(){ { lowpoint=tempcoords1; lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5; - whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1&&fabs(objects.model[i].facenormals[whichhit].y)<.3){ player[k].setAnimation(walljumprightanim); emit_sound_at(movewhooshsound, player[k].coords); if(k==0)pause_sound(whooshsound); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; - if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; + if(lowpointtarget.z<0)player[k].yaw=180-player[k].yaw; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; if(k==0)numwallflipped++; } else { lowpoint=tempcoords1; lowpointtarget=lowpoint+player[k].facing*2; - whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1&&fabs(objects.model[i].facenormals[whichhit].y)<.3){ player[k].setAnimation(walljumpbackanim); emit_sound_at(movewhooshsound, player[k].coords); if(k==0)pause_sound(whooshsound); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; - if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; + if(lowpointtarget.z<0)player[k].yaw=180-player[k].yaw; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; if(k==0)numwallflipped++; } else { lowpoint=tempcoords1; lowpointtarget=lowpoint-player[k].facing*2; - whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1&&fabs(objects.model[i].facenormals[whichhit].y)<.3){ player[k].setAnimation(walljumpfrontanim); emit_sound_at(movewhooshsound, player[k].coords); if(k==0)pause_sound(whooshsound); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; - if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation; - player[k].rotation+=180; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; + if(lowpointtarget.z<0)player[k].yaw=180-player[k].yaw; + player[k].yaw+=180; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; if(k==0)numwallflipped++; } } @@ -3476,7 +3568,7 @@ void Game::doAerialAcrobatics(){ lowpoint2=player[k].coords; lowpoint=player[k].coords; lowpoint.y+=2; - if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){ + if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.yaw[i])!=-1){ player[k].coords=colpoint; player[k].collide=1; tempcollide=1; @@ -3524,7 +3616,7 @@ void Game::doAerialAcrobatics(){ lowpoint=player[k].coords; lowpoint.y+=1.35; if(objects.type[i]!=rocktype) - if(player[k].SphereCheck(&lowpoint,1.33,&colpoint,&objects.position[i],&objects.rotation[i],&objects.model[i])!=-1){ + if(player[k].SphereCheck(&lowpoint,1.33,&colpoint,&objects.position[i],&objects.yaw[i],&objects.model[i])!=-1){ if(player[k].targetanimation!=jumpupanim&& player[k].targetanimation!=jumpdownanim&& player[k].onterrain) @@ -3540,14 +3632,14 @@ void Game::doAerialAcrobatics(){ player[k].targetanimation==jumpupanim|| player[k].targetanimation==jumpdownanim)){ lowpoint=player[k].coords; - objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]); + objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.yaw[i]); lowpoint=player[k].coords; lowpoint.y+=.05; facing=0; facing.z=-1; - facing=DoRotation(facing,0,player[k].targetrotation+180,0); + facing=DoRotation(facing,0,player[k].targetyaw+180,0); lowpointtarget=lowpoint+facing*1.4; - whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1){ lowpoint=player[k].coords; lowpoint.y+=.1; @@ -3576,7 +3668,7 @@ void Game::doAerialAcrobatics(){ lowpointtarget6.y+=45/13; lowpointtarget6+=facing*.6; lowpointtarget7.y+=90/13; - whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(objects.friction[i]>.5) if(whichhit!=-1){ if(whichhit!=-1&&player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim) @@ -3584,28 +3676,28 @@ void Game::doAerialAcrobatics(){ if(checkcollide(lowpoint7,lowpointtarget7)==-1) if(checkcollide(lowpoint6,lowpointtarget6)==-1) if( objects.model[i].LineCheckPossible(&lowpoint2,&lowpointtarget2, - &colpoint,&objects.position[i],&objects.rotation[i])!=-1&& + &colpoint,&objects.position[i],&objects.yaw[i])!=-1&& objects.model[i].LineCheckPossible(&lowpoint3,&lowpointtarget3, - &colpoint,&objects.position[i],&objects.rotation[i])!=-1&& + &colpoint,&objects.position[i],&objects.yaw[i])!=-1&& objects.model[i].LineCheckPossible(&lowpoint4,&lowpointtarget4, - &colpoint,&objects.position[i],&objects.rotation[i])!=-1&& + &colpoint,&objects.position[i],&objects.yaw[i])!=-1&& objects.model[i].LineCheckPossible(&lowpoint5,&lowpointtarget5, - &colpoint,&objects.position[i],&objects.rotation[i])!=-1) + &colpoint,&objects.position[i],&objects.yaw[i])!=-1) for(int j=0;j<45;j++){ lowpoint=player[k].coords; lowpoint.y+=(float)j/13; lowpointtarget=lowpoint+facing*1.4; if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget, - &colpoint2,&objects.position[i],&objects.rotation[i])==-1){ + &colpoint2,&objects.position[i],&objects.yaw[i])==-1){ if(j<=6||j<=25&&player[k].targetanimation==jumpdownanim) break; if(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim){ - lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0); + lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[k],0); lowpoint=player[k].coords; lowpoint.y+=(float)j/13; lowpointtarget=lowpoint+facing*1.3; flatfacing=player[k].coords; - player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01; + player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[k],0)*.01; player[k].coords.y=lowpointtarget.y-.07; player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale; @@ -3616,12 +3708,12 @@ void Game::doAerialAcrobatics(){ } emit_sound_at(jumpsound, player[k].coords, 128.); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; if(lowpointtarget.z<0) - player[k].rotation=180-player[k].rotation; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + player[k].yaw=180-player[k].yaw; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; //player[k].velocity=lowpointtarget*.03; player[k].velocity=0; @@ -3682,7 +3774,7 @@ void Game::doAerialAcrobatics(){ } } -void Game::doAttacks(){ +void doAttacks(){ static XYZ relative; static int randattack; static bool playerrealattackkeydown=0; @@ -3744,19 +3836,19 @@ void Game::doAttacks(){ player[i].targetanimation==staffspinhitanim) if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){ player[k].setAnimation(dodgebackanim); - player[k].targetrotation=roughDirectionTo(player[k].coords,player[i].coords); + player[k].targetyaw=roughDirectionTo(player[k].coords,player[i].coords); player[k].targettilt2=pitchTo(player[k].coords,player[i].coords); } } if(player[k].targetanimation!=dodgebackanim){ if(k==0)numflipped++; player[k].setAnimation(backhandspringanim); - player[k].targetrotation=-rotation+180; + player[k].targetyaw=-yaw+180; if(player[k].leftkeydown) - player[k].targetrotation-=45; + player[k].targetyaw-=45; if(player[k].rightkeydown) - player[k].targetrotation+=45; - player[k].rotation=player[k].targetrotation; + player[k].targetyaw+=45; + player[k].yaw=player[k].targetyaw; player[k].jumppower-=2; } } @@ -3992,9 +4084,9 @@ void Game::doAttacks(){ player[k].targetframe=player[i].targetframe; player[k].target=player[i].target; player[k].velocity=0; - player[k].targetrotation=player[i].rotation; - player[k].rotation=player[i].rotation; - player[i].targetrotation=player[i].rotation; + player[k].targetyaw=player[i].yaw; + player[k].yaw=player[i].yaw; + player[i].targetyaw=player[i].yaw; } } if(animation[player[k].targetanimation].attack==normalattack&& @@ -4004,7 +4096,7 @@ void Game::doAttacks(){ player[k].targetframe=0; player[k].target=0; - player[k].targetrotation=roughDirectionTo(player[k].coords,player[i].coords); + player[k].targetyaw=roughDirectionTo(player[k].coords,player[i].coords); player[k].targettilt2=pitchTo(player[k].coords,player[i].coords); player[k].lastattack3=player[k].lastattack2; player[k].lastattack2=player[k].lastattack; @@ -4013,7 +4105,7 @@ void Game::doAttacks(){ if(player[k].targetanimation==knifefollowanim&& player[k].victim==&player[i]){ oldattackkey=1; - player[k].targetrotation=roughDirectionTo(player[k].coords,player[i].coords); + player[k].targetyaw=roughDirectionTo(player[k].coords,player[i].coords); player[k].targettilt2=pitchTo(player[k].coords,player[i].coords); player[k].victim=&player[i]; player[k].hasvictim=1; @@ -4034,10 +4126,10 @@ void Game::doAttacks(){ player[k].velocity=0; player[k].oldcoords=player[k].coords; player[i].coords=player[k].coords; - player[i].targetrotation=player[k].targetrotation; - player[i].rotation=player[k].targetrotation; - player[k].rotation=player[k].targetrotation; - player[i].rotation=player[k].targetrotation; + player[i].targetyaw=player[k].targetyaw; + player[i].yaw=player[k].targetyaw; + player[k].yaw=player[k].targetyaw; + player[i].yaw=player[k].targetyaw; } } } @@ -4145,11 +4237,11 @@ void Game::doAttacks(){ player[i].getJointFor(neck).position)/2* player[i].scale; } - player[k].targetrotation=roughDirectionTo(player[k].coords,targetpoint); + player[k].targetyaw=roughDirectionTo(player[k].coords,targetpoint); player[k].targettilt2=pitchTo(player[k].coords,targetpoint); if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){ - player[k].targetrotation+=(float)(abs(Random()%100)-50)/4; + player[k].targetyaw+=(float)(abs(Random()%100)-50)/4; } if(player[k].targetanimation==staffgroundsmashanim) @@ -4160,7 +4252,7 @@ void Game::doAttacks(){ player[k].lastattack=player[k].targetanimation; if(player[k].targetanimation==swordgroundstabanim){ - player[k].targetrotation+=30; + player[k].targetyaw+=30; } } } @@ -4216,7 +4308,7 @@ void Game::doAttacks(){ } } -void Game::doPlayerCollisions(){ +void doPlayerCollisions(){ static XYZ rotatetarget; static float collisionradius; if(numplayers>1) @@ -4287,7 +4379,7 @@ void Game::doPlayerCollisions(){ player[0].coords.y=player[l].coords.y; player[l].velocity=player[0].velocity; player[l].skeleton.free=0; - player[l].rotation=0; + player[l].yaw=0; player[l].RagDoll(0); player[l].DoDamage(20); camerashake+=.3; @@ -4417,7 +4509,7 @@ void Game::doPlayerCollisions(){ } } -void Game::doAI(int i){ +void doAI(int i){ static bool connected; if(player[i].aitype!=playercontrolled&&indialogue==-1){ player[i].jumpclimb=0; @@ -4521,8 +4613,8 @@ void Game::doAI(int i){ } player[i].losupdatedelay-=multiplier; - player[i].targetrotation=roughDirectionTo(player[i].coords,pathpoint[player[i].targetpathfindpoint]); - player[i].lookrotation=player[i].targetrotation; + player[i].targetyaw=roughDirectionTo(player[i].coords,pathpoint[player[i].targetpathfindpoint]); + player[i].lookyaw=player[i].targetyaw; //reached target point if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){ @@ -4554,7 +4646,7 @@ void Game::doAI(int i){ player[i].throwkeydown=0; if(player[i].avoidcollided>.8 && !player[i].jumpkeydown && player[i].collided<.8) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); if(player[i].collided<1||player[i].targetanimation!=jumpupanim) player[i].jumpkeydown=0; @@ -4585,9 +4677,9 @@ void Game::doAI(int i){ if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0) if(player[j].coords.y1&&player[i].howactive==typeactive&&player[i].pausetime<=0){ - player[i].targetrotation=roughDirectionTo(player[i].coords,player[i].waypoints[player[i].waypoint]); - player[i].lookrotation=player[i].targetrotation; + player[i].targetyaw=roughDirectionTo(player[i].coords,player[i].waypoints[player[i].waypoint]); + player[i].lookyaw=player[i].targetyaw; player[i].aiupdatedelay=.05; if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){ @@ -4645,7 +4737,7 @@ void Game::doAI(int i){ if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){ if(!player[i].avoidsomething) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); else{ XYZ leftpos,rightpos; float leftdist,rightdist; @@ -4654,9 +4746,9 @@ void Game::doAI(int i){ leftdist = findDistancefast(&leftpos, &player[i].avoidwhere); rightdist = findDistancefast(&rightpos, &player[i].avoidwhere); if(leftdist0) if((-1==checkcollide( - DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)* + DoRotation(player[i].getJointFor(head).position,0,player[i].yaw,0)* player[i].scale+player[i].coords, - DoRotation(player[j].getJointFor(head).position,0,player[j].rotation,0)* + DoRotation(player[j].getJointFor(head).position,0,player[j].yaw,0)* player[j].scale+player[j].coords)&& !player[j].isWallJump())|| (player[j].targetanimation==hanganim&& @@ -4786,7 +4878,7 @@ void Game::doAI(int i){ if(j==-1){ player[i].velocity=0; player[i].setAnimation(player[i].getStop()); - player[i].targetrotation+=180; + player[i].targetyaw+=180; player[i].stunned=.5; //player[i].aitype=passivetype; player[i].aitype=pathfindtype; @@ -4803,8 +4895,8 @@ void Game::doAI(int i){ } //check out last seen location if(player[i].aiupdatedelay<0){ - player[i].targetrotation=roughDirectionTo(player[i].coords,player[i].lastseen); - player[i].lookrotation=player[i].targetrotation; + player[i].targetyaw=roughDirectionTo(player[i].coords,player[i].lastseen); + player[i].lookyaw=player[i].targetyaw; player[i].aiupdatedelay=.05; player[i].forwardkeydown=1; @@ -4824,7 +4916,7 @@ void Game::doAI(int i){ player[i].throwkeydown=0; if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){ - if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1); + if(!player[i].avoidsomething)player[i].targetyaw+=90*(player[i].whichdirection*2-1); else{ XYZ leftpos,rightpos; float leftdist,rightdist; @@ -4832,8 +4924,8 @@ void Game::doAI(int i){ rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0); leftdist = findDistancefast(&leftpos, &player[i].avoidwhere); rightdist = findDistancefast(&rightpos, &player[i].avoidwhere); - if(leftdist0) if((checkcollide( - DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)* + DoRotation(player[i].getJointFor(head).position,0,player[i].yaw,0)* player[i].scale+player[i].coords, - DoRotation(player[0].getJointFor(head).position,0,player[0].rotation,0)* + DoRotation(player[0].getJointFor(head).position,0,player[0].yaw,0)* player[0].scale+player[0].coords)==-1)|| (player[0].targetanimation==hanganim&&normaldotproduct( player[0].facing,player[i].coords-player[0].coords)<0)){ @@ -4951,8 +5043,8 @@ void Game::doAI(int i){ //seek out ally if(player[i].ally>0){ - player[i].targetrotation=roughDirectionTo(player[i].coords,player[player[i].ally].coords); - player[i].lookrotation=player[i].targetrotation; + player[i].targetyaw=roughDirectionTo(player[i].coords,player[player[i].ally].coords); + player[i].lookyaw=player[i].targetyaw; player[i].aiupdatedelay=.05; player[i].forwardkeydown=1; @@ -4969,7 +5061,7 @@ void Game::doAI(int i){ if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){ if(!player[i].avoidsomething) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); else{ XYZ leftpos,rightpos; float leftdist,rightdist; @@ -4978,9 +5070,9 @@ void Game::doAI(int i){ leftdist = findDistancefast(&leftpos, &player[i].avoidwhere); rightdist = findDistancefast(&rightpos, &player[i].avoidwhere); if(leftdist.8&&!player[i].jumpkeydown&&player[i].collided<.8){ if(!player[i].avoidsomething) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); else{ XYZ leftpos,rightpos; float leftdist,rightdist; @@ -5056,9 +5148,9 @@ void Game::doAI(int i){ leftdist = findDistancefast(&leftpos, &player[i].avoidwhere); rightdist = findDistancefast(&rightpos, &player[i].avoidwhere); if(leftdist5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1)) @@ -5243,7 +5335,7 @@ void Game::doAI(int i){ player[i].throwkeydown=0; if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); //attack!!! if(Random()%2==0||player[i].weaponactive!=-1||player[i].creature==wolftype) player[i].attackkeydown=1; @@ -5352,7 +5444,7 @@ void Game::doAI(int i){ player[i].pause&&player[i].damage>player[i].superpermanentdamage){ if(player[i].pause) player[i].lastseentime=1; - player[i].targetrotation=player[i].rotation; + player[i].targetyaw=player[i].yaw; player[i].forwardkeydown=0; player[i].leftkeydown=0; player[i].backkeydown=0; @@ -5368,15 +5460,15 @@ void Game::doAI(int i){ facing=0; facing.z=-1; - XYZ flatfacing=DoRotation(facing,0,player[i].rotation+180,0); + XYZ flatfacing=DoRotation(facing,0,player[i].yaw+180,0); facing=flatfacing; if(player[i].aitype==attacktypecutoff){ - player[i].targetheadrotation=180-roughDirectionTo(player[i].coords,player[0].coords); - player[i].targetheadrotation2=pitchTo(player[i].coords,player[0].coords); + player[i].targetheadyaw=180-roughDirectionTo(player[i].coords,player[0].coords); + player[i].targetheadpitch=pitchTo(player[i].coords,player[0].coords); }else if(player[i].howactive>=typesleeping){ - player[i].targetheadrotation=player[i].targetrotation; - player[i].targetheadrotation2=0; + player[i].targetheadyaw=player[i].targetyaw; + player[i].targetheadpitch=0; }else{ if(player[i].interestdelay<=0){ player[i].interestdelay=.7+(float)(abs(Random()%100))/100; @@ -5386,12 +5478,70 @@ void Game::doAI(int i){ player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300; player[i].headtarget+=player[i].facing*1.5; } - player[i].targetheadrotation=180-roughDirectionTo(player[i].coords,player[i].headtarget); - player[i].targetheadrotation2=pitchTo(player[i].coords,player[i].headtarget); + player[i].targetheadyaw=180-roughDirectionTo(player[i].coords,player[i].headtarget); + player[i].targetheadpitch=pitchTo(player[i].coords,player[i].headtarget); } } } + + +void updateSettingsMenu(){ + char sbuf[256]; + if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59) + sprintf (sbuf, "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight); + else + sprintf (sbuf, "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight); + Menu::setText(0,sbuf); + if(newdetail==0) Menu::setText(1,"Detail: Low"); + if(newdetail==1) Menu::setText(1,"Detail: Medium"); + if(newdetail==2) Menu::setText(1,"Detail: High"); + if(bloodtoggle==0) Menu::setText(2,"Blood: Off"); + if(bloodtoggle==1) Menu::setText(2,"Blood: On, low detail"); + if(bloodtoggle==2) Menu::setText(2,"Blood: On, high detail (slower)"); + if(difficulty==0) Menu::setText(3,"Difficulty: Easier"); + if(difficulty==1) Menu::setText(3,"Difficulty: Difficult"); + if(difficulty==2) Menu::setText(3,"Difficulty: Insane"); + Menu::setText(4,ismotionblur?"Blur Effects: Enabled (less compatible)":"Blur Effects: Disabled (more compatible)"); + Menu::setText(5,decals?"Decals: Enabled (slower)":"Decals: Disabled"); + Menu::setText(6,musictoggle?"Music: Enabled":"Music: Disabled"); + Menu::setText(9,invertmouse?"Invert mouse: Yes":"Invert mouse: No"); + sprintf (sbuf, "Mouse Speed: %d", (int)(usermousesensitivity*5)); + Menu::setText(10,sbuf); + sprintf (sbuf, "Volume: %d%%", (int)(volume*100)); + Menu::setText(11,sbuf); + Menu::setText(13,showdamagebar?"Damage Bar: On":"Damage Bar: Off"); + if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth) + sprintf (sbuf, "Back"); + else + sprintf (sbuf, "Back (some changes take effect next time Lugaru is opened)"); + Menu::setText(8,sbuf); +} + +void updateStereoConfigMenu(){ + char sbuf[256]; + sprintf(sbuf, "Stereo mode: %s", StereoModeName(newstereomode)); + Menu::setText(0,sbuf); + sprintf(sbuf, "Stereo separation: %.3f", stereoseparation); + Menu::setText(1,sbuf); + sprintf(sbuf, "Reverse stereo: %s", stereoreverse ? "Yes" : "No"); + Menu::setText(2,sbuf); +} + +void updateControlsMenu(){ + Menu::setText(0,(string)"Forwards: "+(keyselect==0?"_":Input::keyToChar(forwardkey))); + Menu::setText(1,(string)"Back: " +(keyselect==1?"_":Input::keyToChar(backkey))); + Menu::setText(2,(string)"Left: " +(keyselect==2?"_":Input::keyToChar(leftkey))); + Menu::setText(3,(string)"Right: " +(keyselect==3?"_":Input::keyToChar(rightkey))); + Menu::setText(4,(string)"Crouch: " +(keyselect==4?"_":Input::keyToChar(crouchkey))); + Menu::setText(5,(string)"Jump: " +(keyselect==5?"_":Input::keyToChar(jumpkey))); + Menu::setText(6,(string)"Draw: " +(keyselect==6?"_":Input::keyToChar(drawkey))); + Menu::setText(7,(string)"Throw: " +(keyselect==7?"_":Input::keyToChar(throwkey))); + Menu::setText(8,(string)"Attack: " +(keyselect==8?"_":Input::keyToChar(attackkey))); + if(debugmode) + Menu::setText(9,(string)"Console: "+(keyselect==9?"_":Input::keyToChar(consolekey))); +} + /* Values of mainmenu : 1 Main menu @@ -5407,10 +5557,157 @@ Values of mainmenu : 11 Same that 9 ??? => unused 18 stereo configuration */ - -void Game::MenuTick(){ + +void Game::LoadMenu(){ + Menu::clearMenu(); + switch(mainmenu) { + case 1: + case 2: + Menu::addImage(0,Mainmenuitems[0],150,480-128,256,128); + Menu::addButtonImage(1,Mainmenuitems[mainmenu==1?1:5],18,480-152-32,128,32); + Menu::addButtonImage(2,Mainmenuitems[2],18,480-228-32,112,32); + Menu::addButtonImage(3,Mainmenuitems[mainmenu==1?3:6],18,480-306-32,mainmenu==1?68:132,32); + break; + case 3: + Menu::addButton( 0,"",10+20,440); + Menu::addButton( 1,"",10+60,405); + Menu::addButton( 2,"",10+70,370); + Menu::addButton( 3,"",10+20-1000,335-1000); + Menu::addButton( 4,"",10 ,335); + Menu::addButton( 5,"",10+60,300); + Menu::addButton( 6,"",10+70,265); + Menu::addButton( 9,"",10 ,230); + Menu::addButton(10,"",20 ,195); + Menu::addButton(11,"",10+60,160); + Menu::addButton(13,"",30 ,125); + Menu::addButton( 7,"-Configure Controls-",10+15, 90); + Menu::addButton(12,"-Configure Stereo -",10+15, 55); + Menu::addButton(8,"Back",10,10); + updateSettingsMenu(); + break; + case 4: + Menu::addButton(0,"",10 ,400); + Menu::addButton(1,"",10+40,360); + Menu::addButton(2,"",10+40,320); + Menu::addButton(3,"",10+30,280); + Menu::addButton(4,"",10+20,240); + Menu::addButton(5,"",10+40,200); + Menu::addButton(6,"",10+40,160); + Menu::addButton(7,"",10+30,120); + Menu::addButton(8,"",10+20,80); + if(debugmode) + Menu::addButton(9,"",10+10,40); + Menu::addButton(debugmode?10:9,"Back",10,10); + updateControlsMenu(); + break; + case 5: { + LoadCampaign(); + Menu::addLabel(-1,accountactive->getName(),5,400); + Menu::addButton(1,"Tutorial",5,300); + Menu::addButton(2,"Challenge",5,240); + Menu::addButton(3,"Delete User",400,10); + Menu::addButton(4,"Main Menu",5,10); + Menu::addButton(5,"Change User",5,180); + Menu::addButton(6,"Campaign : "+accountactive->getCurrentCampaign(),200,420); + + //show campaign map + //with (2,-5) offset from old code + Menu::addImage(-1,Mainmenuitems[7],150+2,60-5,400,400); + //show levels + int numlevels = accountactive->getCampaignChoicesMade(); + numlevels += numlevels>0 ? campaignlevels[numlevels-1].nextlevel.size() : 1; + for(int i=0;i=accountactive->getCampaignChoicesMade(); + if(!active) + itemsize/=2; + + if(i>=1){ + XYZ start=campaignlevels[i-1].getCenter(); + Menu::addMapLine(start.x,start.y,midpoint.x-start.x,midpoint.y-start.y,0.5,active?1:0.5,active?1:0.5,0,0); + } + Menu::addMapMarker(NB_CAMPAIGN_MENU_ITEM+i, Mapcircletexture, + midpoint.x-itemsize/2, midpoint.y-itemsize/2, itemsize, itemsize, active?1:0.5, 0, 0); + + if(active){ + Menu::addMapLabel(-2,campaignlevels[i].description, + campaignlevels[i].getStartX()+10, + campaignlevels[i].getStartY()-4); + } + } + } break; + case 6: + Menu::addLabel(-1,"Are you sure you want to delete this user?",10,400); + Menu::addButton(1,"Yes",10,360); + Menu::addButton(2,"No",10,320); + break; + case 7: + if(Account::getNbAccounts()<8) + Menu::addButton(0,"New User",10,400); + else + Menu::addLabel(0,"No More Users",10,400); + Menu::addLabel(-2,"",20,400); + Menu::addButton(Account::getNbAccounts()+1,"Back",10,10); + for(int i=0;igetName(),10,340-20*(i+1)); + break; + case 8: + Menu::addButton(0,"Easier",10,400); + Menu::addButton(1,"Difficult",10,360); + Menu::addButton(2,"Insane",10,320); + break; + case 9: + for(int i=0;igetHighScore(i)); + for(int j=strlen(temp);j<(32-17);j++) + strcat(temp," "); + name+=temp; + sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(i)-(int)(accountactive->getFastTime(i))%60)/60)); + if((int)(accountactive->getFastTime(i))%60<10)strcat(temp,"0"); + name+=temp; + sprintf (temp, "%d",(int)(accountactive->getFastTime(i))%60); + name+=temp; + + Menu::addButton(i,name,10,400-i*25,i>accountactive->getProgress()?0.5:1,0,0); + } + + Menu::addButton(-1," High Score Best Time",10,440); + Menu::addButton(numchallengelevels,"Back",10,10); + break; + case 10: { + Menu::addLabel(0,"Congratulations!",220,330); + Menu::addLabel(1,"You have avenged your family and",140,300); + Menu::addLabel(2,"restored peace to the island of Lugaru.",110,270); + Menu::addButton(3,"Back",10,10); + char sbuf[256]; + sprintf(sbuf,"Your score: %d",(int)accountactive->getCampaignScore()); + Menu::addLabel(4,sbuf,190,200); + sprintf(sbuf,"Highest score: %d",(int)accountactive->getCampaignHighScore()); + Menu::addLabel(5,sbuf,190,180); + } break; + case 18: + Menu::addButton(0,"",70,400); + Menu::addButton(1,"",10,360); + Menu::addButton(2,"",40,320); + Menu::addButton(3,"Back",10,10); + updateStereoConfigMenu(); + break; + } +} + +extern SDL_Rect **resolutions; + +void MenuTick(){ //menu buttons - + selected=Menu::getSelected(mousecoordh*640/screenwidth,480-mousecoordv*480/screenheight); + // some specific case where we do something even if the left mouse button is not pressed. if((mainmenu==5) && (endgame==2)) { accountactive->endGame(); @@ -5418,9 +5715,15 @@ void Game::MenuTick(){ } if(mainmenu==10) endgame=2; - if( (mainmenu==18) && Input::isKeyPressed(MOUSEBUTTON2) && (selected==1) ) + if(mainmenu==18 && Input::isKeyPressed(MOUSEBUTTON2) && selected==1){ stereoseparation-=0.001; - + updateStereoConfigMenu(); + } + + static int oldmainmenu=mainmenu; + + char sbuf[256]; + if(Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus switch(mainmenu) { case 1: @@ -5467,7 +5770,6 @@ void Game::MenuTick(){ bool isCustomResolution,found; switch(selected){ case 0: - extern SDL_Rect **resolutions; isCustomResolution = true; found = false; for(int i = 0; (!found) && (resolutions[i]); i++) { @@ -5520,7 +5822,6 @@ void Game::MenuTick(){ break; case 6: musictoggle = !musictoggle; - if(musictoggle) { emit_stream_np(stream_menutheme); } else { @@ -5533,7 +5834,6 @@ void Game::MenuTick(){ musicvolume[i]=0; } } - break; case 7: // controls flash(); @@ -5543,8 +5843,7 @@ void Game::MenuTick(){ break; case 8: flash(); - - SaveSettings(*this); + SaveSettings(); mainmenu=gameon?2:1; break; case 9: @@ -5552,16 +5851,17 @@ void Game::MenuTick(){ break; case 10: usermousesensitivity+=.2; - if(usermousesensitivity>2) usermousesensitivity=.2; + if(usermousesensitivity>2) + usermousesensitivity=.2; break; case 11: volume+=.1f; - if(volume>1.0001f) volume=0; + if(volume>1.0001f) + volume=0; OPENAL_SetSFXMasterVolume((int)(volume*255)); break; case 12: flash(); - newstereomode = stereomode; mainmenu=18; keyselect=-1; @@ -5570,20 +5870,21 @@ void Game::MenuTick(){ showdamagebar = !showdamagebar; break; } + updateSettingsMenu(); break; case 4: if(!waiting) { fireSound(); - if(selectedsetCurrentCampaign(*c); } - LoadCampaign(); + LoadMenu(); break; } break; @@ -5674,7 +5975,10 @@ void Game::MenuTick(){ accountactive=Account::get(selected-1); } else if (selected == Account::getNbAccounts()+1) { flash(); - mainmenu=5; + if(accountactive) + mainmenu=5; + else + mainmenu=1; for(int j=0;j<255;j++){ displaytext[0][j]=0; } @@ -5747,6 +6051,7 @@ void Game::MenuTick(){ InitStereo(stereomode); } } + updateStereoConfigMenu(); break; } } @@ -5754,13 +6059,13 @@ void Game::MenuTick(){ if(Input::isKeyDown(SDLK_q) && Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3) { - SaveSettings(*this); + SaveSettings(); } } OPENAL_SetFrequency(channels[stream_menutheme], 22050); - if(entername) { + if(entername){ inputText(displaytext[0],&displayselected,&displaychars[0]); if(!waiting) { // the input as finished if(displaychars[0]){ // with enter @@ -5780,6 +6085,7 @@ void Game::MenuTick(){ displayselected=0; } entername=0; + LoadMenu(); } displayblinkdelay-=multiplier; @@ -5788,6 +6094,16 @@ void Game::MenuTick(){ displayblink=1-displayblink; } } + + if(entername){ + Menu::setText(0,displaytext[0],20,400,-1,-1); + Menu::setText(-2,displayblink?"_":"",20+displayselected*10,400,-1,-1); + } + + if(oldmainmenu!=mainmenu) + LoadMenu(); + oldmainmenu=mainmenu; + } void Game::Tick(){ @@ -5868,10 +6184,9 @@ void Game::Tick(){ emit_stream_np(stream_menutheme); pause_sound(leveltheme); } - LoadCampaign(); + LoadMenu(); } //escape key pressed - //TODO: there must be code somewhere else that handles clicking the Back button, merge it with this if(Input::isKeyPressed(SDLK_ESCAPE)&& (gameon||mainmenu==0||(mainmenu>=3&&mainmenu!=8&&!(mainmenu==7&&entername)))) { selected=-1; @@ -5893,7 +6208,7 @@ void Game::Tick(){ } //finished with settings menu if(mainmenu==3){ - SaveSettings(*this); + SaveSettings(); } //effects if(mainmenu>=3&&mainmenu!=8){ @@ -5968,10 +6283,9 @@ void Game::Tick(){ if(console&&!Input::isKeyDown(SDLK_LMETA)) { inputText(consoletext[0],&consoleselected,&consolechars[0]); if(!waiting) { - archiveselected=0; if(consolechars[0]>0) { consoletext[0][consolechars[0]]='\0'; - cmd_dispatch(this, consoletext[0]); + cmd_dispatch(consoletext[0]); for(int k=14;k>=1;k--) { for(int j=0;j<255;j++) consoletext[k][j]=consoletext[k-1][j]; @@ -5996,7 +6310,7 @@ void Game::Tick(){ if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3) { - SaveSettings(*this); + SaveSettings(); } } @@ -6025,10 +6339,11 @@ void Game::Tick(){ - //TODO: what is this test? if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){ //dialogues + static float talkdelay = 0; + if(indialogue!=-1) talkdelay=1; talkdelay-=multiplier; @@ -6072,8 +6387,8 @@ void Game::Tick(){ whichdialogue=i; for(int j=0;j0.5) if( Input::isKeyPressed(SDLK_1)|| Input::isKeyPressed(SDLK_2)|| @@ -6386,10 +6701,10 @@ void Game::Tick(){ dialoguetime+=multiplier; - hawkrotation+=multiplier*25; + hawkyaw+=multiplier*25; realhawkcoords=0; realhawkcoords.x=25; - realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords; + realhawkcoords=DoRotation(realhawkcoords,0,hawkyaw,0)+hawkcoords; hawkcalldelay-=multiplier/2; if(hawkcalldelay<=0){ @@ -6445,9 +6760,9 @@ void Game::Tick(){ //? for(int i=0;i1.5&& !player[j].skeleton.free&& - -1==checkcollide(DoRotation(player[j].getJointFor(head).position,0,player[j].rotation,0)*player[j].scale+player[j].coords,DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)*player[i].scale+player[i].coords)){ + -1==checkcollide(DoRotation(player[j].getJointFor(head).position,0,player[j].yaw,0)*player[j].scale+player[j].coords,DoRotation(player[i].getJointFor(head).position,0,player[i].yaw,0)*player[i].scale+player[i].coords)){ if(!player[i].isFlip()){ player[i].throwtogglekeydown=1; player[i].victim=&player[j]; player[i].setAnimation(knifethrowanim); - player[i].targetrotation=roughDirectionTo(player[i].coords,player[j].coords); + player[i].targetyaw=roughDirectionTo(player[i].coords,player[j].coords); player[i].targettilt2=pitchTo(player[i].coords,player[j].coords); } if(player[i].isFlip()){ @@ -6823,7 +7138,7 @@ void Game::Tick(){ player[i].victim=&player[j]; XYZ aim; weapons[player[i].weaponids[0]].owner=-1; - aim=player[i].victim->coords+DoRotation(player[i].victim->getJointFor(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].getJointFor(righthand).position,0,player[i].rotation,0)*player[i].scale); + aim=player[i].victim->coords+DoRotation(player[i].victim->getJointFor(abdomen).position,0,player[i].victim->yaw,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(player[i].getJointFor(righthand).position,0,player[i].yaw,0)*player[i].scale); Normalise(&aim); aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0); @@ -6931,7 +7246,7 @@ void Game::Tick(){ absflatfacing=0; absflatfacing.z=-1; - absflatfacing=DoRotation(absflatfacing,0,-rotation,0); + absflatfacing=DoRotation(absflatfacing,0,-yaw,0); } else absflatfacing=flatfacing; @@ -7047,7 +7362,7 @@ void Game::Tick(){ if(player[i].forwardkeydown){ if(player[i].isIdle()|| (player[i].isStop()&& - player[i].targetrotation==player[i].rotation)|| + player[i].targetyaw==player[i].yaw)|| (player[i].isLanding()&& player[i].targetframe>0&& !player[i].jumpkeydown)|| @@ -7080,7 +7395,7 @@ void Game::Tick(){ if (player[i].rightkeydown){ if(player[i].isIdle()|| (player[i].isStop()&& - player[i].targetrotation==player[i].rotation)|| + player[i].targetyaw==player[i].yaw)|| (player[i].isLanding()&& player[i].targetframe>0&& !player[i].jumpkeydown)|| @@ -7099,15 +7414,15 @@ void Game::Tick(){ if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){ player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0); } - player[i].targetrotation-=90; - if(player[i].forwardkeydown)player[i].targetrotation+=45; - if(player[i].backkeydown)player[i].targetrotation-=45; + player[i].targetyaw-=90; + if(player[i].forwardkeydown)player[i].targetyaw+=45; + if(player[i].backkeydown)player[i].targetyaw-=45; movekey=1; } if ( player[i].leftkeydown){ if(player[i].isIdle()|| (player[i].isStop()&& - player[i].targetrotation==player[i].rotation)|| + player[i].targetyaw==player[i].yaw)|| (player[i].isLanding()&& player[i].targetframe>0&& !player[i].jumpkeydown)|| @@ -7126,15 +7441,15 @@ void Game::Tick(){ if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){ player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0); } - player[i].targetrotation+=90; - if(player[i].forwardkeydown)player[i].targetrotation-=45; - if(player[i].backkeydown)player[i].targetrotation+=45; + player[i].targetyaw+=90; + if(player[i].forwardkeydown)player[i].targetyaw-=45; + if(player[i].backkeydown)player[i].targetyaw+=45; movekey=1; } if(player[i].backkeydown){ if(player[i].isIdle()|| (player[i].isStop()&& - player[i].targetrotation==player[i].rotation)|| + player[i].targetyaw==player[i].yaw)|| (player[i].isLanding()&& player[i].targetframe>0&& !player[i].jumpkeydown)|| @@ -7165,7 +7480,7 @@ void Game::Tick(){ player[i].grabdelay=1; } if ( !player[i].leftkeydown&&!player[i].rightkeydown) - player[i].targetrotation+=180; + player[i].targetyaw+=180; movekey=1; } if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){ @@ -7179,14 +7494,14 @@ void Game::Tick(){ player[i].targetanimation!=wolfrunninganim)||i!=0)){ player[i].jumpstart=0; player[i].setAnimation(jumpupanim); - player[i].rotation=player[i].targetrotation; + player[i].yaw=player[i].targetyaw; player[i].transspeed=20; player[i].FootLand(0,1); player[i].FootLand(1,1); facing=0; facing.z=-1; - flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0); + flatfacing=DoRotation(facing,0,player[i].targetyaw+180,0); if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale; if(!movekey)player[i].velocity=0; @@ -7269,20 +7584,20 @@ void Game::Tick(){ } } if(player[i].targetanimation==rollanim) - player[i].targetrotation=oldtargetrotation; + player[i].targetyaw=oldtargetyaw; } //Rotation for(int k=0;k180){ - if(player[k].rotation>player[k].targetrotation) - player[k].rotation-=360; + if(fabs(player[k].yaw-player[k].targetyaw)>180){ + if(player[k].yaw>player[k].targetyaw) + player[k].yaw-=360; else - player[k].rotation+=360; + player[k].yaw+=360; } //stop to turn in right direction - if(fabs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)) + if(fabs(player[k].yaw-player[k].targetyaw)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)) player[k].setAnimation(player[k].getStop()); if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim) @@ -7303,7 +7618,7 @@ void Game::Tick(){ } if(player[k].isRun()) - player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4; + player[k].targettilt=(player[k].yaw-player[k].targetyaw)/4; player[k].tilt=stepTowardf(player[k].tilt,player[k].targettilt,multiplier*150); player[k].grabdelay-=multiplier; @@ -7379,7 +7694,7 @@ void Game::Tick(){ if(Random()%2==0){ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2; if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2; - 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; + 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].yaw,0)*player[1].scale+player[1].coords; if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords; Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1); } @@ -7391,7 +7706,7 @@ void Game::Tick(){ if(Random()%2==0){ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2; if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2; - 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; + 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].yaw,0)*player[1].scale+player[1].coords; if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords; Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1); } @@ -7415,14 +7730,14 @@ void Game::Tick(){ upvector=0; upvector.z=-1; - upvector=DoRotation(upvector,-rotation2+90,0,0); - upvector=DoRotation(upvector,0,0-rotation,0); + upvector=DoRotation(upvector,-pitch+90,0,0); + upvector=DoRotation(upvector,0,0-yaw,0); facing=0; facing.z=-1; - facing=DoRotation(facing,-rotation2,0,0); - facing=DoRotation(facing,0,0-rotation,0); + facing=DoRotation(facing,-pitch,0,0); + facing=DoRotation(facing,0,0-yaw,0); static float ori[6]; @@ -7446,18 +7761,18 @@ void Game::Tick(){ void Game::TickOnce(){ if(mainmenu) - rotation+=multiplier*5; + yaw+=multiplier*5; else if(directing||indialogue==-1) { - rotation+=deltah*.7; + yaw+=deltah*.7; if(!invertmouse) - rotation2+=deltav*.7; + pitch+=deltav*.7; if(invertmouse) - rotation2-=deltav*.7; - if(rotation2>90) - rotation2=90; - if(rotation2<-70) - rotation2=-70; + pitch-=deltav*.7; + if(pitch>90) + pitch=90; + if(pitch<-70) + pitch=-70; } } @@ -7473,6 +7788,7 @@ void Game::TickOnceAfter(){ static float cameraspeed; if(!mainmenu){ + static int oldmusictype=musictype; if(environment==snowyenvironment) leveltheme=stream_snowtheme; @@ -7768,8 +8084,8 @@ void Game::TickOnceAfter(){ facing=0; facing.z=-1; - facing=DoRotation(facing,-rotation2,0,0); - facing=DoRotation(facing,0,0-rotation,0); + facing=DoRotation(facing,-pitch,0,0); + facing=DoRotation(facing,0,0-yaw,0); viewerfacing=facing; if(!cameramode){ @@ -7783,7 +8099,7 @@ void Game::TickOnceAfter(){ } target.y+=.1; } - if(player[0].skeleton.free!=2&&!autocam){ + if(player[0].skeleton.free!=2/*&&!autocam*/){ cameraspeed=20; if(findLengthfast(&player[0].velocity)>400){ cameraspeed=20+(findLength(&player[0].velocity)-20)*.96; @@ -7808,13 +8124,13 @@ void Game::TickOnceAfter(){ int i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j]; colviewer=viewer; coltarget=cameraloc; - if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col; + if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.yaw[i])!=-1)viewer=col; } if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz]) for(int j=0;j400){ @@ -7850,13 +8168,13 @@ void Game::TickOnceAfter(){ int i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j]; colviewer=viewer; coltarget=cameraloc; - if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col; + if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.yaw[i])!=-1)viewer=col; } if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz]) for(int j=0;j.8)camerashake=.8; //if(woozy>10)woozy=10; //woozy+=multiplier;