X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=99dab372a90a5850442ae0b97b3706401a20522e;hb=263a338c0c3648cfa2388d4a21584a09294ffd9e;hp=74419e6468f46b238a87a34d841a5d7114c56ef1;hpb=c44a844d9305c4f1f7dd0479e4a3af3e90b96a1b;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 74419e6..99dab37 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -29,12 +29,14 @@ 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 @@ -83,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]; @@ -117,6 +120,7 @@ extern float damagedealt; extern int maptype; extern int editoractive; extern int editorpathtype; +extern TGAImageRec texture; extern float hostiletime; @@ -137,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", @@ -187,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; @@ -201,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; @@ -255,7 +343,47 @@ 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; +} @@ -286,7 +414,7 @@ static void ch_save(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;j1)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", @@ -1331,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", @@ -1368,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", @@ -1386,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; @@ -1401,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:"; @@ -1472,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; @@ -1576,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; @@ -1617,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++; @@ -1846,7 +2018,7 @@ void Game::Loadlevel(const char *name) { int j=objects.numobjects; objects.numobjects=0; for(int i=0;itutorialmaxtime){ tutorialstage++; tutorialsuccess=0; @@ -2140,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); } @@ -2371,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); } @@ -2458,7 +2630,7 @@ void Game::doTutorial(){ } } -void Game::doDebugKeys(){ +void doDebugKeys(){ float headprop,bodyprop,armprop,legprop; if(debugmode){ if(Input::isKeyPressed(SDLK_h)){ @@ -2534,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; } @@ -2688,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; @@ -2740,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; @@ -3399,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++; } @@ -3419,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++; } } @@ -3477,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; @@ -3525,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) @@ -3541,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; @@ -3577,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) @@ -3585,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; @@ -3617,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; @@ -3683,7 +3855,7 @@ void Game::doAerialAcrobatics(){ } } -void Game::doAttacks(){ +void doAttacks(){ static XYZ relative; static int randattack; static bool playerrealattackkeydown=0; @@ -3745,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; } } @@ -3993,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&& @@ -4005,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; @@ -4014,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; @@ -4035,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; } } } @@ -4146,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) @@ -4161,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; } } } @@ -4217,7 +4389,7 @@ void Game::doAttacks(){ } } -void Game::doPlayerCollisions(){ +void doPlayerCollisions(){ static XYZ rotatetarget; static float collisionradius; if(numplayers>1) @@ -4288,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; @@ -4418,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; @@ -4522,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){ @@ -4555,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; @@ -4586,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){ @@ -4646,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; @@ -4655,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&& @@ -4787,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; @@ -4804,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; @@ -4825,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; @@ -4833,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)){ @@ -4952,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; @@ -4970,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; @@ -4979,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; @@ -5057,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)) @@ -5244,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; @@ -5353,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; @@ -5369,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; @@ -5387,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 @@ -5408,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(); @@ -5419,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: @@ -5521,7 +5902,6 @@ void Game::MenuTick(){ break; case 6: musictoggle = !musictoggle; - if(musictoggle) { emit_stream_np(stream_menutheme); } else { @@ -5534,7 +5914,6 @@ void Game::MenuTick(){ musicvolume[i]=0; } } - break; case 7: // controls flash(); @@ -5544,7 +5923,6 @@ void Game::MenuTick(){ break; case 8: flash(); - SaveSettings(); mainmenu=gameon?2:1; break; @@ -5553,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; @@ -5571,6 +5950,7 @@ void Game::MenuTick(){ showdamagebar = !showdamagebar; break; } + updateSettingsMenu(); break; case 4: if(!waiting) { @@ -5584,6 +5964,7 @@ void Game::MenuTick(){ mainmenu=3; } } + updateControlsMenu(); break; case 5: fireSound(); @@ -5649,7 +6030,7 @@ void Game::MenuTick(){ c=campaigns.begin(); accountactive->setCurrentCampaign(*c); } - LoadCampaign(); + LoadMenu(); break; } break; @@ -5674,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; } @@ -5747,6 +6131,7 @@ void Game::MenuTick(){ InitStereo(stereomode); } } + updateStereoConfigMenu(); break; } } @@ -5760,7 +6145,7 @@ void Game::MenuTick(){ 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 +6165,7 @@ void Game::MenuTick(){ displayselected=0; } entername=0; + LoadMenu(); } displayblinkdelay-=multiplier; @@ -5788,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(){ @@ -5868,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; @@ -5968,7 +6363,6 @@ 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(consoletext[0]); @@ -6025,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; @@ -6072,8 +6467,8 @@ void Game::Tick(){ whichdialogue=i; for(int j=0;j0.5) if( Input::isKeyPressed(SDLK_1)|| Input::isKeyPressed(SDLK_2)|| @@ -6386,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){ @@ -6445,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()){ @@ -6823,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); @@ -6931,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; @@ -7047,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)|| @@ -7080,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)|| @@ -7099,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)|| @@ -7126,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)|| @@ -7165,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){ @@ -7179,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; @@ -7269,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) @@ -7303,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; @@ -7379,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); } @@ -7391,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); } @@ -7415,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]; @@ -7446,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; } } @@ -7473,6 +7868,7 @@ void Game::TickOnceAfter(){ static float cameraspeed; if(!mainmenu){ + static int oldmusictype=musictype; if(environment==snowyenvironment) leveltheme=stream_snowtheme; @@ -7768,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){ @@ -7783,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; @@ -7808,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){ @@ -7850,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;