1
1

Humanoid.ts 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. /// <reference path="../Person.ts" />
  2. /// <reference path="../Bodypart/HumanoidParts.ts" />
  3. /// <reference path="../../Action/ActionRemove.ts" />
  4. /// <reference path="../../Action/ActionWear.ts" />
  5. // TODO : Implements LiquidContainer for Milk udders. Maybe prostates.
  6. interface HumanoidOptions extends ThingOptions {
  7. isMale : boolean;
  8. }
  9. interface HumanoidGender {
  10. hasPenis : boolean;
  11. hasPenisBulge : boolean;
  12. hasVagina : boolean;
  13. hasTits : boolean;
  14. genderValue : number; // Only includes clothing and bodyparts, good measure for bisexual NPCs
  15. genderValueCorrected : number; // Includes sexual characteristics being visible: breast size existing, a crotch bulge, etc. Heavily altered by a penis/vagina being out in the open
  16. }
  17. interface HumanoidSluttiness {
  18. halfNaked : boolean;
  19. naked : boolean;
  20. sluttiness : number; // Only includes clothing
  21. sluttinessCorrected : number; // Includes mannerisms caused by personality
  22. }
  23. interface HumanoidBulges {
  24. breasts : number;
  25. crotch : number;
  26. butt : number;
  27. waist : number;
  28. }
  29. class Humanoid extends Person {
  30. public static SEX_MALE = 0;
  31. public static SEX_FEMALE = 1;
  32. public static SEX_HERM = 2;
  33. public breastVisibleSize = 0;
  34. public isBreastVisible = false;
  35. public isBreastTight = false;
  36. public isBreastLoose = false;
  37. public crotchVisibleSize = 0;
  38. public isCrotchVisible = false;
  39. public isCrotchTight = false;
  40. public buttVisibleSize = 0;
  41. public isButtVisible = false;
  42. public isButtTight = false;
  43. public isGenderCached : boolean = false;
  44. public isSluttinessCached : boolean = false;
  45. public cachedGenderValue : HumanoidGender;
  46. public cachedSluttiness : HumanoidSluttiness;
  47. public cachedBulges : HumanoidBulges;
  48. public uncoveredSlots : Array<number> = [];
  49. public invalidateCaches () {
  50. this.isGenderCached = false;
  51. this.isSluttinessCached = false;
  52. }
  53. public getGenderValue () : HumanoidGender {
  54. if (!this.isSluttinessCached) {
  55. this.updateCaches();
  56. }
  57. return this.cachedGenderValue;
  58. }
  59. public getSluttiness () : HumanoidSluttiness {
  60. if (!this.isSluttinessCached) {
  61. this.updateCaches();
  62. }
  63. return this.cachedSluttiness;
  64. }
  65. public getBulges () {
  66. if (!this.isGenderCached) {
  67. this.updateCaches();
  68. }
  69. return this.cachedBulges;
  70. }
  71. public updateCaches () {
  72. this.updateClothing();
  73. this.updateSlots();
  74. this.updateBodyparts();
  75. this.updateBulges();
  76. this.updateGenderValue();
  77. this.updateSluttiness();
  78. }
  79. public updateSlots () {
  80. this.uncoveredSlots = [];
  81. for (let i = 0; i < Humanoid.SLOT_SLOT_COUNT; i++) { this.uncoveredSlots.push(i); }
  82. let clothing = <Array<Clothing>>Thing.WearRelation.getRightType(this, Clothing);
  83. for (let i = 0; i < clothing.length; i++) {
  84. let covering = clothing[i].getCoveringSlots();
  85. for (let k = 0; k < covering.length; k++) {
  86. let idx = this.uncoveredSlots.indexOf(covering[k]);
  87. if (idx >= 0) {
  88. this.uncoveredSlots.splice(idx, 1);
  89. }
  90. }
  91. if (this.uncoveredSlots.length == 0) break;
  92. }
  93. }
  94. public updateGenderValue () {
  95. let clothingGender = Clothing.getGenderValueOn(this);
  96. let bodypartGender = Bodypart.getGenderValueOn(this);
  97. let genderWeight = clothingGender.weight + bodypartGender.weight;
  98. let genderValue = clothingGender.value + bodypartGender.value;
  99. let correctionWeight = Bodypart.WEIGHT_HIGHEST;
  100. let correctionValue = this.getStat(Attributes.GenderIdentity) * Bodypart.WEIGHT_HIGHEST; // Gender Identity has weight for Gender Value. It includes things such as intonation and manneirisms, so it counts.
  101. let hasPenis : boolean = false;
  102. let hasVagina : boolean = false;
  103. if (this.isCrotchVisible) {
  104. // Does this have a vagina or not? It's visible, so it affects OBVIOUSLY MALE/FEMALE
  105. if (Thing.PartRelation.getRightTypeOne(this, HumanoidPenis) != undefined) {
  106. hasPenis = true;
  107. hasVagina = false;
  108. correctionValue += 0 * Bodypart.WEIGHT_LOWEST;
  109. correctionWeight += Bodypart.WEIGHT_LOWEST;
  110. } else if (Thing.PartRelation.getRightTypeOne(this, HumanoidVagina) != undefined) {
  111. hasPenis = false;
  112. hasVagina = true;
  113. correctionValue += 100 * Bodypart.WEIGHT_LOWEST;
  114. correctionWeight += Bodypart.WEIGHT_LOWEST;
  115. }
  116. }
  117. if (this.breastVisibleSize > 0) {
  118. correctionValue += 100 * Bodypart.WEIGHT_LOWEST;
  119. correctionWeight += Bodypart.WEIGHT_LOWEST;
  120. }
  121. if (this.crotchVisibleSize > 0 && !hasVagina) {
  122. correctionValue += 0 * Bodypart.WEIGHT_LOWEST;
  123. correctionWeight += Bodypart.WEIGHT_LOWEST;
  124. }
  125. let genderValueFinal = genderValue / genderWeight;
  126. let genderValueCorrected = (genderValue + correctionValue) / (genderWeight + correctionWeight);
  127. this.cachedGenderValue = {
  128. hasTits : this.breastVisibleSize > 1, // ignore microtits
  129. hasPenisBulge : this.crotchVisibleSize > 0 && !hasVagina, //safe guard against puffy vaginas if they ever come up
  130. hasPenis : hasPenis,
  131. hasVagina : hasVagina,
  132. genderValue : genderValueFinal,
  133. genderValueCorrected : genderValueCorrected
  134. };
  135. this.isGenderCached = true;
  136. }
  137. public isVisibleOn (slot : number) {
  138. return this.uncoveredSlots.indexOf(slot) != -1;
  139. }
  140. /* TODO: This will suck. Goals: Sluttiness of a naked normal person should be between 45-50.
  141. * A naked person should max out at around 80 with TERRIBLE holes. So some clothing is sluttier than being outright naked, and being naked is not that slutty unless you're fucked up.
  142. * Being mostly covered with the exception of genitals should be seen as worse than being nake-der as well. Might just leave that for the outfits, though.
  143. */
  144. public updateSluttiness () {
  145. // TODO: Maybe use these.
  146. // let nakedBreakpoint = 0.3;
  147. // let halfnakedBreakpoint = 0.5;
  148. let clothingSluttiness = Clothing.getSluttinessValueOn(this);
  149. let bodypartSluttiness = Bodypart.getSluttinessValueOn(this);
  150. let sluttinessWeight = clothingSluttiness.weight + bodypartSluttiness.weight;
  151. let sluttinessValue = clothingSluttiness.value + bodypartSluttiness.value;
  152. let correctionWeight = 0;
  153. let correctionValue = 0;
  154. let somewhatSlutty = [Humanoid.SLOT_MIDRIFF, Humanoid.SLOT_LEG_UPPER, Humanoid.SLOT_WAIST, Humanoid.SLOT_HIPS, Humanoid.SLOT_BACK];
  155. for (let i = 0; i < somewhatSlutty.length; i++) {
  156. if (this.isVisibleOn(somewhatSlutty[i])) {
  157. correctionWeight += 1;
  158. correctionValue += 75;
  159. }
  160. }
  161. let verySlutty = [Humanoid.SLOT_BREASTS, Humanoid.SLOT_CROTCH_FRONT, Humanoid.SLOT_CROTCH_BACK, Humanoid.SLOT_BUTT];
  162. for (let i = 0; i < verySlutty.length; i++) {
  163. if (this.isVisibleOn(verySlutty[i])) {
  164. correctionWeight += 3;
  165. correctionValue += 75;
  166. }
  167. }
  168. if ((this.isVisibleOn.length / Humanoid.SLOT_SLOT_COUNT) > 0.75) {
  169. let extremeSlutty = [Humanoid.SLOT_BREASTS, Humanoid.SLOT_CROTCH_FRONT, Humanoid.SLOT_CROTCH_BACK, Humanoid.SLOT_BUTT];
  170. for (let i = 0; i < extremeSlutty.length; i++) {
  171. if (this.isVisibleOn(extremeSlutty[i])) {
  172. correctionWeight += 5;
  173. correctionValue += 85;
  174. }
  175. }
  176. }
  177. let halfNaked : boolean;
  178. let naked : boolean;
  179. if (!this.isMale()) {
  180. halfNaked = (this.isVisibleOn.length / Humanoid.SLOT_SLOT_COUNT) < 0.5 &&
  181. !this.isVisibleOnArray([Humanoid.SLOT_BREASTS, Humanoid.SLOT_CROTCH_FRONT, Humanoid.SLOT_CROTCH_BACK]);
  182. naked = (this.isVisibleOn.length / Humanoid.SLOT_SLOT_COUNT) < 0.3 &&
  183. this.isVisibleOnArray([Humanoid.SLOT_BREASTS, Humanoid.SLOT_CROTCH_FRONT, Humanoid.SLOT_CROTCH_BACK, Humanoid.SLOT_BUTT]);
  184. } else {
  185. if (this.hasBreasts()) {
  186. halfNaked = (this.isVisibleOn.length / Humanoid.SLOT_SLOT_COUNT) < 0.5 &&
  187. !this.isVisibleOnArray([Humanoid.SLOT_BREASTS, Humanoid.SLOT_CROTCH_FRONT, Humanoid.SLOT_CROTCH_BACK]);
  188. naked = (this.isVisibleOn.length / Humanoid.SLOT_SLOT_COUNT) < 0.3 &&
  189. this.isVisibleOnArray([Humanoid.SLOT_BREASTS, Humanoid.SLOT_CROTCH_FRONT, Humanoid.SLOT_CROTCH_BACK, Humanoid.SLOT_BUTT]);
  190. } else {
  191. halfNaked = (this.isVisibleOn.length / Humanoid.SLOT_SLOT_COUNT) < 0.5 &&
  192. !this.isVisibleOnArray([Humanoid.SLOT_CROTCH_FRONT, Humanoid.SLOT_CROTCH_BACK]);
  193. naked = (this.isVisibleOn.length / Humanoid.SLOT_SLOT_COUNT) < 0.3 &&
  194. this.isVisibleOnArray([Humanoid.SLOT_CROTCH_FRONT, Humanoid.SLOT_CROTCH_BACK, Humanoid.SLOT_BUTT]);
  195. }
  196. }
  197. let sluttinessValueFinal = sluttinessValue / sluttinessWeight;
  198. let sluttinessCorrected = (sluttinessValue + correctionValue) / (sluttinessWeight + correctionWeight);
  199. this.cachedSluttiness = {
  200. halfNaked : halfNaked,
  201. naked : naked,
  202. sluttiness : sluttinessValueFinal,
  203. sluttinessCorrected : sluttinessCorrected
  204. };
  205. this.isSluttinessCached = true;
  206. }
  207. public isVisibleOnArray (arr : Array<number>) {
  208. for (let i =0 ; i < arr.length; i++) {
  209. if (!this.isVisibleOn(arr[i])) {
  210. return false;
  211. }
  212. }
  213. return true;
  214. }
  215. public addMaleParts () {
  216. if (!this.isMale() && !this.isHerm()) {
  217. this.addParts(
  218. new HumanoidTesticles(), new HumanoidPenis()
  219. );
  220. }
  221. this.invalidateCaches();
  222. }
  223. public addFemaleParts () {
  224. if (!this.isFemale() && !this.isHerm()) {
  225. this.addParts(
  226. new HumanoidVagina()
  227. );
  228. }
  229. this.invalidateCaches();
  230. }
  231. public removeGenderedParts () {
  232. this.removeParts(HumanoidVagina);
  233. this.removeParts(HumanoidPenis);
  234. this.removeParts(HumanoidTesticles);
  235. this.invalidateCaches();
  236. }
  237. public setGenderValue (value : number) {
  238. let bp = this.getParts(Bodypart);
  239. for (let i = 0; i < bp.length; i++) {
  240. if (bp[i] instanceof HumanoidBreasts && this.isMale()) { // don't add breasts automatically to a male!
  241. bp[i].arrangeGenderValue(0);
  242. } else {
  243. bp[i].arrangeGenderValue(value);
  244. }
  245. }
  246. }
  247. public constructor (options? : HumanoidOptions) {
  248. super(options);
  249. this.addParts(
  250. new HumanoidSkin(), new HumanoidHead(), new HumanoidArms(),
  251. new HumanoidHands(), new HumanoidBreasts(), new HumanoidFeet(),
  252. new HumanoidTorso(), new HumanoidButt()
  253. );
  254. if (options.isMale) {
  255. this.addMaleParts();
  256. this.setGenderValue(25);
  257. } else {
  258. this.addFemaleParts();
  259. this.setGenderValue(75);
  260. }
  261. this.addGetAlterations((humanoid : Humanoid) => {
  262. // Let's not do this for NPCs. It can break patches.
  263. if (humanoid.isPlayer()) {
  264. return {
  265. HumanoidGender: humanoid.isMale() ? Humanoid.SEX_MALE :
  266. humanoid.isFemale() ? Humanoid.SEX_FEMALE :
  267. Humanoid.SEX_HERM
  268. }
  269. }
  270. });
  271. this.addGetAlterations((humanoid : Humanoid) => {
  272. // Let's not do this for NPCs. It can break patches.
  273. let allParts = this.getParts();
  274. let changes = {};
  275. for (let i = 0; i < allParts.length; i++) {
  276. let part = <Bodypart> allParts[i];
  277. changes[part.getName()] = part.getChanges();
  278. }
  279. return {bodyparts : changes};
  280. });
  281. this.addSetAlterations((humanoid : Humanoid, changes) => {
  282. // Let's not do this for NPCs. It can break patches.
  283. if (changes.HumanoidGender != undefined) {
  284. humanoid.removeGenderedParts();
  285. if (changes.HumanoidGender == Humanoid.SEX_MALE) {
  286. humanoid.addMaleParts();
  287. } else if (changes.HumanoidGender == Humanoid.SEX_FEMALE) {
  288. humanoid.addFemaleParts();
  289. } else {
  290. humanoid.addMaleParts();
  291. humanoid.addFemaleParts();
  292. }
  293. }
  294. this.addSetAlterations((humanoid : Humanoid, changes : any) => {
  295. if (changes.bodyparts != undefined) {
  296. let bpChanges = <any>changes.bodyparts;
  297. let allParts = this.getParts();
  298. for (let i = 0; i < allParts.length; i++) {
  299. let part = <Bodypart>allParts[i];
  300. if (bpChanges[part.getName()] != undefined) {
  301. part.setChanges(bpChanges[part.getName()]);
  302. }
  303. }
  304. }
  305. });
  306. });
  307. }
  308. public updateBodyparts () {
  309. let parts = <Array<Bodypart>> Thing.PartRelation.getRightType(this, Bodypart);
  310. for (let i = 0; i < parts.length; i++) {
  311. parts[i].updateStatus();
  312. }
  313. }
  314. public updateClothing () {
  315. let clothes = <Array<Clothing>> Thing.WearRelation.getRightType(this, Clothing);
  316. for (let i = 0; i < clothes.length; i++) {
  317. clothes[i].updateStatus();
  318. }
  319. }
  320. public updateBulges () {
  321. let clothes = Thing.WearRelation.getRightType(this, Clothing).sort(function (a : Clothing, b : Clothing) {
  322. return a.layer - b.layer;
  323. });
  324. this.isBreastVisible = true;
  325. this.isCrotchVisible = true;
  326. this.isButtVisible = true;
  327. let bras = [];
  328. let butts = [];
  329. let junks = [];
  330. clothes.forEach((cloth : Clothing) => {
  331. cloth.updateStatus();
  332. if (cloth.slots.indexOf(Humanoid.SLOT_BREASTS) != -1) {
  333. bras.push(cloth);
  334. if (cloth.transparentSlots.indexOf(Humanoid.SLOT_BREASTS) == -1) {
  335. this.isBreastVisible = false;
  336. }
  337. }
  338. if (cloth.slots.indexOf(Humanoid.SLOT_BUTT) != -1) {
  339. butts.push(cloth);
  340. if (cloth.transparentSlots.indexOf(Humanoid.SLOT_BUTT) == -1) {
  341. this.isButtVisible = false;
  342. }
  343. }
  344. if (cloth.slots.indexOf(Humanoid.SLOT_CROTCH_FRONT) != -1) {
  345. junks.push(cloth);
  346. if (cloth.transparentSlots.indexOf(Humanoid.SLOT_CROTCH_FRONT) == -1) {
  347. this.isCrotchVisible = false;
  348. }
  349. }
  350. });
  351. this.updateBreastSizes(bras);
  352. this.updateCrotchSizes(junks);
  353. this.updateButtSizes(butts);
  354. this.cachedBulges = {
  355. breasts : this.breastVisibleSize,
  356. butt : this.buttVisibleSize,
  357. crotch : this.crotchVisibleSize,
  358. waist : 0
  359. };
  360. }
  361. public getTopClothOn (slot : number) {
  362. return Thing.WearRelation.getRightType(this, Clothing).filter(otherCloth => {
  363. return otherCloth.visibleOn.includes(slot);
  364. }).sort((a : Clothing, b : Clothing) => {
  365. return a.layer - b.layer;
  366. })[0];
  367. }
  368. public updateBreastSizes (bras : Array<Clothing>) {
  369. this.isBreastTight = false;
  370. this.isBreastLoose = true;
  371. let breasts = <HumanoidBreasts> Thing.PartRelation.getRightTypeOne(this, HumanoidBreasts);
  372. this.breastVisibleSize = breasts.getSize();
  373. bras.forEach((bra : Clothing) => {
  374. if (bra.tightBreastSize >= 0 && this.breastVisibleSize > bra.tightBreastSize) {
  375. this.isBreastTight = true;
  376. }
  377. if (bra.maxBreastSize >= 0 && this.breastVisibleSize > bra.maxBreastSize) {
  378. this.breastVisibleSize = bra.maxBreastSize;
  379. }
  380. if (this.breastVisibleSize >= bra.looseBreastSize) {
  381. this.isBreastLoose = false;
  382. }
  383. this.breastVisibleSize += bra.breastPadding;
  384. if (this.breastVisibleSize < 0) {
  385. this.breastVisibleSize = 0;
  386. }
  387. });
  388. }
  389. public updateCrotchSizes (cloths : Array<Clothing>) {
  390. this.isCrotchTight = false;
  391. this.crotchVisibleSize = 0;
  392. let penis = <HumanoidPenis> Thing.PartRelation.getRightTypeOne(this, HumanoidPenis);
  393. let testicles = <HumanoidTesticles> Thing.PartRelation.getRightTypeOne(this, HumanoidTesticles);
  394. this.crotchVisibleSize = 0;
  395. if (penis != undefined) {
  396. this.crotchVisibleSize += penis.getBulgeSize();
  397. }
  398. if (testicles != undefined) {
  399. this.crotchVisibleSize += testicles.getBulgeSize();
  400. }
  401. this.crotchVisibleSize = Math.floor(this.crotchVisibleSize * 10) / 10;
  402. cloths.forEach((worn : Clothing) => {
  403. if (worn.tightCrotchSize >= 0 && this.crotchVisibleSize > worn.tightCrotchSize) {
  404. this.isCrotchTight = true;
  405. }
  406. if (worn.maxCrotchSize >= 0 && this.crotchVisibleSize > worn.maxCrotchSize) {
  407. this.crotchVisibleSize = worn.maxCrotchSize;
  408. }
  409. this.crotchVisibleSize += worn.crotchPadding;
  410. if (this.crotchVisibleSize < 0) {
  411. this.crotchVisibleSize = 0;
  412. }
  413. });
  414. }
  415. public updateButtSizes (cloths : Array<Clothing>) {
  416. this.isButtTight = false;
  417. let butt = <HumanoidButt> Thing.PartRelation.getRightTypeOne(this, HumanoidButt);
  418. this.buttVisibleSize = butt == undefined ? 0 : butt.getSize();
  419. cloths.forEach((worn : Clothing) => {
  420. if (worn.tightButtSize >= 0 && this.buttVisibleSize > worn.tightButtSize) {
  421. this.isButtTight = true;
  422. }
  423. if (worn.maxButtSize >= 0 && this.buttVisibleSize > worn.maxButtSize) {
  424. this.buttVisibleSize = worn.maxButtSize;
  425. }
  426. this.buttVisibleSize += worn.buttPadding;
  427. if (this.buttVisibleSize < 0) {
  428. this.buttVisibleSize = 0;
  429. }
  430. });
  431. }
  432. public hasBreasts () {
  433. let breasts = <HumanoidBreasts> this.getPart(HumanoidBreasts);
  434. if (breasts.size > 1) {
  435. return true;
  436. }
  437. return false;
  438. }
  439. public isMale () {
  440. return this.getParts(HumanoidPenis).length > 0 && this.getParts(HumanoidVagina).length == 0;
  441. }
  442. public isFemale () {
  443. return this.getParts(HumanoidPenis).length == 0 && this.getParts(HumanoidVagina).length > 0;
  444. }
  445. public isHerm () {
  446. return this.getParts(HumanoidPenis).length > 0 && this.getParts(HumanoidVagina).length > 0;
  447. }
  448. public getShortestDescription () {
  449. let playerGender = this.getGenderValue();
  450. let playerSluttiness = this.getSluttiness();
  451. let presentation = "";
  452. if (playerSluttiness.sluttinessCorrected > 75) {
  453. presentation += ("slutty, ");
  454. } else if (playerSluttiness.sluttinessCorrected > 35) {
  455. } else if (playerSluttiness.sluttinessCorrected > 20) {
  456. presentation += ("prude, ");
  457. } else {
  458. presentation += ("saintly, ");
  459. }
  460. if (playerGender.genderValueCorrected < 40) {
  461. presentation += ("masculine ");
  462. } else if (playerGender.genderValueCorrected < 60) {
  463. presentation += ("androgynous ");
  464. } else {
  465. presentation += ("feminine ");
  466. }
  467. if (playerGender.hasTits) {
  468. if (playerGender.hasPenis || playerGender.hasPenisBulge) {
  469. // Shemale Status (Tits + Penis)
  470. presentation += ("shemale");
  471. } else if (playerGender.hasVagina) {
  472. // is a woman
  473. presentation += ("woman");
  474. }
  475. } else {
  476. // No tits
  477. if (playerGender.hasPenis) {
  478. // Simply male
  479. if (playerGender.genderValueCorrected < 60) {
  480. presentation += ("man");
  481. } else {
  482. presentation += ("trap");
  483. }
  484. } else if (playerGender.hasPenisBulge) {
  485. // Possible Shemale status - has bulge and tits maybe get better terms sometime
  486. if (playerGender.genderValueCorrected < 60) {
  487. presentation += ("man");
  488. } else {
  489. presentation += ("trap");
  490. }
  491. } else if (playerGender.hasVagina) {
  492. // is a woman
  493. presentation += ("woman");
  494. }
  495. }
  496. return presentation;
  497. }
  498. public static SLOT_HAIR = 0;
  499. public static SLOT_HEADGEAR = 1;
  500. public static SLOT_FACE = 2;
  501. public static SLOT_EARS = 3;
  502. public static SLOT_EYES = 4;
  503. public static SLOT_NOSE = 5;
  504. public static SLOT_MOUTH = 6;
  505. public static SLOT_NECK = 7;
  506. public static SLOT_SHOULDERS = 8;
  507. public static SLOT_ARMS = 9;
  508. public static SLOT_HANDS = 10;
  509. public static SLOT_FINGERS = 11;
  510. public static SLOT_FINGERNAILS = 12;
  511. public static SLOT_UPPER_CHEST = 13;
  512. public static SLOT_MIDRIFF = 14;
  513. public static SLOT_WAIST = 15;
  514. public static SLOT_BACK = 16;
  515. public static SLOT_HIPS = 17;
  516. public static SLOT_CROTCH_FRONT = 18;
  517. public static SLOT_CROTCH_BACK = 19;
  518. public static SLOT_BUTT = 20;
  519. public static SLOT_LEG_UPPER = 21;
  520. public static SLOT_LEG_LOWER = 22;
  521. public static SLOT_FEET = 23;
  522. public static SLOT_FEET_NAILS = 24;
  523. public static SLOT_BREASTS = 25;
  524. public static SLOT_LEFTHAND = 26;
  525. public static SLOT_RIGHTHAND = 27;
  526. public static SLOT_SLOT_COUNT = 28;
  527. public static cacheInvalidationActionRule = new Rule({
  528. name : "Invalidate humanoid caches",
  529. firstPriority : Rule.PRIORITY_LOWEST,
  530. code : (runner : RulebookRunner<Action>) => {
  531. (<Humanoid> runner.noun.actor).invalidateCaches();
  532. },
  533. conditions : (runner : RulebookRunner<Action>) => {
  534. return runner.noun.actor instanceof Humanoid;
  535. }
  536. });
  537. public static getPlayerDescription () : Say {
  538. let say = new Say();
  539. say.add("You are ");
  540. let player = <Humanoid> WorldState.player;
  541. let male = player.getParts(HumanoidPenis).length > 0;
  542. let female = player.getParts(HumanoidVagina).length > 0;
  543. if (male && female) {
  544. say.add( "hermaphrodite");
  545. } else if (male) {
  546. say.add("male");
  547. } else {
  548. say.add("female");
  549. }
  550. say.add(". You are presenting as ", new SayAn(), player.getShortestDescription() + ". ");
  551. say.add(Attributes.GenderIdentity.getDescription(player.getStat(Attributes.GenderIdentity)));
  552. //let gv = player.getGenderValue();
  553. let sv = player.getSluttiness();
  554. let bulges = player.getBulges();
  555. let coveredPerc = 1 - (player.uncoveredSlots.length / Humanoid.SLOT_SLOT_COUNT);
  556. say.add(" ", (<HumanoidSkin> player.getPart(HumanoidSkin)).getDescription());
  557. if (sv.halfNaked) {
  558. say.add(" You are almost naked. ");
  559. } else if (sv.naked) {
  560. say.add(" You are naked. ");
  561. } else if (coveredPerc < 0.2) {
  562. say.add("You are not showing much of it, though.");
  563. }
  564. say.add(Attributes.Degeneration.getDescription(player.getStat(Attributes.Degeneration)));
  565. say.add(Say.PARAGRAPH_BREAK);
  566. say.add((<HumanoidArms> player.getPart(HumanoidArms)).getDescription(), " ");
  567. say.add((<HumanoidHands> player.getPart(HumanoidHands)).getDescription(), " ");
  568. say.add((<HumanoidFeet> player.getPart(HumanoidFeet)).getDescription(), " ");
  569. let penis = <HumanoidPenis> player.getPart(HumanoidPenis);
  570. let vagina = <HumanoidVagina> player.getPart(HumanoidVagina);
  571. if (penis != undefined) {
  572. say.add("You have a ",
  573. penis.getSizeText(), (penis.isFlaccid() ? " flaccid " : " erect "),
  574. Say.COCK, " between your legs"
  575. );
  576. if (penis.isUncovered()) {
  577. let oneOf = new OneOf(OneOf.PURELY_AT_RANDOM, ...[
  578. ", it is not covered by any clothing",
  579. ", it is not covered by any clothes",
  580. ", it is uncovered",
  581. ", it is visible to all",
  582. ", it is hanging freely"
  583. ]);
  584. say.add(oneOf.getOne());
  585. }
  586. let testicles = <HumanoidTesticles> player.getPart(HumanoidTesticles);
  587. if (HumanoidPenis.getSizeText(bulges.crotch) != HumanoidPenis.getSizeText(penis.getBulgeSize() + testicles.getBulgeSize())) {
  588. say.add(", but it looks like it's actually ", HumanoidPenis.getSizeText(bulges.crotch), " due to your clothing")
  589. }
  590. say.add(". ");
  591. if (testicles != undefined) {
  592. // TODO: Describe testicles. Are we making these variable?
  593. }
  594. } else {
  595. say.add(vagina.getDescription());
  596. }
  597. //say.add(Say.PARAGRAPH_BREAK);
  598. say.add( " ");
  599. let breasts = <HumanoidBreasts> player.getPart(HumanoidBreasts);
  600. let butt = <HumanoidButt> player.getPart(HumanoidButt);
  601. say.add("You have ", breasts.getSizeText(), " breasts and a ", butt.getSizeText(), " butt.");
  602. if (bulges.breasts != breasts.getSize() && bulges.butt != butt.getSize()) {
  603. say.add(" Your clothing makes your breasts look like they're actually ", HumanoidBreasts.getSizeText(bulges.breasts),
  604. " and make your butt appear ", HumanoidButt.getSizeText(bulges.butt), ".");
  605. } else if (bulges.breasts != breasts.getSize()) {
  606. say.add(" Your clothing makes your breasts look like they're actually ", HumanoidBreasts.getSizeText(bulges.breasts), ".");
  607. } else if (bulges.butt != butt.getSize()) {
  608. say.add(" Your clothing makes your butt appear ", HumanoidButt.getSizeText(bulges.butt), ".");
  609. }
  610. say.add(Say.PARAGRAPH_BREAK);
  611. let clothingSluttiness = Clothing.getSluttinessValueOn(player);
  612. let bodypartSluttiness = Bodypart.getSluttinessValueOn(player);
  613. if (clothingSluttiness.weight > 0) {
  614. let clothingSluttinessFinal = clothingSluttiness.value / clothingSluttiness.weight;
  615. if (clothingSluttinessFinal > 75) {
  616. say.add("Your outfit can only be described as \"whore-ish\", it is far too nasty.")
  617. } else if (clothingSluttinessFinal > 60) {
  618. say.add("Your clothing are obviously making you look a bit naughty.")
  619. } else if (clothingSluttinessFinal < 30 && sv.sluttinessCorrected < 30) {
  620. say.add("Your clothing are definitely a bit prude.")
  621. } else if (clothingSluttinessFinal < 15 && sv.sluttinessCorrected < 30) {
  622. say.add("Your outfit is so prude that it could be worn by a saint.")
  623. }
  624. }
  625. say.add(" ");
  626. if (bodypartSluttiness.weight > 0) {
  627. let bodypartSluttinessFinal = bodypartSluttiness.value / bodypartSluttiness.weight;
  628. if (bodypartSluttinessFinal > 75) {
  629. say.add("The way your body is makes you look like you were made purely for sex");
  630. if (coveredPerc > 0.7) {
  631. say.add(", thankfully it's mostly covered")
  632. } else if (coveredPerc < 0.2) {
  633. say.add(", and you didn't even bother covering it up")
  634. }
  635. say.add(".");
  636. } else if (bodypartSluttinessFinal > 60) {
  637. say.add("Your body definitely has a lot of sex-appeal going on");
  638. if (coveredPerc > 0.7) {
  639. say.add(", although it's covered")
  640. } else if (coveredPerc < 0.2) {
  641. say.add(", proudly displayed for all to see")
  642. }
  643. say.add(".");
  644. } else if (bodypartSluttinessFinal < 30) {
  645. say.add("You have very little sex-appeal, maybe you are a kitchen table?");
  646. if (coveredPerc > 0.7) {
  647. say.add(" At least you covered it up.")
  648. } else if (coveredPerc < 0.2) {
  649. say.add(" Maybe you could cover it up a bit.")
  650. }
  651. }
  652. }
  653. say.add(Say.PARAGRAPH_BREAK);
  654. let stats = new SayLeftRight();
  655. stats.addLeft(new SayBold("Strength: "), Attributes.Strength.getDescription(player.getStat(Attributes.Strength)));
  656. stats.addLeft(Say.LINE_BREAK);
  657. stats.addLeft(new SayBold("Agility: "), Attributes.Agility.getDescription(player.getStat(Attributes.Agility)));
  658. stats.addLeft(Say.LINE_BREAK);
  659. stats.addLeft(new SayBold("Charm: "), Attributes.Charm.getDescription(player.getStat(Attributes.Charm)));
  660. stats.addLeft(Say.LINE_BREAK);
  661. stats.addLeft(new SayBold("Intelligence: "), Attributes.Intelligence.getDescription(player.getStat(Attributes.Intelligence)));
  662. Skill.getSkills().forEach((skill: Skill) => {
  663. if (player.getSkill(skill) > 0) {
  664. stats.addRight(new SayBold(skill.id + ": "), skill.getDescription(player.getSkill(skill)));
  665. }
  666. });
  667. say.add(stats);
  668. return say;
  669. }
  670. }
  671. ActionWear.carry.addRule(Humanoid.cacheInvalidationActionRule);
  672. ActionRemove.carry.addRule(Humanoid.cacheInvalidationActionRule);