Establish creature repo
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / Creature.as
blob88a7a8e9af3fe56480fee06bad6759560337f9ae
1 package org.sevenchan.dongs
3 import org.sevenchan.AdventureController;
4 import flash.net.*;
5 import org.sevenchan.dongs.bodyparts.*;
6 import org.sevenchan.dongs.bodyparts.asshole.Abdomen;
7 import org.sevenchan.dongs.creature.*;
8 import org.sevenchan.dongs.enchantment.*;
9 import org.sevenchan.dongs.enchantment.events.*;
10 import org.sevenchan.dongs.screens.*;
11 /**
12 * It's alive!
13 * @author N3X15
15 public class Creature
17 registerClassAlias("ECreature", Creature);
19 public static var BodyPartRegistry:Object = {
20 assholes: {
21 human:new Asshole("human"),
22 demon:new Asshole("demon"),
23 arachnid:new Abdomen("Arachnid")
25 arms: {
26 human: new Arm("human", null, null)
28 balls: {
29 arachnid: new Testicle("internal testes", 3785, null, null, "hot, thick mixture of semen and eggs"),
30 demon: new Testicle("demon nut",38,new Corruption(10),null,"boiling-hot, sticky black substance"),
31 human: new Testicle("human testicle", 17, null, null, "hot, stringy, off-white seed")
33 breasts: {
34 demon: new Breast("demon"),
35 human: new Breast("human")
37 dicks: {
38 arachnid: new Penis("Arachnid"),
39 demon: new Penis("demon",10,new Corruption(1),null),
40 human: new Penis("human", 5, null, null)
42 eyes: {
43 human_blue: new Eye("human", "blue", "round"),
44 human_brown: new Eye("human", "brown", "round"),
45 human_green: new Eye("human", "green", "round"),
46 human_red: new Eye("human", "red", "round"),
47 arachnid_big: new Eye("human-ish Arachnid", "red", "round"),
48 arachnid_small: new Eye("small Arachnid", "black", "segment"),
49 harpy_light: new Eye("harpy", "amber", "slit"),
50 harpy_dark: new Eye("darkharpy", "red", "slit"),
51 demon: new Eye("demon", "amber", "slit")
53 legs: {
54 arachnid: new Leg("Arachnid"),
55 harpy: new Leg("long, birdlike harpy"),
56 human: new Leg("human")
58 vaginas: {
59 arachnid: new Vagina("Arachnid"),
60 demon: new Vagina("demon"),
61 human: new Vagina("human")
63 wings: {
64 harpy: new Wing("harpy", false, "brown and white", 10),
65 harpy_dark: new Wing("darkharpy", false, "black and violet", 10)
69 public static var CreatureRegistry:Object = {
70 arachnid: new Arachnid(false),
71 arachnid_pregnant: new Arachnid(true),
72 harpy: new Harpy(false),
73 harpy_dark: new Harpy(true),
74 human: new Human(),
75 morel: new Morel(),
76 oldspace: new SandNigger()
79 // Characteristics
80 public var customized:Boolean = false;
81 public var ownName:String = "Blah Blah"; // Who am I?
82 public var height:Number = 0.0; // How tall am I?
83 public var build:Build = Build.AVG; // How fat am I?
84 public var material:Material = Material.NO_MATERIAL_MODIFIER; // What am I made of?
85 public var hair:Hair = Hair.BALD; // His/her/hir hair is...
86 public var skin:Skin = new Skin("human"); // His/her/hir hair is...
87 public var _gender:Gender = Gender.ASEXUAL; // Boy, Girl, Neither, Both?
88 public var sexualPreference:SexualPreference = SexualPreference.ASEXUAL; // Straight, Gay, ASexual, Bi?
90 // Stats (CACHED VALUES)
91 public var _level:int = 0; // In comparison to standard human being. No attacking rats for 20 levels.
92 private var d_level:int = 0; // Delta
93 public var _strength:int = 1; // Damage caused in case of a successful attack.
94 public var _speed:int = 1; // Chance of dodging. defending.speed-attacking.speed = relative chance of dodging.
95 public var _intellect:int = 1; // Smartness. Opens dialog trees and gives hints.
96 public var _lust:int = 1; // Slowly increases over time, eliminated by masturbation or smecks. Some battles are nonsexual and will not affect lust, others will slightly increase it based on ((number of balls x ball hormone output)+(number of vaginas * vagina hormone output)* sensitivity).
97 public var _sensitivity:Number = 0; // 0-1, 0 being not sensitive
98 public var _HP:int = 100; //100*(level*0.02)
99 public var _XP:int = 0; // 50*(level*0.5)
100 public var _mana:int = 0; // Magic shit, increases over time, especially near relaxing places.
101 public var _gold:int = 0; // Currency
103 // Collections
104 public var _abilities:Object = new Object(); // What magic/techniques can I use?
105 public var _assholes:Array = new Array(); // How many, and what type of assholes do I possess?
106 public var _arms:Array = new Array(); // Needed to attack. Tentacles are ok.
107 public var _balls:Array = new Array(); // Testes (Cum and pregnancy options)
108 public var _breasts:Array = new Array(); // Boobs (fuckable)
109 public var _dicks:Array = new Array(); // Penises (Pleasure options, testes required for preggo/cum stuff)
110 public var enchantments:Object = new Object(); // What kinds of effects am I suffering/benefiting from?
111 public var _eyes:Array = new Array(); // How many/what kinds of eyes do I have?
112 public var inventory:Array = new Array(); // What stuff am I carrying?
113 public var _legs:Array = new Array(); // Legs or locomotive tentacles or some other propulsion. (NONE = CAN'T MOVE OR DODGE)
114 public var _vaginas:Array = new Array(); // Places to put babies if the "father" has a penis and doesn't know the FALCON PUNCH. Anal pregnancy is okay but only with dicks with that flag.
115 public var _wings:Array = new Array(); // For flight.
116 public var explored:Array = new Array();
118 private var main:AdventureController = null;
119 public function Creature()
121 trace("Creature.init()");
122 _gold = MathUtils.rand(0, 50);
123 genName();
126 public function addEnchantment(ench:Enchantment):String {
127 var story:String = ench.onInit(this);
128 if(!ench.cancelAddition)
129 this.enchantments[ench.getID()] = ench;
130 return story;
133 public function initialGenderSetup():void { }
135 public function yourMove(cs:CombatScreen, ply:Creature):void {
136 if (notifyEnchantments(new CombatTurnEvent(ply))) {
137 InfoScreen.push("<p>The " + getTypeName() + " cannot attack!</p>");
138 return;
140 if (MathUtils.lengthOf(abilities) > 0 && MathUtils.rand(0,1) == 0) {
141 var ab:Ability = Ability(MathUtils.getRandomObjectEntry(abilities));
142 if(ab.activate(this, ply))
143 return;
145 cs.tryAttack(this, ply);
146 return;
148 public function addDick(type:String="human"):void {
151 public function addLust(amt:Number=1):void {
152 lust += (amt * getLustMult());
155 private function getLustMult():Number {
156 var numballs:Number = balls.length;
157 var loadMultSum:Number = 0;
158 for (var i:int = 0; i < balls.length; i++) {
159 loadMultSum += (balls[i] as Testicle).loadMult;
161 return (numballs * (loadMultSum / numballs))*0.5;
164 public function addToInventory(item:Item):void {
165 for (var i:int = 0; i < inventory.length; i++) {
166 if ((inventory[i] as Item).id == item.id) {
167 (inventory[i] as Item).amount += item.amount;
168 return;
171 if(inventory.length<11) {
172 inventory.push(item);
173 } else {
174 if (main != null)
175 main.showInventory(item);
179 public function combatDescr(subj:Creature):String {
180 if (getInterested(subj)) {
181 this.lust = 100;
183 var o:String = "<p>" + Utils.A(getTypeName(),true) + " "+getTypeName()+" leaps from the bushes and attacks!</p><p>Your attacker is ";
184 o += getDescription();
186 return o;
189 public function onEncounter(ply:Creature):Boolean { return false; }
191 public function onWin(ply:Creature):Boolean { return false; }
192 public function onLose(ply:Creature):Boolean { return false; }
194 protected function genName():void {
195 var firstNames:Array = [
196 "Andrew",
197 "Alex",
198 "Boris",
199 "Charles",
200 "Alexei",
201 "Drew",
202 "Scruffy",
203 "Gonnadi",
204 "Adolf",
205 "Albert",
206 "Bruno",
207 "Frederick",
208 "Ray"
211 var lastNames:Array = [
212 "Lenin",
213 "Hitler",
214 "Jenkins",
215 "Balboa",
216 "Nelson",
217 "O'Reilly",
218 "McDonald",
219 "Charles",
220 "Rubin",
221 "Schwarzeneggar"
223 ownName = MathUtils.getRandomEntry(firstNames) + " " + MathUtils.getRandomEntry(lastNames);
224 //trace(ownName);
228 * What am I?
229 * @return String Whatever it's called
231 public function getTypeName():String {
232 return "NOT FUCKING NAMED YET";
235 public function getDescription():String {
236 var descr:String = "";
237 // a gay human male of average height and build. He also possesses a long, flowing mane of golden hair,
238 // which contrasts nicely with your blue eyes and light skin.
240 // In the equipment department, you're not too odd. You have two human testicles swinging between your legs, paired with
241 // a single, 5.5" human schlong. Your breasts are flat, but well-sculpted human pecs, and you have a standard-issue male
242 // ass with a standard-issue virgin male asshole between its buns. You've got two human arms, two human legs.
244 // In other words, you're an average human, which probably won't last long down here.
246 descr = Utils.A(sexualPreference.label)+" "+sexualPreference.label+ " " + gender.label + " " + getTypeName() + ", who " + build.getDescription()
247 +" %CSUB% also possesses " + hair.getDescription();
249 if (hair == Hair.BALD)
250 descr += ", %POS% glistening scalp distracting from %POS% ";
251 else
252 descr += ", which constrasts nicely with %POS% ";
253 if(eyes.length == 0)
254 descr += " complete lack of eyes (<b>and resulting blindness</b>)";
255 else
256 descr += getEyesDescr();
258 descr += " and " + skin.getDescr(0, this);
259 descr += "</p>";
261 descr += "<p>In the equipment department, ";
262 var haveBalls:Boolean = (balls.length > 0);
263 var haveDicks:Boolean = (dicks.length > 0);
264 var haveVags:Boolean = (vaginas.length > 0);
265 if (haveBalls && haveDicks)
266 descr += "%SUB% has " + getTesticleDescr() + " swinging between %POS% legs, paired with " + getDickDescr() + ".";
267 if (!haveBalls && haveDicks)
268 descr += "no testicles rub between %POS% thighs when %SUB% walks, but %SUB% does have " + getDickDescr() + ".";
269 if (haveBalls && !haveDicks)
270 descr += "%SUB% doesn't have a dick, but %SUB% does have " + getTesticleDescr() + ". %SUB% seems to get more horny as time passes.";
272 if (haveVags)
273 descr += " %CPOS% body possesses " + getVagDescr() + ".";
275 if (!haveBalls && !haveDicks && !haveVags)
276 descr += " %CSUB% doesn't have any sexual organs. At least you won't get raped.";
279 if (breasts.length > 0)
280 descr += " %CSUB% has " + getBreastDescr() + ", and wears ";
281 else
282 descr += " %CSUB% doesn't have any breasts, but does have ";
283 descr += getAssDescr() + ".";
285 if (arms.length > 0)
286 descr += " %CSUB% has "+getArmsDescr()+", ";
287 else
288 descr += " %CSUB% doesn't have any arms (<b>and therefore can't attack</b>), ";
290 if (legs.length > 0) {
291 if (arms.length == 0)
292 descr += "but %SUB% DOES have ";
293 else
294 descr += "and ";
295 descr += getLegsDescr()+".";
296 } else
297 descr += "and no legs (<b>so %SUB% can't dodge attacks</b>).";
299 if (wings.length > 0) {
300 descr += " %CSUB% also has " + getWingsDescr() + ".";
302 descr += "</p>";
304 return gender.doReplace(descr);
307 public function hasEnchantment(name:String):Boolean {
308 return Utils.objHas(enchantments,name);
311 public function levelUp(firstOne:Boolean = false):void {
312 _level++;
313 if(!firstOne)
314 InfoScreen.push("<h2>Levelled up!</h2><p>You are now level " + level + "!</p>");
315 recalcStrength();
316 //recalcSpeed();
319 public function onCombatInit():void {
320 HP = this.maxHP;
323 public function get maxHP():int {
324 return 100 + ((level-1) * 5);
327 public function get maxXP():int {
328 trace("_level", _level);
329 trace("_strength", _strength);
330 return Math.max(1,50*(_level * 0.5));
333 public function getExplored(loc:String):Boolean {
334 for (var i:int = 0; i < explored.length; i++) {
335 if (explored[i] == loc)
336 return true;
338 return false;
341 public function setExplored(loc:String):void {
342 if (getExplored(loc)) return;
343 explored.push(loc);
346 public function recalcStrength():void {
347 //trace("height:", height);
348 var weight:Number = build.calculateWeight(height, 0.5)
349 //trace("weight:",weight);
350 var A:Number = Math.ceil((Math.pow(level, 2) * 0.01) - (Math.abs(17.5 - (weight * 0.1))) + 8);
351 if (level <= 1)
352 _strength = A;
353 var B:Number = Math.ceil((Math.pow(level-1,2) * 0.01) - (Math.abs(17.5 - (weight * 0.1))) + 8);
354 _strength = _strength + (A - B);
357 public function get strength():int { return _strength; }
358 public function set strength(str:int):void {
359 _strength = str;
360 doStatsUpdate();
363 public function get speed():int { return _speed; }
364 public function set speed(spd:int):void {
365 _speed = spd;
366 doStatsUpdate();
369 public function get lust():int { return _lust; }
370 public function set lust(lst:int):void
372 _lust = lst;
373 if (_lust > 100)
374 _lust = 100;
375 doStatsUpdate();
377 public function get gold():int { return _gold; }
378 public function set gold(value:int):void
380 if (value < 0)
381 value = 0;
382 _gold = value;
383 doStatsUpdate();
385 public function get intellect():int { return _intellect; }
386 public function set intellect(i:int):void
388 _intellect = i;
389 doStatsUpdate();
391 public function get mana():int { return _mana; }
392 public function set mana(i:int):void
394 _mana = i;
395 doStatsUpdate();
397 public function get sensitivity():int { return _sensitivity; }
398 public function set sensitivity(i:int):void
400 _sensitivity = i;
401 doStatsUpdate();
404 public function get assholes():Array { return this._assholes; }
405 public function set assholes(balls:Array):void { this._assholes=balls;
406 customized = true; }
410 public function get breasts():Array { return this._breasts; }
411 public function set breasts(balls:Array):void { this._breasts=balls;
412 customized = true; }
414 public function get eyes():Array { return this._eyes; }
415 public function set eyes(balls:Array):void { this._eyes=balls;
416 customized = true; }
418 public function get vaginas():Array { return this._vaginas; }
419 public function set vaginas(balls:Array):void { this._vaginas=balls;
420 customized = true; }
422 public function get arms():Array { return _arms; }
423 public function set arms(arr:Array):void {
424 _arms = arr;
425 customized = true;
428 public function get legs():Array { return _legs; }
429 public function set legs(arr:Array):void { _legs = arr;
430 customized = true; }
432 public function get wings():Array { return _wings; }
433 public function set wings(arr:Array):void { _wings = arr;
434 customized = true; }
436 public function get balls():Array { return _balls; }
437 public function set balls(balls:Array):void { _balls=balls;
438 customized = true; }
440 public function get dicks():Array { return _dicks; }
441 public function set dicks(balls:Array):void { _dicks=balls;
442 customized = true; }
444 public function get abilities():Object { return _abilities; }
445 public function set abilities(arr:Object):void{ _abilities=arr; }
447 public function get gender():Gender { return _gender; }
448 public function set gender(value:Gender):void { _gender=value;
449 customized = true; }
451 public function get HP():int { return _HP; }
452 public function set HP(value:int):void {
453 _HP=value;
454 doStatsUpdate();
456 public function get XP():int { return _XP; }
457 public function set XP(value:int):void {
458 //trace("XP", value);
459 _XP = value;
460 if (_XP >= maxXP) {
461 _XP = 0;
462 levelUp();
464 doStatsUpdate();
468 public function setMain(main:AdventureController):void {
469 this.main = main;
472 private function doStatsUpdate():void {
473 if (main != null) {
474 main.refreshStats();
478 public function get level():int {
479 return _level;
482 private function getBodyPartDesc(collection:Array, singular:String):String {
484 if (collection.length== 0) {
485 return "no "+singular+"s";
487 var out:String = "";
488 var varying:Boolean = false;
489 var types:Object = new Object();
490 var lname:String = "";
491 var numtypes:Number = 0;
492 for each (var i:* in collection) {
493 var t:IBodyPart = i as IBodyPart;
494 if (t == null)
495 continue;
496 //trace(t);
497 lname = t.name;
498 if(!(lname in types)) {
499 types[lname] = 0;
500 numtypes++;
502 types[lname]++;
504 for (var k:String in types) {
505 trace(k + " = " + types[k]);
507 if(numtypes==1) {
508 for each (t in collection) {
509 if (t.name == lname)
510 return t.getDescr(types[lname], this);
512 } else {
513 var n:Number = 0;
514 for (var ot:* in types) {
515 var gotdescr:Boolean = false;
516 for each (t in collection) {
517 if (t.name == ot) {
518 if(!gotdescr) {
519 out += ", " + t.getDescr(types[ot] as Number, this);
520 gotdescr = true;
522 n += types[ot];
526 return collection.length + " "+singular+"s of varying types ("+out.substr(2)+")";
528 return "";
531 public function notifyEnchantments(e:*):Boolean {
532 var collection:Array = [];
533 for (var eID:String in enchantments) {
534 var ench:Enchantment = enchantments[eID];
535 if (e is CombatStartEvent) {
536 ench.onCombatInit(e.other);
538 if (e is CombatEndEvent) {
539 ench.onCombatComplete(e.won, e.other);
541 if (e is CombatTurnEvent) {
542 return ench.onMyCombatTurn(e.other);
545 return false;
548 public function getTesticleDescr():String {
549 return getBodyPartDesc(balls,"ball");
552 public function getDickDescr():String {
553 return getBodyPartDesc(dicks,"dick");
556 public function getVagDescr():String {
557 return getBodyPartDesc(vaginas,"vag");
560 public function getBreastDescr():String {
561 return getBodyPartDesc(breasts, "boob");
564 public function getAssDescr():String {
565 return getBodyPartDesc(assholes,"asshole");
568 public function getArmsDescr():String {
569 return getBodyPartDesc(arms, "arm");
572 public function getEyesDescr():String {
573 return getBodyPartDesc(eyes, "eye");
576 public function getLegsDescr():String {
577 return getBodyPartDesc(legs, "leg");
580 public function getWingsDescr():String {
581 return getBodyPartDesc(wings, "wing");
585 * Wants your body
587 * I = Interested
588 * H = Hostile
589 * +---------------+---+---+
590 * | Type | I | H |
591 * +---------------+---+---+
592 * | Rape | T | T |
593 * | Fight | F | T |
594 * | Horny | T | F |
595 * | - | F | F |
596 * +---------------+---+---+
598 public function getInterested(subj:Creature):Boolean {
599 return sexualPreference.isOppositeGender(gender, subj.gender);
602 public function getHostile(subj:Creature):Boolean {
603 return false;
606 public function performConversion(oldMe:Creature):void {
610 public function changeFrom(f:Creature):void {
611 this._speed = f._speed;
612 this._strength = f._strength;
613 this.abilities = f.abilities;
614 this.enchantments = f.enchantments;
615 this.explored = f.explored;
616 this.gender = f.gender;
617 this.gold = f.gold;
618 this.height = f.height;
619 this.HP = f.maxHP;
620 this.ownName = f.ownName;
621 this.sensitivity = f.sensitivity;
622 this.sexualPreference = f.sexualPreference;
623 this.inventory = f.inventory;
625 this.performConversion(f);