*/
#include "Animation/Joint.h"
+#include "binio.h"
Joint::Joint() :
blurred(0),
delay(0)
{
}
+
+void Joint::load(FILE* tfile, std::vector<Joint>& joints)
+{
+ int parentID;
+
+ funpackf(tfile, "Bf Bf Bf Bf Bf", &position.x, &position.y, &position.z, &length, &mass);
+ funpackf(tfile, "Bb Bb", &hasparent, &locked);
+ funpackf(tfile, "Bi", &modelnum);
+ funpackf(tfile, "Bb Bb", &visible, &sametwist);
+ funpackf(tfile, "Bi Bi", &label, &hasgun);
+ funpackf(tfile, "Bb", &lower);
+ funpackf(tfile, "Bi", &parentID);
+ if (hasparent) {
+ parent = &joints[parentID];
+ }
+ velocity = 0;
+ oldposition = position;
+ startpos = position;
+}
#define _JOINT_H_
#include "Quaternions.h"
+#include <vector>
class Joint
{
XYZ velchange;
Joint();
+ void load(FILE* tfile, std::vector<Joint>& joints);
};
#endif
{
}
-void Muscle::load(FILE* tfile, int vertexNum, Joint* joints)
+void Muscle::load(FILE* tfile, int vertexNum, std::vector<Joint>& joints)
{
int numvertices, vertice, parentID;
Muscle();
~Muscle();
- void load(FILE* tfile, int vertexNum, Joint* joints);
+ void load(FILE* tfile, int vertexNum, std::vector<Joint>& joints);
void loadVerticesLow(FILE* tfile, int vertexNum);
void loadVerticesClothes(FILE* tfile, int vertexNum);
void DoConstraint(bool spinny);
Skeleton::Skeleton()
{
- num_joints = 0;
-
- num_muscles = 0;
-
selected = 0;
memset(forwardjoints, 0, sizeof(forwardjoints));
oldfree = 0;
freetime = 0;
freefall = 0;
-
- joints = 0;
- muscles = 0;
}
Skeleton::~Skeleton()
{
- if (muscles) {
- delete [] muscles;
- }
- muscles = 0;
-
- if (joints) {
- delete [] joints;
- }
- joints = 0;
}
/* EFFECT
objects.SphereCheckPossible(&terrainlight, 1);
//Add velocity
- for (i = 0; i < num_joints; i++) {
+ for (i = 0; i < joints.size(); i++) {
joints[i].position = joints[i].position + joints[i].velocity * multiplier;
switch (joints[i].label) {
}
}
- for (i = 0; i < num_joints; i++) {
+ for (i = 0; i < joints.size(); i++) {
if (joints[i].locked && !spinny && findLengthfast(&joints[i].velocity) > 320)
joints[i].locked = 0;
if (spinny && findLengthfast(&joints[i].velocity) > 600)
joints[i].locked = 0;
if (joints[i].delay > 0) {
bool freely = true;
- for (j = 0; j < num_joints; j++) {
+ for (j = 0; j < joints.size(); j++) {
if (joints[j].locked)
freely = false;
}
}
}
- if (num_muscles)
- for (i = 0; i < num_muscles; i++) {
- //Length constraints
- muscles[i].DoConstraint(spinny);
- }
+ for (i = 0; i < muscles.size(); i++) {
+ //Length constraints
+ muscles[i].DoConstraint(spinny);
+ }
- for (i = 0; i < num_joints; i++) {
+ for (i = 0; i < joints.size(); i++) {
//Length constraints
//Ground constraint
groundlevel = 0;
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++) {
+ for (j = 0; j < muscles.size(); j++) {
if ((muscles[j].parent1->label == whichjointstartarray[i] && muscles[j].parent2->label == whichjointendarray[i]) || (muscles[j].parent2->label == whichjointstartarray[i] && muscles[j].parent1->label == whichjointendarray[i]))
muscles[j].DoConstraint(spinny);
}
}
}
- for (i = 0; i < num_joints; i++) {
+ for (i = 0; i < joints.size(); i++) {
switch (joints[i].label) {
case head:
groundlevel = .8;
}
if (!free) {
- for (i = 0; i < num_muscles; i++) {
+ for (i = 0; i < muscles.size(); i++) {
if (muscles[i].type == boneconnect)
muscles[i].DoConstraint(0);
}
void Skeleton::DoGravity(float *scale)
{
static int i;
- for (i = 0; i < num_joints; i++) {
+ for (i = 0; i < joints.size(); i++) {
if (
(
((joints[i].label != leftknee) && (joints[i].label != rightknee)) ||
const std::string& modelclothesfilename, bool clothes)
{
GLfloat M[16];
- int parentID;
FILE *tfile;
float lSize;
- int i, j;
- int edit;
+ int i, j, num_joints, num_muscles;
LOGFUNC;
// read num_joints
funpackf(tfile, "Bi", &num_joints);
- // allocate memory
- if (joints)
- delete [] joints; //dealloc2(joints);
- joints = (Joint*)new Joint[num_joints];
+ joints.resize(num_joints);
// read info for each joint
for (i = 0; i < num_joints; i++) {
- funpackf(tfile, "Bf Bf Bf Bf Bf", &joints[i].position.x, &joints[i].position.y, &joints[i].position.z, &joints[i].length, &joints[i].mass);
- funpackf(tfile, "Bb Bb", &joints[i].hasparent, &joints[i].locked);
- funpackf(tfile, "Bi", &joints[i].modelnum);
- funpackf(tfile, "Bb Bb", &joints[i].visible, &joints[i].sametwist);
- funpackf(tfile, "Bi Bi", &joints[i].label, &joints[i].hasgun);
- funpackf(tfile, "Bb", &joints[i].lower);
- funpackf(tfile, "Bi", &parentID);
- if (joints[i].hasparent)
- joints[i].parent = &joints[parentID];
- joints[i].velocity = 0;
- joints[i].oldposition = joints[i].position;
- joints[i].startpos = joints[i].position;
+ joints[i].load(tfile, joints);
}
// read num_muscles
funpackf(tfile, "Bi", &num_muscles);
// allocate memory
- if (muscles)
- delete [] muscles; //dealloc2(muscles);
- muscles = (Muscle*)new Muscle[num_muscles]; //malloc(sizeof(Muscle)*num_muscles);
+ muscles.resize(num_muscles);
// for each muscle...
for (i = 0; i < num_muscles; i++) {
// skip joints section
- lSize = sizeof(num_joints);
- fseek(tfile, lSize, SEEK_CUR);
+ fseek(tfile, sizeof(num_joints), SEEK_CUR);
for (i = 0; i < num_joints; i++) {
// skip joint info
lSize = sizeof(XYZ)
fseek(tfile, lSize, SEEK_CUR);
}
- // read num_muscles
- funpackf(tfile, "Bi", &num_muscles);
+ // skip num_muscles
+ fseek(tfile, sizeof(num_muscles), SEEK_CUR);
for (i = 0; i < num_muscles; i++) {
// skip muscle info
tfile = Folders::openMandatoryFile( Folders::getResourcePath(clothesfilename), "rb" );
// skip num_joints
- lSize = sizeof(num_joints);
- fseek ( tfile, lSize, SEEK_CUR);
+ fseek(tfile, sizeof(num_joints), SEEK_CUR);
for (i = 0; i < num_joints; i++) {
// skip joint info
fseek(tfile, lSize, SEEK_CUR);
}
- // read num_muscles
- funpackf(tfile, "Bi", &num_muscles);
+ // skip num_muscles
+ fseek(tfile, sizeof(num_muscles), SEEK_CUR);
for (i = 0; i < num_muscles; i++) {
// skip muscle info
free = 0;
}
-
-#if 0
-
-// the following functions are not used anywhere
-
-/* EFFECT
- * sets forward, lowforward, specialforward[]
- *
- * USES:
- * NONE
- */
-void Skeleton::FindForwardsfirst()
-{
- //Find forward vectors
- CrossProduct(joints[forwardjoints[1]].position - joints[forwardjoints[0]].position, joints[forwardjoints[2]].position - joints[forwardjoints[0]].position, &forward);
- Normalise(&forward);
-
- CrossProduct(joints[lowforwardjoints[1]].position - joints[lowforwardjoints[0]].position, joints[lowforwardjoints[2]].position - joints[lowforwardjoints[0]].position, &lowforward);
- Normalise(&lowforward);
-
- //Special forwards
- specialforward[0] = forward;
- specialforward[1] = forward;
- specialforward[2] = forward;
- specialforward[3] = forward;
- specialforward[4] = forward;
-
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::Draw(int muscleview)
-{
- static float jointcolor[4];
-
- if (muscleview == 2) {
- jointcolor[0] = 0;
- jointcolor[1] = 0;
- jointcolor[2] = 0;
- jointcolor[3] = .5;
- } else {
- jointcolor[0] = 0;
- jointcolor[1] = 0;
- jointcolor[2] = .5;
- jointcolor[3] = 1;
- }
-
- //Calc motionblur-ness
- for (int i = 0; i < num_joints; i++) {
- joints[i].oldposition = joints[i].position;
- joints[i].blurred = findDistance(&joints[i].position, &joints[i].oldposition) * 100;
- if (joints[i].blurred < 1)
- joints[i].blurred = 1;
- }
-
- //Do Motionblur
- glDepthMask(0);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glBegin(GL_QUADS);
- for (int i = 0; i < num_joints; i++) {
- if (joints[i].hasparent) {
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].blurred);
- glVertex3f(joints[i].position.x, joints[i].position.y, joints[i].position.z);
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].parent->blurred);
- glVertex3f(joints[i].parent->position.x, joints[i].parent->position.y, joints[i].parent->position.z);
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].parent->blurred);
- glVertex3f(joints[i].parent->oldposition.x, joints[i].parent->oldposition.y, joints[i].parent->oldposition.z);
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].blurred);
- glVertex3f(joints[i].oldposition.x, joints[i].oldposition.y, joints[i].oldposition.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].parent2->blurred);
- glVertex3f(muscles[i].parent1->position.x, muscles[i].parent1->position.y, muscles[i].parent1->position.z);
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent2->blurred);
- glVertex3f(muscles[i].parent2->position.x, muscles[i].parent2->position.y, muscles[i].parent2->position.z);
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent2->blurred);
- glVertex3f(muscles[i].parent2->oldposition.x, muscles[i].parent2->oldposition.y, muscles[i].parent2->oldposition.z);
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent1->blurred);
- glVertex3f(muscles[i].parent1->oldposition.x, muscles[i].parent1->oldposition.y, muscles[i].parent1->oldposition.z);
- }
- }
- glEnd();
-
- glBegin(GL_LINES);
- for (int i = 0; i < num_joints; i++) {
- if (joints[i].hasparent) {
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].blurred);
- glVertex3f(joints[i].position.x, joints[i].position.y, joints[i].position.z);
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].parent->blurred);
- glVertex3f(joints[i].parent->position.x, joints[i].parent->position.y, joints[i].parent->position.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);
- glVertex3f(muscles[i].parent1->position.x, muscles[i].parent1->position.y, muscles[i].parent1->position.z);
- glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent2->blurred);
- glVertex3f(muscles[i].parent2->position.x, muscles[i].parent2->position.y, muscles[i].parent2->position.z);
- }
- }
- glColor3f(.6, .6, 0);
- if (muscleview == 1)
- for (int i = 0; i < num_muscles; i++) {
- if (muscles[i].type != boneconnect) {
- glVertex3f(muscles[i].parent1->position.x, muscles[i].parent1->position.y, muscles[i].parent1->position.z);
- glVertex3f(muscles[i].parent2->position.x, muscles[i].parent2->position.y, muscles[i].parent2->position.z);
- }
- }
- glEnd();
-
- if (muscleview != 2) {
- glPointSize(3);
- glBegin(GL_POINTS);
- for (int i = 0; i < num_joints; i++) {
- if (i != selected)
- glColor4f(0, 0, .5, 1);
- if (i == selected)
- glColor4f(1, 1, 0, 1);
- if (joints[i].locked && i != selected)
- glColor4f(1, 0, 0, 1);
- glVertex3f(joints[i].position.x, joints[i].position.y, joints[i].position.z);
- }
- glEnd();
- }
-
- //Set old position to current position
- if (muscleview == 2)
- for (int i = 0; i < num_joints; i++) {
- joints[i].oldposition = joints[i].position;
- }
- glDepthMask(1);
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::AddJoint(float x, float y, float z, int which)
-{
- if (num_joints < max_joints - 1) {
- joints[num_joints].velocity = 0;
- joints[num_joints].position.x = x;
- joints[num_joints].position.y = y;
- joints[num_joints].position.z = z;
- joints[num_joints].mass = 1;
- joints[num_joints].locked = 0;
-
- joints[num_joints].hasparent = 0;
- num_joints++;
- if (which < num_joints && which >= 0)
- AddMuscle(num_joints - 1, which, 0, 10, boneconnect);
- }
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::DeleteJoint(int whichjoint)
-{
- if (whichjoint < num_joints && whichjoint >= 0) {
- joints[whichjoint].velocity = joints[num_joints - 1].velocity;
- joints[whichjoint].position = joints[num_joints - 1].position;
- joints[whichjoint].oldposition = joints[num_joints - 1].oldposition;
- joints[whichjoint].hasparent = joints[num_joints - 1].hasparent;
- joints[whichjoint].parent = joints[num_joints - 1].parent;
- joints[whichjoint].length = joints[num_joints - 1].length;
- joints[whichjoint].locked = joints[num_joints - 1].locked;
- joints[whichjoint].modelnum = joints[num_joints - 1].modelnum;
- joints[whichjoint].visible = joints[num_joints - 1].visible;
-
- for (int i = 0; i < num_muscles; i++) {
- while (muscles[i].parent1 == &joints[whichjoint] && i < num_muscles)DeleteMuscle(i);
- while (muscles[i].parent2 == &joints[whichjoint] && i < num_muscles)DeleteMuscle(i);
- }
- for (int i = 0; i < num_muscles; i++) {
- while (muscles[i].parent1 == &joints[num_joints - 1] && i < num_muscles)muscles[i].parent1 = &joints[whichjoint];
- while (muscles[i].parent2 == &joints[num_joints - 1] && i < num_muscles)muscles[i].parent2 = &joints[whichjoint];
- }
- for (int i = 0; i < num_joints; i++) {
- if (joints[i].parent == &joints[whichjoint])
- joints[i].hasparent = 0;
- }
- for (int i = 0; i < num_joints; i++) {
- if (joints[i].parent == &joints[num_joints - 1])
- joints[i].parent = &joints[whichjoint];
- }
-
- num_joints--;
- }
-}
-
-/* EFFECT
- *
- * USES:
- * Skeleton::DeleteJoint - UNUSED
- */
-void Skeleton::DeleteMuscle(int whichmuscle)
-{
- if (whichmuscle < num_muscles) {
- muscles[whichmuscle].minlength = muscles[num_muscles - 1].minlength;
- muscles[whichmuscle].maxlength = muscles[num_muscles - 1].maxlength;
- muscles[whichmuscle].strength = muscles[num_muscles - 1].strength;
- muscles[whichmuscle].parent1 = muscles[num_muscles - 1].parent1;
- muscles[whichmuscle].parent2 = muscles[num_muscles - 1].parent2;
- muscles[whichmuscle].length = muscles[num_muscles - 1].length;
- muscles[whichmuscle].visible = muscles[num_muscles - 1].visible;
- muscles[whichmuscle].type = muscles[num_muscles - 1].type;
- muscles[whichmuscle].targetlength = muscles[num_muscles - 1].targetlength;
-
- num_muscles--;
- }
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::SetJoint(float x, float y, float z, int which, int whichjoint)
-{
- if (whichjoint < num_joints) {
- joints[whichjoint].velocity = 0;
- joints[whichjoint].position.x = x;
- joints[whichjoint].position.y = y;
- joints[whichjoint].position.z = z;
-
- if (which >= num_joints || which < 0)
- joints[whichjoint].hasparent = 0;
- if (which < num_joints && which >= 0) {
- joints[whichjoint].parent = &joints[which];
- joints[whichjoint].hasparent = 1;
- joints[whichjoint].length = findDistance(&joints[whichjoint].position, &joints[whichjoint].parent->position);
- }
- }
-}
-
-/* EFFECT
- *
- * USES:
- * Skeleton::AddJoint - UNUSED
- */
-void Skeleton::AddMuscle(int attach1, int attach2, float minlength, float maxlength, int type)
-{
- const int max_muscles = 100; // FIXME: Probably can be dropped
- if (num_muscles < max_muscles - 1 && attach1 < num_joints && attach1 >= 0 && attach2 < num_joints && attach2 >= 0 && attach1 != attach2) {
- muscles[num_muscles].parent1 = &joints[attach1];
- muscles[num_muscles].parent2 = &joints[attach2];
- muscles[num_muscles].length = findDistance(&muscles[num_muscles].parent1->position, &muscles[num_muscles].parent2->position);
- muscles[num_muscles].targetlength = findDistance(&muscles[num_muscles].parent1->position, &muscles[num_muscles].parent2->position);
- muscles[num_muscles].strength = .7;
- muscles[num_muscles].type = type;
- muscles[num_muscles].minlength = minlength;
- muscles[num_muscles].maxlength = maxlength;
-
- num_muscles++;
- }
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::MusclesSet()
-{
- for (int i = 0; i < num_muscles; i++) {
- muscles[i].length = findDistance(&muscles[i].parent1->position, &muscles[i].parent2->position);
- }
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::DoBalance()
-{
- /*XYZ newpoint;
- newpoint=joints[0].position;
- newpoint.x=(joints[2].position.x+joints[4].position.x)/2;
- newpoint.z=(joints[2].position.z+joints[4].position.z)/2;
- joints[0].velocity=joints[0].velocity+(newpoint-joints[0].position);
- //Move child point to within certain distance of parent point
- joints[0].position=newpoint;
-
- MusclesSet();*/
-}
-
-#endif
-
class Skeleton
{
public:
- int num_joints;
- //Joint joints[max_joints];
- //Joint *joints;
- Joint* joints;
-
- int num_muscles;
- //Muscle muscles[max_muscles];
- //Muscle *muscles;
- Muscle* muscles;
+ std::vector<Joint> joints;
+
+ std::vector<Muscle> muscles;
int selected;
for (unsigned k = 0; k < Person::players.size(); k++) {
if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y + Person::players[k]->scale * 3, Person::players[k]->coords.z, Person::players[k]->scale * 7) && Person::players[k]->occluded < 25)
- for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin) {
point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
size = .4f;
}
if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5) && Person::players[k]->occluded < 25)
- for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin || Person::players[k]->skeleton.joints[i].label == leftelbow || Person::players[k]->skeleton.joints[i].label == rightelbow || Person::players[k]->skeleton.joints[i].label == neck) {
if (Person::players[k]->skeleton.free)
point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
if (distance >= 1)
glDisable(GL_BLEND);
if (distance >= .5) {
- checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
+ checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
checkpoint.y += 1;
int i = -1;
if (Person::players[k]->occluded != 0)
if (distance >= 1)
glDisable(GL_BLEND);
if (distance >= .5) {
- checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
+ checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
checkpoint.y += 1;
int i = -1;
if (Person::players[k]->occluded != 0)
XYZ moveamount;
moveamount = 0;
moveamount.z = 2;
- // FIXME - Why this uses skeleton.num_joints and not Animation::numjoints? (are they equal?)
- // It seems skeleton.num_joints is 0 at this point, so this is useless.
- for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+ // FIXME - Why this uses skeleton.joints.size() and not Animation::numjoints? (are they equal?)
+ // It seems skeleton.joints.size() is 0 at this point, so this is useless.
+ for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
for (j = 0; j < Animation::animations[knifesneakattackanim].frames.size(); j++) {
Animation::animations[knifesneakattackanim].frames[j].joints[i].position += moveamount;
}
LoadingScreen();
- for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+ for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
for (j = 0; j < Animation::animations[knifesneakattackedanim].frames.size(); j++) {
Animation::animations[knifesneakattackedanim].frames[j].joints[i].position += moveamount;
}
LoadingScreen();
- for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+ for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
Animation::animations[dead1anim].frames[1].joints[i].position = Animation::animations[dead1anim].frames[0].joints[i].position;
Animation::animations[dead2anim].frames[1].joints[i].position = Animation::animations[dead2anim].frames[0].joints[i].position;
Animation::animations[dead3anim].frames[1].joints[i].position = Animation::animations[dead3anim].frames[0].joints[i].position;
Animation::animations[dead3anim].frames[1].speed = 0.001;
Animation::animations[dead4anim].frames[1].speed = 0.001;
- for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+ for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
for (j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) {
Animation::animations[swordsneakattackanim].frames[j].joints[i].position += moveamount;
}
LoadingScreen();
- for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+ for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
for (j = 0; j < Animation::animations[swordsneakattackedanim].frames.size(); j++) {
Animation::animations[swordsneakattackedanim].frames[j].joints[i].position += moveamount;
}
emit_sound_at(fireendsound, Person::players[1]->coords);
- for (int i = 0; i < Person::players[1]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
if (Random() % 2 == 0) {
if (!Person::players[1]->skeleton.free)
temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
XYZ temp, temp2;
emit_sound_at(fireendsound, Person::players[1]->coords);
- for (int i = 0; i < Person::players[1]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
if (Random() % 2 == 0) {
if (!Person::players[1]->skeleton.free)
temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
XYZ headspurtdirection;
//int i = Person::players[closest]->skeleton.jointlabels[head];
Joint& headjoint = Person::players[closest]->joint(head);
- for (int k = 0; k < Person::players[closest]->skeleton.num_joints; k++) {
+ for (int k = 0; k < Person::players[closest]->skeleton.joints.size(); k++) {
if (!Person::players[closest]->skeleton.free)
flatvelocity2 = Person::players[closest]->velocity;
if (Person::players[closest]->skeleton.free)
emit_sound_at(splattersound, blah);
emit_sound_at(breaksound2, blah);
- for (int i = 0; i < Person::players[closest]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
if (!Person::players[closest]->skeleton.free)
flatvelocity2 = Person::players[closest]->velocity;
if (Person::players[closest]->skeleton.free)
Sprite::MakeSprite(cloudsprite, flatfacing2, flatvelocity2 * 0, .6, 0, 0, 1, .5);
}
- for (int i = 0; i < Person::players[closest]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
if (!Person::players[closest]->skeleton.free)
flatvelocity2 = Person::players[closest]->velocity;
if (Person::players[closest]->skeleton.free)
Sprite::MakeSprite(bloodsprite, flatfacing2, flatvelocity2, 1, 1, 1, .4, 1);
}
- for (int i = 0; i < Person::players[closest]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
if (!Person::players[closest]->skeleton.free)
flatvelocity2 = Person::players[closest]->velocity;
if (Person::players[closest]->skeleton.free)
Sprite::MakeSprite(bloodsprite, flatfacing2, flatvelocity2 * 2, 1, 1, 1, .4, 1);
}
- for (int i = 0; i < Person::players[closest]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
if (!Person::players[closest]->skeleton.free)
flatvelocity2 = Person::players[closest]->velocity;
if (Person::players[closest]->skeleton.free)
Person::players[j]->skeleton.free = 1;
Person::players[j]->skeleton.longdead = 0;
Person::players[j]->RagDoll(0);
- for (int i = 0; i < Person::players[j]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[j]->skeleton.joints.size(); i++) {
temppos = Person::players[j]->skeleton.joints[i].position + Person::players[j]->coords;
if (distsq(&temppos, &Person::players[closest]->coords) < 25) {
flatvelocity2 = temppos - Person::players[closest]->coords;
}
Person::players[k]->DoDamage(findLengthfast(&rotatetarget) / 4);
- for (int j = 0; j < Person::players[i]->skeleton.num_joints; j++) {
+ for (int j = 0; j < Person::players[i]->skeleton.joints.size(); j++) {
Person::players[i]->skeleton.joints[j].velocity = Person::players[i]->skeleton.joints[j].velocity / 5 + Person::players[k]->velocity;
}
- for (int j = 0; j < Person::players[k]->skeleton.num_joints; j++) {
+ for (int j = 0; j < Person::players[k]->skeleton.joints.size(); j++) {
Person::players[k]->skeleton.joints[j].velocity = Person::players[k]->skeleton.joints[j].velocity / 5 + Person::players[i]->velocity;
}
Person::players[i]->victim->skeleton.free = 1;
Person::players[i]->victim->skeleton.broken = 0;
- for (int l = 0; l < Person::players[i]->victim->skeleton.num_joints; l++) {
+ for (int l = 0; l < Person::players[i]->victim->skeleton.joints.size(); l++) {
Person::players[i]->victim->skeleton.joints[l].velchange = 0;
Person::players[i]->victim->skeleton.joints[l].locked = 0;
}
if (distsq(&temp, &Person::players[1]->coords) >= distsq(&temp, &temp2) - 1 || distsq(&temp3, &Person::players[1]->coords) < 4) {
emit_sound_at(fireendsound, Person::players[1]->coords);
- for (int i = 0; i < Person::players[1]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
if (Random() % 2 == 0) {
if (!Person::players[1]->skeleton.free)
temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
}
Person::players[1]->coords = (oldtemp + oldtemp2) / 2;
- for (int i = 0; i < Person::players[1]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
Person::players[1]->skeleton.joints[i].velocity = 0;
if (Random() % 2 == 0) {
if (!Person::players[1]->skeleton.free)
target = Person::players[0]->oldcoords + Person::players[0]->currentoffset * (1 - Person::players[0]->target) * Person::players[0]->scale + Person::players[0]->targetoffset * Person::players[0]->target * Person::players[0]->scale - Person::players[0]->facing * .05;
target.y += .1;
if (Person::players[0]->skeleton.free) {
- for (int i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+ for (int i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
if (Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y > target.y)
target.y = Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y;
}
if (tutoriallevel != 1)
emit_sound_at(heavyimpactsound, victim->coords);
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * 120 * damagemult;
}
victim->Puff(neck);
XYZ flatfacing, flatvelocity;
int howmany;
for (int i = 0; i < 10; i++) {
- howmany = abs(Random() % (skeleton.num_joints));
+ howmany = abs(Random() % (skeleton.joints.size()));
if (skeleton.free) {
flatvelocity = skeleton.joints[howmany].velocity;
flatfacing = skeleton.joints[howmany].position * scale + coords;
if (howmuch > damagetolerance * 50 && skeleton.free != 2) {
XYZ flatvelocity2;
XYZ flatfacing2;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
if (skeleton.free) {
flatvelocity2 = skeleton.joints[i].velocity;
flatfacing2 = skeleton.joints[i].position * scale + coords;
skeleton.specialforward[0] = facing;
//skeleton.specialforward[0]=DoRotation(facing,0,yaw,0);
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible && (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head)) {
skeleton.FindRotationMuscle(i, animTarget);
}
if (!isnormal(tilt)) tilt = 0;
if (!isnormal(tilt2)) tilt2 = 0;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); 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, yaw, 0);
skeleton.joints[i].realoldposition = skeleton.joints[i].position * scale + coords;
}
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].velocity = 0;
skeleton.joints[i].velchange = 0;
}
speed *= speedmult;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
if ((Animation::animations[animCurrent].attack != reversed || animCurrent == swordslashreversedanim) && animCurrent != rabbitkickanim && !isLanding() && !wasLanding() && Animation::animations[animCurrent].height == Animation::animations[animTarget].height)
skeleton.joints[i].velocity = velocity / scale + facing * 5 + DoRotation(DoRotation(DoRotation((targetFrame().joints[i].position - currentFrame().joints[i].position) * speed, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
else
change.y = (float)(Random() % 100) / 100;
change.z = (float)(Random() % 100) / 100;
skeleton.joints[i].velocity += change;
- skeleton.joints[abs(Random() % skeleton.num_joints)].velocity -= change;
+ skeleton.joints[abs(Random() % skeleton.joints.size())].velocity -= change;
change.x = (float)(Random() % 100) / 100;
change.y = (float)(Random() % 100) / 100;
change.z = (float)(Random() % 100) / 100;
skeleton.joints[i].velchange += change;
- skeleton.joints[abs(Random() % skeleton.num_joints)].velchange -= change;
+ skeleton.joints[abs(Random() % skeleton.joints.size())].velchange -= change;
}
if (checkcollision) {
int howmany;
average = 0;
howmany = 0;
- for (j = 0; j < skeleton.num_joints; j++) {
+ for (j = 0; j < skeleton.joints.size(); j++) {
average += skeleton.joints[j].position;
howmany++;
}
average /= howmany;
coords += average * scale;
- for (j = 0; j < skeleton.num_joints; j++) {
+ for (j = 0; j < skeleton.joints.size(); j++) {
skeleton.joints[j].position -= average;
}
updatedelay = 0;
velocity = 0;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
velocity += skeleton.joints[i].velocity * scale;
}
- velocity /= skeleton.num_joints;
+ velocity /= skeleton.joints.size();
// drop weapon
if (Random() % 2 == 0) {
victim->skeleton.free = 1;
victim->skeleton.broken = 0;
- for (int j = 0; j < victim->skeleton.num_joints; j++) {
+ for (int j = 0; j < victim->skeleton.joints.size(); j++) {
victim->skeleton.joints[j].velchange = 0;
victim->skeleton.joints[j].locked = 0;
}
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 200;
relative.y -= 1;
Normalise(&relative);
relative = DoRotation(relative, 0, 90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
victim->jointVel(head) += relative * damagemult * 100;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 200;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, 90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 200;
relative = victim->coords - coords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 30;
}
victim->jointVel(head) += relative * damagemult * 100;
victim->skeleton.broken = 0;
victim->skeleton.spinny = 1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
victim->skeleton.joints[i].delay = 0;
victim->skeleton.joints[i].locked = 0;
relative = 0;
relative.y = 1;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity.y = relative.y * 10;
victim->skeleton.joints[i].position.y += relative.y * .3;
victim->skeleton.joints[i].oldposition.y += relative.y * .3;
relative = victim->coords - coords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 90;
}
victim->Puff(abdomen);
victim->skeleton.broken = 0;
victim->skeleton.spinny = 1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
//victim->skeleton.joints[i].delay=0;
victim->skeleton.joints[i].locked = 0;
Normalise(&relative);
relative.y += .3;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
if (!victim->dead)
victim->skeleton.free = 1;
victim->skeleton.broken = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
victim->skeleton.joints[i].locked = 0;
//victim->skeleton.joints[i].velocity=0;
victim->skeleton.free = 1;
victim->skeleton.broken = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
victim->skeleton.joints[i].locked = 0;
//victim->skeleton.joints[i].velocity=0;
relative = victim->coords - coords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = relative * 30;
}
victim->jointVel(head) += relative * damagemult * 150;
Normalise(&relative);
relative.y = .3;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = relative * 5;
}
victim->jointVel(abdomen) += relative * damagemult * 400;
relative = DoRotation(relative, 0, 90, 0);
relative.y -= 1;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 60;
}
victim->jointVel(head) += relative * damagemult * 230;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 220;
victim->skeleton.free = 1;
victim->skeleton.broken = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velchange = 0;
victim->skeleton.joints[i].locked = 0;
//victim->skeleton.joints[i].velocity=0;
relative.y = -1;
Normalise(&relative);
if (!victim->dead) {
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = relative * damagemult * 40;
}
victim->jointVel(abdomen) += relative * damagemult * 40;
}
if (victim->dead) {
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = relative * damagemult * abs(Random() % 20);
}
}
DoBlood(.2, 250);
}
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(head) += relative * damagemult * 200;
} else {
if (victim->damage >= victim->damagetolerance)
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 10;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
if (Animation::animations[victim->animTarget].height == middleheight || Animation::animations[victim->animCurrent].height == middleheight || victim->damage >= victim->damagetolerance - 40) {
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 15;
}
relative = DoRotation(relative, 0, -90, 0);
relative.y += .1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
victim->skeleton.joints[i].velocity = relative * 80;
}
} else {
if (victim->damage >= victim->damagetolerance)
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 10;
}
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
victim->skeleton.joints[i].velocity += relative * damagemult * 80;
}
relative = victim->coords - oldcoords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
relative = victim->coords - oldcoords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 30;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
relative = victim->coords - oldcoords;
relative.y = 0;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 30;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
relative.y = 0;
Normalise(&relative);
relative.y -= .1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 70;
}
victim->jointVel(lefthand) *= .1;
relative.y = 0;
Normalise(&relative);
relative.y -= .1;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 70;
}
victim->jointVel(lefthand) *= .1 - 1;
relative.y = 0;
Normalise(&relative);
relative = DoRotation(relative, 0, -90, 0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->jointVel(abdomen) += relative * damagemult * 200;
Normalise(&relative);
if (victim->id == 0)
relative /= 30;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->damage = victim->damagetolerance;
if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
escapednum = 0;
victim->velocity = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = 0;
}
if (animTarget == knifefollowanim) {
victim->RagDoll(0);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = 0;
}
}
if (hasvictim && animTarget == swordsneakattackanim && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
escapednum = 0;
victim->velocity = 0;
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity = 0;
}
if (weaponactive != -1) {
relative = DoRotation(relative, 0, 90, 0);
relative.y = .5;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
victim->jointVel(head) += relative * damagemult * 200;
relative = DoRotation(relative, 0, 90, 0);
relative.y = .5;
Normalise(&relative);
- for (int i = 0; i < victim->skeleton.num_joints; i++) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
victim->jointVel(head) += relative * damagemult * 200;
}
if (animCurrent != oldanimCurrent || animTarget != oldanimTarget || ((frameCurrent != oldframeCurrent || frameTarget != oldframeTarget) && !calcrot)) {
//Old rotates
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].position = currentFrame().joints[i].position;
}
skeleton.FindForwards();
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
skeleton.FindRotationMuscle(i, animTarget);
}
}
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
skeleton.muscles[i].oldrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
}
//New rotates
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].position = targetFrame().joints[i].position;
}
skeleton.FindForwards();
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
skeleton.FindRotationMuscle(i, animTarget);
}
}
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
skeleton.muscles[i].newrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
oldframeTarget = frameTarget;
oldframeCurrent = frameCurrent;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].velocity = (currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target) - skeleton.joints[i].position) / multiplier;
skeleton.joints[i].position = currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target);
}
offset = currentoffset * (1 - target) + targetoffset * target;
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
skeleton.muscles[i].rotate1 = skeleton.muscles[i].oldrotate1 * (1 - target) + skeleton.muscles[i].newrotate1 * (target);
skeleton.muscles[i].rotate2 = skeleton.muscles[i].oldrotate2 * (1 - target) + skeleton.muscles[i].newrotate2 * (target);
}
while (flamedelay < 0 && onfire) {
flamedelay += .006;
- howmany = abs(Random() % (skeleton.num_joints));
+ howmany = abs(Random() % (skeleton.joints.size()));
if (skeleton.free) {
flatvelocity = skeleton.joints[howmany].velocity * scale / 2;
flatfacing = skeleton.joints[howmany].position * scale + coords;
while (flamedelay < 0 && !onfire && tutoriallevel == 1 && id != 0) {
flamedelay += .05;
- howmany = abs(Random() % (skeleton.num_joints));
+ howmany = abs(Random() % (skeleton.joints.size()));
if (skeleton.free) {
flatvelocity = skeleton.joints[howmany].velocity * scale / 2;
flatfacing = skeleton.joints[howmany].position * scale + coords;
}
dead = 2;
if (animTarget == knifefollowedanim && !skeleton.free) {
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].velocity = 0;
skeleton.joints[i].velocity.y = -2;
}
dead = 0;
skeleton.free = 1;
damage -= 20;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].velocity = 0;
}
}
average = 0;
howmany = 0;
- for (j = 0; j < skeleton.num_joints; j++) {
+ for (j = 0; j < skeleton.joints.size(); j++) {
average += skeleton.joints[j].position;
howmany++;
}
average /= howmany;
coords += average * scale;
- for (j = 0; j < skeleton.num_joints; j++) {
+ for (j = 0; j < skeleton.joints.size(); j++) {
skeleton.joints[j].position -= average;
}
average /= multiplier;
velocity = 0;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
velocity += skeleton.joints[i].velocity * scale;
}
- velocity /= skeleton.num_joints;
+ velocity /= skeleton.joints.size();
if (!isnormal(velocity.x) && velocity.x) {
velocity = 0;
frameCurrent = 0;
target = 0;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
tempanimation.frames[0].joints[i].position = skeleton.joints[i].position;
tempanimation.frames[0].joints[i].position = DoRotation(tempanimation.frames[0].joints[i].position, 0, -yaw, 0);
}
if (middle.y > 0 && animTarget != rollanim)
targetoffset.y = middle.y + 1;
- for (int i = 0; i < skeleton.num_joints; i++) {
+ for (int i = 0; i < skeleton.joints.size(); i++) {
tempanimation.frames[0].joints[i].position = skeleton.joints[i].position;
tempanimation.frames[0].joints[i].position = DoRotation(tempanimation.frames[0].joints[i].position, 0, -yaw, 0);
}
skeleton.drawmodelclothes.vertex[i] = 0;
skeleton.drawmodelclothes.vertex[i].y = 999;
}
- for (int i = 0; i < skeleton.num_muscles; i++) {
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
// convenience renames
const int p1 = skeleton.muscles[i].parent1->label;
const int p2 = skeleton.muscles[i].parent2->label;
i = weaponids[k];
if (weaponactive == k) {
if (weapons[i].getType() != staff) {
- for (j = 0; j < skeleton.num_muscles; j++) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].vertices.size() > 0) {
weaponattachmuscle = j;
}
}
- for (j = 0; j < skeleton.num_muscles; j++) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
if ((skeleton.muscles[j].parent1->label == rightwrist || skeleton.muscles[j].parent2->label == rightwrist) && (skeleton.muscles[j].parent1->label != righthand && skeleton.muscles[j].parent2->label != righthand) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}
weaponpoint = (jointPos(rightwrist) * .7 + jointPos(righthand) * .3);
}
if (weapons[i].getType() == staff) {
- for (j = 0; j < skeleton.num_muscles; j++) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].vertices.size() > 0) {
weaponattachmuscle = j;
}
}
- for (j = 0; j < skeleton.num_muscles; j++) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
if ((skeleton.muscles[j].parent1->label == rightelbow || skeleton.muscles[j].parent2->label == rightelbow) && (skeleton.muscles[j].parent1->label != rightshoulder && skeleton.muscles[j].parent2->label != rightshoulder) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}
weaponpoint = jointPos(abdomen) + (jointPos(lefthip) - jointPos(righthip)) * .09 + (jointPos(leftshoulder) - jointPos(rightshoulder)) * .33;
if (weapons[i].getType() == staff)
weaponpoint = jointPos(abdomen) + (jointPos(lefthip) - jointPos(righthip)) * .09 + (jointPos(leftshoulder) - jointPos(rightshoulder)) * .33;
- for (j = 0; j < skeleton.num_muscles; j++) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}
weaponpoint = jointPos(abdomen) * .5 + jointPos(neck) * .5 - skeleton.forward * .8;
else
weaponpoint = jointPos(abdomen) * .5 + jointPos(neck) * .5 + skeleton.forward * .8;
- for (j = 0; j < skeleton.num_muscles; j++) {
+ for (j = 0; j < skeleton.muscles.size(); j++) {
if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}