glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
- //glFinish();
static XYZ terrainlight;
static float distance;
if (drawmode == normalmode)
terrain.draw(0);
terraintexture2.bind();
terrain.draw(1);
- //glBindTexture( GL_TEXTURE_2D, terraintexture3);
- //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- //terrain.draw(2);
terrain.drawdecals();
text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
}
loading = 2;
- //if(ismotionblur)drawmode=motionblurmode;
drawmode = normalmode;
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
- //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
}
}
- //glFlush();
}
glClear(GL_DEPTH_BUFFER_BIT);
if (drawmode == motionblurmode) {
if (motionbluramount < .2)
motionbluramount = .2;
- //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
glColor4f(1, 1, 1, motionbluramount);
glPushMatrix();
glBegin(GL_QUADS);
}
if (drawmode == radialzoommode) {
for (int i = 0; i < 3; i++) {
- //glRotatef((float)i*.1,0,0,1);
glColor4f(1, 1, 1, 1 / ((float)i + 1));
glPushMatrix();
glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
multiplier = 0;
}
- //glFlush();
if ( side == stereoRight || side == stereoCenter ) {
if (drawmode != motionblurmode || mainmenu) {
swap_gl_buffers();
}
}
- //myassert(glGetError() == GL_NO_ERROR);
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
- //glFlush();
weapons.DoStuff();
glColor4f(1, 1, 1, 1);
Game::cursortexture.bind();
glPushMatrix();
- //glScalef(.25,.25,.25);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(-1, -1, 0.0f);
void Game::LoadingScreen()
{
static float loadprogress;
- //~ static AbsoluteTime time = {0, 0};
static AbsoluteTime frametime = {0, 0};
AbsoluteTime currTime = UpTime ();
double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
if (loadprogress > 100)
loadprogress = 100;
- //loadprogress=abs(Random()%100);
-
//Background
glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
glPushMatrix();
- //glScalef(.25,.25,.25);
glBegin(GL_QUADS);
glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
glVertex3f(-1, -1, 0.0f);
glPopMatrix();
glEnable(GL_BLEND);
glPushMatrix();
- //glScalef(.25,.25,.25);
glBegin(GL_QUADS);
glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
glVertex3f(-1, -1, 0.0f);
glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_BLEND);
- //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
glPushMatrix();
- //glScalef(.25,.25,.25);
glBegin(GL_QUADS);
glTexCoord2f(0 + .5, 0 + .5);
glVertex3f(-1, -1, 0.0f);
glEnable(GL_BLEND);
glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
glPushMatrix();
- //glScalef(.25,.25,.25);
glBegin(GL_QUADS);
glTexCoord2f(0 + .2, 0 + .8);
glVertex3f(-1, -1, 0.0f);
loadprogress = howmuch;
- //loadprogress=abs(Random()%100);
-
//Background
- //glEnable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_2D);
- //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glColor4f(loadprogress / 100, 0, 0, 1);
glPushMatrix();
- //glScalef(.25,.25,.25);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(-1, -1, 0.0f);
}
}
- //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
-
return -1;
}
int mapvers;
FILE *tfile;
- //~ char* buff=getcwd(NULL,0);
- //~ cout << buff << " " << FixedFN << endl;
- //~ free(buff);
tfile = fopen( FixedFN, "rb" );
if (tfile) {
pause_sound(stream_firesound);
}
if (Input::isKeyPressed(SDL_SCANCODE_N) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
- //if(!Person::players[0]->skeleton.free)Person::players[0]->damage+=500;
Person::players[0]->RagDoll(0);
- //Person::players[0]->spurt=1;
- //Person::players[0]->DoDamage(1000);
emit_sound_at(whooshsound, Person::players[0]->coords, 128.);
}
}
if (Input::isKeyPressed(SDL_SCANCODE_M) && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
- //drawmode++;
- //if(drawmode>2)drawmode=0;
if (objects.numobjects < max_objects - 1) {
XYZ boxcoords;
boxcoords.x = Person::players[0]->coords.x;
Person::players[k]->yaw = stepTowardf(Person::players[k]->yaw, Person::players[k]->targetyaw, multiplier * Person::players[k]->turnspeed * 4);
}
- /*if(Person::players[k]->aitype!=passivetype||(distsq(&Person::players[k]->coords,&viewer)<viewdistance*viewdistance))*/
Person::players[k]->DoStuff();
if (Person::players[k]->immobile && k != 0)
Person::players[k]->coords = Person::players[k]->realoldcoords;
hotspotvisual[i] -= multiplier / 320;
for (int i = 0; i < numhotspots; i++) {
- //if(hotspottype[i]<=10)
while (hotspotvisual[i] < 0) {
hotspotsprite = 0;
hotspotsprite.x = float(abs(Random() % 100000)) / 100000 * hotspotsize[i];
}
target.y += .1;
}
- if (Person::players[0]->skeleton.free != 2/*&&!autocam*/) {
+ if (Person::players[0]->skeleton.free != 2) {
cameraspeed = 20;
if (findLengthfast(&Person::players[0]->velocity) > 400) {
cameraspeed = 20 + (findLength(&Person::players[0]->velocity) - 20) * .96;
cameraloc.y = terrain.getHeight(cameraloc.x, cameraloc.z);
}
}
- /*
- //what did autocam do?
- if(Person::players[0]->skeleton.free!=2&&autocam){
- cameraspeed=20;
- if(findLengthfast(&Person::players[0]->velocity)>400){
- cameraspeed=20+(findLength(&Person::players[0]->velocity)-20)*.96;
- }
- if(Person::players[0]->skeleton.free==0&&Person::players[0]->animTarget!=hanganim&&Person::players[0]->animTarget!=climbanim)target.y+=1.4;
- cameradist+=multiplier*5;
- if(cameradist>3.3)cameradist=3.3;
- coltarget=target-cameraloc;
- if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
- else if(findLengthfast(&coltarget)>1)
- {
- Normalise(&coltarget);
- if(Person::players[0]->animTarget!=hanganim&&Person::players[0]->animTarget!=climbanim&&Person::players[0]->animCurrent!=climbanim&&Person::players[0]->currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
- else cameraloc=cameraloc+coltarget*multiplier*8;
- }
- if(editorenabled)cameraloc=target;
- viewer=cameraloc;
- colviewer=viewer;
- coltarget=cameraloc;
- objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
- if(terrain.patchobjectnum[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz])
- for(int j=0;j<terrain.patchobjectnum[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz];j++){
- int i=terrain.patchobjects[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz][j];
- colviewer=viewer;
- coltarget=cameraloc;
- if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.yaw[i])!=-1)viewer=col;
- }
- if(terrain.patchobjectnum[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz])
- for(int j=0;j<terrain.patchobjectnum[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz];j++){
- int i=terrain.patchobjects[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz][j];
- colviewer=viewer;
- if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.yaw[i])!=-1){
- viewer=colviewer;
- }
- }
- cameradist=findDistance(&viewer,&target);
- viewer.y=max((double)viewer.y,terrain.getHeight(viewer.x,viewer.z)+.6);
- if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
- cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
- }
- }
- */
if (camerashake > .8)
camerashake = .8;
- //if(woozy>10)woozy=10;
- //woozy+=multiplier;
woozy += multiplier;
if (Person::players[0]->dead)
camerashake = 0;
woozy = 0;
camerashake -= multiplier * 2;
blackout -= multiplier * 2;
- //if(Person::players[0]->isCrouch())woozy-=multiplier*8;
if (camerashake < 0)
camerashake = 0;
if (blackout < 0)
blackout = 0;
- //if(woozy<0)woozy=0;
if (camerashake) {
viewer.x += (float)(Random() % 100) * .0005 * camerashake;
viewer.y += (float)(Random() % 100) * .0005 * camerashake;
GLfloat LightDiffuse[] = { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
GLfloat LightPosition[] = { whichsource->location.x, whichsource->location.y, whichsource->location.z, 0.0f };
- //glLightfv(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, qattenuation);
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[2]], p1, &radius);
if (intersecting) {
*p1 += facenormals[j] * (distance - radius);
- /*start=*p1;
- end=*p1;
- end.y-=radius;
- if(LineFacetd(&start,&end,&vertex[Triangles[j].vertex[0]],&vertex[Triangles[j].vertex[1]],&vertex[Triangles[j].vertex[2]],&facenormals[j],&point)){
- p1->y=point.y+radius;
- }*/
}
}
if ((distance < olddistance || firstintersecting == -1) && intersecting) {
if (!intersecting)
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[2]], p1, &radius);
if (intersecting) {
- //if(j>=0&&j<TriangleNum)
possible[numpossible] = j;
numpossible++;
}
LOG(std::string("Loading decal...") + FixedFN);
- //~ int oldvertexNum, oldTriangleNum;
- //~ oldvertexNum = vertexNum;
- //~ oldTriangleNum = TriangleNum;
-
type = decalstype;
numdecals = 0;
color = 0;
decaltexcoords[i][j] = (float*)malloc(sizeof(float) * 2);
}
}
- //if(decalvertex)free(decalvertex);
decalvertex = (XYZ**)malloc(sizeof(XYZ*)*max_model_decals);
for (i = 0; i < max_model_decals; i++) {
decalvertex[i] = (XYZ*)malloc(sizeof(XYZ) * 3);
textureptr.bind();
glBegin(GL_TRIANGLES);
for (int i = 0; i < TriangleNum; i++) {
- /*if(Triangles[i].vertex[0]<vertexNum&&Triangles[i].vertex[1]<vertexNum&&Triangles[i].vertex[2]<vertexNum&&Triangles[i].vertex[0]>=0&&Triangles[i].vertex[1]>=0&&Triangles[i].vertex[2]>=0){
- if(isnormal(vertex[Triangles[i].vertex[0]].x)&&isnormal(vertex[Triangles[i].vertex[0]].y)&&isnormal(vertex[Triangles[i].vertex[0]].z)
- &&isnormal(vertex[Triangles[i].vertex[1]].x)&&isnormal(vertex[Triangles[i].vertex[1]].y)&&isnormal(vertex[Triangles[i].vertex[1]].z)
- &&isnormal(vertex[Triangles[i].vertex[2]].x)&&isnormal(vertex[Triangles[i].vertex[2]].y)&&isnormal(vertex[Triangles[i].vertex[2]].z)){
- */
glTexCoord2f(Triangles[i].gx[0], Triangles[i].gy[0]);
if (color)
glColor3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
if (!color && flat)
glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
glVertex3f(vertex[Triangles[i].vertex[2]].x, vertex[Triangles[i].vertex[2]].y, vertex[Triangles[i].vertex[2]].z);
- //}
- //}
}
glEnd();
}
if (type != decalstype)
return;
static int i;
- //~ static float distancemult;
static int lasttype;
- //~ static float viewdistsquared;
static bool blend;
- //~ viewdistsquared = viewdistance * viewdistance;
blend = 1;
lasttype = -1;
static float placex, placez;
static XYZ rot;
- //static XYZ point,point1,point2;
static float distance;
static int i, j;
static float placex, placez;
static XYZ rot;
- //static XYZ point,point1,point2;
static float distance;
static int i, j;
distance = 1;
if (distance > 0) {
- /*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;*/
if (occluded[i] < 6) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
position[numobjects] = where;
if (atype == bushtype)
position[numobjects].y = terrain.getHeight(position[numobjects].x, position[numobjects].z) - .3;
- /*if(atype==firetype){
- 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;
- }*/
yaw[numobjects] = ayaw;
pitch[numobjects] = apitch;
{
XYZ spawnpoint;
for (int i = 0; i < numobjects; i++) {
- /*if(type[i]==firetype){
- Sprite::MakeSprite(weaponshinesprite, position[i],position[i]*0, 1,1,1, 5, 1);
- }*/
-
if (type[i] == firetype)
onfire[i] = 1;
if (onfire[i]) {
glDisable( GL_ALPHA_TEST);
glDisable( GL_BLEND);
glDisable( GL_DEPTH_TEST);
- //glDisable( GL_DITHER);
glDisable( GL_FOG);
glDisable( GL_LIGHTING);
glDisable( GL_LOGIC_OP);
glClearDepth( 1.0f);
glDepthFunc( GL_LEQUAL);
glDepthMask( GL_TRUE);
- //glDepthRange( FRONT_CLIP, BACK_CLIP);
glEnable( GL_DEPTH_TEST);
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glCullFace( GL_FRONT);
glEnable( GL_CULL_FACE);
glEnable( GL_LIGHTING);
- //glEnable( GL_LIGHT_MODEL_AMBIENT);
glEnable( GL_DITHER);
glEnable( GL_COLOR_MATERIAL);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// FIXME: should abstract out inputs
static int bleedxint, bleedyint;
static XYZ bloodvel;
- //if(howmuch&&id==0)blooddimamount=1;
if (bloodtoggle && tutoriallevel != 1) {
if (bleeding <= 0 && spurt) {
spurt = 0;
envsoundvol[numenvsounds] = 16;
envsoundlife[numenvsounds] = .4;
numenvsounds++;
- //if(i==2)whichsound=rabbitpain2sound;
}
if (whichsound != -1)
// texture manipulation follows
int offsetx = 0, offsety = 0;
- /*if(which==225){
- offsety=Random()%40;
- offsetx=abs(Random()%120);
- }
- if(which==220||which==215){
- offsety=Random()%20;
- offsetx=abs(Random()%80);
- }*/
- //which=220;
offsetx = (1 + coordsy) * 512 - 291;
offsety = coordsx * 512 - 437;
skeleton.free = 2;
DoDamage(10000);
RagDoll(0);
- /*if(autoslomo){
- slomo=1;
- slomodelay=.2;
- }*/
if (!dead && creature == wolftype) {
award_bonus(0, Wolfbonus);
}
envsoundvol[numenvsounds] = 16;
envsoundlife[numenvsounds] = .4;
numenvsounds++;
- //if(i==2)whichsound=rabbitpain2sound;
}
if (whichsound != -1) {
}
}
speechdelay = .3;
-
- //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
- //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
}
/* EFFECT
}
if (animTarget == rabbittacklinganim && frameTarget == 1) {
- //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->animTarget].attack==neutral&&victim->id!=0)Reverse();
if (victim->aitype == attacktypecutoff && victim->stunned <= 0 && victim->surprised <= 0 && victim->id != 0)
Reverse();
if (animTarget == rabbittacklinganim && frameTarget == 1 && !victim->isCrouch() && victim->animTarget != backhandspringanim) {
}
speechdelay = .3;
}
- //if(animation[animTarget].attack==neutral)whichsound=movewhooshsound;
}
- //else if(animation[animTarget].label[frameTarget]==4)whichsound=knifeswishsound;
- //if(animation[animTarget].label[frameTarget]==8)whichsound=landsound2;
if (whichsound != -1) {
emit_sound_at(whichsound, coords);
if (hasvictim) {
damagemult /= victim->damagetolerance / 200;
}
- //if(onfire)damagemult=3;
if ((animation[animTarget].attack == normalattack || animTarget == walljumprightkickanim || animTarget == walljumpleftkickanim) && (!feint) && (victim->skeleton.free != 2 || animTarget == killanim || animTarget == dropkickanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || animTarget == staffgroundsmashanim)) {
if (animTarget == spinkickanim && animation[animTarget].label[frameCurrent] == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && animation[victim->animTarget].height != lowheight) {
}
if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && animation[animTarget].label[frameCurrent] == 5) {
- //if(id==0)camerashake+=.4;
if (hasvictim)
if (!victim->skeleton.free)
weapons[weaponids[0]].owner = -1;
aim = victim->coords + DoRotation(victim->jointPos(abdomen), 0, victim->yaw, 0) * victim->scale + victim->velocity * findDistance(&victim->coords, &coords) / 50 - (coords + DoRotation(jointPos(righthand), 0, yaw, 0) * scale);
Normalise(&aim);
- /*if(victim->animTarget==jumpupanim||victim->animTarget==jumpdownanim){
- aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
- }*/
weapons[weaponids[0]].velocity = aim * 50;
weapons[weaponids[0]].tipvelocity = aim * 50;
weapons[weaponids[0]].missed = 0;
victim->num_weapons--;
if (victim->num_weapons > 0) {
victim->weaponids[victim->weaponactive] = victim->weaponids[victim->num_weapons];
- //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
}
victim->weaponactive = -1;
}
relative = victim->coords - oldcoords;
relative.y = 0;
Normalise(&relative);
- //relative=DoRotation(relative,0,-90,0);
for (int i = 0; i < victim->skeleton.num_joints; i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 30;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
- //FootLand(1,2);
victim->Puff(head);
victim->DoDamage(damagemult * 70 / victim->protectionhigh);
}
relative = victim->coords - oldcoords;
relative.y = 0;
Normalise(&relative);
- //relative=DoRotation(relative,0,-90,0);
for (int i = 0; i < victim->skeleton.num_joints; i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 30;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
- //FootLand(1,2);
victim->Puff(head);
victim->DoDamage(damagemult * 70 / victim->protectionhigh);
}
relative = facing;
relative.y = 0;
Normalise(&relative);
- //relative*=-1;
relative.y -= .1;
for (int i = 0; i < victim->skeleton.num_joints; i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 70;
relative = facing;
relative.y = 0;
Normalise(&relative);
- //relative*=-1;
relative.y -= .1;
for (int i = 0; i < victim->skeleton.num_joints; i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 70;
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
- //FootLand(1,2);
victim->Puff(abdomen);
victim->DoDamage(damagemult * 30 / victim->protectionhigh);
for (int i = 0; i < victim->skeleton.num_joints; i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
- //victim->DoDamage(1000);
victim->damage = victim->damagetolerance;
victim->permanentdamage = victim->damagetolerance - 1;
bool doslice;
if (animTarget == knifefollowanim)
victim->DoBloodBig(200, 210);
if (animTarget == knifesneakattackanim) {
- /*victim->DoBloodBig(200,195);
- XYZ bloodvel;
- bloodvel=0;
- bloodvel.z=20;
- bloodvel.y=5;
- bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
- Sprite::MakeSprite(bloodsprite, DoRotation(jointPos(neck),0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- */
XYZ footvel, footpoint;
footvel = 0;
footpoint = weapons[weaponids[0]].tippoint;
victim->Puff(neck);
XYZ relative;
- //relative=victim->coords-oldcoords;
relative = facing * -1;
relative.y = 0;
Normalise(&relative);
escapednum = 0;
victim->RagDoll(0);
XYZ relative;
- //relative=victim->coords-oldcoords;
relative = facing * -1;
relative.y = 0;
Normalise(&relative);
transspeed = 15;
}
}
- //skeleton.DoConstraints();
}
/* EFFECT
if (onfire) {
burnt += multiplier;
- /*if(aitype!=playercontrolled)*///deathbleeding=5;
- /*if(aitype!=playercontrolled)*/
deathbleeding = 1;
if (burnt > .6)
burnt = .6;
}
bloodloss += deathbleeding * multiplier * 80;
deathbleeding -= multiplier * 1.6;
- //if(id==0)deathbleeding-=multiplier*.2;
if (deathbleeding < 0)
deathbleeding = 0;
if (bloodloss > damagetolerance && animation[animTarget].attack == neutral) {
damage += 20;
}
- //if(dead)damage-=multiplier/4;
if (!dead)
damage -= multiplier * 13;
- //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
if (!dead)
permanentdamage -= multiplier * 4;
if (isIdle() || isCrouch()) {
if (!dead)
permanentdamage -= multiplier * 4;
- //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
}
if (damage < 0)
damage = 0;
yaw = targetyaw;
frameTarget = 0;
- // frameTarget=2;
animTarget = flipanim;
crouchtogglekeydown = 1;
target = 0;
animCurrent = tempanim;
frameCurrent = 0;
target = 0;
- //tilt2=targettilt2;
-
- //if(middle.y>0)targetoffset.y=middle.y+1;
for (int i = 0; i < skeleton.num_joints; i++) {
tempanimation.position[i][0] = skeleton.joints[i].position;
}
//Running velocity
- //if(!creature==wolftype||animTarget==rabbitkickanim)
if (animTarget == rabbittackleanim) {
velocity += facing * multiplier * speed * 700 * scale;
velspeed = findLength(&velocity);
velocity = flatfacing * velspeed;
}
-
- /*if(animCurrent==rollanim&&(isCrouch()||isIdle())){
- velocity+=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(velspeed>speed*25*scale){
- velocity/=velspeed;
- velspeed=speed*25*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed;
- }*/
-
if (animTarget == sneakanim || animTarget == walkanim) {
velocity += facing * multiplier * speed * 700 * scale;
velspeed = findLength(&velocity);
(v0.y * (1 - morphness) + v1.y * morphness) * proportionhead.y,
(v0.z * (1 - morphness) + v1.z * morphness) * proportionhead.z);
glGetFloatv(GL_MODELVIEW_MATRIX, M);
- //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
- //if(!isnormal(scale))test=1;
skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x = M[12] * scale;
skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y = M[13] * scale;
skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z = M[14] * scale;
- //test=2;
glPopMatrix();
}
}
glEnable(GL_BLEND);
}
if (tutoriallevel && id != 0) {
- //glDisable(GL_TEXTURE_2D);
glColor4f(.7, .7, .7, 0.6);
glDepthMask(0);
glEnable(GL_LIGHTING);
calcrot = 1;
if (animCurrent != animTarget)
calcrot = 1;
- //if(id==0)calcrot=1;
if (skeleton.free == 2)
calcrot = 0;
if (tfile) {
// read numframes, joints to know how much memory to allocate
funpackf(tfile, "Bi Bi", &numframes, &joints);
- /*
- for(i = 0; i < joints; i++){
- if(position[i])dealloc2(position[i]);
- if(twist[i])dealloc2(twist[i]);
- if(twist2[i])dealloc2(twist2[i]);
- if(onground[i])dealloc2(onground[i]);
- }*/
- /*
- if(position)dealloc2(position);
- if(twist)dealloc2(twist);
- if(twist2)dealloc2(twist2);
- if(speed)dealloc2(speed);
- if(onground)dealloc2(onground);
- if(forward)dealloc2(forward);
- if(weapontarget)dealloc2(weapontarget);
- if(label)dealloc2(label);*/
-
// allocate memory for everything
weapontarget = (XYZ*)malloc(sizeof(XYZ) * numframes);
label = (int*)malloc(sizeof(int) * numframes);
- /*position = new XYZ[joints][numframes];
- twist = new float[joints][numframes];
- twist2 = new float[joints][numframes];
- speed = new float[numframes];
- onground = new bool[joints][numframes];
- forward = new XYZ[numframes];
- label = new int[numframes];*/
-
-
// read binary data as animation
// for each frame...
funpackf(tfile, "Bi", &num_joints);
// allocate memory
- //joints.resize(num_joints);
if (joints)
delete [] joints; //dealloc2(joints);
- joints = (Joint*)new Joint[num_joints]; //malloc(sizeof(Joint)*num_joints);
+ joints = (Joint*)new Joint[num_joints];
// read info for each joint
for (i = 0; i < num_joints; i++) {
funpackf(tfile, "Bi", &num_muscles);
// allocate memory
- //muscles.clear();
if (muscles)
delete [] muscles; //dealloc2(muscles);
muscles = (Muscle*)new Muscle[num_muscles]; //malloc(sizeof(Muscle)*num_muscles);
funpackf(tfile, "Bf Bf Bf Bf Bf Bi Bi", &muscles[i].length, &muscles[i].targetlength, &muscles[i].minlength, &muscles[i].maxlength, &muscles[i].strength, &muscles[i].type, &muscles[i].numvertices);
// allocate memory for vertices
- //muscles[i].vertices.clear();
- //muscles[i].vertices.resize(muscles[i].numvertices);
- //if(muscles[i].vertices)dealloc2(muscles[i].vertices);
muscles[i].vertices = (int*)malloc(sizeof(int) * muscles[i].numvertices);
// read vertices
lSize = sizeof(num_joints);
fseek(tfile, lSize, SEEK_CUR);
- //joints = new Joint[num_joints];
- //jointlabels = new int[num_joints];
for (i = 0; i < num_joints; i++) {
// skip joint info
lSize = sizeof(XYZ)
// read num_muscles
funpackf(tfile, "Bi", &num_muscles);
- //muscles = new Muscle[num_muscles];
for (i = 0; i < num_muscles; i++) {
// skip muscle info
if (muscles[i].numverticeslow) {
// allocate memory
- //muscles[i].verticeslow.clear();
- //muscles[i].verticeslow.resize(muscles[i].numverticeslow);
- //if(muscles[i].verticeslow)dealloc2(muscles[i].verticeslow);
muscles[i].verticeslow = (int*)malloc(sizeof(int) * muscles[i].numverticeslow);
// read verticeslow
}
}
- /*FindForwards();
- for(i=0;i<num_joints;i++){
- joints[i].startpos=joints[i].position;
- }
- for(i=0;i<num_muscles;i++){
- FindRotationMuscle(i,-1);
- }*/
-
// use opengl for its matrix math
for (i = 0; i < modellow.vertexNum; i++) {
modellow.vertex[i] = modellow.vertex[i] - (muscles[modellow.owner[i]].parent1->position + muscles[modellow.owner[i]].parent2->position) / 2;
// skip num_joints
lSize = sizeof(num_joints);
fseek ( tfile, lSize, SEEK_CUR);
- //joints = new Joint[num_joints];
- //jointlabels = new int[num_joints];
for (i = 0; i < num_joints; i++) {
// skip joint info
// read num_muscles
funpackf(tfile, "Bi", &num_muscles);
- //muscles = new Muscle[num_muscles];
for (i = 0; i < num_muscles; i++) {
// skip muscle info
// read verticesclothes
if (muscles[i].numverticesclothes) {
- //muscles[i].verticesclothes.clear();
- //muscles[i].verticesclothes.resize(muscles[i].numverticesclothes);
- //if(muscles[i].verticesclothes)dealloc2(muscles[i].verticesclothes);
muscles[i].verticesclothes = (int*)malloc(sizeof(int) * muscles[i].numverticesclothes);
edit = 0;
for (j = 0; j < muscles[i].numverticesclothes - edit; j++) {
}
}
- /*FindForwards();
- for(i=0;i<num_joints;i++){
- joints[i].startpos=joints[i].position;
- }
- for(i=0;i<num_muscles;i++){
- FindRotationMuscle(i,-1);
- }*/
-
// use opengl for its matrix math
for (i = 0; i < modelclothes.vertexNum; i++) {
modelclothes.vertex[i] = modelclothes.vertex[i] - (muscles[modelclothes.owner[i]].parent1->position + muscles[modelclothes.owner[i]].parent2->position) / 2;
glVertex3f(joints[i].parent->position.x, joints[i].parent->position.y, joints[i].parent->position.z);
}
}
- /*for(int i=0; i<num_joints; i++){
- if(joints[i].hasparent){
- glColor4f(jointcolor[0],jointcolor[1],jointcolor[2],1);
- glVertex3f(joints[i].position.x,joints[i].position.y,joints[i].position.z);
- glColor4f(jointcolor[0],jointcolor[1],jointcolor[2],1);
- glVertex3f(joints[i].position.x+forward.x,joints[i].position.y+forward.y,joints[i].position.z+forward.z);
- }
- }*/
for (int i = 0; i < num_muscles; i++) {
if (muscles[i].type == boneconnect) {
glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent1->blurred);
joints[num_joints].mass = 1;
joints[num_joints].locked = 0;
- /*if(which>=num_joints||which<0)*/
joints[num_joints].hasparent = 0;
- /*if(which<num_joints&&which>=0){
- joints[num_joints].parent=&joints[which];
- joints[num_joints].hasparent=1;
- joints[num_joints].length=findDistance(joints[num_joints].position,joints[num_joints].parent->position);
- }*/
num_joints++;
if (which < num_joints && which >= 0)
AddMuscle(num_joints - 1, which, 0, 10, boneconnect);
if (!spritehit)
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);
+ objects.model[k].MakeDecal(blooddecalfast, DoRotation(colpoint - objects.position[k], 0, -objects.yaw[k], 0), sprites[i]->size * 1.6, .5, Random() % 360);
DeleteSprite(i);
spritehit = 1;
}
}
if (!spritehit)
if (sprites[i]->position.y < terrain.getHeight(sprites[i]->position.x, sprites[i]->position.z)) {
- terrain.MakeDecal(blooddecalfast, sprites[i]->position, sprites[i]->size * 1.6/*+abs((float)(Random()%100))/2400*/, .6, Random() % 360);
+ terrain.MakeDecal(blooddecalfast, sprites[i]->position, sprites[i]->size * 1.6, .6, Random() % 360);
DeleteSprite(i);
}
}
// for Windows, just use TGA loader for now
char fileName[256];
CopyPascalStringToC( filePath, fileName);
- /*
- // change extension to .TGA
- int len = strlen( fileName);
- if (len > 3)
- {
- fileName[ len - 3] = 't';
- fileName[ len - 2] = 'g';
- fileName[ len - 1] = 'a';
- }
- */
-//return (LoadTGA( fileName) != NULL);
return (LoadImage(fileName, texture));
#else
OSStatus err;
ComponentResult cr;
- /*FSRef fsref;
- Boolean isdir;
- err = FSPathMakeRef((const UInt8*)filePath, &fsref, &isdir);
- if(err)return;
-
- FSSpec fsspec;
- err = FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, &fsspec, NULL);
- if(err)return;
- */
-
//Boolean isdir;
FSSpec fsspec;
- //err = FSMakeFSSpec (0, 0, (const unsigned char*)filePath, &fsspec);
err = FSMakeFSSpec (0, 0, filePath, &fsspec);
- //err=FSPathMakeFSSpec((const UInt8*)filePath,&fsspec,&isdir);*/
if (err)
return;
Rect natbounds;
cr = GraphicsImportGetNaturalBounds(gi, &natbounds);
- //~ size_t buffersize = 4 * natbounds.bottom * natbounds.right;
- //void* buf = malloc(buffersize);
texture.sizeX = natbounds.right;
texture.sizeY = natbounds.bottom;
- /*if(hasalpha)*/
texture.bpp = 32;
- //if(!hasalpha)texture.bpp = 24;
GWorldPtr gw;
err = QTNewGWorldFromPtr(&gw, k32ARGBPixelFormat, &natbounds, NULL, NULL,
if (err)
return;
- /*glTexImage2D(textureTarget, 0, GL_RGBA, natbounds.right, natbounds.top, 0,
- GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buf);
- */
-
- //free(buf);
DisposeGWorld(gw);
// Loop Through The Image Data
GLuint bytesPerPixel; // Temporary Variable
bytesPerPixel = texture.bpp / 8;
imageSize = texture.sizeX * texture.sizeY * bytesPerPixel;
- //~ int alltrans=10;
for ( GLuint i = 0; i < int( imageSize ); i += 4 ) {
// Swaps The 1st And 3rd Bytes ('R'ed and 'B'lue)
texture.data[i + 3] = temp;
}
- //~ int tempplace;
- //~ tempplace=0;
if (!hasalpha) {
for ( GLuint i = 0; i < int( imageSize ); i += 4 ) {
texture.data[i + 3] = 255;
- /*texture.data[tempplace] = texture.data[i]; // Set The 1st Byte To The Value Of The 3rd Byte
- texture.data[tempplace + 1] = texture.data[i + 1]; // Set The 3rd Byte To The Value In 'temp' (1st Byte Value)
- texture.data[tempplace + 2] = texture.data[i + 2];
- tempplace+=3;*/
}
}
if (visibleloading)
Game::LoadingScreen();
- /*float total;
- int todivide;
- //Smooth opacityother
- for(i=0;i<size;i++){
- for(j=0;j<size;j++){
- total=0;
- todivide=0;
- if(i!=0){total+=opacityother[j][i-1]; todivide++;}
- if(i!=size-1){total+=opacityother[j][i+1]; todivide++;}
- if(j!=0){total+=opacityother[j-1][i]; todivide++;}
- if(j!=size-1){total+=opacityother[j+1][i]; todivide++;}
- if(i!=0&&j!=0){total+=opacityother[j-1][i-1]; todivide++;}
- if(i!=size-1&&j!=0){total+=opacityother[j-1][i+1]; todivide++;}
- if(j!=size-1&&i!=size-1){total+=opacityother[j+1][i+1]; todivide++;}
- if(j!=size-1&&i!=0){total+=opacityother[j+1][i-1]; todivide++;}
- total+=opacityother[j][i]; todivide++;
-
- opacityother[j][i]=total/(float)todivide;
- }
- }*/
-
-
for (i = 0; i < size; i++) {
for (j = 0; j < size; j++) {
if (opacityother[i][j] < .1)
patch_size = size / subdivision;
patch_elements = (patch_size) * (patch_size) * 54;
CalculateNormals();
- /*DoShadows();
-
- for(i=0;i<subdivision;i++){
- for(j=0;j<subdivision;j++){
- UpdateVertexArray(i,j);
- }
- }*/
return 1;
}
LineFacetd(&startpoint, &endpoint, &triangle[0], &triangle[1], &triangle[2], &intersect);
}
return intersect.y * scale + getOpacity(pointx * scale, pointz * scale) / 8;
-
- //height1=heightmap[tilex][tiley]*(1-(pointx-tilex))+heightmap[tilex+1][tiley]*(pointx-tilex);
- //height2=heightmap[tilex][tiley+1]*(1-(pointx-tilex))+heightmap[tilex+1][tiley+1]*(pointx-tilex);
-
- //return height1*(1-(pointz-tiley))*scale+height2*(pointz-tiley)*scale;
}
float Terrain::getOpacity(float pointx, float pointz)
patchy[2] = (where.z + size) / scale;
patchy[3] = (where.z + size) / scale;
- /*if(patchx[1]<subdivision-1&&patchy[1]<subdivision-1&&patchx[1]>0&&patchy[1]>0)
- if(patchx[2]<subdivision-1&&patchy[2]<subdivision-1&&patchx[2]>0&&patchy[2]>0)
- if(patchx[3]<subdivision-1&&patchy[3]<subdivision-1&&patchx[3]>0&&patchy[3]>0)
- if(patchx[0]<subdivision-1&&patchy[0]<subdivision-1&&patchx[0]>0&&patchy[0]>0){
- */
if ((patchx[0] != patchx[1] || patchy[0] != patchy[1]) && (patchx[0] != patchx[2] || patchy[0] != patchy[2]) && (patchx[0] != patchx[3] || patchy[0] != patchy[3])) {
MakeDecalLock(type, where, patchx[0], patchy[0], size, opacity, rotation);
}
LOG(std::string("Loading font texture...") + fileName);
FontTexture.load(fileName, false, false);
- /*
- //Load Image
- //LoadTGA( fileName );
- unsigned char fileNamep[256];
- CopyCStringToPascal(fileName,fileNamep);
- //Load Image
- upload_image( fileNamep ,1);
-
- //Is it valid?
- if(1==1){
- //Alpha channel?
- if ( texture.bpp == 24 )
- type = GL_RGB;
- else
- type = GL_RGBA;
-
- glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
- if(!FontTexture)glGenTextures( 1, &FontTexture );
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
- glBindTexture( GL_TEXTURE_2D, FontTexture);
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-
- gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
- }
- */
if (base) {
glDeleteLists(base, 512);
base = 0;
if (base) {
glDeleteLists(base, 512);
base = 0;
- //LOG("Font already created...");
- //return;
}
-//base=glGenLists(256); // Creating 256 Display Lists
base = glGenLists(512); // Creating 256 Display Lists
FontTexture.bind();
for (loop = 0; loop < 512; loop++) { // Loop Through All 256 Lists