XYZ participantlocation[max_dialogues][10];
int participantfocus[max_dialogues][max_dialoguelength];
int participantaction[max_dialogues][max_dialoguelength];
-float participantrotation[max_dialogues][10];
+float participantyaw[max_dialogues][10];
XYZ participantfacing[max_dialogues][max_dialoguelength][10];
-float dialoguecamerarotation[max_dialogues][max_dialoguelength];
-float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
+float dialoguecamerayaw[max_dialogues][max_dialoguelength];
+float dialoguecamerapitch[max_dialogues][max_dialoguelength];
int indialogue;
int whichdialogue;
int directing;
int dialoguegonethrough[20];
namespace Game{
- GLuint terraintexture;
- GLuint terraintexture2;
- GLuint terraintexture3;
- GLuint screentexture;
- GLuint screentexture2;
- GLuint logotexture;
- GLuint loadscreentexture;
- GLuint Maparrowtexture;
- GLuint Mapboxtexture;
- GLuint Mapcircletexture;
- GLuint cursortexture;
- GLuint Mainmenuitems[10];
-
- int selected;
- int keyselect;
- int indemo;
-
- bool won;
-
- bool entername;
-
- char registrationname[256];
- float registrationnumber;
-
- int newdetail;
- int newscreenwidth;
- int newscreenheight;
-
- bool gameon;
- float deltah,deltav;
- int mousecoordh,mousecoordv;
- int oldmousecoordh,oldmousecoordv;
- float rotation,rotation2;
- SkyBox skybox;
- bool cameramode;
- int olddrawmode;
- int drawmode;
- bool firstload;
- bool oldbutton;
-
- float leveltime;
- float loadtime;
+ GLuint terraintexture = 0;
+ GLuint terraintexture2 = 0;
+ GLuint terraintexture3 = 0;
+ GLuint screentexture = 0;
+ GLuint screentexture2 = 0;
+ GLuint logotexture = 0;
+ GLuint loadscreentexture = 0;
+ GLuint Maparrowtexture = 0;
+ GLuint Mapboxtexture = 0;
+ GLuint Mapcircletexture = 0;
+ GLuint cursortexture = 0;
+ GLuint Mainmenuitems[10] = {};
+
+ int selected = 0;
+ int keyselect = 0;
+
+ int newdetail = 0;
+ int newscreenwidth = 0;
+ int newscreenheight = 0;
+
+ bool gameon = 0;
+ float deltah = 0;
+ float deltav = 0;
+ int mousecoordh = 0;
+ int mousecoordv = 0;
+ int oldmousecoordh = 0;
+ int oldmousecoordv = 0;
+ float yaw = 0;
+ float pitch = 0;
+ SkyBox *skybox = NULL;
+ bool cameramode = 0;
+ bool firstload = 0;
+
+ GLuint hawktexture = 0;
+ float hawkyaw = 0;
+ float hawkcalldelay = 0;
+ float leveltime = 0;
+ float loadtime = 0;
Model hawk;
XYZ hawkcoords;
XYZ realhawkcoords;
- GLuint hawktexture;
- float hawkrotation;
- float hawkcalldelay;
Model eye;
Model iris;
Model cornea;
- bool stealthloading;
-
- std::vector<CampaignLevel> campaignlevels;
- int whichchoice;
- int actuallevel;
- bool winhotspot;
- bool windialogue;
-
- bool minimap;
+ bool stealthloading = 0;
- int musictype,oldmusictype,oldoldmusictype;
- bool realthreat;
-
- Model rabbit;
- XYZ rabbitcoords;
+ int musictype = 0;
XYZ mapcenter;
- float mapradius;
-
- Text* text;
- float fps;
+ float mapradius = 0;
- XYZ cameraloc;
- float cameradist;
+ Text *text = NULL;
+ float fps = 0;
- int drawtoggle;
+ bool editorenabled = 0;
+ int editortype = 0;
+ float editorsize = 0;
+ float editoryaw = 0;
+ float editorpitch = 0;
- bool editorenabled;
- int editortype;
- float editorsize;
- float editorrotation;
- float editorrotation2;
-
- float brightness;
-
- int quit;
- int tryquit;
+ int tryquit = 0;
XYZ pathpoint[30];
- int numpathpoints;
- int numpathpointconnect[30];
- int pathpointconnect[30][30];
- int pathpointselected;
-
- int endgame;
- bool scoreadded;
- int numchallengelevels;
-
- bool console;
- int archiveselected;
- char consoletext[15][256];
- int consolechars[15];
- bool chatting;
- char displaytext[15][256];
- int displaychars[15];
- float displaytime[15];
- float displayblinkdelay;
- bool displayblink;
- int displayselected;
- bool consolekeydown;
- float consoleblinkdelay;
- bool consoleblink;
- int consoleselected;
- bool autocam;
-
- unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
- unsigned short consolekey;
- bool oldattackkey;
-
- int loading;
- float talkdelay;
+ int numpathpoints = 0;
+ int numpathpointconnect[30] = {};
+ int pathpointconnect[30][30] = {};
+ int pathpointselected = 0;
+
+ int endgame = 0;
+ bool scoreadded = 0;
+ int numchallengelevels = 0;
+
+ bool console = false;
+ char consoletext[15][256] = {};
+ int consolechars[15] = {};
+ bool chatting = 0;
+ char displaytext[15][256] = {};
+ int displaychars[15] = {};
+ float displaytime[15] = {};
+ float displayblinkdelay = 0;
+ bool displayblink = 0;
+ int displayselected = 0;
+ float consoleblinkdelay = 0;
+ bool consoleblink = 0;
+ int consoleselected = 0;
+
+ unsigned short crouchkey=0,jumpkey=0,forwardkey=0,chatkey=0,backkey=0,leftkey=0,rightkey=0,drawkey=0,throwkey=0,attackkey=0;
+ unsigned short consolekey=0;
+
+ int loading = 0;
- int numboundaries;
- XYZ boundary[360];
-
- int whichlevel;
- int oldenvironment;
- int targetlevel;
- float changedelay;
-
- float musicvolume[4];
- float oldmusicvolume[4];
- int musicselected;
- int change;
+ int oldenvironment = 0;
+ int targetlevel = 0;
+ float changedelay = 0;
- bool waiting;
- Account* accountactive;
-}
-
-void Game::newGame()
-{
- text=NULL;
- text=new Text();
-
- terraintexture = 0;
- terraintexture2 = 0;
- terraintexture3 = 0;
- screentexture = 0;
- screentexture2 = 0;
- logotexture = 0;
- loadscreentexture = 0;
- Maparrowtexture = 0;
- Mapboxtexture = 0;
- Mapcircletexture = 0;
- cursortexture = 0;
-
- memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
-
- selected = 0;
- keyselect = 0;
- indemo = 0;
-
- won = 0;
-
- entername = 0;
-
- memset(registrationname, 0, sizeof(registrationname));
- registrationnumber = 0;
-
- newdetail = 0;
- newscreenwidth = 0;
- newscreenheight = 0;
-
- gameon = 0;
- deltah = 0,deltav = 0;
- mousecoordh = 0,mousecoordv = 0;
- oldmousecoordh = 0,oldmousecoordv = 0;
- rotation = 0,rotation2 = 0;
-
-// SkyBox skybox;
-
- cameramode = 0;
- olddrawmode = 0;
- drawmode = 0;
- firstload = 0;
- oldbutton = 0;
-
- leveltime = 0;
- loadtime = 0;
-
-// Model hawk;
-
-// XYZ hawkcoords;
-// XYZ realhawkcoords;
-
- hawktexture = 0;
- hawkrotation = 0;
- hawkcalldelay = 0;
-/*
- Model eye;
- Model iris;
- Model cornea;
-*/
- stealthloading = 0;
-
- whichchoice = 0;
- actuallevel = 0;
- winhotspot = false;
- windialogue = false;
-
- minimap = 0;
-
- musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
- realthreat = 0;
-
-// Model rabbit;
-// XYZ rabbitcoords;
-
-// XYZ mapcenter;
- mapradius = 0;
-
-// Text text;
- fps = 0;
-
-// XYZ cameraloc;
- cameradist = 0;
-
- drawtoggle = 0;
-
- editorenabled = 0;
- editortype = 0;
- editorsize = 0;
- editorrotation = 0;
- editorrotation2 = 0;
-
- brightness = 0;
-
- quit = 0;
- tryquit = 0;
-
-// XYZ pathpoint[30];
- numpathpoints = 0;
- memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
- memset(pathpointconnect, 0, sizeof(pathpointconnect));
- pathpointselected = 0;
-
- endgame = 0;
- scoreadded = 0;
- numchallengelevels = 0;
-
- console = false;
- archiveselected = 0;
-
- memset(consoletext, 0, sizeof(consoletext));
- memset(consolechars, 0, sizeof(consolechars));
- chatting = 0;
- memset(displaytext, 0, sizeof(displaytext));
- memset(displaychars, 0, sizeof(displaychars));
- memset(displaytime, 0, sizeof(displaytime));
- displayblinkdelay = 0;
- displayblink = 0;
- displayselected = 0;
- consolekeydown = 0;
- consoleblinkdelay = 0;
- consoleblink = 0;
- consoleselected = 0;
- autocam = 0;
-
- crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
- consolekey = 0;
- oldattackkey = 0;
-
- loading = 0;
- talkdelay = 0;
-
- numboundaries = 0;
-// XYZ boundary[360];
-
- whichlevel = 0;
- oldenvironment = 0;
- targetlevel = 0;
- changedelay = 0;
-
- memset(musicvolume, 0, sizeof(musicvolume));
- memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
- musicselected = 0;
- change = 0;
-
-//------------
-
- waiting = false;
- mainmenu = 0;
-
- accountactive = NULL;
-}
-
-void Game::deleteGame(){
- if(text)
- delete text;
- for(int i=0;i<10;i++){
- if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
- }
- glDeleteTextures( 1, &cursortexture );
- glDeleteTextures( 1, &Maparrowtexture );
- glDeleteTextures( 1, &Mapboxtexture );
- glDeleteTextures( 1, &Mapcircletexture );
- glDeleteTextures( 1, &terraintexture );
- glDeleteTextures( 1, &terraintexture2 );
- if(screentexture>0)glDeleteTextures( 1, &screentexture );
- if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
- glDeleteTextures( 1, &hawktexture );
- glDeleteTextures( 1, &logotexture );
- glDeleteTextures( 1, &loadscreentexture );
-
- Dispose();
+ bool waiting = false;
+ Account* accountactive = NULL;
}
void Game::fireSound(int sound) {
}
}
-void Game::setKeySelected() {
- waiting=true;
- printf("launch thread\n");
- SDL_Thread* thread = SDL_CreateThread(Game::setKeySelected_thread,NULL);
- if ( thread == NULL ) {
- fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
- waiting=false;
- return;
- }
-}
-
-int Game::setKeySelected_thread(void* data) {
+int setKeySelected_thread(void* data) {
+ using namespace Game;
int keycode=-1;
SDL_Event evenement;
while(keycode==-1) {
return 0;
}
-void Game::DrawGL() {
- if ( stereomode == stereoNone ) {
- DrawGLScene(stereoCenter);
- } else {
- DrawGLScene(stereoLeft);
- DrawGLScene(stereoRight);
- }
+void Game::setKeySelected() {
+ waiting=true;
+ printf("launch thread\n");
+ SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread,NULL);
+ if ( thread == NULL ) {
+ fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
+ waiting=false;
+ return;
+ }
}
#define NB_CAMPAIGN_MENU_ITEM 7
-extern GLuint rabbittexture;
-
-struct TextureInfo;
-
-class CampaignLevel
-{
-private:
- int width;
- struct Position
- {
- int x;
- int 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<int> 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<numnext;j++) {
- is.ignore(256,':');
- is >> 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;
- }
-};
-
-namespace Game
-{
- //public:
+namespace Game {
extern GLuint terraintexture;
extern GLuint terraintexture2;
extern GLuint terraintexture3;
extern int selected;
extern int keyselect;
- extern int indemo;
-
- extern bool won;
-
- extern bool entername;
-
- extern char registrationname[256];
- extern float registrationnumber;
extern int newdetail;
extern int newscreenwidth;
extern float deltah,deltav;
extern int mousecoordh,mousecoordv;
extern int oldmousecoordh,oldmousecoordv;
- extern float rotation,rotation2;
- extern SkyBox skybox;
+ extern float yaw,pitch;
+ extern SkyBox *skybox;
extern bool cameramode;
- extern int olddrawmode;
- extern int drawmode;
extern bool firstload;
- extern bool oldbutton;
extern float leveltime;
extern float loadtime;
extern XYZ hawkcoords;
extern XYZ realhawkcoords;
extern GLuint hawktexture;
- extern float hawkrotation;
+ extern float hawkyaw;
extern float hawkcalldelay;
extern Model eye;
extern Model cornea;
extern bool stealthloading;
+ extern int loading;
- extern std::vector<CampaignLevel> campaignlevels;
- extern int whichchoice;
- extern int actuallevel;
- extern bool winhotspot;
- extern bool windialogue;
-
- extern bool minimap;
-
- extern int musictype,oldmusictype,oldoldmusictype;
- extern bool realthreat;
-
- extern Model rabbit;
- extern XYZ rabbitcoords;
+ extern int musictype;
extern XYZ mapcenter;
extern float mapradius;
- extern Text* text;
+ extern Text *text;
extern float fps;
- extern XYZ cameraloc;
- extern float cameradist;
-
- extern int drawtoggle;
-
extern bool editorenabled;
extern int editortype;
extern float editorsize;
- extern float editorrotation;
- extern float editorrotation2;
-
- extern float brightness;
+ extern float editoryaw;
+ extern float editorpitch;
- extern int quit;
extern int tryquit;
extern XYZ pathpoint[30];
extern int numchallengelevels;
extern bool console;
- extern int archiveselected;
extern char consoletext[15][256];
extern int consolechars[15];
extern bool chatting;
extern float displayblinkdelay;
extern bool displayblink;
extern int displayselected;
- extern bool consolekeydown;
extern float consoleblinkdelay;
extern bool consoleblink;
extern int consoleselected;
- extern bool autocam;
+
+ extern int oldenvironment;
+ extern int targetlevel;
+ extern float changedelay;
+
+ extern bool waiting;
+ extern Account* accountactive;
extern unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
extern unsigned short consolekey;
- extern bool oldattackkey;
+
+ void newGame();
+ void deleteGame();
void LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha);
void LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
- void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
- bool AddClothes(const char *fileName, GLubyte *array);
void InitGame();
- void LoadScreenTexture();
void LoadStuff();
void LoadingScreen();
- void LoadCampaign();
- std::vector<std::string> ListCampaigns();
- void FadeLoadingScreen(float howmuch);
- void Dispose();
int DrawGLScene(StereoSide side);
- void DrawMenu();
- void DrawGL();
void LoadMenu();
- //factored from Tick() -sf17k
- void MenuTick();
- void doTutorial();
- void doDebugKeys();
- void doJumpReversals();
- void doAerialAcrobatics();
- void doAttacks();
- void doPlayerCollisions();
- void doAI(int i);
- //end factored
void Tick();
void TickOnce();
void TickOnceAfter();
void SetUpLighting();
- void Loadlevel(int which);
- void Loadlevel(const char *name);
- void Setenvironment(int which);
GLvoid ReSizeGLScene(float fov, float near);
- int findPathDist(int start,int end);
int checkcollide(XYZ startpoint, XYZ endpoint);
int checkcollide(XYZ startpoint, XYZ endpoint, int what);
- extern int loading;
- extern float talkdelay;
void fireSound(int sound=fireendsound);
void setKeySelected();
- extern int numboundaries;
- extern XYZ boundary[360];
-
- extern int whichlevel;
- extern int oldenvironment;
- extern int targetlevel;
- extern float changedelay;
-
- extern float musicvolume[4];
- extern float oldmusicvolume[4];
- extern int musicselected;
- extern int change;
- void newGame();
- void deleteGame();
- extern bool waiting;
- //private:
- int setKeySelected_thread(void*);
- int thread(void *data);
void inputText(char* str, int* charselected, int* nb_chars);
void flash();
- //bool waiting;
- extern Account* accountactive;
}
#ifndef __forceinline
extern XYZ participantlocation[max_dialogues][10];
extern int participantfocus[max_dialogues][max_dialoguelength];
extern int participantaction[max_dialogues][max_dialoguelength];
-extern float participantrotation[max_dialogues][10];
+extern float participantyaw[max_dialogues][10];
extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
-extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
-extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
+extern float dialoguecamerayaw[max_dialogues][max_dialoguelength];
+extern float dialoguecamerapitch[max_dialogues][max_dialoguelength];
extern int indialogue;
extern int whichdialogue;
extern int directing;
#include "Awards.h"
#include "Menu.h"
-#include <dirent.h>
-
-using namespace std;
-
extern XYZ viewer;
extern int environment;
extern float texscale;
extern bool showdamagebar;
+
+
+int drawtoggle = 0;
+int numboundaries = 0;
+XYZ boundary[360];
+int change = 0;
+
+
+
enum drawmodes {
normalmode, motionblurmode, radialzoommode,
realmotionblurmode, doublevisionmode, glowmode,
flashamount=1;
flashdelay=1;
}
+
+void DrawMenu();
+
/*********************> DrawGLScene() <*****/
int Game::DrawGLScene(StereoSide side)
-{
+{
static float texcoordwidth,texcoordheight;
static float texviewwidth, texviewheight;
static int i,j,k,l;
static char string[256]="";
static char string2[256]="";
static char string3[256]="";
+ static int drawmode = 0;
if ( stereomode == stereoAnaglyph ) {
switch(side) {
static int changed;
changed=0;
- olddrawmode=drawmode;
+ int olddrawmode=drawmode;
if(ismotionblur&&!loading){
if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
drawmode=motionblurmode;
static XYZ terrainlight;
static float distance;
if(drawmode==normalmode)
- ReSizeGLScene(90,.1f);
+ Game::ReSizeGLScene(90,.1f);
if(drawmode!=normalmode)
glViewport(0,0,texviewwidth,texviewheight);
glDepthFunc(GL_LEQUAL);
//shake
glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
//sway
- glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
- glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
+ glRotatef(pitch+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
+ glRotatef(yaw+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
}
if(cameramode||freeze||winfreeze){
- glRotatef(rotation2,1,0,0);
- glRotatef(rotation,0,1,0);
+ glRotatef(pitch,1,0,0);
+ glRotatef(yaw,0,1,0);
}
if(environment==desertenvironment){
glRotatef((float)(abs(Random()%100))/1000,1,0,0);
glRotatef((float)(abs(Random()%100))/1000,0,1,0);
}
- skybox.draw();
+ skybox->draw();
glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
glPopMatrix();
glTranslatef(-viewer.x,-viewer.y,-viewer.z);
if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y+player[k].scale*3,player[k].coords.z,player[k].scale*7)&&player[k].occluded<25)
for(i=0;i<player[k].skeleton.num_joints;i++){
if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
- point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
+ point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].yaw,0)*player[k].scale+player[k].coords;
size=.4f;
opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
if(k!=0&&tutoriallevel==1){
for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
- point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+ point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].yaw,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.yaw[j],0);
size=.4f;
opacity=.4f;
if(k!=0&&tutoriallevel==1){
if(player[k].skeleton.free)
point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
else
- point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
+ point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].yaw,0)*player[k].scale+player[k].coords;
size=.4f;
opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
if(k!=0&&tutoriallevel==1){
for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
- if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
- else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+ if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.yaw[j],0);
+ else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].yaw,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.yaw[j],0);
size=.4f;
opacity=.4f;
if(k!=0&&tutoriallevel==1){
terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
- point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+ point=DoRotation(player[k].coords-objects.position[j],0,-objects.yaw[j],0);
size=.7;
opacity=.4f;
objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
if(distance>=1)
glDisable(GL_BLEND);
if(distance>=.5){
- checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
+ checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].yaw,0)*player[k].scale+player[k].coords;
checkpoint.y+=1;
if(!player[k].occluded==0)
i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
- glRotatef(hawkrotation,0,1,0);
+ glRotatef(hawkyaw,0,1,0);
glTranslatef(25,0,0);
distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
if(distance>=1)
glDisable(GL_BLEND);
if(distance>=.5){
- checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
+ checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].yaw,0)*player[k].scale+player[k].coords;
checkpoint.y+=1;
if(!player[k].occluded==0)
i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
whichdialogue=hotspottype[closest]-20;
for(j=0;j<numdialogueboxes[whichdialogue];j++){
player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
- player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
- player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
+ player[participantfocus[whichdialogue][j]].yaw=participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
+ player[participantfocus[whichdialogue][j]].targetyaw=participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
player[participantfocus[whichdialogue][j]].velocity=0;
player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
player[participantfocus[whichdialogue][j]].targetframe=0;
sprintf (string, "The framespersecond is %d.",(int)(fps));
text->glPrint(10,30,string,0,.8,1024,768);
- sprintf (string, "Name: %s", registrationname);
- text->glPrint(10,260,string,0,.8,1024,768);
-
-
if(editorenabled)
sprintf (string, "Map editor enabled.");
else
if(editorenabled){
sprintf (string, "Object size: %f",editorsize);
text->glPrint(10,75,string,0,.8,1024,768);
- if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
- else sprintf (string, "Object rotation: Random");
+ if(editoryaw>=0)sprintf (string, "Object yaw: %f",editoryaw);
+ else sprintf (string, "Object yaw: Random");
text->glPrint(10,90,string,0,.8,1024,768);
- if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
- else sprintf (string, "Object rotation2: Random");
+ if(editorpitch>=0)sprintf (string, "Object pitch: %f",editorpitch);
+ else sprintf (string, "Object pitch: Random");
text->glPrint(10,105,string,0,.8,1024,768);
sprintf (string, "Object type: %d",editortype);
text->glPrint(10,120,string,0,.8,1024,768);
}
}
- if(minimap&&indialogue==-1){
+ if(difficulty<2&&indialogue==-1){ // minimap
float mapviewdist = 20000;
glDisable(GL_DEPTH_TEST);
glPushMatrix();
glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
glPopMatrix();
- glRotatef(player[0].lookrotation*-1+180,0,0,1);
+ glRotatef(player[0].lookyaw*-1+180,0,0,1);
glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
for(i=0;i<objects.numobjects;i++){
if(objects.type[i]==treetrunktype){
glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
glPushMatrix();
glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
- glRotatef(objects.rotation[i],0,0,1);
+ glRotatef(objects.yaw[i],0,0,1);
glScalef(.003,.003,.003);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
glPushMatrix();
glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
- glRotatef(objects.rotation[i],0,0,1);
+ glRotatef(objects.yaw[i],0,0,1);
glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
else glColor4f(1,1,0,1);
glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
- glRotatef(player[i].rotation+180,0,0,1);
+ glRotatef(player[i].yaw+180,0,0,1);
glScalef(.005,.005,.005);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
}
glClear(GL_DEPTH_BUFFER_BIT);
- ReSizeGLScene(90,.1f);
+ Game::ReSizeGLScene(90,.1f);
glViewport(0,0,screenwidth,screenheight);
if(drawmode!=normalmode){
return 0;
}
-vector<string> Game::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<string> 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 Game::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<numlevels;i++) {
- CampaignLevel cl;
- ipstream >> 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();
- }
-}
-
-void Game::DrawMenu() {
+void DrawMenu() {
// !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
SDL_Delay(15);
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- ReSizeGLScene(90,.1f);
+ Game::ReSizeGLScene(90,.1f);
//draw menu background
glClear(GL_DEPTH_BUFFER_BIT);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
+ glBindTexture( GL_TEXTURE_2D, Game::Mainmenuitems[4]);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(-1,-1,0);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glPopMatrix();
- if(!waiting) { // hide the cursor while waiting for a key
+ if(!Game::waiting) { // hide the cursor while waiting for a key
glPushMatrix();
- glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
+ glTranslatef(Game::mousecoordh-screenwidth/2,Game::mousecoordv*-1+screenheight/2,0);
glScalef((float)screenwidth/64,(float)screenwidth/64,1);
glTranslatef(1,-1,0);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1,1,1,1);
- glBindTexture( GL_TEXTURE_2D, cursortexture);
+ glBindTexture( GL_TEXTURE_2D, Game::cursortexture);
glPushMatrix();
//glScalef(.25,.25,.25);
glBegin(GL_QUADS);
extern float viewdistance;
extern XYZ viewer;
extern XYZ lightlocation;
-extern float lightambient[3],lightbrightness[3];
extern float fadestart;
extern float texscale;
extern float gravity;
extern char dialoguetext[20][20][128];
extern char dialoguename[20][20][64];
extern XYZ dialoguecamera[20][20];
-extern float dialoguecamerarotation[20][20];
-extern float dialoguecamerarotation2[20][20];
+extern float dialoguecamerayaw[20][20];
+extern float dialoguecamerapitch[20][20];
extern int indialogue;
extern int whichdialogue;
extern float dialoguetime;
// !!! FIXME: write me.
}
-void Game::Dispose()
+void Dispose()
{
LOGFUNC;
- if(endgame==2){
- accountactive->endGame();
- endgame=0;
+ if(Game::endgame==2){
+ Game::accountactive->endGame();
+ Game::endgame=0;
}
- Account::saveFile(":Data:Users", accountactive);
+ Account::saveFile(":Data:Users", Game::accountactive);
//textures.clear();
#endif
}
+void Game::newGame(){
+ text = new Text();
+ skybox = new SkyBox();
+}
+
+void Game::deleteGame(){
+ if(skybox)
+ delete skybox;
+ if(text)
+ delete text;
+ for(int i=0;i<10;i++){
+ if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
+ }
+ glDeleteTextures( 1, &cursortexture );
+ glDeleteTextures( 1, &Maparrowtexture );
+ glDeleteTextures( 1, &Mapboxtexture );
+ glDeleteTextures( 1, &Mapcircletexture );
+ glDeleteTextures( 1, &terraintexture );
+ glDeleteTextures( 1, &terraintexture2 );
+ if(screentexture>0)glDeleteTextures( 1, &screentexture );
+ if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
+ glDeleteTextures( 1, &hawktexture );
+ glDeleteTextures( 1, &logotexture );
+ glDeleteTextures( 1, &loadscreentexture );
+
+ Dispose();
+}
+
+
void Game::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) {
*textureid = Texture::Load(fileName,mipmap,hasalpha);
*textureid = Texture::Load(fileName,mipmap,false,array,skinsize);
}
-void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
+void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
{
int i;
int bytesPerPixel;
}
}
-bool Game::AddClothes(const char *fileName, GLubyte *array)
-{
- int i;
- int bytesPerPixel;
-
- LOGFUNC;
-
- //upload_image( fileName );
- //LoadTGA( fileName );
- //Load Image
- unsigned char fileNamep[256];
- CopyCStringToPascal(fileName,fileNamep);
- //Load Image
- 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;
-
- bytesPerPixel=texture.bpp/8;
-
- int tempnum=0;
- alphanum=255;
- for(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;
-}
//***************> ResizeGLScene() <******/
}
}
-void Game::FadeLoadingScreen(float howmuch)
+void FadeLoadingScreen(float howmuch)
{
static float loadprogress;
LOGFUNC;
- autocam=0;
-
numchallengelevels=14;
accountactive=Account::loadFile(":Data:Users");
}
-void Game::LoadScreenTexture() {
+void LoadScreenTexture() {
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
- if(!screentexture)
- glGenTextures( 1, &screentexture );
+ if(!Game::screentexture)
+ glGenTextures( 1, &Game::screentexture );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, screentexture);
+ glBindTexture( GL_TEXTURE_2D, Game::screentexture);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
}
+//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
void Game::LoadStuff()
{
static float temptexdetail;
viewdistdetail=2;
viewdistance=50*megascale*viewdistdetail;
- brightness=100;
-
if(detail==2){
texdetail=1;
}
LoadTexture(":Data:Textures:leaf.png",&Sprite::leaftexture,1,1);
LoadTexture(":Data:Textures:tooth.png",&Sprite::toothtexture,1,1);
- rotation=0;
- rotation2=0;
+ yaw=0;
+ pitch=0;
ReSizeGLScene(90,.01);
viewer=0;
firstload=0;
- rabbitcoords=player[0].coords;
- rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
-
loadAllAnimations();
//Fix knife stab, too lazy to do it manually
XYZ moveamount;
#include <limits>
#include <ctime>
+#include <dirent.h>
#include "Game.h"
#include "openal_wrapper.h"
#include "Settings.h"
extern int maptype;
extern int editoractive;
extern int editorpathtype;
+extern TGAImageRec texture;
extern float hostiletime;
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<int> 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<numnext;j++) {
+ is.ignore(256,':');
+ is >> 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<CampaignLevel> 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",
-// 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;
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)<by) return to;
else if(from>to) return from-by;
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;
+}
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;j<player[0].num_weapons;j++)
fpackf(tfile, "Bi", weapons[player[0].weaponids[j]].getType());
fpackf(tfile, "Bi", dialoguetype[k]);
for(int l=0;l<10;l++){
fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
- fpackf(tfile, "Bf", participantrotation[k][l]);
+ fpackf(tfile, "Bf", participantyaw[k][l]);
}
for(int l=0;l<numdialogueboxes[k];l++){
fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
for(int m=0;m<10;m++)
fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
- fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
+ fpackf(tfile, "Bf Bf",dialoguecamerayaw[k][l],dialoguecamerapitch[k][l]);
}
}
fpackf(tfile, "Bi", objects.numobjects);
for(int k=0;k<objects.numobjects;k++)
- fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", objects.type[k], objects.rotation[k], objects.rotation2[k],
+ fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", objects.type[k], objects.yaw[k], objects.pitch[k],
objects.position[k].x, objects.position[k].y, objects.position[k].z, objects.scale[k]);
fpackf(tfile, "Bi", numhotspots);
for(int j=1;j<numplayers;j++){
fpackf(tfile, "Bi Bi Bf Bf Bf Bi Bi Bf Bb Bf", player[j].whichskin, player[j].creature,
player[j].coords.x, player[j].coords.y, player[j].coords.z,
- player[j].num_weapons, player[j].howactive, player[j].scale, player[j].immobile, player[j].rotation);
+ player[j].num_weapons, player[j].howactive, player[j].scale, player[j].immobile, player[j].yaw);
if(player[j].num_weapons<5)
for(int k=0;k<player[j].num_weapons;k++)
fpackf(tfile, "Bi", weapons[player[j].weaponids[k]].getType());
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(const char *args)
for(int i=0;i<numdialogueboxes[whichdialogue];i++){
player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
- player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
- player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
+ player[participantfocus[whichdialogue][i]].yaw=participantyaw[whichdialogue][participantfocus[whichdialogue][i]];
+ player[participantfocus[whichdialogue][i]].targetyaw=participantyaw[whichdialogue][participantfocus[whichdialogue][i]];
player[participantfocus[whichdialogue][i]].velocity=0;
player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
player[participantfocus[whichdialogue][i]].targetframe=0;
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;
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;
}
}
}
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;
}
}
}
return -1;
}
-void Game::Setenvironment(int which)
+void Setenvironment(int which)
{
LOGFUNC;
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",
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",
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",
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<numlevels;i++) {
+ CampaignLevel cl;
+ ipstream >> 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<string> 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<string> 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;
Loadlevel("mapsave");
}
-void Game::Loadlevel(const char *name) {
+void Loadlevel(const char *name) {
int templength;
float lamefloat;
static const char *pfx = ":Data:Maps:";
if(accountactive)
difficulty=accountactive->getDifficulty();
- if(difficulty!=2)
- minimap=1;
- else
- minimap=0;
-
numhotspots=0;
currenthotspot=-1;
bonustime=1;
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;
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<numdialogueboxes[k];l++){
funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
for(m=0;m<10;m++)
funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
- funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
+ funpackf(tfile, "Bf Bf",&dialoguecamerayaw[k][l],&dialoguecamerapitch[k][l]);
}
}
}else
funpackf(tfile, "Bi", &objects.numobjects);
for(int i=0;i<objects.numobjects;i++){
- funpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", &objects.type[i],&objects.rotation[i],&objects.rotation2[i], &objects.position[i].x, &objects.position[i].y, &objects.position[i].z,&objects.scale[i]);
+ funpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", &objects.type[i],&objects.yaw[i],&objects.pitch[i], &objects.position[i].x, &objects.position[i].y, &objects.position[i].z,&objects.scale[i]);
if(objects.type[i]==treeleavestype)
objects.scale[i]=objects.scale[i-1];
}
else
player[i-howmanyremoved].immobile=0;
if(mapvers>=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++;
int j=objects.numobjects;
objects.numobjects=0;
for(int i=0;i<j;i++){
- objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
+ objects.MakeObject(objects.type[i],objects.position[i],objects.yaw[i],objects.pitch[i],objects.scale[i]);
if(visibleloading)
LoadingScreen();
}
player[0].armorlow*=1.5;
cameraloc=player[0].coords;
cameraloc.y+=5;
- rotation=player[0].rotation;
+ yaw=player[0].yaw;
hawkcoords=player[0].coords;
hawkcoords.y+=30;
visibleloading=0;
}
-void Game::doTutorial(){
+void doTutorial(){
if(tutorialstagetime>tutorialmaxtime){
tutorialstage++;
tutorialsuccess=0;
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);
}
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);
}
}
}
-void Game::doDebugKeys(){
+void doDebugKeys(){
float headprop,bodyprop,armprop,legprop;
if(debugmode){
if(Input::isKeyPressed(SDLK_h)){
closest=i;
}
}
- player[closest].rotation+=multiplier*50;
- player[closest].targetrotation=player[closest].rotation;
+ player[closest].yaw+=multiplier*50;
+ player[closest].targetyaw=player[closest].yaw;
}
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;
for(int i=0;i<player[closest].skeleton.num_joints; i++){
if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
- if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
+ if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].yaw,0)*player[closest].scale+player[closest].coords;
if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
for(int i=0;i<player[closest].skeleton.num_joints; i++){
if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
- if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
+ if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].yaw,0)*player[closest].scale+player[closest].coords;
if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
for(int i=0;i<player[closest].skeleton.num_joints; i++){
if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
- if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
+ if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].yaw,0)*player[closest].scale+player[closest].coords;
if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
for(int i=0;i<player[closest].skeleton.num_joints; i++){
if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
- if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
+ if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].yaw,0)*player[closest].scale+player[closest].coords;
if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
//objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
float temprotat,temprotat2;
- temprotat=editorrotation;
- temprotat2=editorrotation2;
+ temprotat=editoryaw;
+ temprotat2=editorpitch;
if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
if(temprotat2<0)temprotat2=Random()%360;
objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
if(editortype==treetrunktype)
- objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
+ objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editoryaw-((int)editoryaw)%30,editorpitch,editorsize);
}
}
player[numplayers].bled=0;
player[numplayers].speed=1+(float)(Random()%100)/1000;
- player[numplayers].targetrotation=player[0].targetrotation;
- player[numplayers].rotation=player[0].rotation;
+ player[numplayers].targetyaw=player[0].targetyaw;
+ player[numplayers].yaw=player[0].yaw;
player[numplayers].velocity=0;
player[numplayers].coords=player[0].coords;
}
if(Input::isKeyDown(SDLK_LEFT)&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
- editorrotation-=multiplier*100;
- if(editorrotation<-.01)editorrotation=-.01;
+ editoryaw-=multiplier*100;
+ if(editoryaw<-.01)editoryaw=-.01;
}
if(Input::isKeyDown(SDLK_RIGHT)&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
- editorrotation+=multiplier*100;
+ editoryaw+=multiplier*100;
}
if(Input::isKeyDown(SDLK_UP)&&!Input::isKeyDown(SDLK_LCTRL)){
mapradius+=multiplier*10;
}
if(Input::isKeyDown(SDLK_UP)&&Input::isKeyDown(SDLK_LCTRL)){
- editorrotation2+=multiplier*100;
+ editorpitch+=multiplier*100;
}
if(Input::isKeyDown(SDLK_DOWN)&&Input::isKeyDown(SDLK_LCTRL)){
- editorrotation2-=multiplier*100;
- if(editorrotation2<-.01)editorrotation2=-.01;
+ editorpitch-=multiplier*100;
+ if(editorpitch<-.01)editorpitch=-.01;
}
if(Input::isKeyPressed(SDLK_DELETE)&&objects.numobjects&&Input::isKeyDown(SDLK_LSHIFT)){
int closest=-1;
}
}
-void Game::doJumpReversals(){
+void doJumpReversals(){
for(int k=0;k<numplayers;k++)
for(int i=k;i<numplayers;i++){
if(i==k)continue;
player[i].target=0;
player[k].oldcoords=player[k].coords;
player[i].coords=player[k].coords;
- player[k].targetrotation=player[i].targetrotation;
- player[k].rotation=player[i].targetrotation;
+ player[k].targetyaw=player[i].targetyaw;
+ player[k].yaw=player[i].targetyaw;
if(player[k].aitype==attacktypecutoff)
player[k].stunned=.5;
}
player[k].target=0;
player[i].oldcoords=player[i].coords;
player[k].coords=player[i].coords;
- player[i].targetrotation=player[k].targetrotation;
- player[i].rotation=player[k].targetrotation;
+ player[i].targetyaw=player[k].targetyaw;
+ player[i].yaw=player[k].targetyaw;
if(player[i].aitype==attacktypecutoff)
player[i].stunned=.5;
}
}
}
-void Game::doAerialAcrobatics(){
+void doAerialAcrobatics(){
static XYZ facing,flatfacing;
for(int k=0;k<numplayers;k++){
player[k].turnspeed=500;
if((player[k].isRun()&&
- ((player[k].targetrotation!=rabbitrunninganim&&
- player[k].targetrotation!=wolfrunninganim)||
+ ((player[k].targetyaw!=rabbitrunninganim&&
+ player[k].targetyaw!=wolfrunninganim)||
player[k].targetframe==4))||
player[k].targetanimation==removeknifeanim||
player[k].targetanimation==crouchremoveknifeanim||
player[k].targetanimation==flipanim||
player[k].targetanimation==fightsidestep||
player[k].targetanimation==walkanim){
- player[k].rotation=stepTowardf(player[k].rotation, player[k].targetrotation, multiplier*player[k].turnspeed);
+ player[k].yaw=stepTowardf(player[k].yaw, player[k].targetyaw, multiplier*player[k].turnspeed);
}
player[k].targetanimation!=rabbitkickanim&&
(player[k].targetanimation!=crouchstabanim||player[k].hasvictim)&&
(player[k].targetanimation!=swordgroundstabanim||player[k].hasvictim))){
- player[k].rotation=stepTowardf(player[k].rotation, player[k].targetrotation, multiplier*player[k].turnspeed*2);
+ player[k].yaw=stepTowardf(player[k].yaw, player[k].targetyaw, multiplier*player[k].turnspeed*2);
}
if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
- player[k].rotation=stepTowardf(player[k].rotation, player[k].targetrotation, multiplier*player[k].turnspeed*4);
+ player[k].yaw=stepTowardf(player[k].yaw, player[k].targetyaw, multiplier*player[k].turnspeed*4);
}
/*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/
if( player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)&&
player[k].coords.y>terrain.getHeight(player[k].coords.x,player[k].coords.z)-.1)
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;
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++;
}
{
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++;
}
}
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;
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)
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;
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)
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;
}
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;
}
}
-void Game::doAttacks(){
+void doAttacks(){
static XYZ relative;
static int randattack;
static bool playerrealattackkeydown=0;
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;
}
}
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&&
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;
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;
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;
}
}
}
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)
player[k].lastattack=player[k].targetanimation;
if(player[k].targetanimation==swordgroundstabanim){
- player[k].targetrotation+=30;
+ player[k].targetyaw+=30;
}
}
}
}
}
-void Game::doPlayerCollisions(){
+void doPlayerCollisions(){
static XYZ rotatetarget;
static float collisionradius;
if(numplayers>1)
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;
}
}
-void Game::doAI(int i){
+void doAI(int i){
static bool connected;
if(player[i].aitype!=playercontrolled&&indialogue==-1){
player[i].jumpclimb=0;
}
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){
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;
if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
if(!player[j].isWallJump()&&-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].targetanimation==hanganim&&
normaldotproduct(player[j].facing,player[i].coords-player[j].coords)<0)){
if(player[i].aiupdatedelay<0){
if(player[i].numwaypoints>1&&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){
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;
leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
if(leftdist<rightdist)
- player[i].targetrotation+=90;
+ player[i].targetyaw+=90;
else
- player[i].targetrotation-=90;
+ player[i].targetyaw-=90;
}
}
}
if(findDistancefast(&player[i].coords,&player[j].coords)<400)
if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
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&&
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;
}
//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;
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;
rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
- if(leftdist<rightdist)player[i].targetrotation+=90;
- else player[i].targetrotation-=90;
+ if(leftdist<rightdist)player[i].targetyaw+=90;
+ else player[i].targetyaw-=90;
}
}
}
if(findDistancefast(&player[i].coords,&player[0].coords)<400)
if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
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)){
//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;
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;
leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
if(leftdist<rightdist)
- player[i].targetrotation+=90;
+ player[i].targetyaw+=90;
else
- player[i].targetrotation-=90;
+ player[i].targetyaw-=90;
}
}
}
player[i].lastseentime=1;
}
//TODO: factor these out as moveToward()
- player[i].targetrotation=roughDirectionTo(player[i].coords,weapons[player[i].ally].position);
- player[i].lookrotation=player[i].targetrotation;
+ player[i].targetyaw=roughDirectionTo(player[i].coords,weapons[player[i].ally].position);
+ player[i].lookyaw=player[i].targetyaw;
player[i].aiupdatedelay=.05;
player[i].forwardkeydown=1;
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;
leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
if(leftdist<rightdist)
- player[i].targetrotation+=90;
+ player[i].targetyaw+=90;
else
- player[i].targetrotation-=90;
+ player[i].targetyaw-=90;
}
}
}
player[i].setAnimation(backhandspringanim);
else
player[i].setAnimation(rollanim);
- player[i].targetrotation+=90*(abs(Random()%2)*2-1);
+ player[i].targetyaw+=90*(abs(Random()%2)*2-1);
player[i].wentforweapon=0;
}
if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim)
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=pathfindtype;
player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
findDistancefast(&rotatetarget,&player[i].coords))
targetpoint+=player[0].velocity*
findDistance(&player[0].coords,&player[i].coords)/findLength(&player[i].velocity);
- player[i].targetrotation=roughDirectionTo(player[i].coords,targetpoint);
- player[i].lookrotation=player[i].targetrotation;
+ player[i].targetyaw=roughDirectionTo(player[i].coords,targetpoint);
+ player[i].lookyaw=player[i].targetyaw;
player[i].aiupdatedelay=.2+fabs((float)(Random()%100)/1000);
if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))
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;
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;
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;
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 Game::MenuTick(){
+void MenuTick(){
//menu buttons
selected=Menu::getSelected(mousecoordh*640/screenwidth,480-mousecoordv*480/screenheight);
displayselected=0;
}
entername=0;
+ LoadMenu();
}
displayblinkdelay-=multiplier;
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;
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]);
- //TODO: what is this test?
if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
//dialogues
+ static float talkdelay = 0;
+
if(indialogue!=-1)
talkdelay=1;
talkdelay-=multiplier;
whichdialogue=i;
for(int j=0;j<numdialogueboxes[whichdialogue];j++){
player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
- player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
- player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
+ player[participantfocus[whichdialogue][j]].yaw=participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
+ player[participantfocus[whichdialogue][j]].targetyaw=participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
player[participantfocus[whichdialogue][j]].velocity=0;
player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
player[participantfocus[whichdialogue][j]].targetframe=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);
flatfacing=0;
flatfacing.z=-1;
- flatfacing=DoRotation(flatfacing,0,-rotation,0);
+ flatfacing=DoRotation(flatfacing,0,-yaw,0);
if(Input::isKeyDown(forwardkey))
viewer+=facing*multiplier*4;
if(whichend!=-1){
participantfocus[whichdialogue][indialogue]=whichend;
participantlocation[whichdialogue][whichend]=player[whichend].coords;
- participantrotation[whichdialogue][whichend]=player[whichend].rotation;
+ participantyaw[whichdialogue][whichend]=player[whichend].yaw;
}
if(whichend==-1){
participantfocus[whichdialogue][indialogue]=-1;
cameramode=0;
}
dialoguecamera[whichdialogue][indialogue]=viewer;
- dialoguecamerarotation[whichdialogue][indialogue]=rotation;
- dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
+ dialoguecamerayaw[whichdialogue][indialogue]=yaw;
+ dialoguecamerapitch[whichdialogue][indialogue]=pitch;
indialogue++;
if(indialogue<numdialogueboxes[whichdialogue]){
if(dialogueboxsound[whichdialogue][indialogue]!=0){
pause_sound(whooshsound);
viewer=dialoguecamera[whichdialogue][indialogue];
viewer.y=max((double)viewer.y,terrain.getHeight(viewer.x,viewer.z)+.1);
- rotation=dialoguecamerarotation[whichdialogue][indialogue];
- rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
+ yaw=dialoguecamerayaw[whichdialogue][indialogue];
+ pitch=dialoguecamerapitch[whichdialogue][indialogue];
if(dialoguetime>0.5)
if( Input::isKeyPressed(SDLK_1)||
Input::isKeyPressed(SDLK_2)||
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){
//?
for(int i=0;i<numplayers;i++){
- static float oldtargetrotation;
+ static float oldtargetyaw;
if(!player[i].skeleton.free){
- oldtargetrotation=player[i].targetrotation;
+ oldtargetyaw=player[i].targetyaw;
if(i==0&&indialogue==-1){
//TODO: refactor repetitive code
if(!animation[player[0].targetanimation].attack&&
player[0].targetanimation!=walljumprightkickanim&&
player[0].targetanimation!=walljumpleftkickanim){
if(cameramode)
- player[0].targetrotation=0;
+ player[0].targetyaw=0;
else
- player[0].targetrotation=-rotation+180;
+ player[0].targetyaw=-yaw+180;
}
facing=0;
facing.z=-1;
- flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
+ flatfacing=DoRotation(facing,0,player[i].yaw+180,0);
if(cameramode){
facing=flatfacing;
}else{
- 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);
}
- player[0].lookrotation=-rotation;
+ player[0].lookyaw=-yaw;
- player[i].targetheadrotation=rotation;
- player[i].targetheadrotation2=rotation2;
+ player[i].targetheadyaw=yaw;
+ player[i].targetheadpitch=pitch;
}
if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
if(!animation[player[i].targetanimation].attack&&
player[i].targetanimation!=dodgebackanim&&
player[i].targetanimation!=walljumprightkickanim&&
player[i].targetanimation!=walljumpleftkickanim){
- player[i].targetrotation=-player[i].lookrotation+180;
+ player[i].targetyaw=-player[i].lookyaw+180;
}
facing=0;
facing.z=-1;
- flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
+ flatfacing=DoRotation(facing,0,player[i].yaw+180,0);
- facing=DoRotation(facing,-player[i].lookrotation2,0,0);
- facing=DoRotation(facing,0,0-player[i].lookrotation,0);
+ facing=DoRotation(facing,-player[i].lookpitch,0,0);
+ facing=DoRotation(facing,0,0-player[i].lookyaw,0);
- player[i].targetheadrotation=player[i].lookrotation;
- player[i].targetheadrotation2=player[i].lookrotation2;
+ player[i].targetheadyaw=player[i].lookyaw;
+ player[i].targetheadpitch=player[i].lookpitch;
}
if(indialogue!=-1){
- player[i].targetheadrotation=180-roughDirection(participantfacing[whichdialogue][indialogue][i]);
- player[i].targetheadrotation2=pitch(participantfacing[whichdialogue][indialogue][i]);
+ player[i].targetheadyaw=180-roughDirection(participantfacing[whichdialogue][indialogue][i]);
+ player[i].targetheadpitch=pitchOf(participantfacing[whichdialogue][indialogue][i]);
}
if(leveltime<.5)
doAI(i);
if(animation[player[i].targetanimation].attack==reversed){
- //player[i].targetrotation=player[i].rotation;
+ //player[i].targetyaw=player[i].yaw;
player[i].forwardkeydown=0;
player[i].leftkeydown=0;
player[i].backkeydown=0;
player[i].aitype!=playercontrolled){
player[i].throwtogglekeydown=1;
player[i].setAnimation(crouchremoveknifeanim);
- player[i].targetrotation=roughDirectionTo(player[i].coords,weapons[j].position);
+ player[i].targetyaw=roughDirectionTo(player[i].coords,weapons[j].position);
player[i].hasvictim=0;
}
if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
if(!player[i].isFlip()){
player[i].throwtogglekeydown=1;
player[i].setAnimation(removeknifeanim);
- player[i].targetrotation=roughDirectionTo(player[i].coords,weapons[j].position);
+ player[i].targetyaw=roughDirectionTo(player[i].coords,weapons[j].position);
}
if(player[i].isFlip()){
player[i].throwtogglekeydown=1;
player[i].victim=&player[j];
player[i].hasvictim=1;
player[i].setAnimation(crouchremoveknifeanim);
- player[i].targetrotation=roughDirectionTo(player[i].coords,player[j].coords);
+ player[i].targetyaw=roughDirectionTo(player[i].coords,player[j].coords);
}
if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
player[i].throwtogglekeydown=1;
findDistancefast(&player[i].coords,&player[j].coords)<100&&
findDistancefast(&player[i].coords,&player[j].coords)>1.5&&
!player[j].skeleton.free&&
- -1==checkcollide(DoRotation(player[j].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()){
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);
absflatfacing=0;
absflatfacing.z=-1;
- absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
+ absflatfacing=DoRotation(absflatfacing,0,-yaw,0);
} else
absflatfacing=flatfacing;
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)||
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)||
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)||
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)||
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){
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;
}
}
if(player[i].targetanimation==rollanim)
- player[i].targetrotation=oldtargetrotation;
+ player[i].targetyaw=oldtargetyaw;
}
//Rotation
for(int k=0;k<numplayers;k++){
- if(fabs(player[k].rotation-player[k].targetrotation)>180){
- 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)
}
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;
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);
}
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);
}
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];
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;
}
}
static float cameraspeed;
if(!mainmenu){
+ static int oldmusictype=musictype;
if(environment==snowyenvironment)
leveltheme=stream_snowtheme;
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){
}
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;
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<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
int i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
colviewer=viewer;
- if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
+ if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.yaw[i])!=-1){
viewer=colviewer;
}
}
cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
}
}
+ /*
+ //what did autocam do?
if(player[0].skeleton.free!=2&&autocam){
cameraspeed=20;
if(findLengthfast(&player[0].velocity)>400){
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<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
int i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
colviewer=viewer;
- if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
+ if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.yaw[i])!=-1){
viewer=colviewer;
}
}
cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
}
}
+ */
if(camerashake>.8)camerashake=.8;
//if(woozy>10)woozy=10;
//woozy+=multiplier;
TGAImageRec texture;
bool debugmode = false;
-bool won = false;
-
bool campaign = false;
#include "Objects.h"
extern XYZ viewer;
extern float viewdistance;
-extern float lightambient[3],lightbrightness[3];
extern float fadestart;
extern int environment;
extern float texscale;
if(type[i]!=treeleavestype&&type[i]!=treetrunktype&&type[i]!=bushtype&&type[i]!=firetype&&i!=which){
colviewer=startpoint;
coltarget=endpoint;
- if(model[i].LineCheck(&colviewer,&coltarget,&colpoint,&position[i],&rotation[i])!=-1)return 1;
+ if(model[i].LineCheck(&colviewer,&coltarget,&colpoint,&position[i],&yaw[i])!=-1)return 1;
}
}
for(j=0;j<terrain.patchobjectnum[whichpatchx][whichpatchz];j++){
i=terrain.patchobjects[whichpatchx][whichpatchz][j];
possible[i]=0;
- if(model[i].SphereCheckPossible(p1, radius, &position[i], &rotation[i])!=-1){
+ if(model[i].SphereCheckPossible(p1, radius, &position[i], &yaw[i])!=-1){
possible[i]=1;
}
}
for(i=0;i<numobjects;i++){
if(type[i]!=firetype){
- moved=DoRotation(model[i].boundingspherecenter,0,rotation[i],0);
+ moved=DoRotation(model[i].boundingspherecenter,0,yaw[i],0);
if(type[i]==tunneltype||frustum.SphereInFrustum(position[i].x+moved.x,position[i].y+moved.y,position[i].z+moved.z,model[i].boundingsphereradius)){
distance=findDistancefast(&viewer,&position[i]);
distance*=1.2;
if(distance>1)distance=1;
if(distance>0){
- /*if(checkcollide(viewer,DoRotation(model[i].vertex[model[i].vertexNum],0,rotation[i],0)*scale[i]+position[i],i)){
+ /*if(checkcollide(viewer,DoRotation(model[i].vertex[model[i].vertexNum],0,yaw[i],0)*scale[i]+position[i],i)){
occluded[i]+=1;
}
else occluded[i]=0;*/
glRotatef((sin(windvar+position[i].x*.3)+.5)*4*.5*(sin(windvar*2+position[i].x*.3)+1)/2,1,0,0);
}
}
- glRotatef(rotation[i],0,1,0);
+ glRotatef(yaw[i],0,1,0);
if(distance>1)distance=1;
glColor4f((1-shadowed[i])/2+.5,(1-shadowed[i])/2+.5,(1-shadowed[i])/2+.5,distance);
if(distance>=1){
glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
for(i=0;i<numobjects;i++){
if(type[i]==treeleavestype||type[i]==bushtype){
- moved=DoRotation(model[i].boundingspherecenter,0,rotation[i],0);
+ moved=DoRotation(model[i].boundingspherecenter,0,yaw[i],0);
if(frustum.SphereInFrustum(position[i].x+moved.x,position[i].y+moved.y,position[i].z+moved.z,model[i].boundingsphereradius)){
hidden=findDistancefastflat(&viewer,&position[i])<=playerdist+3;
if(hidden){
glRotatef((sin(windvar+position[i].x*.3)+.5)*4*.5*(sin(windvar*2+position[i].x*.3)+1)/2,1,0,0);
}
}
- glRotatef(rotation[i],0,1,0);
+ glRotatef(yaw[i],0,1,0);
glColor4f(1,1,1,distance);
if(type[i]==treeleavestype){
glDisable(GL_CULL_FACE);
void Objects::DeleteObject(int which)
{
type[numobjects-1]=0;
- rotation[numobjects-1]=0;
+ yaw[numobjects-1]=0;
position[numobjects-1]=0;
scale[numobjects-1]=0;
friction[numobjects-1]=0;
numobjects--;
}
-void Objects::MakeObject(int atype, XYZ where, float arotation, float ascale){
+void Objects::MakeObject(int atype, XYZ where, float ayaw, float ascale){
if((atype!=treeleavestype&&atype!=bushtype)||foliage==1){
scale[numobjects]=ascale;
if(atype==treeleavestype)scale[numobjects]+=fabs((float)(Random()%100)/900)*ascale;
position[numobjects]=where;
if(atype==bushtype)position[numobjects].y=terrain.getHeight(position[numobjects].x,position[numobjects].z)-.3;
- rotation[numobjects]=arotation;
+ yaw[numobjects]=ayaw;
rotxvel[numobjects]=0;
rotyvel[numobjects]=0;
model[numobjects].Scale(.3*scale[numobjects],.3*scale[numobjects],.3*scale[numobjects]);
model[numobjects].Rotate(90,1,1);
if(type[numobjects]==rocktype){
- model[numobjects].Rotate(arotation*5,1,1);
+ model[numobjects].Rotate(ayaw*5,1,1);
}
model[numobjects].CalculateNormals(1);
model[numobjects].ScaleNormals(-1,-1,-1);
}
if(atype!=treeleavestype&&atype!=bushtype&&atype!=firetype)
- terrain.AddObject(where+DoRotation(model[numobjects].boundingspherecenter,0,arotation,0),model[numobjects].boundingsphereradius,numobjects);
+ terrain.AddObject(where+DoRotation(model[numobjects].boundingspherecenter,0,ayaw,0),model[numobjects].boundingsphereradius,numobjects);
numobjects++;
}
}
-void Objects::MakeObject(int atype, XYZ where, float arotation, float arotation2, float ascale){
+void Objects::MakeObject(int atype, XYZ where, float ayaw, float apitch, float ascale){
if((atype!=treeleavestype&&atype!=bushtype)||foliage==1){
scale[numobjects]=ascale;
if(atype==treeleavestype)scale[numobjects]+=fabs((float)(Random()%100)/900)*ascale;
if(position[numobjects].y<terrain.getHeight(position[numobjects].x,position[numobjects].z)-.3)
position[numobjects].y=terrain.getHeight(position[numobjects].x,position[numobjects].z)-.3;
}*/
- rotation[numobjects]=arotation;
- rotation2[numobjects]=arotation2;
+ yaw[numobjects]=ayaw;
+ pitch[numobjects]=apitch;
rotxvel[numobjects]=0;
rotyvel[numobjects]=0;
if(atype==treetrunktype)friction[numobjects]=.4;
if(atype==treeleavestype)friction[numobjects]=0;
- if(friction[numobjects]==1.5&&fabs(arotation2)>5)friction[numobjects]=.5;
+ if(friction[numobjects]==1.5&&fabs(apitch)>5)friction[numobjects]=.5;
if(atype==platformtype){
model[numobjects].loaddecal((char *)":Data:Models:Platform.solid",0);
}
model[numobjects].Scale(.3*scale[numobjects],.3*scale[numobjects],.3*scale[numobjects]);
model[numobjects].Rotate(90,1,1);
- model[numobjects].Rotate(arotation2,0,0);
+ model[numobjects].Rotate(apitch,0,0);
if(type[numobjects]==rocktype){
- model[numobjects].Rotate(arotation*5,0,0);
+ model[numobjects].Rotate(ayaw*5,0,0);
}
model[numobjects].CalculateNormals(1);
model[numobjects].ScaleNormals(-1,-1,-1);
}
if(atype!=treeleavestype&&atype!=bushtype&&atype!=firetype)
- terrain.AddObject(where+DoRotation(model[numobjects].boundingspherecenter,0,arotation,0),model[numobjects].boundingsphereradius,numobjects);
+ terrain.AddObject(where+DoRotation(model[numobjects].boundingspherecenter,0,ayaw,0),model[numobjects].boundingsphereradius,numobjects);
numobjects++;
}
void Objects::DoShadows()
{
- int i,j,k,l,todivide;
- static float brightness, total;
+ int i,j,k,l;
static XYZ testpoint,testpoint2, terrainpoint,lightloc,col;
lightloc=light.location;
if(!skyboxtexture)lightloc=0;
for(i=0;i<numobjects;i++){
if(type[i]!=treeleavestype&&type[i]!=treetrunktype&&type[i]!=bushtype&&type[i]!=firetype){
for(j=0;j<model[i].vertexNum;j++){
- terrainpoint=position[i]+DoRotation(model[i].vertex[j]+model[i].normals[j]*.1,0,rotation[i],0);
+ terrainpoint=position[i]+DoRotation(model[i].vertex[j]+model[i].normals[j]*.1,0,yaw[i],0);
//terrainpoint.y+=model[i].boundingsphereradius;
shadowed[i]=0;
patchx=terrainpoint.x/(terrain.size/subdivision*terrain.scale);
if(type[l]!=treetrunktype/*&&l!=i*/){
testpoint=terrainpoint;
testpoint2=terrainpoint+lightloc*50*(1-shadowed[i]);
- if(model[l].LineCheck(&testpoint,&testpoint2,&col,&position[l],&rotation[l])!=-1){
+ if(model[l].LineCheck(&testpoint,&testpoint2,&col,&position[l],&yaw[l])!=-1){
shadowed[i]=1-(findDistance(&terrainpoint,&col)/50);
}
}
}
if(shadowed[i]>0){
- col=model[i].normals[j]-DoRotation(lightloc*shadowed[i],0,-rotation[i],0);
+ col=model[i].normals[j]-DoRotation(lightloc*shadowed[i],0,-yaw[i],0);
Normalise(&col);
for(k=0;k<model[i].TriangleNum;k++){
if(model[i].Triangles[k].vertex[0]==j){
memset(position, 0, sizeof(position));
memset(type, 0, sizeof(type));
- memset(rotation, 0, sizeof(rotation));
- memset(rotation2, 0, sizeof(rotation2));
+ memset(yaw, 0, sizeof(yaw));
+ memset(pitch, 0, sizeof(pitch));
memset(rotx, 0, sizeof(rotx));
memset(rotxvel, 0, sizeof(rotxvel));
memset(roty, 0, sizeof(roty));
float radius;
XYZ position[max_objects];
int type[max_objects];
- float rotation[max_objects];
- float rotation2[max_objects];
+ float yaw[max_objects];
+ float pitch[max_objects];
float rotx[max_objects];
float rotxvel[max_objects];
float roty[max_objects];
void SphereCheckPossible(XYZ *p1,float radius);
void DeleteObject(int which);
- void MakeObject(int atype, XYZ where, float arotation, float ascale);
- void MakeObject(int atype, XYZ where, float arotation, float arotation2, float ascale);
+ void MakeObject(int atype, XYZ where, float ayaw, float ascale);
+ void MakeObject(int atype, XYZ where, float ayaw, float apitch, float ascale);
void Draw();
void DoShadows();
void DoStuff();
num_channels = 0;
}
*/
- DrawGL();
+ if ( stereomode == stereoNone ) {
+ DrawGLScene(stereoCenter);
+ } else {
+ DrawGLScene(stereoLeft);
+ DrawGLScene(stereoRight);
+ }
}
// --------------------------------------------------------------------------
if (!SetUp ())
return 42;
- while (!gDone&&!quit&&(!tryquit))
+ while (!gDone&&!tryquit)
{
if (IsFocused())
{
velocity=0;
victim->oldcoords=victim->coords;
coords=victim->coords;
- victim->targetrotation=targetrotation;
+ victim->targetyaw=targetyaw;
victim->victim=this;
}
}
howmany=abs(Random()%(skeleton.num_joints));
if(!skeleton.free)flatvelocity=velocity;
if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
- if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
+ if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,yaw,0)*scale+coords;
if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
}
bloodvel=0;
if(!skeleton.free){
bloodvel.z=10;
- bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
}
if(skeleton.free){
bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
}
- if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
if(skeleton.free){
Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
}
if(!skeleton.free){
- Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
}
}
if(Random()%2==0)
bloodvel=0;
if(skeleton.free) {
bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
- bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
} else {
bloodvel.z=10;
- bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
}
bloodvel*=.2;
if(skeleton.free){
Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
} else {
- Sprite::MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
}
Sprite::setLastSpriteSpecial(3);
}
bloodvel=0;
if(!skeleton.free){
bloodvel.z=10;
- bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
}
if(skeleton.free){
bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
}
- if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
if(skeleton.free){
Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
}
if(!skeleton.free){
- Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
}
}
}
if(bloodtoggle&&decals&&tutoriallevel!=1){
where-=coords;
- if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
+ if(!skeleton.free)where=DoRotation(where,0,-yaw,0);
//where=scale;
startpoint=where;
startpoint.y+=100;
bloodvel=0;
if(!skeleton.free){
bloodvel.z=10;
- bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
}
if(skeleton.free){
bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
}
- if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
if(skeleton.free){
Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
}
if(!skeleton.free){
- Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
}
}
}
victim->velocity=0;
victim->oldcoords=victim->coords;
victim->coords=coords;
- victim->targetrotation=targetrotation;
- victim->rotation=targetrotation;
+ victim->targetyaw=targetyaw;
+ victim->yaw=targetyaw;
victim->victim=this;
}
if(targetanimation==winduppunchanim){
victim->targetframe=1;
victim->target=.5;
victim->victim=this;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
}
if(targetanimation==wolfslapanim){
targetanimation=winduppunchblockedanim;
victim->targetframe=1;
victim->target=.5;
victim->victim=this;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
}
if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
targetanimation=swordslashparriedanim;
victim->targetframe=1;
victim->target=.5;
victim->victim=this;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
if(abs(Random()%20)==0||weapons[victim->weaponids[victim->weaponactive]].getType()==knife){
if(victim->weaponactive!=-1){
victim->target=0;
victim->targetframe=0;
victim->targetanimation=staggerbackhighanim;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
victim->target=0;
weapons[victim->weaponids[0]].owner=-1;
aim=DoRotation(facing,0,90,0)*21;
target=0;
targetframe=0;
targetanimation=staggerbackhighanim;
- targetrotation=targetrotation+180;
+ targetyaw=targetyaw+180;
target=0;
weapons[weaponids[0]].owner=-1;
aim=DoRotation(facing,0,90,0)*21;
XYZ rotatetarget;
rotatetarget=coords-victim->coords;
Normalise(&rotatetarget);
- victim->targetrotation=-asin(0-rotatetarget.x);
- victim->targetrotation*=360/6.28;
- if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
+ victim->targetyaw=-asin(0-rotatetarget.x);
+ victim->targetyaw*=360/6.28;
+ if(rotatetarget.z<0)victim->targetyaw=180-victim->targetyaw;
victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
XYZ rotatetarget;
rotatetarget=coords-victim->coords;
Normalise(&rotatetarget);
- victim->targetrotation=-asin(0-rotatetarget.x);
- victim->targetrotation*=360/6.28;
- if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
+ victim->targetyaw=-asin(0-rotatetarget.x);
+ victim->targetyaw*=360/6.28;
+ if(rotatetarget.z<0)victim->targetyaw=180-victim->targetyaw;
victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
for(int i=0;i<skeleton.num_joints; i++){
if(!skeleton.free)flatvelocity2=velocity;
if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
- if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
+ if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,yaw,0)*scale+coords;
if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
if(!freeze&&!winfreeze){
//head facing
- targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
- targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
+ targetheadyaw=(float)((int)((0-yaw-targetheadyaw+180)*100)%36000)/100;
+ targetheadpitch=(float)((int)(targetheadpitch*100)%36000)/100;
- while(targetheadrotation>180)targetheadrotation-=360;
- while(targetheadrotation<-180)targetheadrotation+=360;
+ while(targetheadyaw>180)targetheadyaw-=360;
+ while(targetheadyaw<-180)targetheadyaw+=360;
- if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
- if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
- if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
- if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
+ if(targetheadyaw>160)targetheadpitch=targetheadpitch*-1;
+ if(targetheadyaw<-160)targetheadpitch=targetheadpitch*-1;
+ if(targetheadyaw>160)targetheadyaw=targetheadyaw-180;
+ if(targetheadyaw<-160)targetheadyaw=targetheadyaw+180;
- if(targetheadrotation2>120)targetheadrotation2=120;
- if(targetheadrotation2<-120)targetheadrotation2=-120;
- if(targetheadrotation>120)targetheadrotation=120;
- if(targetheadrotation<-120)targetheadrotation=-120;
+ if(targetheadpitch>120)targetheadpitch=120;
+ if(targetheadpitch<-120)targetheadpitch=-120;
+ if(targetheadyaw>120)targetheadyaw=120;
+ if(targetheadyaw<-120)targetheadyaw=-120;
- if(!isIdle())targetheadrotation2=0;
+ if(!isIdle())targetheadpitch=0;
if(isIdle()){
- if(targetheadrotation>80)targetheadrotation=80;
- if(targetheadrotation<-80)targetheadrotation=-80;
- if(targetheadrotation2>50)targetheadrotation2=50;
- if(targetheadrotation2<-50)targetheadrotation2=-50;
+ if(targetheadyaw>80)targetheadyaw=80;
+ if(targetheadyaw<-80)targetheadyaw=-80;
+ if(targetheadpitch>50)targetheadpitch=50;
+ if(targetheadpitch<-50)targetheadpitch=-50;
}
- if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
- else if(headrotation>targetheadrotation){
- headrotation-=multiplier*lookspeed;
+ if(abs(headyaw-targetheadyaw)<multiplier*lookspeed)headyaw=targetheadyaw;
+ else if(headyaw>targetheadyaw){
+ headyaw-=multiplier*lookspeed;
}
- else if(headrotation<targetheadrotation){
- headrotation+=multiplier*lookspeed;
+ else if(headyaw<targetheadyaw){
+ headyaw+=multiplier*lookspeed;
}
- if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
- else if(headrotation2>targetheadrotation2){
- headrotation2-=multiplier*lookspeed/2;
+ if(abs(headpitch-targetheadpitch)<multiplier*lookspeed/2)headpitch=targetheadpitch;
+ else if(headpitch>targetheadpitch){
+ headpitch-=multiplier*lookspeed/2;
}
- else if(headrotation2<targetheadrotation2){
- headrotation2+=multiplier*lookspeed/2;
+ else if(headpitch<targetheadpitch){
+ headpitch+=multiplier*lookspeed/2;
}
rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
- skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
+ skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headpitch,0,0);
facing=0;
facing.z=-1;
if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
- facing=DoRotation(facing,headrotation2*.4,0,0);
- facing=DoRotation(facing,0,headrotation*.4,0);
+ facing=DoRotation(facing,headpitch*.4,0,0);
+ facing=DoRotation(facing,0,headyaw*.4,0);
}
if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
- facing=DoRotation(facing,headrotation2*.8,0,0);
- facing=DoRotation(facing,0,headrotation*.8,0);
+ facing=DoRotation(facing,headpitch*.8,0,0);
+ facing=DoRotation(facing,0,headyaw*.8,0);
}
if(targetanimation==walkanim){
- facing=DoRotation(facing,headrotation2*.6,0,0);
- facing=DoRotation(facing,0,headrotation*.6,0);
+ facing=DoRotation(facing,headpitch*.6,0,0);
+ facing=DoRotation(facing,0,headyaw*.6,0);
}
skeleton.specialforward[0]=facing;
- //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
+ //skeleton.specialforward[0]=DoRotation(facing,0,yaw,0);
static int i;
for(i=0;i<skeleton.num_muscles;i++){
if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
facing=0;
facing.z=1;
- facing=DoRotation(facing,0,rotation,0);
+ facing=DoRotation(facing,0,yaw,0);
skeleton.freetime=0;
if(!isnormal(velocity.x))velocity.x=0;
if(!isnormal(velocity.y))velocity.y=0;
if(!isnormal(velocity.z))velocity.z=0;
- if(!isnormal(rotation))rotation=0;
+ if(!isnormal(yaw))yaw=0;
if(!isnormal(coords.x))coords=0;
if(!isnormal(tilt))tilt=0;
if(!isnormal(tilt2))tilt2=0;
for(i=0;i<skeleton.num_joints;i++){
skeleton.joints[i].delay=0;
skeleton.joints[i].locked=0;
- skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
- if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
+ skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,yaw,0);
+ if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,yaw,0);
if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
skeleton.joints[i].position.y+=.1;
speed*=speedmult;
for(i=0;i<skeleton.num_joints;i++){
- if((animation[currentanimation].attack!=reversed||currentanimation==swordslashreversedanim)&¤tanimation!=rabbitkickanim&&!isLanding()&&!wasLanding()&&animation[currentanimation].height==animation[targetanimation].height)skeleton.joints[i].velocity=velocity/scale+facing*5+DoRotation(DoRotation(DoRotation((animation[targetanimation].position[i][targetframe]-animation[currentanimation].position[i][currentframe])*speed,0,0,tilt),tilt2,0,0),0,rotation,0);
+ if((animation[currentanimation].attack!=reversed||currentanimation==swordslashreversedanim)&¤tanimation!=rabbitkickanim&&!isLanding()&&!wasLanding()&&animation[currentanimation].height==animation[targetanimation].height)skeleton.joints[i].velocity=velocity/scale+facing*5+DoRotation(DoRotation(DoRotation((animation[targetanimation].position[i][targetframe]-animation[currentanimation].position[i][currentframe])*speed,0,0,tilt),tilt2,0,0),0,yaw,0);
else skeleton.joints[i].velocity=velocity/scale+facing*5;
change.x=(float)(Random()%100)/100;
change.y=(float)(Random()%100)/100;
i=terrain.patchobjects[whichpatchx][whichpatchz][l];
lowpoint=coords;
lowpoint.y+=1;
- if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
+ if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.yaw[i], &objects.model[i])!=-1){
coords.x=lowpoint.x;
coords.z=lowpoint.z;
}
}
}
- rotation=0;
+ yaw=0;
updatedelay=0;
velocity=0;
if(opacity>1)
{
footvel=0;
- if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
+ if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
//footpoint.y=coords.y;
if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
}
else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
footvel=velocity/5;
if(footvel.y<.8)footvel.y=.8;
- if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
+ if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
- if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
+ if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,yaw);
}
else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
footvel=velocity/5;
if(footvel.y<.8)footvel.y=.8;
- if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
+ if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5*opacity);
else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
footvel=velocity/5;
if(footvel.y<.8)footvel.y=.8;
- if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
+ if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7*opacity);
- if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
+ if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,yaw);
}
else if(isLanding()||targetanimation==jumpupanim||isLandhard())
{
footvel=velocity/5;
if(footvel.y<.8)footvel.y=.8;
- if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
+ if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
//footpoint.y=coords.y;
if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
}
static XYZ footvel,footpoint;
footvel=0;
- footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
+ footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,yaw,0)*scale+coords;
Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
}
targfacing=0;
targfacing.z=1;
- targfacing=DoRotation(targfacing,0,targetrotation,0);
+ targfacing=DoRotation(targfacing,0,targetyaw,0);
if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
else targetanimation=backflipanim;
else victim->targetanimation=rabbittackledfrontanim;
victim->targetframe=2;
victim->target=0;
- victim->rotation=rotation;
- victim->targetrotation=rotation;
+ victim->yaw=yaw;
+ victim->targetyaw=yaw;
if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
//victim->DoDamage(30);
if(creature==wolftype){
if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
- XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
+ XYZ rotatetarget=DoRotation(skeleton.forward,0,yaw,0);
Normalise(&rotatetarget);
- targetrotation=-asin(0-rotatetarget.x);
- targetrotation*=360/6.28;
- if(rotatetarget.z<0)targetrotation=180-targetrotation;
+ targetyaw=-asin(0-rotatetarget.x);
+ targetyaw*=360/6.28;
+ if(rotatetarget.z<0)targetyaw=180-targetyaw;
- if(targetanimation==walljumprightkickanim)targetrotation+=40;
- if(targetanimation==walljumpleftkickanim)targetrotation-=40;
+ if(targetanimation==walljumprightkickanim)targetyaw+=40;
+ if(targetanimation==walljumpleftkickanim)targetyaw-=40;
}
bool dojumpattack;
if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
rotatetarget=coords-victim->coords;
Normalise(&rotatetarget);
- targetrotation=-asin(0-rotatetarget.x);
- targetrotation*=360/6.28;
- if(rotatetarget.z<0)targetrotation=180-targetrotation;
+ targetyaw=-asin(0-rotatetarget.x);
+ targetyaw*=360/6.28;
+ if(rotatetarget.z<0)targetyaw=180-targetyaw;
}
if(targetanimation!=rabbitrunninganim){
emit_sound_at(jumpsound, coords, 128.);
if(weapons[weaponids[weaponactive]].getType()==knife){
where=(weapons[weaponids[weaponactive]].tippoint*.6+weapons[weaponids[weaponactive]].position*.4);
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
//where=scale;
startpoint=where;
startpoint.y+=100;
if(weapons[weaponids[weaponactive]].getType()==sword){
where=weapons[weaponids[weaponactive]].position;
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
startpoint=where;
where=weapons[weaponids[weaponactive]].tippoint;
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
endpoint=where;
}
if(weapons[weaponids[weaponactive]].getType()==staff){
where=weapons[weaponids[weaponactive]].position;
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
startpoint=where;
where=weapons[weaponids[weaponactive]].tippoint;
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
endpoint=where;
}
movepoint=0;
where=weapons[weaponids[weaponactive]].position;
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
startpoint=where;
where=weapons[weaponids[weaponactive]].tippoint;
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
endpoint=where;
movepoint=0;
where=weapons[weaponids[weaponactive]].position;
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
startpoint=where;
where=weapons[weaponids[weaponactive]].tippoint;
where-=victim->coords;
- if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
+ if(!victim->skeleton.free)where=DoRotation(where,0,-victim->yaw,0);
endpoint=where;
movepoint=0;
victim->targetframe=0;
victim->targetanimation=staggerbackhardanim;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
victim->target=0;
victim->stunned=1;
victim->targetframe=0;
victim->targetanimation=staggerbackhardanim;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
victim->target=0;
victim->stunned=1;
escapednum=0;
XYZ aim;
weapons[weaponids[0]].owner=-1;
- aim=victim->coords+DoRotation(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position,0,victim->rotation,0)*victim->scale+victim->velocity*findDistance(&victim->coords,&coords)/50-(coords+DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position,0,rotation,0)*scale);
+ aim=victim->coords+DoRotation(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position,0,victim->yaw,0)*victim->scale+victim->velocity*findDistance(&victim->coords,&coords)/50-(coords+DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position,0,yaw,0)*scale);
Normalise(&aim);
/*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
if(victim->id != 0 || difficulty==2){
victim->targetframe=0;
victim->targetanimation=staggerbackhardanim;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
victim->target=0;
}
}
footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
}
if(!skeleton.free){
- footpoint=DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2,0,victim->rotation,0)*victim->scale+victim->coords;
+ footpoint=DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2,0,victim->yaw,0)*victim->scale+victim->coords;
}
if(tutoriallevel!=1){
if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
if(tutoriallevel!=1){
victim->targetframe=0;
victim->targetanimation=staggerbackhardanim;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
victim->target=0;
}
footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
}
if(!skeleton.free){
- footpoint=DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2,0,victim->rotation,0)*victim->scale+victim->coords;
+ footpoint=DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2,0,victim->yaw,0)*victim->scale+victim->coords;
}
if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
footvel=DoRotation(facing,0,90,0)*.8;
victim->target=0;
victim->targetframe=0;
victim->targetanimation=staggerbackhighanim;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
victim->target=0;
weapons[victim->weaponids[0]].owner=-1;
aim=DoRotation(facing,0,90,0)*21;
victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
victim->targetframe=0;
victim->targetanimation=staggerbackhighanim;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
victim->target=0;
if(tutoriallevel!=1){
emit_sound_at(landsound2, victim->coords, 128.);
victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
victim->targetframe=0;
victim->targetanimation=staggerbackhighanim;
- victim->targetrotation=targetrotation+180;
+ victim->targetyaw=targetyaw+180;
victim->target=0;
if(tutoriallevel!=1){
emit_sound_at(landsound2, victim->coords, 128.);
bloodvel=0;
bloodvel.z=20;
bloodvel.y=5;
- bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
- Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
+ Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
*/
XYZ footvel,footpoint;
footvel=0;
targetframe=0;
XYZ rotatetarget=victim->coords-coords;
Normalise(&rotatetarget);
- rotation=-asin(0-rotatetarget.x);
- rotation*=360/6.28;
- if(rotatetarget.z<0)rotation=180-rotation;
+ yaw=-asin(0-rotatetarget.x);
+ yaw*=360/6.28;
+ if(rotatetarget.z<0)yaw=180-yaw;
targettilt2=-asin(rotatetarget.y)*360/6.28;
velocity=(victim->coords-coords)*4;
velocity.y+=2;
if(targetanimation==walljumprightanim){
targetanimation=rightflipanim;
targetframe=4;
- targetrotation-=90;
- rotation-=90;
+ targetyaw-=90;
+ yaw-=90;
velocity=DoRotation(facing,0,30,0)*-8;
velocity.y=4;
}
if(targetanimation==walljumpfrontanim){
targetanimation=frontflipanim;
targetframe=2;
- //targetrotation-=180;
- ////rotation-=180;
+ //targetyaw-=180;
+ ////yaw-=180;
velocity=facing*8;
velocity.y=4;
}
targetframe=0;
XYZ rotatetarget=victim->coords-coords;
Normalise(&rotatetarget);
- rotation=-asin(0-rotatetarget.x);
- rotation*=360/6.28;
- if(rotatetarget.z<0)rotation=180-rotation;
+ yaw=-asin(0-rotatetarget.x);
+ yaw*=360/6.28;
+ if(rotatetarget.z<0)yaw=180-yaw;
targettilt2=-asin(rotatetarget.y)*360/6.28;
velocity=(victim->coords-coords)*4;
velocity.y+=2;
if(targetanimation!=walljumpleftkickanim){
targetanimation=leftflipanim;
targetframe=4;
- targetrotation+=90;
- rotation+=90;
+ targetyaw+=90;
+ yaw+=90;
velocity=DoRotation(facing,0,-30,0)*-8;
velocity.y=4;
}
targetanimation=getCrouch();
targetframe=1;
currentframe=0;
- targetrotation+=180;
- rotation+=180;
+ targetyaw+=180;
+ yaw+=180;
targettilt2*=-1;
tilt2*=-1;
transspeed=1000000;
- targetheadrotation+=180;
+ targetheadyaw+=180;
coords-=facing*.7;
if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
float ycoords=oldcoords.y;
targetanimation=getStop();
- targetrotation+=180;
- rotation+=180;
+ targetyaw+=180;
+ yaw+=180;
targettilt2*=-1;
tilt2*=-1;
transspeed=1000000;
- targetheadrotation+=180;
+ targetheadyaw+=180;
if(!isnormal(coords.x))
coords=oldcoords;
if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
oldcoords=coords+facing*1.1;
else if(currentanimation==upunchreversalanim){
oldcoords=coords+facing*1.5;
- targetrotation+=180;
- rotation+=180;
- targetheadrotation+=180;
+ targetyaw+=180;
+ yaw+=180;
+ targetheadyaw+=180;
targettilt2*=-1;
tilt2*=-1;
}
else if(currentanimation==knifeslashreversalanim){
oldcoords=coords+facing*.5;
- targetrotation+=90;
- rotation+=90;
- targetheadrotation+=90;
+ targetyaw+=90;
+ yaw+=90;
+ targetheadyaw+=90;
targettilt2=0;
tilt2=0;
}
else if(currentanimation==staffspinhitreversalanim){
- targetrotation+=180;
- rotation+=180;
- targetheadrotation+=180;
+ targetyaw+=180;
+ yaw+=180;
+ targetheadyaw+=180;
targettilt2=0;
tilt2=0;
}
}
if(animation[targetanimation].attack==reversed){
escapednum++;
- if(targetanimation==sweepreversedanim)targetrotation+=90;
+ if(targetanimation==sweepreversedanim)targetyaw+=90;
targetanimation=backhandspringanim;
targetframe=2;
emit_sound_at(landsound, coords, 128);
targetanimation=rollanim;
targetframe=5;
oldcoords=coords;
- coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
+ coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0))/2*scale;
coords.y=oldcoords.y;
}
if(currentanimation==knifeslashreversedanim){
targetanimation=rollanim;
targetframe=0;
- targetrotation+=90;
- rotation+=90;
+ targetyaw+=90;
+ yaw+=90;
oldcoords=coords;
- coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
+ coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0))/2*scale;
coords.y=oldcoords.y;
}
}
if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
targetanimation=getIdle();
oldcoords=coords;
- coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
+ coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0))/2*scale;
coords.y=oldcoords.y;
- //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
+ //coords+=DoRotation(animation[currentanimation].offset,0,yaw,0)*scale;
targetoffset.y=coords.y;
if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
- currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
+ currentoffset=DoRotation(animation[currentanimation].offset*-1,0,yaw,0)*scale;
currentoffset.y-=(coords.y-targetoffset.y);
coords.y=targetoffset.y;
targetoffset=0;
lastfeint=0;
}
if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
- targetrotation=rotation;
+ targetyaw=yaw;
bool hasstaff;
hasstaff=0;
if(num_weapons>0)if(weapons[0].getType()==staff)hasstaff=1;
if(target>1){currentframe=targetframe; target=1;}
oldrot=rot;
rot=targetrot*target;
- rotation+=rot-oldrot;
+ yaw+=rot-oldrot;
if(target==1){
rot=0;
oldrot=0;
howmany=abs(Random()%(skeleton.num_joints));
if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
- if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
+ if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,yaw,0)*scale+coords;
if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
}
howmany=abs(Random()%(skeleton.num_joints));
if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
- if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
+ if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,yaw,0)*scale+coords;
if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
}
bloodvel=0;
if(!skeleton.free){
bloodvel.z=5*neckspurtamount;
- bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
+ bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,yaw+((float)(Random()%100))/40,0)*scale;
}
if(skeleton.free){
bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
}
- if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
+ if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,yaw+((float)(Random()%100))/40,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
if(skeleton.free)Sprite::MakeSprite(bloodsprite, (skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5)*scale+coords,bloodvel, 1,1,1, .05, .9);
- if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, .9);
+ if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, .9);
neckspurtparticledelay=.05;
}
if(neckspurtdelay<0){
XYZ bloodvel;
if(bloodtoggle){
bloodvel=0;
- if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
- if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
}
}
bloodloss+=deathbleeding*multiplier*80;
if(environment==snowyenvironment){
XYZ footpoint;
XYZ footvel;
- if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
+ if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,yaw,0)*-1;
if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
- if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
+ if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,yaw,0)*scale+coords;
if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
if(bloodtoggle&&!bled)
for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
j=terrain.patchobjects[whichpatchx][whichpatchz][l];
- XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
+ XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.yaw[j],0);
float size=.8;
float opacity=.6;
- float rotation=0;
- objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
+ float yaw=0;
+ objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&yaw);
}
bled=1;
}
if(bloodtoggle&&!bled)
for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
j=terrain.patchobjects[whichpatchx][whichpatchz][l];
- XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
+ XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.yaw[j],0);
float size=.2*1.2;
float opacity=.6;
- float rotation=0;
- objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
+ float yaw=0;
+ objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&yaw);
}
bled=1;
}
if(bloodtoggle&&!bled)
for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
j=terrain.patchobjects[whichpatchx][whichpatchz][l];
- XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
+ XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.yaw[j],0);
float size=.8;
float opacity=.6;
- float rotation=0;
- objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
+ float yaw=0;
+ objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&yaw);
}
bled=1;
}
if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
colviewer=startpoint;
coltarget=endpoint;
- if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
+ if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.yaw[i])!=-1)canrecover=0;
}
}
if(canrecover){
}
Normalise(&terrainnormal);
- targetrotation=-asin(0-terrainnormal.x);
- targetrotation*=360/6.28;
- if(terrainnormal.z<0)targetrotation=180-targetrotation;
- rotation=targetrotation;
+ targetyaw=-asin(0-terrainnormal.x);
+ targetyaw*=360/6.28;
+ if(terrainnormal.z<0)targetyaw=180-targetyaw;
+ yaw=targetyaw;
targetframe=0;
// targetframe=2;
for(i=0;i<skeleton.num_joints;i++){
tempanimation.position[i][0]=skeleton.joints[i].position;
- tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
+ tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-yaw,0);
}
}
}
}
Normalise(&terrainnormal);
- targetrotation=-asin(0-terrainnormal.x);
- targetrotation*=360/6.28;
- if(terrainnormal.z<0)targetrotation=180-targetrotation;
- rotation=targetrotation;
+ targetyaw=-asin(0-terrainnormal.x);
+ targetyaw*=360/6.28;
+ if(terrainnormal.z<0)targetyaw=180-targetyaw;
+ yaw=targetyaw;
targettilt2=asin(terrainnormal.y)*180/3.14*-1;
}
if(skeleton.forward.y>-.3){
targetanimation=getupfromfrontanim;
- rotation+=180;
- targetrotation+=180;
+ yaw+=180;
+ targetyaw+=180;
targettilt2*=-1;
targetframe=0;
targettilt2=0;
if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
targetanimation=rollanim;
- targetrotation=lookrotation;
+ targetyaw=lookyaw;
if(id==0){
if(rightkeydown){
- targetrotation-=90;
- if(forwardkeydown)targetrotation+=45;
- if(backkeydown)targetrotation-=45;
+ targetyaw-=90;
+ if(forwardkeydown)targetyaw+=45;
+ if(backkeydown)targetyaw-=45;
}
if(leftkeydown){
- targetrotation+=90;
- if(forwardkeydown)targetrotation-=45;
- if(backkeydown)targetrotation+=45;
+ targetyaw+=90;
+ if(forwardkeydown)targetyaw-=45;
+ if(backkeydown)targetyaw+=45;
}
if(backkeydown){
if ( !leftkeydown&&!rightkeydown)
- targetrotation+=180;
+ targetyaw+=180;
}
- targetrotation+=180;
+ targetyaw+=180;
}
}
for(i=0;i<skeleton.num_joints;i++){
tempanimation.position[i][0]=skeleton.joints[i].position;
- tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
+ tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-yaw,0);
}
}
}
XYZ tempvelocity;
tempvelocity=velocity;
Normalise(&tempvelocity);
- targetrotation=-asin(0-tempvelocity.x);
- targetrotation*=360/6.28;
- if(velocity.z<0)targetrotation=180-targetrotation;
- //targetrotation+=180;
+ targetyaw=-asin(0-tempvelocity.x);
+ targetyaw*=360/6.28;
+ if(velocity.z<0)targetyaw=180-targetyaw;
+ //targetyaw+=180;
skeleton.free=0;
if(dotproduct(&skeleton.forward,&tempvelocity)<0){
}
else{
targetanimation=backhandspringanim;
- targetrotation+=180;
+ targetyaw+=180;
targetframe=6;
}
target=0;
velocity=0;
- rotation=targetrotation;
+ yaw=targetyaw;
tilt=0;
targettilt=0;
tilt2=0;
}
XYZ tempcoord;
if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
- if(objects.rotation2[i]==0)tempcoord=coords;
+ if(objects.pitch[i]==0)tempcoord=coords;
else{
tempcoord=coords-objects.position[i];
- tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
- tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
+ tempcoord=DoRotation(tempcoord,0,-objects.yaw[i],0);
+ tempcoord=DoRotation(tempcoord,-objects.pitch[i],0,0);
tempcoord+=objects.position[i];
}
if(findDistancefastflat(&tempcoord,&objects.position[i])<objects.scale[i]*objects.scale[i]*8&&findDistancefast(&tempcoord,&objects.position[i])<objects.scale[i]*objects.scale[i]*300&&tempcoord.y>objects.position[i].y+3*objects.scale[i]){
if(!isnormal(targettilt2)&&targettilt2){
targettilt2=0;
}
- if(!isnormal(targetrotation)&&targetrotation){
- targetrotation=0;
+ if(!isnormal(targetyaw)&&targetyaw){
+ targetyaw=0;
}
if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
flatfacing=0;
flatfacing.z=1;
- flatfacing=DoRotation(flatfacing,0,rotation,0);
+ flatfacing=DoRotation(flatfacing,0,yaw,0);
facing=flatfacing;
ReflectVector(&facing,terrainnormal);
Normalise(&facing);
if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
terrainnormal=victim->coords-coords;
Normalise(&terrainnormal);
- targetrotation=-asin(0-terrainnormal.x);
- targetrotation*=360/6.28;
- if(terrainnormal.z<0)targetrotation=180-targetrotation;
+ targetyaw=-asin(0-terrainnormal.x);
+ targetyaw*=360/6.28;
+ if(terrainnormal.z<0)targetyaw=180-targetyaw;
targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
}
if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
- targetrotation=victim->targetrotation;
+ targetyaw=victim->targetyaw;
}
if(targetanimation==rabbittacklinganim){
coords=victim->coords;
XYZ terrainlight;
float terrainheight;
float distance;
- if(!isnormal(rotation))rotation=0;
+ if(!isnormal(yaw))yaw=0;
if(!isnormal(tilt))tilt=0;
if(!isnormal(tilt2))tilt2=0;
oldplayerdetail=playerdetail;
if(!isSleeping()&&!isSitting()){
if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
XYZ point,newpoint,change,change2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
heightleft=terrain.getHeight(point.x,point.z)+.04;
point.y=heightleft;
change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
+ skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0);
skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
heightright=terrain.getHeight(point.x,point.z)+.04;
point.y=heightright;
change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
+ skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0);
skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
skeleton.DoConstraints(&coords,&scale);
if(creature==wolftype){
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
heightleft=terrain.getHeight(point.x,point.z)+.04;
point.y=heightleft;
change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
+ skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0);
skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
heightright=terrain.getHeight(point.x,point.z)+.04;
point.y=heightright;
change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
+ skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0);
skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
skeleton.DoConstraints(&coords,&scale);
}
if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
XYZ point,newpoint,change,change2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
heightleft=terrain.getHeight(point.x,point.z)+.04;
point.y=heightleft;
change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
+ skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
heightright=terrain.getHeight(point.x,point.z)+.04;
point.y=heightright;
change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
+ skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
skeleton.DoConstraints(&coords,&scale);
if(creature==wolftype){
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
heightleft=terrain.getHeight(point.x,point.z)+.04;
point.y=heightleft;
change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
+ skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
heightright=terrain.getHeight(point.x,point.z)+.04;
point.y=heightright;
change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
+ skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
skeleton.DoConstraints(&coords,&scale);
if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
XYZ point,newpoint,change,change2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
heightleft=terrain.getHeight(point.x,point.z)+.04;
point.y=heightleft;
change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
+ skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
heightright=terrain.getHeight(point.x,point.z)+.04;
point.y=heightright;
change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
+ skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
skeleton.DoConstraints(&coords,&scale);
if(creature==wolftype){
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,yaw,0)*scale+coords;
heightleft=terrain.getHeight(point.x,point.z)+.04;
point.y=heightleft;
change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
+ skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
+ point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,yaw,0)*scale+coords;
heightright=terrain.getHeight(point.x,point.z)+.04;
point.y=heightright;
change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
+ skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-yaw,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
skeleton.DoConstraints(&coords,&scale);
if(!skeleton.free&&(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&((targetanimation!=rollanim&&!isFlip())||animation[targetanimation].label[targetframe]==6)&&targetanimation!=getupfromfrontanim&&targetanimation!=wolfrunninganim&&targetanimation!=rabbitrunninganim&&targetanimation!=backhandspringanim&&targetanimation!=walljumpfrontanim&&targetanimation!=hurtidleanim&&!isLandhard()&&!isSleeping()))
DoHead();
else {
- targetheadrotation=-targetrotation;
- targetheadrotation2=0;
- if(animation[targetanimation].attack==3)targetheadrotation+=180;
+ targetheadyaw=-targetyaw;
+ targetheadpitch=0;
+ if(animation[targetanimation].attack==3)targetheadyaw+=180;
}
for(i=0;i<skeleton.drawmodel.vertexNum;i++){
skeleton.drawmodel.vertex[i]=0;
if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
- if(!skeleton.free)glRotatef(rotation,0,1,0);
+ if(!skeleton.free)glRotatef(yaw,0,1,0);
if(showpoints){
glPointSize(5);
glColor4f(.4,1,.4,1);
weapons[i].bigtilt=0;
weapons[i].bigtilt2=0;
} else {
- weapons[i].position=DoRotation(DoRotation(DoRotation(weaponpoint,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords+currentoffset*(1-target)*scale+targetoffset*target*scale;
- weapons[i].bigrotation=rotation;
+ weapons[i].position=DoRotation(DoRotation(DoRotation(weaponpoint,0,0,tilt),tilt2,0,0),0,yaw,0)*scale+coords+currentoffset*(1-target)*scale+targetoffset*target*scale;
+ weapons[i].bigrotation=yaw;
weapons[i].bigtilt=tilt;
weapons[i].bigtilt2=tilt2;
}
bool immobile;
float velspeed;
- float targetrotation;
+ float targetyaw;
float targetrot;
float rot;
float oldrot;
- float lookrotation;
- float lookrotation2;
- float rotation;
- float rotation2;
- float lowrotation;
+ float lookyaw;
+ float lookpitch;
+ float yaw;
+ float pitch;
+ float lowyaw;
float tilt;
float targettilt;
float tilt2;
int direction;
float texupdatedelay;
- float headrotation,headrotation2;
- float targetheadrotation,targetheadrotation2;
+ float headyaw,headpitch;
+ float targetheadyaw,targetheadpitch;
bool onterrain;
bool pause;
if(tutoriallevel!=1||id==0)
if(findLengthfast(&bounceness)>8000&&breaking){
- objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360);
+ objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.yaw[k],0),.4,.5,Random()%360);
Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2);
//Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 1, .2);
breaking=0;
friction=objects.friction[k];
start=joints[i].realoldposition;
end=joints[i].position*(*scale)+*coords;
- whichhit=objects.model[k].LineCheckPossible(&start,&end,&temp,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheckPossible(&start,&end,&temp,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1){
if(joints[i].label==groin&&!joints[i].locked&&joints[i].delay<=0){
joints[i].locked=1;
}
}
- terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
+ terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.yaw[k],0)*-1;
if(terrainnormal.y>.8)freefall=0;
bounceness=terrainnormal*findLength(&joints[i].velocity)*(abs(normaldotproduct(joints[i].velocity,terrainnormal)));
if(findLengthfast(&joints[i].velocity)>findLengthfast(&joints[i].oldvelocity)){
}
if(tutoriallevel!=1||id==0)
if(findLengthfast(&bounceness)>4000&&breaking){
- objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360);
+ objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.yaw[k],0),.4,.5,Random()%360);
Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2);
breaking=0;
camerashake+=.6;
//Make this less stupid
start=joints[jointlabels[whichjointstartarray[i]]].position*(*scale)+*coords;
end=joints[jointlabels[whichjointendarray[i]]].position*(*scale)+*coords;
- whichhit=objects.model[k].LineCheckSlidePossible(&start,&end,&temp,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheckSlidePossible(&start,&end,&temp,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1){
joints[jointlabels[whichjointendarray[i]]].position=(end-*coords)/(*scale);
for(j=0; j<num_muscles; j++){
if(!spritehit&&player[j].dead&&sprites[i]->alivetime>.1){
where=sprites[i]->oldposition;
where-=player[j].coords;
- if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0);
+ if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].yaw,0);
startpoint=where;
where=sprites[i]->position;
where-=player[j].coords;
- if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0);
+ if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].yaw,0);
endpoint=where;
movepoint=0;
start=sprites[i]->oldposition;
end=sprites[i]->position;
if(!spritehit)
- if(objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k])!=-1){
- if(detail==2||(detail==1&&abs(Random()%4)==0)||(detail==0&&abs(Random()%8)==0))objects.model[k].MakeDecal(blooddecalfast,DoRotation(colpoint-objects.position[k],0,-objects.rotation[k],0),sprites[i]->size*1.6/*+abs((float)(Random()%100))/2400*/,.5,Random()%360);
+ if(objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k])!=-1){
+ if(detail==2||(detail==1&&abs(Random()%4)==0)||(detail==0&&abs(Random()%8)==0))objects.model[k].MakeDecal(blooddecalfast,DoRotation(colpoint-objects.position[k],0,-objects.yaw[k],0),sprites[i]->size*1.6/*+abs((float)(Random()%100))/2400*/,.5,Random()%360);
DeleteSprite(i);
spritehit=1;
}
#include "Objects.h"
extern XYZ viewer;
extern float viewdistance;
-extern float lightambient[3],lightbrightness[3];
extern float fadestart;
extern int environment;
extern float texscale;
if(objects.type[l]!=treetrunktype){
testpoint=terrainpoint;
testpoint2=terrainpoint+lightloc*50*(1-shadowed);
- if(objects.model[l].LineCheck(&testpoint,&testpoint2,&col,&objects.position[l],&objects.rotation[l])!=-1){
+ if(objects.model[l].LineCheck(&testpoint,&testpoint2,&col,&objects.position[l],&objects.yaw[l])!=-1){
shadowed=1-(findDistance(&terrainpoint,&col)/50);
}
}
int k=terrain.patchobjects[whichpatchx][whichpatchz][j];
start=oldtippoint;
end=tippoint;
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1) {
if(objects.type[k]==treetrunktype){
- objects.model[k].MakeDecal(breakdecal,DoRotation(colpoint-objects.position[k],0,-objects.rotation[k],0),.1,1,Random()%360);
- normalrot=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0);
+ objects.model[k].MakeDecal(breakdecal,DoRotation(colpoint-objects.position[k],0,-objects.yaw[k],0),.1,1,Random()%360);
+ normalrot=DoRotation(objects.model[k].facenormals[whichhit],0,objects.yaw[k],0);
velocity=0;
if(type==knife)
position=colpoint-normalrot*.1;
if(velocity.x||velocity.y||velocity.z) {
for(int j=0;j<numplayers;j++) {
footvel=0;
- footpoint=DoRotation((player[j].skeleton.joints[player[j].skeleton.jointlabels[abdomen]].position+player[j].skeleton.joints[player[j].skeleton.jointlabels[neck]].position)/2,0,player[j].rotation,0)*player[j].scale+player[j].coords;
+ footpoint=DoRotation((player[j].skeleton.joints[player[j].skeleton.jointlabels[abdomen]].position+player[j].skeleton.joints[player[j].skeleton.jointlabels[neck]].position)/2,0,player[j].yaw,0)*player[j].scale+player[j].coords;
if(owner==-1 && findDistancefastflat(&position,&player[j].coords)<1.5 &&
findDistancefast(&position,&player[j].coords)<4 && player[j].weaponstuck==-1 &&
!player[j].skeleton.free && j!=oldowner) {
if(type==staff) {
start=tippoint-(position-tippoint)/5;
end=position+(position-tippoint)/30;
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1) {
XYZ diff;
diff=(colpoint-position);
} else {
start=position-(tippoint-position)/5;
end=tippoint+(tippoint-position)/30;
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1){
XYZ diff;
diff=(colpoint-tippoint);
start=oldposition;
end=position;
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1) {
hitsomething=1;
position=colpoint;
- terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
+ terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.yaw[k],0)*-1;
ReflectVector(&velocity,&terrainnormal);
position+=terrainnormal*.002;
}
start=oldtippoint;
end=tippoint;
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1) {
hitsomething=1;
tippoint=colpoint;
- terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
+ terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.yaw[k],0)*-1;
ReflectVector(&tipvelocity,&terrainnormal);
tippoint+=terrainnormal*.002;
}
}
- if((objects.type[k]!=boxtype && objects.type[k]!=platformtype && objects.type[k]!=walltype && objects.type[k]!=weirdtype)||objects.rotation2[k]!=0)
+ if((objects.type[k]!=boxtype && objects.type[k]!=platformtype && objects.type[k]!=walltype && objects.type[k]!=weirdtype)||objects.pitch[k]!=0)
for(int m=0;m<2;m++){
mid=(position*(21+(float)m*10)+tippoint*(19-(float)m*10))/40;
oldmid2=mid;
start=oldmid;
end=mid;
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1) {
hitsomething=1;
mid=colpoint;
- terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
+ terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.yaw[k],0)*-1;
ReflectVector(&velocity,&terrainnormal);
bounceness=terrainnormal*findLength(&velocity)*(abs(normaldotproduct(velocity,terrainnormal)));
start=oldmid;
end=mid;
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1) {
hitsomething=1;
mid=colpoint;
- terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
+ terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.yaw[k],0)*-1;
ReflectVector(&tipvelocity,&terrainnormal);
bounceness=terrainnormal*findLength(&tipvelocity)*(abs(normaldotproduct(tipvelocity,terrainnormal)));
{
start=position;
end=tippoint;
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
+ whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k]);
if(whichhit!=-1) {
hitsomething=1;
closestdistance=-1;
closestswordpoint=colpoint;//(position+tippoint)/2;
- point[0]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[0]],0,objects.rotation[k],0)+objects.position[k];
- point[1]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[1]],0,objects.rotation[k],0)+objects.position[k];
- point[2]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[2]],0,objects.rotation[k],0)+objects.position[k];
+ point[0]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[0]],0,objects.yaw[k],0)+objects.position[k];
+ point[1]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[1]],0,objects.yaw[k],0)+objects.position[k];
+ point[2]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[2]],0,objects.yaw[k],0)+objects.position[k];
if(DistancePointLine(&closestswordpoint, &point[0], &point[1], &distance,&colpoint )) {
if(distance<closestdistance||closestdistance==-1){
closestpoint=colpoint;