bots
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@300 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+107
-107
@@ -79,9 +79,9 @@ struct md3model
|
||||
md3tag *tags;
|
||||
int numframes, numtags;
|
||||
bool loaded;
|
||||
vec scale;
|
||||
vec scale;
|
||||
bool mirrored;
|
||||
void setanim(int anim);
|
||||
void setanim(int anim);
|
||||
void setanimstate(md3state &as);
|
||||
bool link(md3model *link, char *tag);
|
||||
bool load(char *path, bool mirror);
|
||||
@@ -92,12 +92,12 @@ struct md3model
|
||||
};
|
||||
|
||||
md3model::md3model()
|
||||
{
|
||||
{
|
||||
mirrored = false;
|
||||
loaded = false;
|
||||
scale.x = scale.y = scale.z = MD3_DEFAULT_SCALE;
|
||||
// animstate = NULL;
|
||||
animstate = new md3state();
|
||||
// animstate = NULL;
|
||||
animstate = new md3state();
|
||||
animstate->lastTime = lastmillis;
|
||||
};
|
||||
|
||||
@@ -111,13 +111,13 @@ md3model::~md3model()
|
||||
if(links) free(links);
|
||||
if(tags) delete [] tags;
|
||||
};
|
||||
|
||||
void md3model::setanimstate(md3state &as)
|
||||
{
|
||||
animstate->anim = as.anim;
|
||||
animstate->frm = as.frm;
|
||||
animstate->lastTime = as.lastTime;
|
||||
};
|
||||
|
||||
void md3model::setanimstate(md3state &as)
|
||||
{
|
||||
animstate->anim = as.anim;
|
||||
animstate->frm = as.frm;
|
||||
animstate->lastTime = as.lastTime;
|
||||
};
|
||||
|
||||
void md3model::setanim(int anim)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ bool md3model::link(md3model *link, char *tag)
|
||||
};
|
||||
|
||||
bool md3model::load(char *path, bool mirror=false)
|
||||
{
|
||||
{
|
||||
mirrored = mirror;
|
||||
if(!path) return false;
|
||||
FILE *f = fopen(path, "rb");
|
||||
@@ -268,7 +268,7 @@ void md3model::render()
|
||||
|
||||
if(animdebug) printf("interp. from frame %i to %i, %f percent done\n", a->frm, nextfrm, t*100.0f);
|
||||
|
||||
#define interpolate(p1,p2) ((p1) + t * ((p2) - (p1)))
|
||||
#define interpolate(p1,p2) ((p1) + t * ((p2) - (p1)))
|
||||
|
||||
loopv(meshes)
|
||||
{
|
||||
@@ -295,7 +295,7 @@ void md3model::render()
|
||||
};
|
||||
glEnd();
|
||||
};
|
||||
|
||||
|
||||
|
||||
loopi(numtags) // render the linked models - interpolate rotation and position of the 'link-tags'
|
||||
{
|
||||
@@ -329,11 +329,11 @@ void md3model::draw(float x, float y, float z, float yaw, float pitch, float rad
|
||||
glRotatef(-90, 1, 0, 0);
|
||||
|
||||
glScalef( scale.x, scale.y, scale.z);
|
||||
|
||||
if(mirrored) glCullFace(GL_BACK);
|
||||
|
||||
render();
|
||||
|
||||
if(mirrored) glCullFace(GL_BACK);
|
||||
|
||||
render();
|
||||
|
||||
if(mirrored) glCullFace(GL_FRONT);
|
||||
|
||||
glPopMatrix();
|
||||
@@ -396,7 +396,7 @@ void loadweapons()
|
||||
{
|
||||
firstweapon = models.length();
|
||||
loopi(NUMGUNS+1)
|
||||
{
|
||||
{
|
||||
bool akimbo = i==NUMGUNS;
|
||||
sprintf(basedir, "packages/models/weapons/%s", akimbo ? hudgunnames[GUN_PISTOL] : hudgunnames[i]);
|
||||
md3model *mdl = new md3model();
|
||||
@@ -420,71 +420,71 @@ VAR(swayupmovediv, 1, 200, 1000);
|
||||
|
||||
VAR(x, 0, 0, 1000);
|
||||
VAR(y, 0, 0, 1000);
|
||||
VAR(z, 0, 0, 1000);
|
||||
|
||||
struct weaponmove
|
||||
{
|
||||
float k_rot, kick;
|
||||
vec pos;
|
||||
int anim;
|
||||
|
||||
weaponmove(vec base, int basetime)
|
||||
{
|
||||
bool akimbo = player1->akimbo && player1->gunselect==GUN_PISTOL;
|
||||
bool throwingnade = player1->gunselect==GUN_GRENADE && player1->thrownademillis;
|
||||
int timediff = throwingnade ? (lastmillis-player1->thrownademillis) : lastmillis-basetime;
|
||||
int animtime = attackdelay(player1->gunselect);
|
||||
int rtime = reloadtime(player1->gunselect);
|
||||
kick = k_rot = 0.0f;
|
||||
pos = player1->o;
|
||||
anim = MDL_GUN_IDLE;
|
||||
bool attacking = player1->lastaction && player1->lastattackgun==player1->gunselect /*&& lastmillis-player1->lastaction<rtime*/;
|
||||
|
||||
if(akimbo && basetime>lastmillis) // akimbo gun queued for reloading
|
||||
{
|
||||
|
||||
}
|
||||
else if(player1->reloading)
|
||||
{
|
||||
anim = MDL_GUN_RELOAD;
|
||||
VAR(z, 0, 0, 1000);
|
||||
|
||||
struct weaponmove
|
||||
{
|
||||
float k_rot, kick;
|
||||
vec pos;
|
||||
int anim;
|
||||
|
||||
weaponmove(vec base, int basetime)
|
||||
{
|
||||
bool akimbo = player1->akimbo && player1->gunselect==GUN_PISTOL;
|
||||
bool throwingnade = player1->gunselect==GUN_GRENADE && player1->thrownademillis;
|
||||
int timediff = throwingnade ? (lastmillis-player1->thrownademillis) : lastmillis-basetime;
|
||||
int animtime = attackdelay(player1->gunselect);
|
||||
int rtime = reloadtime(player1->gunselect);
|
||||
kick = k_rot = 0.0f;
|
||||
pos = player1->o;
|
||||
anim = MDL_GUN_IDLE;
|
||||
bool attacking = player1->lastaction && player1->lastattackgun==player1->gunselect /*&& lastmillis-player1->lastaction<rtime*/;
|
||||
|
||||
if(akimbo && basetime>lastmillis) // akimbo gun queued for reloading
|
||||
{
|
||||
|
||||
}
|
||||
else if(player1->reloading)
|
||||
{
|
||||
anim = MDL_GUN_RELOAD;
|
||||
float percent_done = (float)(timediff)*100.0f/rtime;
|
||||
if(percent_done >= 100) percent_done = 100;
|
||||
k_rot = -(sin((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90);
|
||||
}
|
||||
else if(throwingnade && timediff>animtime-rtime/2 && timediff<animtime && attacking)
|
||||
{
|
||||
anim = MDL_GUN_IDLE;
|
||||
float percent_done = (float)50.0f+(timediff-(animtime-rtime/2))*100.0f/rtime;
|
||||
k_rot = -(sin((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90);
|
||||
}
|
||||
else
|
||||
{
|
||||
vec sway = base;
|
||||
float percent_done = 0.0f;
|
||||
float k_back = 0.0f;
|
||||
|
||||
if(player1->gunselect==player1->lastattackgun)
|
||||
{
|
||||
if(percent_done >= 100) percent_done = 100;
|
||||
k_rot = -(sin((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90);
|
||||
}
|
||||
else if(throwingnade && timediff>animtime-rtime/2 && timediff<animtime && attacking)
|
||||
{
|
||||
anim = MDL_GUN_IDLE;
|
||||
float percent_done = (float)50.0f+(timediff-(animtime-rtime/2))*100.0f/rtime;
|
||||
k_rot = -(sin((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90);
|
||||
}
|
||||
else
|
||||
{
|
||||
vec sway = base;
|
||||
float percent_done = 0.0f;
|
||||
float k_back = 0.0f;
|
||||
|
||||
if(player1->gunselect==player1->lastattackgun)
|
||||
{
|
||||
percent_done = timediff*100.0f/(float)animtime;
|
||||
if(percent_done > 100.0f) percent_done = 100.0f;
|
||||
// f(x) = -sin(x-1.5)^3
|
||||
kick = -sin(pow((1.5f/100.0f*percent_done)-1.5f,3));
|
||||
};
|
||||
|
||||
if(attacking && timediff<animtime)
|
||||
{
|
||||
if(throwingnade)
|
||||
{
|
||||
anim = MDL_GUN_ATTACK2;
|
||||
}
|
||||
else anim = MDL_GUN_ATTACK;
|
||||
};
|
||||
|
||||
if(player1->gunselect!=GUN_GRENADE && player1->gunselect!=GUN_KNIFE)
|
||||
{
|
||||
kick = -sin(pow((1.5f/100.0f*percent_done)-1.5f,3));
|
||||
};
|
||||
|
||||
if(attacking && timediff<animtime)
|
||||
{
|
||||
if(throwingnade)
|
||||
{
|
||||
anim = MDL_GUN_ATTACK2;
|
||||
}
|
||||
else anim = MDL_GUN_ATTACK;
|
||||
};
|
||||
|
||||
if(player1->gunselect!=GUN_GRENADE && player1->gunselect!=GUN_KNIFE)
|
||||
{
|
||||
k_rot = kick_rot(player1->gunselect)*kick;
|
||||
k_back = kick_back(player1->gunselect)*kick/10;
|
||||
};
|
||||
k_back = kick_back(player1->gunselect)*kick/10;
|
||||
};
|
||||
|
||||
int swayt = (lastmillis+1)/10 % 100;
|
||||
float swayspeed = (float) (sin((float)lastmillis/swayspeeddiv))/(swaymovediv/10.0f);
|
||||
@@ -505,14 +505,14 @@ struct weaponmove
|
||||
|
||||
sway.x *= swayspeed;
|
||||
sway.y *= swayspeed;
|
||||
sway.z *= swayupspeed;
|
||||
|
||||
pos.x = player1->o.x-base.x*k_back+sway.x;
|
||||
pos.y = player1->o.y-base.y*k_back+sway.y;
|
||||
pos.z = player1->o.z-base.z*k_back+sway.z;
|
||||
};
|
||||
};
|
||||
};
|
||||
sway.z *= swayupspeed;
|
||||
|
||||
pos.x = player1->o.x-base.x*k_back+sway.x;
|
||||
pos.y = player1->o.y-base.y*k_back+sway.y;
|
||||
pos.z = player1->o.z-base.z*k_back+sway.z;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
void rendermd3gun()
|
||||
{
|
||||
@@ -533,25 +533,25 @@ void rendermd3gun()
|
||||
};
|
||||
|
||||
vdist(dist, unitv, player1->o, worldpos);
|
||||
vdiv(unitv, dist);
|
||||
|
||||
md3model *weapon = models[firstweapon + player1->gunselect];
|
||||
md3model *akimbo = player1->akimbo && player1->gunselect==GUN_PISTOL ? models[firstweapon+NUMGUNS] : NULL;
|
||||
|
||||
weaponmove *w1, *w2;
|
||||
|
||||
if(akimbo)
|
||||
{
|
||||
w1 = new weaponmove(unitv, akimbolastaction[0]);
|
||||
w2 = new weaponmove(unitv, akimbolastaction[1]);
|
||||
akimbo->setanim(w2->anim);
|
||||
}
|
||||
else w1 = new weaponmove(unitv, player1->lastaction);
|
||||
|
||||
if(!w1) return;
|
||||
weapon->setanim(w1->anim);
|
||||
weapon->draw( w1->pos.x, w1->pos.z, w1->pos.y, player1->yaw + 90, player1->pitch+w1->k_rot, 1.0f, light);
|
||||
|
||||
vdiv(unitv, dist);
|
||||
|
||||
md3model *weapon = models[firstweapon + player1->gunselect];
|
||||
md3model *akimbo = player1->akimbo && player1->gunselect==GUN_PISTOL ? models[firstweapon+NUMGUNS] : NULL;
|
||||
|
||||
weaponmove *w1, *w2;
|
||||
|
||||
if(akimbo)
|
||||
{
|
||||
w1 = new weaponmove(unitv, akimbolastaction[0]);
|
||||
w2 = new weaponmove(unitv, akimbolastaction[1]);
|
||||
akimbo->setanim(w2->anim);
|
||||
}
|
||||
else w1 = new weaponmove(unitv, player1->lastaction);
|
||||
|
||||
if(!w1) return;
|
||||
weapon->setanim(w1->anim);
|
||||
weapon->draw( w1->pos.x, w1->pos.z, w1->pos.y, player1->yaw + 90, player1->pitch+w1->k_rot, 1.0f, light);
|
||||
|
||||
if(akimbo && w2) akimbo->draw( w2->pos.x, w2->pos.z, w2->pos.y, player1->yaw + 90, player1->pitch+w2->k_rot, 1.0f, light);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user