Added a method for type changing in Person.
void ch_funnybunny(const char*)
{
- Person::players[0]->creature = rabbittype;
- Person::players[0]->skeletonLoad(true);
- Person::players[0]->scale = .2;
+ Person::players[0]->changeCreatureType(rabbittype);
Person::players[0]->headless = 0;
- Person::players[0]->damagetolerance = 200;
set_proportion(0, "1 1 1 1");
}
void ch_wolfie(const char*)
{
- Person::players[0]->creature = wolftype;
- Person::players[0]->skeletonLoad();
- Person::players[0]->scale = .23;
- Person::players[0]->damagetolerance = 300;
+ Person::players[0]->changeCreatureType(wolftype);
set_proportion(0, "1 1 1 1");
}
Person::players[0]->metallow = 1;
Person::players[0]->power = 1;
Person::players[0]->speedmult = 1;
- if (Person::players[0]->creature == wolftype) {
- Person::players[0]->scale = .23;
- } else if (Person::players[0]->creature == rabbittype) {
- Person::players[0]->scale = .2;
- }
+ Person::players[0]->scale = PersonType::types[Person::players[0]->creature].defaultScale;
Person::players[0]->setProportions(1, 1, 1, 1);
editorenabled = !editorenabled;
if (editorenabled) {
Person::players[0]->damagetolerance = 100000;
+ Person::players[0]->damage = 0;
+ Person::players[0]->permanentdamage = 0;
+ Person::players[0]->superpermanentdamage = 0;
+ Person::players[0]->burnt = 0;
+ Person::players[0]->bloodloss = 0;
+ Person::players[0]->deathbleeding = 0;
} else {
Person::players[0]->damagetolerance = 200;
}
- Person::players[0]->damage = 0; // these lines were in both if and else, but I think they would better fit in the if
- Person::players[0]->permanentdamage = 0;
- Person::players[0]->superpermanentdamage = 0;
- Person::players[0]->bloodloss = 0;
- Person::players[0]->deathbleeding = 0;
}
/* Nullify damage and give 200000 health */
if (Input::isKeyPressed(SDL_SCANCODE_H)) {
Person::players[0]->damagetolerance = 200000;
Person::players[0]->damage = 0;
- Person::players[0]->burnt = 0;
Person::players[0]->permanentdamage = 0;
Person::players[0]->superpermanentdamage = 0;
+ Person::players[0]->burnt = 0;
+ Person::players[0]->bloodloss = 0;
+ Person::players[0]->deathbleeding = 0;
}
/* Change environment */
}
if (closest >= 0) {
- if (Person::players[closest]->creature == rabbittype) {
- Person::players[closest]->creature = wolftype;
- Person::players[closest]->whichskin = 0;
- Person::players[closest]->skeletonLoad();
- Person::players[closest]->scale *= 1.15;
-
- Person::players[closest]->damagetolerance = 300;
- } else { // wolftype
- Person::players[closest]->creature = rabbittype;
- Person::players[closest]->whichskin = 0;
- Person::players[closest]->skeletonLoad(true);
-
- Person::players[closest]->scale /= 1.15;
-
- Person::players[closest]->damagetolerance = 200;
- }
+ person_type nextType = static_cast<person_type>((Person::players[closest]->creature + 1) % PersonType::types.size());
+ Person::players[closest]->changeCreatureType(nextType);
}
}
, skiddingdelay(0)
, deathbleeding(0)
, tempdeltav(0)
- ,
- damagetolerance(200)
+ , damagetolerance(0)
, damage(0)
, permanentdamage(0)
, superpermanentdamage(0)
, lastcollide(0)
, dead(0)
- ,
- jumppower(5)
+ , jumppower(5)
, onground(false)
- ,
- wentforweapon(0)
- ,
+ , wentforweapon(0)
- calcrot(false)
- ,
+ , calcrot(false)
- facing()
- ,
+ , facing()
- bleeding(0)
+ , bleeding(0)
, bleedx(0)
, bleedy(0)
, direction(0)
jumpclimb(false)
{
+ damagetolerance = PersonType::types[creature].defaultDamageTolerance;
setProportions(1, 1, 1, 1);
}
loaded = true;
- if (creature == wolftype) {
- damagetolerance = 300;
- }
+ damagetolerance = PersonType::types[creature].defaultDamageTolerance;
if (scale < 0) {
- if (creature == wolftype) {
- scale = .23;
- } else {
- scale = .2;
- }
+ scale = PersonType::types[creature].defaultScale;
}
oldcoords = coords;
realoldcoords = coords;
}
+void Person::changeCreatureType(person_type type)
+{
+ creature = type;
+ whichskin = 0;
+ skeletonLoad(type == rabbittype);
+ scale = PersonType::types[creature].defaultScale;
+ damagetolerance = PersonType::types[creature].defaultDamageTolerance;
+}
+
void Person::skeletonLoad(bool clothes)
{
skeleton.id = id;
float getProportion(int part) const;
XYZ getProportionXYZ(int part) const;
+ void changeCreatureType(person_type type);
+
void CheckKick();
void CatchFire();
void DoBlood(float howmuch, int which);
types[wolftype].skins[2] = "Textures/FurWolfSnow.jpg";
types[wolftype].power = 2.5;
+ types[wolftype].defaultDamageTolerance = 300;
+ types[wolftype].defaultScale = .23;
/* Rabbit */
types[rabbittype].proportions[0] = 1.2;
types[rabbittype].skins[9] = "Textures/FurBrownWhite.jpg";
types[rabbittype].power = 1;
+ types[rabbittype].defaultDamageTolerance = 200;
+ types[rabbittype].defaultScale = .2;
}
std::vector<std::string> skins;
float power;
+ unsigned int defaultDamageTolerance;
+ float defaultScale;
GLubyte bloodText[512 * 512 * 3] = { 0 };