X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FObjects%2FPerson.cpp;h=c055e57b0f49a5a3e24fdb3af0461415d738e9f2;hb=086b9fc6bc5e16d7f77839bfdadb64ab187cca61;hp=ece23ecddef6221a84d89f341e9dc73b3b5c0253;hpb=5ab55c3eea543a30fe979f623d4a984935e2a0fb;p=lugaru.git diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index ece23ec..c055e57 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -42,8 +42,6 @@ extern float slomodelay; extern bool cellophane; extern float texdetail; extern float realtexdetail; -extern GLubyte bloodText[512 * 512 * 3]; -extern GLubyte wolfbloodText[512 * 512 * 3]; extern int bloodtoggle; extern bool autoslomo; extern float camerashake; @@ -81,16 +79,89 @@ void PersonType::Load() { types.resize(2); + /* Wolf */ 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[wolftype].animRun = wolfrunanim; + types[wolftype].animRunning = wolfrunninganim; + types[wolftype].animCrouch = wolfcrouchanim; + types[wolftype].animStop = wolfstopanim; + types[wolftype].animLanding = wolflandanim; + types[wolftype].animLandingHard = wolflandhardanim; + + types[wolftype].soundsAttack[0] = barksound; + types[wolftype].soundsAttack[1] = bark2sound; + types[wolftype].soundsAttack[2] = bark3sound; + types[wolftype].soundsAttack[3] = barkgrowlsound; + types[wolftype].soundsTalk[0] = growlsound; + types[wolftype].soundsTalk[1] = growl2sound; + + types[wolftype].figureFileName = "Skeleton/BasicFigureWolf"; + types[wolftype].lowFigureFileName = "Skeleton/BasicFigureWolfLow"; + types[wolftype].clothesFileName = "Skeleton/RabbitBelt"; + types[wolftype].modelFileNames[0] = "Models/Wolf.solid"; + types[wolftype].modelFileNames[1] = "Models/Wolf2.solid"; + types[wolftype].modelFileNames[2] = "Models/Wolf3.solid"; + types[wolftype].modelFileNames[3] = "Models/Wolf4.solid"; + types[wolftype].modelFileNames[4] = "Models/Wolf5.solid"; + types[wolftype].modelFileNames[5] = "Models/Wolf6.solid"; + types[wolftype].modelFileNames[6] = "Models/Wolf7.solid"; + types[wolftype].lowModelFileName = "Models/WolfLow.solid"; + types[wolftype].modelClothesFileName = "Models/Belt.solid"; + + types[wolftype].skins.resize(3); + types[wolftype].skins[0] = "Textures/Wolf.jpg"; + types[wolftype].skins[1] = "Textures/DarkWolf.jpg"; + types[wolftype].skins[2] = "Textures/SnowWolf.jpg"; + + /* Rabbit */ 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; + + types[rabbittype].animRun = runanim; + types[rabbittype].animRunning = rabbitrunninganim; + types[rabbittype].animCrouch = crouchanim; + types[rabbittype].animStop = stopanim; + types[rabbittype].animLanding = landanim; + types[rabbittype].animLandingHard = landhardanim; + + types[rabbittype].soundsAttack[0] = rabbitattacksound; + types[rabbittype].soundsAttack[1] = rabbitattack2sound; + types[rabbittype].soundsAttack[2] = rabbitattack3sound; + types[rabbittype].soundsAttack[3] = rabbitattack4sound; + types[rabbittype].soundsTalk[0] = rabbitchitter; + types[rabbittype].soundsTalk[1] = rabbitchitter2; + + types[rabbittype].figureFileName = "Skeleton/BasicFigure"; + types[rabbittype].lowFigureFileName = "Skeleton/BasicFigureLow"; + types[rabbittype].clothesFileName = "Skeleton/RabbitBelt"; + types[rabbittype].modelFileNames[0] = "Models/Body.solid"; + types[rabbittype].modelFileNames[1] = "Models/Body2.solid"; + types[rabbittype].modelFileNames[2] = "Models/Body3.solid"; + types[rabbittype].modelFileNames[3] = "Models/Body4.solid"; + types[rabbittype].modelFileNames[4] = "Models/Body5.solid"; + types[rabbittype].modelFileNames[5] = "Models/Body6.solid"; + types[rabbittype].modelFileNames[6] = "Models/Body7.solid"; + types[rabbittype].lowModelFileName = "Models/BodyLow.solid"; + types[rabbittype].modelClothesFileName = "Models/Belt.solid"; + + types[rabbittype].skins.resize(10); + types[rabbittype].skins[0] = "Textures/Fur3.jpg"; + types[rabbittype].skins[1] = "Textures/Fur.jpg"; + types[rabbittype].skins[2] = "Textures/Fur2.jpg"; + types[rabbittype].skins[3] = "Textures/Lynx.jpg"; + types[rabbittype].skins[4] = "Textures/Otter.jpg"; + types[rabbittype].skins[5] = "Textures/Opal.jpg"; + types[rabbittype].skins[6] = "Textures/Sable.jpg"; + types[rabbittype].skins[7] = "Textures/Chocolate.jpg"; + types[rabbittype].skins[8] = "Textures/BW2.jpg"; + types[rabbittype].skins[9] = "Textures/WB2.jpg"; } Person::Person() @@ -470,39 +541,22 @@ Person::Person(FILE* tfile, int mapvers, unsigned i) void Person::skeletonLoad(bool clothes) { skeleton.id = id; - if (creature != wolftype) { - skeleton.Load( - "Skeleton/BasicFigure", - "Skeleton/BasicFigureLow", - "Skeleton/RabbitBelt", - "Models/Body.solid", - "Models/Body2.solid", - "Models/Body3.solid", - "Models/Body4.solid", - "Models/Body5.solid", - "Models/Body6.solid", - "Models/Body7.solid", - "Models/BodyLow.solid", - "Models/Belt.solid", - clothes); - } else { - skeleton.Load( - "Skeleton/BasicFigureWolf", - "Skeleton/BasicFigureWolfLow", - "Skeleton/RabbitBelt", - "Models/Wolf.solid", - "Models/Wolf2.solid", - "Models/Wolf3.solid", - "Models/Wolf4.solid", - "Models/Wolf5.solid", - "Models/Wolf6.solid", - "Models/Wolf7.solid", - "Models/WolfLow.solid", - "Models/Belt.solid", - clothes); - } - - skeleton.drawmodel.textureptr.load(creatureskin[creature][whichskin], 1, &skeleton.skinText[0], &skeleton.skinsize); + skeleton.Load( + PersonType::types[creature].figureFileName, + PersonType::types[creature].lowFigureFileName, + PersonType::types[creature].clothesFileName, + PersonType::types[creature].modelFileNames[0], + PersonType::types[creature].modelFileNames[1], + PersonType::types[creature].modelFileNames[2], + PersonType::types[creature].modelFileNames[3], + PersonType::types[creature].modelFileNames[4], + PersonType::types[creature].modelFileNames[5], + PersonType::types[creature].modelFileNames[6], + PersonType::types[creature].lowModelFileName, + PersonType::types[creature].modelClothesFileName, + clothes); + + skeleton.drawmodel.textureptr.load(PersonType::types[creature].skins[whichskin], 1, &skeleton.skinText[0], &skeleton.skinsize); } void Person::setProportions(float head, float body, float arms, float legs) @@ -694,13 +748,7 @@ int Person::getIdle() */ int Person::getCrouch() { - if (creature == rabbittype) { - return crouchanim; - } - if (creature == wolftype) { - return wolfcrouchanim; - } - return 0; + return PersonType::types[creature].animCrouch; } /* FUNCTION @@ -708,59 +756,32 @@ int Person::getCrouch() */ int Person::getRun() { - if (creature == rabbittype && (!superruntoggle || weaponactive != -1)) { - return runanim; - } - if (creature == wolftype && (!superruntoggle)) { - return wolfrunanim; - } - - if (creature == rabbittype && (superruntoggle && weaponactive == -1)) { - return rabbitrunninganim; - } - if (creature == wolftype && (superruntoggle)) { - return wolfrunninganim; + if (superruntoggle && (weaponactive == -1)) { + return PersonType::types[creature].animRunning; + } else { + return PersonType::types[creature].animRun; } - return 0; } /* FUNCTION */ int Person::getStop() { - if (creature == rabbittype) { - return stopanim; - } - if (creature == wolftype) { - return wolfstopanim; - } - return 0; + return PersonType::types[creature].animStop; } /* FUNCTION */ int Person::getLanding() { - if (creature == rabbittype) { - return landanim; - } - if (creature == wolftype) { - return wolflandanim; - } - return 0; + return PersonType::types[creature].animLanding; } /* FUNCTION */ int Person::getLandhard() { - if (creature == rabbittype) { - return landhardanim; - } - if (creature == wolftype) { - return wolflandhardanim; - } - return 0; + return PersonType::types[creature].animLandingHard; } /* EFFECT @@ -834,17 +855,9 @@ void Person::DoBlood(float howmuch, int which) bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25; bleedxint = 0; bleedyint = 0; - if (creature == rabbittype) { - while (bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) { - bleedxint = abs(Random() % 512); - bleedyint = abs(Random() % 512); - } - } - if (creature == wolftype) { - while (wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) { - bleedxint = abs(Random() % 512); - bleedyint = abs(Random() % 512); - } + while (PersonType::types[creature].bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || PersonType::types[creature].bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) { + bleedxint = abs(Random() % 512); + bleedyint = abs(Random() % 512); } bleedy = bleedxint; bleedx = bleedyint; @@ -957,42 +970,20 @@ void Person::DoBloodBig(float howmuch, int which) int endx = 0; int endy = 0; GLubyte color; - 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 (i < startx) { - startx = i; - } - if (j < starty) { - starty = j; - } - if (i > endx) { - endx = i; - } - if (j > endy) { - endy = j; - } + for (i = 0; i < 512; i++) { + for (j = 0; j < 512; j++) { + if (PersonType::types[creature].bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && PersonType::types[creature].bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) { + if (i < startx) { + startx = 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 (i < startx) { - startx = i; - } - if (j < starty) { - starty = j; - } - if (i > endx) { - endx = i; - } - if (j > endy) { - endy = j; - } + if (j < starty) { + starty = j; + } + if (i > endx) { + endx = i; + } + if (j > endy) { + endy = j; } } } @@ -1029,33 +1020,16 @@ void Person::DoBloodBig(float howmuch, int which) int texdetailint = realtexdetail; int where; - if (creature == rabbittype) { - for (i = startx; i < endx; i++) { - for (j = starty; j < endy; j++) { - if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) { - color = Random() % 85 + 170; - where = i * skeleton.skinsize * 3 + j * 3; - if (skeleton.skinText[where + 0] > color / 2) { - skeleton.skinText[where + 0] = color / 2; - } - skeleton.skinText[where + 1] = 0; - skeleton.skinText[where + 2] = 0; - } - } - } - } - if (creature == wolftype) { - for (i = startx; i < endx; i++) { - for (j = starty; j < endy; j++) { - if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) { - color = Random() % 85 + 170; - where = i * skeleton.skinsize * 3 + j * 3; - if (skeleton.skinText[where + 0] > color / 2) { - skeleton.skinText[where + 0] = color / 2; - } - skeleton.skinText[where + 1] = 0; - skeleton.skinText[where + 2] = 0; + for (i = startx; i < endx; i++) { + for (j = starty; j < endy; j++) { + if (PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) { + color = Random() % 85 + 170; + where = i * skeleton.skinsize * 3 + j * 3; + if (skeleton.skinText[where + 0] > color / 2) { + skeleton.skinText[where + 0] = color / 2; } + skeleton.skinText[where + 1] = 0; + skeleton.skinText[where + 2] = 0; } } } @@ -1064,17 +1038,9 @@ void Person::DoBloodBig(float howmuch, int which) bleedxint = 0; bleedyint = 0; - if (creature == rabbittype) { - while (bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) { - bleedxint = abs(Random() % 512); - bleedyint = abs(Random() % 512); - } - } - if (creature == wolftype) { - while (wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) { - bleedxint = abs(Random() % 512); - bleedyint = abs(Random() % 512); - } + while (PersonType::types[creature].bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || PersonType::types[creature].bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) { + bleedxint = abs(Random() % 512); + bleedyint = abs(Random() % 512); } bleedy = bleedxint + offsetx; bleedx = bleedyint + offsety; @@ -1208,42 +1174,20 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) int endx = 0; int endy = 0; GLubyte color; - 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 (i < startx) { - startx = i; - } - if (j < starty) { - starty = j; - } - if (i > endx) { - endx = i; - } - if (j > endy) { - endy = j; - } + for (i = 0; i < 512; i++) { + for (j = 0; j < 512; j++) { + if (PersonType::types[creature].bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && PersonType::types[creature].bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) { + if (i < startx) { + startx = 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 (i < startx) { - startx = i; - } - if (j < starty) { - starty = j; - } - if (i > endx) { - endx = i; - } - if (j > endy) { - endy = j; - } + if (j < starty) { + starty = j; + } + if (i > endx) { + endx = i; + } + if (j > endy) { + endy = j; } } } @@ -1279,49 +1223,24 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) int texdetailint = realtexdetail; int where; - if (creature == rabbittype) { - for (i = startx; i < endx; i++) { - for (j = starty; j < endy; j++) { - if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) { - color = Random() % 85 + 170; - where = i * skeleton.skinsize * 3 + j * 3; - if (skeleton.skinText[where + 0] > color / 2) { - skeleton.skinText[where + 0] = color / 2; - } - skeleton.skinText[where + 1] = 0; - skeleton.skinText[where + 2] = 0; - } else if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= 160 + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= 160 - 4) { - color = Random() % 85 + 170; - where = i * skeleton.skinsize * 3 + j * 3; - if (skeleton.skinText[where + 0] > color / 2) { - skeleton.skinText[where + 0] = color / 2; - } - skeleton.skinText[where + 1] = 0; - skeleton.skinText[where + 2] = 0; + for (i = startx; i < endx; i++) { + for (j = starty; j < endy; j++) { + if (PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) { + color = Random() % 85 + 170; + where = i * skeleton.skinsize * 3 + j * 3; + if (skeleton.skinText[where + 0] > color / 2) { + skeleton.skinText[where + 0] = color / 2; } - } - } - } - if (creature == wolftype) { - for (i = startx; i < endx; i++) { - for (j = starty; j < endy; j++) { - if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) { - color = Random() % 85 + 170; - where = i * skeleton.skinsize * 3 + j * 3; - if (skeleton.skinText[where + 0] > color / 2) { - skeleton.skinText[where + 0] = color / 2; - } - skeleton.skinText[where + 1] = 0; - skeleton.skinText[where + 2] = 0; - } else if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= 160 + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= 160 - 4) { - color = Random() % 85 + 170; - where = i * skeleton.skinsize * 3 + j * 3; - if (skeleton.skinText[where + 0] > color / 2) { - skeleton.skinText[where + 0] = color / 2; - } - skeleton.skinText[where + 1] = 0; - skeleton.skinText[where + 2] = 0; + skeleton.skinText[where + 1] = 0; + skeleton.skinText[where + 2] = 0; + } else if (PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= 160 + 4 && PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= 160 - 4) { + color = Random() % 85 + 170; + where = i * skeleton.skinsize * 3 + j * 3; + if (skeleton.skinText[where + 0] > color / 2) { + skeleton.skinText[where + 0] = color / 2; } + skeleton.skinText[where + 1] = 0; + skeleton.skinText[where + 2] = 0; } } } @@ -2388,34 +2307,7 @@ void Person::DoAnimations() if (targetFrame().label == 4 && aitype != playercontrolled) { if (Animation::animations[animTarget].attack != neutral) { unsigned r = abs(Random() % 4); - if (creature == rabbittype) { - if (r == 0) { - whichsound = rabbitattacksound; - } - if (r == 1) { - whichsound = rabbitattack2sound; - } - if (r == 2) { - whichsound = rabbitattack3sound; - } - if (r == 3) { - whichsound = rabbitattack4sound; - } - } - if (creature == wolftype) { - if (r == 0) { - whichsound = barksound; - } - if (r == 1) { - whichsound = bark2sound; - } - if (r == 2) { - whichsound = bark3sound; - } - if (r == 3) { - whichsound = barkgrowlsound; - } - } + whichsound = PersonType::types[creature].soundsAttack[r]; speechdelay = .3; } } @@ -5926,21 +5818,8 @@ void Person::DoStuff() int whichsound = -1; if (speechdelay <= 0) { unsigned int i = abs(Random() % 4); - if (creature == rabbittype) { - if (i == 0) { - whichsound = rabbitchitter; - } - if (i == 1) { - whichsound = rabbitchitter2; - } - } - if (creature == wolftype) { - if (i == 0) { - whichsound = growlsound; - } - if (i == 1) { - whichsound = growl2sound; - } + if (i < 2) { + whichsound = PersonType::types[creature].soundsTalk[i]; } } speechdelay = .3;