X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=99dab372a90a5850442ae0b97b3706401a20522e;hb=263a338c0c3648cfa2388d4a21584a09294ffd9e;hp=8b519880e7da4f483bddcfe830334cc7db30cd72;hpb=42bf932baf8cecf12b4daba00c4453093aa4971a;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 8b51988..99dab37 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); + LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,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; } @@ -496,7 +625,7 @@ static int find_closest() return closest; } -static void ch_sizenear(Game *game, const char *args) +static void ch_sizenear(const char *args) { int closest = find_closest(); @@ -524,12 +653,12 @@ 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) @@ -546,12 +675,12 @@ 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) @@ -568,19 +697,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) 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 +725,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], + LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin], &player[pnum].skeleton.drawmodel.textureptr,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); + 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 +767,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); + 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 +798,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,7 +807,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, + LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); player[0].creature=rabbittype; player[0].scale=.2; @@ -687,7 +816,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 +825,80 @@ 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, + LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,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, + LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,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, + LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,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, + LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,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, + LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,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, + LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,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, + LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,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, + LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,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 +906,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 +922,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 +932,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 +949,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 +1000,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 +1038,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,7 +1107,7 @@ static void ch_default(Game *game, const char *args) } player[0].numclothes=0; - game->LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin], + LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin], &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0], &player[0].skeleton.skinsize); @@ -986,7 +1115,7 @@ static void ch_default(Game *game, const char *args) 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 +1126,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 +1223,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 +1266,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 +1333,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 +1368,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 +1378,7 @@ int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){ return -1; } -void Game::Setenvironment(int which) +void Setenvironment(int which) { LOGFUNC; @@ -1292,7 +1421,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", @@ -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", @@ -1367,7 +1496,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 +1514,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()) { + LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0); + } else { + LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],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 +1578,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 +1649,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 +1748,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 +1789,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 +2018,7 @@ void Game::Loadlevel(const char *name) { int j=objects.numobjects; objects.numobjects=0; for(int i=0;itutorialmaxtime){ tutorialstage++; tutorialsuccess=0; @@ -2139,7 +2312,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 +2543,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 +2630,7 @@ void Game::doTutorial(){ } } -void Game::doDebugKeys(){ +void doDebugKeys(){ float headprop,bodyprop,armprop,legprop; if(debugmode){ if(Input::isKeyPressed(SDLK_h)){ @@ -2533,8 +2706,8 @@ void Game::doDebugKeys(){ closest=i; } } - player[closest].rotation+=multiplier*50; - player[closest].targetrotation=player[closest].rotation; + player[closest].yaw+=multiplier*50; + player[closest].targetyaw=player[closest].yaw; } @@ -2687,7 +2860,7 @@ void Game::doDebugKeys(){ if(player[closest].skeleton.free) flatvelocity2=headjoint.velocity; if(!player[closest].skeleton.free) - flatfacing2=DoRotation(DoRotation(DoRotation(headjoint.position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords; + flatfacing2=DoRotation(DoRotation(DoRotation(headjoint.position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].yaw,0)*player[closest].scale+player[closest].coords; if(player[closest].skeleton.free) flatfacing2=headjoint.position*player[closest].scale+player[closest].coords; flatvelocity2.x+=(float)(abs(Random()%100)-50)/10; @@ -2739,7 +2912,7 @@ void Game::doDebugKeys(){ for(int i=0;iterrain.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 +3571,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 +3591,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 +3649,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 +3697,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 +3713,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 +3749,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 +3757,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 +3789,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 +3855,7 @@ void Game::doAerialAcrobatics(){ } } -void Game::doAttacks(){ +void doAttacks(){ static XYZ relative; static int randattack; static bool playerrealattackkeydown=0; @@ -3744,19 +3917,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 +4165,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 +4177,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 +4186,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 +4207,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 +4318,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 +4333,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 +4389,7 @@ void Game::doAttacks(){ } } -void Game::doPlayerCollisions(){ +void doPlayerCollisions(){ static XYZ rotatetarget; static float collisionradius; if(numplayers>1) @@ -4287,7 +4460,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 +4590,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 +4694,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 +4727,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 +4758,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 +4818,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 +4827,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 +4959,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 +4976,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 +4997,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 +5005,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 +5124,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 +5142,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 +5151,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 +5229,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 +5416,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 +5525,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 +5541,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 +5559,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 +5638,155 @@ 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; + } +} + +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 +5794,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: @@ -5520,7 +5902,6 @@ void Game::MenuTick(){ break; case 6: musictoggle = !musictoggle; - if(musictoggle) { emit_stream_np(stream_menutheme); } else { @@ -5533,7 +5914,6 @@ void Game::MenuTick(){ musicvolume[i]=0; } } - break; case 7: // controls flash(); @@ -5543,8 +5923,7 @@ void Game::MenuTick(){ break; case 8: flash(); - - SaveSettings(*this); + SaveSettings(); mainmenu=gameon?2:1; break; case 9: @@ -5552,16 +5931,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,6 +5950,7 @@ void Game::MenuTick(){ showdamagebar = !showdamagebar; break; } + updateSettingsMenu(); break; case 4: if(!waiting) { @@ -5583,6 +5964,7 @@ void Game::MenuTick(){ mainmenu=3; } } + updateControlsMenu(); break; case 5: fireSound(); @@ -5648,7 +6030,7 @@ void Game::MenuTick(){ c=campaigns.begin(); accountactive->setCurrentCampaign(*c); } - LoadCampaign(); + LoadMenu(); break; } break; @@ -5673,7 +6055,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; } @@ -5746,6 +6131,7 @@ void Game::MenuTick(){ InitStereo(stereomode); } } + updateStereoConfigMenu(); break; } } @@ -5753,13 +6139,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 @@ -5779,6 +6165,7 @@ void Game::MenuTick(){ displayselected=0; } entername=0; + LoadMenu(); } displayblinkdelay-=multiplier; @@ -5787,6 +6174,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(){ @@ -5867,10 +6264,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; @@ -5892,7 +6288,7 @@ void Game::Tick(){ } //finished with settings menu if(mainmenu==3){ - SaveSettings(*this); + SaveSettings(); } //effects if(mainmenu>=3&&mainmenu!=8){ @@ -5967,10 +6363,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]; @@ -5995,7 +6390,7 @@ void Game::Tick(){ if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3) { - SaveSettings(*this); + SaveSettings(); } } @@ -6024,10 +6419,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; @@ -6071,8 +6467,8 @@ void Game::Tick(){ whichdialogue=i; for(int j=0;j0.5) if( Input::isKeyPressed(SDLK_1)|| Input::isKeyPressed(SDLK_2)|| @@ -6385,10 +6781,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){ @@ -6444,9 +6840,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()){ @@ -6822,7 +7218,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); @@ -6930,7 +7326,7 @@ void Game::Tick(){ absflatfacing=0; absflatfacing.z=-1; - absflatfacing=DoRotation(absflatfacing,0,-rotation,0); + absflatfacing=DoRotation(absflatfacing,0,-yaw,0); } else absflatfacing=flatfacing; @@ -7046,7 +7442,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)|| @@ -7079,7 +7475,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)|| @@ -7098,15 +7494,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)|| @@ -7125,15 +7521,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)|| @@ -7164,7 +7560,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){ @@ -7178,14 +7574,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; @@ -7268,20 +7664,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) @@ -7302,7 +7698,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; @@ -7378,7 +7774,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); } @@ -7390,7 +7786,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); } @@ -7414,14 +7810,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]; @@ -7445,18 +7841,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; } } @@ -7472,6 +7868,7 @@ void Game::TickOnceAfter(){ static float cameraspeed; if(!mainmenu){ + static int oldmusictype=musictype; if(environment==snowyenvironment) leveltheme=stream_snowtheme; @@ -7767,8 +8164,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){ @@ -7782,7 +8179,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; @@ -7807,13 +8204,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){ @@ -7849,13 +8248,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;