Person player[maxplayers];
+/* EFFECT
+ *
+ * USES:
+ * GameTick/doPlayerCollisions
+ */
void Person::CheckKick()
{
if (!(hasvictim
&& victim != this
&& frameCurrent >= 2
&& animCurrent == rabbitkickanim)
- && (distsq(&coords, &victim->coords) < 1.2)
- && (!victim->skeleton.free)))
+ && distsq(&coords, &victim->coords) < 1.2
+ && !victim->skeleton.free))
return;
if (animation[victim->animTarget].height != lowheight) {
}
}
+/* EFFECT
+ *
+ * USES:
+ * GameTick/doPlayerCollisions - spread fire between players
+ * GameTick/doDebugKeys - press f to ignite
+ * Person::DoStuff - spread fire from lit campfires and bushes
+ */
void Person::CatchFire()
{
XYZ flatfacing, flatvelocity;
onfire = 1;
}
+/* FUNCTION
+ * idle animation for this creature (depending on status)
+ */
int Person::getIdle()
{
if (indialogue != -1 && howactive == typeactive && creature == rabbittype)
return 0;
}
+/* FUNCTION
+ * crouch animation for this creature
+ */
int Person::getCrouch()
{
if (creature == rabbittype)
return 0;
}
+/* FUNCTION
+ * running animation for this creature (can be upright or all fours)
+ */
int Person::getRun()
{
if (creature == rabbittype && (!superruntoggle || weaponactive != -1))
return 0;
}
+/* FUNCTION
+ */
int Person::getStop()
{
if (creature == rabbittype)
return 0;
}
+/* FUNCTION
+ */
int Person::getLanding()
{
if (creature == rabbittype)
return 0;
}
+/* FUNCTION
+ */
int Person::getLandhard()
{
if (creature == rabbittype)
return 0;
}
+/* EFFECT
+ *
+ * USES:
+ * Person::DoAnimations
+ */
static void
SolidHitBonus(int playerid)
{
award_bonus(playerid, solidhit);
}
+/* EFFECT
+ * spawns blood effects
+ */
void Person::DoBlood(float howmuch, int which)
{
+ // FIXME: should abstract out inputs
static int bleedxint, bleedyint;
static XYZ bloodvel;
//if(howmuch&&id==0)blooddimamount=1;
if (bleeding <= 0 && spurt) {
spurt = 0;
for (int i = 0; i < 3; i++) {
+ // emit blood particles
bloodvel = 0;
if (!skeleton.free) {
bloodvel.z = 10;
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)
+ if (Random() % 2 == 0) // 50% chance
for (int i = 0; i < 3; i++) {
if (Random() % 2 != 0) {
+ // emit teeth particles
bloodvel = 0;
if (skeleton.free) {
bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0);
} else {
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);
+ Sprite::setLastSpriteSpecial(3); // sets it to teeth
}
}
}
if (decals) {
+ // FIXME: manipulating attributes
bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
bleedxint = 0;
bleedyint = 0;
bleeding = 2;
}
+/* EFFECT
+ * spawns big blood effects and ???
+ * modifies character's skin texture
+ */
void Person::DoBloodBig(float howmuch, int which)
{
static int bleedxint, bleedyint, i, j;
if (tutoriallevel != 1 || id == 0)
if (aitype != playercontrolled && howmuch > 0) {
+ // play pain sounds
int whichsound = -1;
+ // FIXME: seems to be spawning sounds by manipulating attributes... MESSY!
if (creature == wolftype) {
int i = abs(Random() % 2);
if (i == 0)
}
if (id == 0 && howmuch > 0) {
+ // FIXME: manipulating attributes
flashamount = .5;
flashr = 1;
flashg = 0;
if (bleeding <= 0 && spurt) {
spurt = 0;
for (int i = 0; i < 3; i++) {
+ // emit blood particles
+ // FIXME: copypaste from above
bloodvel = 0;
if (!skeleton.free) {
bloodvel.z = 10;
}
}
}
+
+ // weird texture manipulation code follows.
+ // looks like this is painting blood onto the character's skin texture
+ // FIXME: surely there's a better way
+
int offsetx = 0, offsety = 0;
if (which == 225) {
offsety = Random() % 40;
if (creature == rabbittype)
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
- if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
+ if (bloodText[i*512*3 + j*3 + 0] <= which + 4 && bloodText[i*512*3 + j*3 + 0] >= which - 4) {
if (i < startx) startx = i;
if (j < starty) starty = j;
if (i > endx) endx = i;
if (creature == wolftype)
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
- if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
+ if (wolfbloodText[i*512*3 + j*3 + 0] <= which + 4 && wolfbloodText[i*512*3 + j*3 + 0] >= which - 4) {
if (i < startx) startx = i;
if (j < starty) starty = j;
if (i > endx) endx = i;
bleeding = 2;
}
+/* EFFECT
+ * similar to DoBloodBig
+ */
bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where)
{
static int i, j;
endpoint.y -= 100;
movepoint = 0;
rotationpoint = 0;
+ // ray testing for a tri in the character model
whichtri = skeleton.drawmodel.LineCheck(&startpoint, &endpoint, &colpoint, &movepoint, &rotationpoint);
if (whichtri != -1) {
+ // low level geometry math
p0 = colpoint;
p1 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
p2 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
if (bleeding <= 0 && spurt) {
spurt = 0;
for (int i = 0; i < 3; i++) {
+ // emit blood particles
+ // FIXME: more copypaste code
bloodvel = 0;
if (!skeleton.free) {
bloodvel.z = 10;
}
}
}
+
+ // texture manipulation follows
+
int offsetx = 0, offsety = 0;
/*if(which==225){
offsety=Random()%40;
+/* EFFECT
+ * guessing this performs a reversal
+ */
void Person::Reverse()
{
if (!((victim->aitype == playercontrolled
numreversals++;
}
+/* EFFECT
+ * get hurt
+ */
void Person::DoDamage(float howmuch)
{
+ // subtract health (temporary?)
if (tutoriallevel != 1)
damage += howmuch / power;
+ // stats?
if (id != 0)
damagedealt += howmuch / power;
if (id == 0)
damagetaken += howmuch / power;
+ // reset bonuses
if (id == 0 && (bonus == solidhit || bonus == twoxcombo || bonus == threexcombo || bonus == fourxcombo || bonus == megacombo))
bonus = 0;
+ // subtract health
if (tutoriallevel != 1)
permanentdamage += howmuch / 2 / power;
if (tutoriallevel != 1)
superpermanentdamage += howmuch / 4 / power;
+ // visual effects
if (permanentdamage > damagetolerance / 2 && permanentdamage - howmuch < damagetolerance / 2 && Random() % 2)
DoBlood(1, 255);
if ((permanentdamage > damagetolerance * .8 && Random() % 2 && !deathbleeding) || spurt)
if (blackout > 1)
blackout = 1;
+ // cancel attack?
if (aitype == passivetype && damage < damagetolerance && ((tutoriallevel != 1 || cananger) && hostile))
aitype = attacktypecutoff;
if (tutoriallevel != 1 && aitype != playercontrolled && damage < damagetolerance && damage > damagetolerance * 2 / 3 && creature == rabbittype) {
coords = 20;
}
+ // play sounds
if (tutoriallevel != 1 || id == 0)
if (speechdelay <= 0 && !dead && aitype != playercontrolled) {
int whichsound = -1;
//if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
}
+/* EFFECT
+ * calculate/animate head facing direction?
+ */
void Person::DoHead()
{
static XYZ rotatearound;
}
}
+/* EFFECT
+ * ragdolls character?
+ */
void Person::RagDoll(bool checkcollision)
{
static XYZ change;
}
velocity /= skeleton.num_joints;
+ // drop weapon
if (Random() % 2 == 0) {
if (weaponactive != -1 && animTarget != rabbitkickanim && num_weapons > 0) {
weapons[weaponids[0]].owner = -1;
+/* EFFECT
+ */
void Person::FootLand(int which, float opacity)
{
static XYZ terrainlight;
}
}
+/* EFFECT
+ * make a puff effect at a body part (dust effect?)
+ */
void Person::Puff(int whichlabel)
{
static XYZ footvel, footpoint;
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 1, 1, .9, .3);
}
+/* FUNCTION
+ * convenience function
+ */
Joint& Person::getJointFor(int bodypart)
{
return skeleton.joints[skeleton.jointlabels[bodypart]];
}
+/* EFFECT
+ * I think I added this in an attempt to clean up code
+ */
void Person::setAnimation(int animation)
{
animTarget = animation;
target = 0;
}
-void Person::DoAnimations()
+/* EFFECT
+ * MONSTER
+ * TODO: ???
+ */
+void Person::DoAnimations()
{
if (!skeleton.free) {
int i = 0;
//skeleton.DoConstraints();
}
-void Person::DoStuff()
+/* EFFECT
+ * MONSTER
+ * TODO
+ */
+void Person::DoStuff()
{
static XYZ terrainnormal;
static XYZ flatfacing;
}
}
+/* EFFECT
+ * MONSTER
+ * TODO: ???
+ */
int Person::DrawSkeleton()
{
int oldplayerdetail;
}
+/* FUNCTION?
+ */
int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
{
static int i, j;
intersecting = 0;
start = *p1;
start.y -= radius / 4;
- distance = abs((model->facenormals[j].x * start.x) + (model->facenormals[j].y * start.y) + (model->facenormals[j].z * start.z) - ((model->facenormals[j].x * model->vertex[model->Triangles[j].vertex[0]].x) + (model->facenormals[j].y * model->vertex[model->Triangles[j].vertex[0]].y) + (model->facenormals[j].z * model->vertex[model->Triangles[j].vertex[0]].z)));
+ XYZ &v0 = model->vertex[model->Triangles[j].vertex[0]];
+ XYZ &v1 = model->vertex[model->Triangles[j].vertex[1]];
+ XYZ &v2 = model->vertex[model->Triangles[j].vertex[2]];
+ distance = abs((model->facenormals[j].x * start.x)
+ + (model->facenormals[j].y * start.y)
+ + (model->facenormals[j].z * start.z)
+ - ((model->facenormals[j].x * v0.x)
+ + (model->facenormals[j].y * v0.y)
+ + (model->facenormals[j].z * v0.z)));
if (distance < radius * .5) {
point = start - model->facenormals[j] * distance;
- if (PointInTriangle( &point, model->facenormals[j], &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]]))
+ if (PointInTriangle( &point, model->facenormals[j], &v0, &v1, &v2))
intersecting = 1;
if (!intersecting)
- intersecting = sphere_line_intersection(model->vertex[model->Triangles[j].vertex[0]].x, model->vertex[model->Triangles[j].vertex[0]].y, model->vertex[model->Triangles[j].vertex[0]].z,
- model->vertex[model->Triangles[j].vertex[1]].x, model->vertex[model->Triangles[j].vertex[1]].y, model->vertex[model->Triangles[j].vertex[1]].z,
- p1->x, p1->y, p1->z, radius / 2);
+ intersecting = sphere_line_intersection(v0.x,v0.y,v0.z, v1.x,v1.y,v1.z, p1->x, p1->y, p1->z, radius / 2);
if (!intersecting)
- intersecting = sphere_line_intersection(model->vertex[model->Triangles[j].vertex[1]].x, model->vertex[model->Triangles[j].vertex[1]].y, model->vertex[model->Triangles[j].vertex[1]].z,
- model->vertex[model->Triangles[j].vertex[2]].x, model->vertex[model->Triangles[j].vertex[2]].y, model->vertex[model->Triangles[j].vertex[2]].z,
- p1->x, p1->y, p1->z, radius / 2);
+ intersecting = sphere_line_intersection(v1.x,v1.y,v1.z, v2.x,v2.y,v2.z, p1->x, p1->y, p1->z, radius / 2);
if (!intersecting)
- intersecting = sphere_line_intersection(model->vertex[model->Triangles[j].vertex[0]].x, model->vertex[model->Triangles[j].vertex[0]].y, model->vertex[model->Triangles[j].vertex[0]].z,
- model->vertex[model->Triangles[j].vertex[2]].x, model->vertex[model->Triangles[j].vertex[2]].y, model->vertex[model->Triangles[j].vertex[2]].z,
- p1->x, p1->y, p1->z, radius / 2);
+ intersecting = sphere_line_intersection(v0.x,v0.y,v0.z, v2.x,v2.y,v2.z, p1->x, p1->y, p1->z, radius / 2);
end = *p1 - point;
if (dotproduct(&model->facenormals[j], &end) > 0 && intersecting) {
if ((animTarget == jumpdownanim || animTarget == jumpupanim || isFlip())) {
*p1 += *move;
return firstintersecting;
}
+