sscanf(args, "%f%f%f%f", &headprop, &bodyprop, &armprop, &legprop);
- if (Person::players[pnum]->creature == wolftype) {
- Person::players[pnum]->proportionhead = 1.1 * headprop;
- Person::players[pnum]->proportionbody = 1.1 * bodyprop;
- Person::players[pnum]->proportionarms = 1.1 * armprop;
- Person::players[pnum]->proportionlegs = 1.1 * legprop;
- } else if (Person::players[pnum]->creature == rabbittype) {
- Person::players[pnum]->proportionhead = 1.2 * headprop;
- Person::players[pnum]->proportionbody = 1.05 * bodyprop;
- Person::players[pnum]->proportionarms = 1.00 * armprop;
- Person::players[pnum]->proportionlegs = 1.1 * legprop;
- Person::players[pnum]->proportionlegs.y = 1.05 * legprop;
- }
+ Person::players[pnum]->setProportions(headprop, bodyprop, armprop, legprop);
}
static void set_protection(int pnum, const char* args)
fpackf(tfile, "Bf Bf Bf", Person::players[j]->protectionhead, Person::players[j]->protectionhigh, Person::players[j]->protectionlow);
fpackf(tfile, "Bf Bf Bf", Person::players[j]->metalhead, Person::players[j]->metalhigh, Person::players[j]->metallow);
fpackf(tfile, "Bf Bf", Person::players[j]->power, Person::players[j]->speedmult);
-
- float headprop, bodyprop, armprop, legprop;
- if (Person::players[j]->creature == wolftype) {
- headprop = Person::players[j]->proportionhead.x / 1.1;
- bodyprop = Person::players[j]->proportionbody.x / 1.1;
- armprop = Person::players[j]->proportionarms.x / 1.1;
- legprop = Person::players[j]->proportionlegs.x / 1.1;
- } else {
- // rabbittype
- headprop = Person::players[j]->proportionhead.x / 1.2;
- bodyprop = Person::players[j]->proportionbody.x / 1.05;
- armprop = Person::players[j]->proportionarms.x / 1.00;
- legprop = Person::players[j]->proportionlegs.x / 1.1;
- }
-
- fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
+ fpackf(tfile, "Bf Bf Bf Bf", Person::players[j]->getProportion(0), Person::players[j]->getProportion(1), Person::players[j]->getProportion(2), Person::players[j]->getProportion(3));
fpackf(tfile, "Bi", Person::players[j]->numclothes);
if (Person::players[j]->numclothes) {
void ch_cellophane(const char*)
{
cellophane = !cellophane;
- float mul = (cellophane ? 0 : 1);
-
- for (auto player : Person::players) {
- player->proportionhead.z = player->proportionhead.x * mul;
- player->proportionbody.z = player->proportionbody.x * mul;
- player->proportionarms.z = player->proportionarms.x * mul;
- player->proportionlegs.z = player->proportionlegs.x * mul;
- }
}
void ch_funnybunny(const char*)
Person::players[0]->speedmult = 1;
Person::players[0]->scale = 1;
- if (Person::players[0]->creature == wolftype) {
- Person::players[0]->proportionhead = 1.1;
- Person::players[0]->proportionbody = 1.1;
- Person::players[0]->proportionarms = 1.1;
- Person::players[0]->proportionlegs = 1.1;
- } else if (Person::players[0]->creature == rabbittype) {
- Person::players[0]->proportionhead = 1.2;
- Person::players[0]->proportionbody = 1.05;
- Person::players[0]->proportionarms = 1.00;
- Person::players[0]->proportionlegs = 1.1;
- Person::players[0]->proportionlegs.y = 1.05;
- }
+ Person::players[0]->setProportions(1, 1, 1, 1);
Person::players[0]->numclothes = 0;
Person::players[0]->skeleton.drawmodel.textureptr.load(
Menu::Load();
Animation::loadAll();
+
+ PersonType::Load();
}
void Game::LoadScreenTexture()
Person::players[i]->updatedelay = 0;
Person::players[i]->normalsupdatedelay = 0;
- Person::players[i]->proportionhead = 1.2;
- Person::players[i]->proportionbody = 1.05;
- Person::players[i]->proportionarms = 1.00;
- Person::players[i]->proportionlegs = 1.1;
- Person::players[i]->proportionlegs.y = 1.05;
+ Person::players[i]->setProportions(1, 1, 1, 1);
Person::players[i]->headless = 0;
Person::players[i]->currentoffset = 0;
Person::players[i]->targetoffset = 0;
Game::LoadingScreen();
- if (cellophane) {
- Person::players[i]->proportionhead.z = 0;
- Person::players[i]->proportionbody.z = 0;
- Person::players[i]->proportionarms.z = 0;
- Person::players[i]->proportionlegs.z = 0;
- }
-
Person::players[i]->tempanimation = Animation("Tempanim", lowheight, neutral);
if (i == 0) {
return;
}
- float headprop, bodyprop, armprop, legprop;
-
/* Console */
if (Input::isKeyPressed(consolekey)) {
console = !console;
// FIXME: Those proportions are buggy
if (closest >= 0) {
- if (Person::players[closest]->creature == wolftype) {
- headprop = Person::players[closest]->proportionhead.x / 1.1;
- bodyprop = Person::players[closest]->proportionbody.x / 1.1;
- armprop = Person::players[closest]->proportionarms.x / 1.1;
- legprop = Person::players[closest]->proportionlegs.x / 1.1;
- } else { // rabbittype
- headprop = Person::players[closest]->proportionhead.x / 1.2;
- bodyprop = Person::players[closest]->proportionbody.x / 1.05;
- armprop = Person::players[closest]->proportionarms.x / 1.00;
- legprop = Person::players[closest]->proportionlegs.x / 1.1;
- }
-
if (Person::players[closest]->creature == rabbittype) {
Person::players[closest]->creature = wolftype;
Person::players[closest]->whichskin = 0;
Person::players[closest]->skeletonLoad();
-
- Person::players[closest]->proportionhead = 1.1;
- Person::players[closest]->proportionbody = 1.1;
- Person::players[closest]->proportionarms = 1.1;
- Person::players[closest]->proportionlegs = 1.1;
- Person::players[closest]->proportionlegs.y = 1.1;
Person::players[closest]->scale = .23 * 5 * Person::players[0]->scale;
Person::players[closest]->damagetolerance = 300;
Person::players[closest]->whichskin = 0;
Person::players[closest]->skeletonLoad(true);
- Person::players[closest]->proportionhead = 1.2;
- Person::players[closest]->proportionbody = 1.05;
- Person::players[closest]->proportionarms = 1.00;
- Person::players[closest]->proportionlegs = 1.1;
- Person::players[closest]->proportionlegs.y = 1.05;
Person::players[closest]->scale = .2 * 5 * Person::players[0]->scale;
Person::players[closest]->damagetolerance = 200;
}
-
- if (Person::players[closest]->creature == wolftype) {
- Person::players[closest]->proportionhead = 1.1 * headprop;
- Person::players[closest]->proportionbody = 1.1 * bodyprop;
- Person::players[closest]->proportionarms = 1.1 * armprop;
- Person::players[closest]->proportionlegs = 1.1 * legprop;
- }
-
- if (Person::players[closest]->creature == rabbittype) {
- Person::players[closest]->proportionhead = 1.2 * headprop;
- Person::players[closest]->proportionbody = 1.05 * bodyprop;
- Person::players[closest]->proportionarms = 1.00 * armprop;
- Person::players[closest]->proportionlegs = 1.1 * legprop;
- Person::players[closest]->proportionlegs.y = 1.05 * legprop;
- }
}
}
Person::players.back()->oldcoords = Person::players.back()->coords;
Person::players.back()->realoldcoords = Person::players.back()->coords;
- if (Person::players[0]->creature == wolftype) {
- headprop = Person::players[0]->proportionhead.x / 1.1;
- bodyprop = Person::players[0]->proportionbody.x / 1.1;
- armprop = Person::players[0]->proportionarms.x / 1.1;
- legprop = Person::players[0]->proportionlegs.x / 1.1;
- } else {
- // rabbittype
- headprop = Person::players[0]->proportionhead.x / 1.2;
- bodyprop = Person::players[0]->proportionbody.x / 1.05;
- armprop = Person::players[0]->proportionarms.x / 1.00;
- legprop = Person::players[0]->proportionlegs.x / 1.1;
- }
-
- if (Person::players.back()->creature == wolftype) {
- Person::players.back()->proportionhead = 1.1 * headprop;
- Person::players.back()->proportionbody = 1.1 * bodyprop;
- Person::players.back()->proportionarms = 1.1 * armprop;
- Person::players.back()->proportionlegs = 1.1 * legprop;
- }
-
- if (Person::players.back()->creature == rabbittype) {
- Person::players.back()->proportionhead = 1.2 * headprop;
- Person::players.back()->proportionbody = 1.05 * bodyprop;
- Person::players.back()->proportionarms = 1.00 * armprop;
- Person::players.back()->proportionlegs = 1.1 * legprop;
- Person::players.back()->proportionlegs.y = 1.05 * legprop;
- }
-
- if (cellophane) {
- Person::players.back()->proportionhead.z = 0;
- Person::players.back()->proportionbody.z = 0;
- Person::players.back()->proportionarms.z = 0;
- Person::players.back()->proportionlegs.z = 0;
- }
+ Person::players.back()->setProportions(1, 1, 1, 1);
Person::players.back()->tempanimation = Animation("Tempanim", lowheight, neutral);
extern XYZ windvector;
std::vector<std::shared_ptr<Person>> Person::players(1, std::shared_ptr<Person>(new Person()));
+std::vector<PersonType> PersonType::types;
+
+void PersonType::Load()
+{
+ types.resize(2);
+
+ types[wolftype].proportions[0] = 1.1;
+ types[wolftype].proportions[1] = 1.1;
+ types[wolftype].proportions[2] = 1.1;
+ types[wolftype].proportions[3] = 1.1;
+
+ types[rabbittype].proportions[0] = 1.2;
+ types[rabbittype].proportions[1] = 1.05;
+ types[rabbittype].proportions[2] = 1;
+ types[rabbittype].proportions[3] = 1.1;
+ types[rabbittype].proportions[3].y = 1.05;
+}
Person::Person()
: whichpatchx(0)
, oldcoords()
, coords()
, velocity()
- ,
-
- proportionhead()
- , proportionlegs()
- , proportionarms()
- , proportionbody()
- ,
- unconscioustime(0)
- ,
+ , unconscioustime(0)
- immobile(false)
- ,
+ , immobile(false)
- velspeed(0)
+ , velspeed(0)
, targetyaw(0)
, targetrot(0)
, rot(0)
jumpclimb(false)
{
+ setProportions(1, 1, 1, 1);
}
/* Read a person in tfile. Throws an error if it’s not valid */
funpackf(tfile, "Bf Bf Bf", &metalhead, &metalhigh, &metallow);
funpackf(tfile, "Bf Bf", &power, &speedmult);
- float headprop, legprop, armprop, bodyprop;
-
if (mapvers >= 4) {
- funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
+ funpackf(tfile, "Bf Bf Bf Bf", &proportions[0], &proportions[1], &proportions[2], &proportions[3]);
} else {
- headprop = 1;
- bodyprop = 1;
- armprop = 1;
- legprop = 1;
- }
-
- if (creature == wolftype) {
- proportionhead = 1.1 * headprop;
- proportionbody = 1.1 * bodyprop;
- proportionarms = 1.1 * armprop;
- proportionlegs = 1.1 * legprop;
- } else if (creature == rabbittype) {
- proportionhead = 1.2 * headprop;
- proportionbody = 1.05 * bodyprop;
- proportionarms = 1.00 * armprop;
- proportionlegs = 1.1 * legprop;
- proportionlegs.y = 1.05 * legprop;
+ setProportions(1, 1, 1, 1);
}
funpackf(tfile, "Bi", &numclothes);
skeleton.drawmodel.textureptr.load(creatureskin[creature][whichskin], 1, &skeleton.skinText[0], &skeleton.skinsize);
}
+void Person::setProportions(float head, float body, float arms, float legs)
+{
+ proportions[0] = head;
+ proportions[1] = body;
+ proportions[2] = arms;
+ proportions[3] = legs;
+}
+
+XYZ Person::getProportion(int part) const
+{
+ XYZ prop = PersonType::types[creature].proportions[part] * proportions[part];
+ if (cellophane) {
+ prop.z = 0;
+ }
+ return prop;
+}
+
/* EFFECT
*
* USES:
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (p1 == abdomen || p2 == abdomen) {
- glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * proportionbody.x,
- (v0.y * (1 - morphness) + v1.y * morphness) * proportionbody.y,
- (v0.z * (1 - morphness) + v1.z * morphness) * proportionbody.z);
+ glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * getProportion(1).x,
+ (v0.y * (1 - morphness) + v1.y * morphness) * getProportion(1).y,
+ (v0.z * (1 - morphness) + v1.z * morphness) * getProportion(1).z);
}
if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow) {
- glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * proportionarms.x,
- (v0.y * (1 - morphness) + v1.y * morphness) * proportionarms.y,
- (v0.z * (1 - morphness) + v1.z * morphness) * proportionarms.z);
+ glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * getProportion(2).x,
+ (v0.y * (1 - morphness) + v1.y * morphness) * getProportion(2).y,
+ (v0.z * (1 - morphness) + v1.z * morphness) * getProportion(2).z);
}
if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee) {
- glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * proportionlegs.x,
- (v0.y * (1 - morphness) + v1.y * morphness) * proportionlegs.y,
- (v0.z * (1 - morphness) + v1.z * morphness) * proportionlegs.z);
+ glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * getProportion(3).x,
+ (v0.y * (1 - morphness) + v1.y * morphness) * getProportion(3).y,
+ (v0.z * (1 - morphness) + v1.z * morphness) * getProportion(3).z);
}
if (p1 == head || p2 == head) {
- glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * proportionhead.x,
- (v0.y * (1 - morphness) + v1.y * morphness) * proportionhead.y,
- (v0.z * (1 - morphness) + v1.z * morphness) * proportionhead.z);
+ glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * getProportion(0).x,
+ (v0.y * (1 - morphness) + v1.y * morphness) * getProportion(0).y,
+ (v0.z * (1 - morphness) + v1.z * morphness) * getProportion(0).z);
}
glGetFloatv(GL_MODELVIEW_MATRIX, M);
skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x = M[12] * scale;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (p1 == abdomen || p2 == abdomen) {
- glTranslatef(v0.x * proportionbody.x,
- v0.y * proportionbody.y,
- v0.z * proportionbody.z);
+ glTranslatef(v0.x * getProportion(1).x,
+ v0.y * getProportion(1).y,
+ v0.z * getProportion(1).z);
}
if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow) {
- glTranslatef(v0.x * proportionarms.x,
- v0.y * proportionarms.y,
- v0.z * proportionarms.z);
+ glTranslatef(v0.x * getProportion(2).x,
+ v0.y * getProportion(2).y,
+ v0.z * getProportion(2).z);
}
if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee) {
- glTranslatef(v0.x * proportionlegs.x,
- v0.y * proportionlegs.y,
- v0.z * proportionlegs.z);
+ glTranslatef(v0.x * getProportion(3).x,
+ v0.y * getProportion(3).y,
+ v0.z * getProportion(3).z);
}
if (p1 == head || p2 == head) {
- glTranslatef(v0.x * proportionhead.x,
- v0.y * proportionhead.y,
- v0.z * proportionhead.z);
+ glTranslatef(v0.x * getProportion(0).x,
+ v0.y * getProportion(0).y,
+ v0.z * getProportion(0).z);
}
glGetFloatv(GL_MODELVIEW_MATRIX, M);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (p1 == abdomen || p2 == abdomen) {
- glTranslatef(v0.x * proportionbody.x,
- v0.y * proportionbody.y,
- v0.z * proportionbody.z);
+ glTranslatef(v0.x * getProportion(1).x,
+ v0.y * getProportion(1).y,
+ v0.z * getProportion(1).z);
}
if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow) {
- glTranslatef(v0.x * proportionarms.x,
- v0.y * proportionarms.y,
- v0.z * proportionarms.z);
+ glTranslatef(v0.x * getProportion(2).x,
+ v0.y * getProportion(2).y,
+ v0.z * getProportion(2).z);
}
if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee) {
- glTranslatef(v0.x * proportionlegs.x,
- v0.y * proportionlegs.y,
- v0.z * proportionlegs.z);
+ glTranslatef(v0.x * getProportion(3).x,
+ v0.y * getProportion(3).y,
+ v0.z * getProportion(3).z);
}
if (p1 == head || p2 == head) {
- glTranslatef(v0.x * proportionhead.x,
- v0.y * proportionhead.y,
- v0.z * proportionhead.z);
+ glTranslatef(v0.x * getProportion(0).x,
+ v0.y * getProportion(0).y,
+ v0.z * getProportion(0).z);
}
glGetFloatv(GL_MODELVIEW_MATRIX, M);
skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x = M[12] * scale;
#define getweapontype 7
#define pathfindtype 8
-#define rabbittype 0
-#define wolftype 1
+enum person_type
+{
+ rabbittype = 0,
+ wolftype = 1
+};
struct InvalidPersonException : public exception {
const char * what () const throw () {
}
};
+class PersonType
+{
+public:
+ // head, body, arms, legs
+ XYZ proportions[4];
+ static std::vector<PersonType> types;
+ static void Load();
+};
+
class Person : public enable_shared_from_this<Person>
{
+private:
+ float proportions[4];
+
public:
static std::vector<std::shared_ptr<Person>> players;
XYZ coords;
XYZ velocity;
- XYZ proportionhead;
- XYZ proportionlegs;
- XYZ proportionarms;
- XYZ proportionbody;
+ //~ XYZ proportionhead;
+ //~ XYZ proportionlegs;
+ //~ XYZ proportionarms;
+ //~ XYZ proportionbody;
float unconscioustime;
inline AnimationFrame& currentFrame() { return Animation::animations.at(animCurrent).frames.at(frameCurrent); }
inline AnimationFrame& targetFrame() { return Animation::animations.at(animTarget).frames.at(frameTarget); }
+ void setProportions(float, float, float, float);
+ XYZ getProportion(int part) const;
void CheckKick();
void CatchFire();