Wind Guardian shit
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / Creature.as
blobed031d7a88ec29cc99de302742181a558720feeb
1 package org.sevenchan.dongs
3 import flash.media.ID3Info;
4 import org.sevenchan.AdventureController;
5 import flash.net.*;
6 import org.sevenchan.dongs.bodyparts.*;
7 import org.sevenchan.dongs.bodyparts.asshole.Abdomen;
8 import org.sevenchan.dongs.bodyparts.eye.GhostEye;
9 import org.sevenchan.dongs.creature.*;
10 import org.sevenchan.dongs.enchantment.*;
11 import org.sevenchan.dongs.enchantment.events.*;
12 import org.sevenchan.dongs.screens.*;
13 /**
14 * It's alive!
15 * @author N3X15
17 public class Creature
19 registerClassAlias("ECreature", Creature);
21 public static var CreatureRegistry:Object = null;
23 public static var BodyPartRegistry:Object = {
24 assholes: {
25 human:new Asshole("human"),
26 demon:new Asshole("demon"),
27 arachnid:new Abdomen("Arachnid")
29 arms: {
30 human: new Arm("human", null, null)
32 balls: {
33 arachnid: new Testicle("internal testes", 3785, null, null, "hot, thick mixture of semen and eggs"),
34 demon: new Testicle("demon nut",38,new Corruption(10),null,"boiling-hot, sticky black substance"),
35 human: new Testicle("human testicle", 17, null, null, "hot, stringy, off-white seed")
37 breasts: {
38 demon: new Breast("demon"),
39 human: new Breast("human")
41 dicks: {
42 arachnid: new Penis("Arachnid"),
43 demon: new Penis("demon",10,new Corruption(1),null),
44 human: new Penis("human", 5, null, null)
46 eyes: {
47 ghost_yellow: new GhostEye("ghost", "yellow"),
48 human_blue: new Eye("human", "blue", "round"),
49 human_brown: new Eye("human", "brown", "round"),
50 human_green: new Eye("human", "green", "round"),
51 human_red: new Eye("human", "red", "round"),
52 arachnid_big: new Eye("human-ish Arachnid", "red", "round"),
53 arachnid_small: new Eye("small Arachnid", "black", "segment"),
54 harpy_light: new Eye("harpy", "amber", "slit"),
55 harpy_dark: new Eye("darkharpy", "red", "slit"),
56 demon: new Eye("demon", "amber", "slit")
58 legs: {
59 arachnid: new Leg("Arachnid"),
60 harpy: new Leg("long, birdlike harpy"),
61 human: new Leg("human")
63 vaginas: {
64 arachnid: new Vagina("Arachnid"),
65 demon: new Vagina("demon"),
66 human: new Vagina("human")
68 wings: {
69 harpy: new Wing("harpy", false, "brown and white", 10),
70 harpy_dark: new Wing("darkharpy", false, "black and violet", 10)
74 // Characteristics
75 public var customized:Boolean = false;
76 public var ownName:String = "Blah Blah"; // Who am I?
77 public var height:Number = 0.0; // How tall am I?
78 public var build:Build = Build.AVG; // How fat am I?
79 public var material:Material = Material.NO_MATERIAL_MODIFIER; // What am I made of?
80 public var hair:Hair = Hair.BALD; // His/her/hir hair is...
81 public var skin:Skin = new Skin("human"); // His/her/hir hair is...
82 public var _gender:Gender = Gender.ASEXUAL; // Boy, Girl, Neither, Both?
83 public var sexualPreference:SexualPreference = SexualPreference.ASEXUAL; // Straight, Gay, ASexual, Bi?
85 // Stats (CACHED VALUES)
86 public var _level:int = 0; // In comparison to standard human being. No attacking rats for 20 levels.
87 private var d_level:int = 0; // Delta
88 public var _strength:int = 1; // Damage caused in case of a successful attack.
89 public var _speed:int = 1; // Chance of dodging. defending.speed-attacking.speed = relative chance of dodging.
90 public var _intellect:int = 1; // Smartness. Opens dialog trees and gives hints.
91 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).
92 public var _sensitivity:Number = 0; // 0-1, 0 being not sensitive
93 public var _HP:int = 100; //100*(level*0.02)
94 public var _XP:int = 0; // 50*(level*0.5)
95 public var _mana:int = 0; // Magic shit, increases over time, especially near relaxing places.
96 public var _gold:int = 0; // Currency
98 // Collections
99 // What magic/techniques can I use?
100 public var _abilities:Object = new Object();
101 // How many, and what type of assholes do I possess?
102 public var _assholes:Vector.<Asshole> = new Vector.<Asshole>();
103 // Needed to attack. Tentacles are ok.
104 public var _arms:Vector.<Arm> = new Vector.<Arm>();
105 // Testes (Cum and pregnancy options)
106 public var _balls:Vector.<Testicle> = new Vector.<Testicle>();
107 // Boobs (fuckable)
108 public var _breasts:Vector.<Breast> = new Vector.<Breast>();
109 // Penises (Pleasure options, testes required for preggo/cum stuff)
110 public var _dicks:Vector.<Penis> = new Vector.<Penis>();
111 // What kinds of effects am I suffering/benefiting from?
112 public var enchantments:Object = new Object();
113 // How many/what kinds of eyes do I have?
114 public var _eyes:Vector.<Eye> = new Vector.<Eye>();
115 // What stuff am I carrying?
116 public var inventory:Vector.<Item> = new Vector.<Item>();
117 // Legs or locomotive tentacles or some other propulsion. (NONE = CAN'T MOVE OR DODGE)
118 public var _legs:Vector.<Leg> = new Vector.<Leg>();
119 // 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.
120 public var _vaginas:Vector.<Vagina> = new Vector.<Vagina>();
121 // For flight.
122 public var _wings:Vector.<Wing> = new Vector.<Wing>();
123 // Explored locations
124 public var explored:Vector.<String> = new Vector.<String>();
126 private var main:AdventureController = null;
127 protected var abilityUseProbability:Number = 1;
128 protected var turnsToLose:int = 0;
130 public static function init_creatures():void {
131 CreatureRegistry = {
132 ala: new Ala(),
133 arachnid: new Arachnid(false),
134 arachnid_pregnant: new Arachnid(true),
135 harpy: new Harpy(false),
136 harpy_dark: new Harpy(true),
137 human: new Human(),
138 morel: new Morel(),
139 oldspace: new SandNigger()
142 public function Creature()
144 trace("Creature.init()");
145 _gold = MathUtils.rand(0, 50);
146 _mana = maxMana;
149 public function addBoob():void { trace("USING CREATURE.ADDBOOB INSTEAD OF OVERRIDING"); }
151 public function addEnchantment(ench:Enchantment):String {
152 var story:String = ench.onInit(this);
153 if(!ench.cancelAddition)
154 this.enchantments[ench.getID()] = ench;
155 return story;
158 public function initialGenderSetup():void { }
160 public function yourMove(cs:CombatScreen, ply:Creature):void {
161 if ((turnsToLose>0)||notifyEnchantments(new CombatTurnEvent(ply))) {
162 InfoScreen.push("<p>The " + getTypeName() + " cannot attack!</p>");
163 return;
165 if (turnsToLose > 0) {
166 turnsToLose--;
168 if (MathUtils.lengthOf(abilities) > 0 && MathUtils.rand(0,abilityUseProbability) == 0) {
169 var ab:Ability = Ability(MathUtils.getRandomObjectEntry(abilities));
170 if (this.mana < ab.manaCost)
172 InfoScreen.push("<p>The " + getTypeName() + " tried to use " + ab.name + " but is too exhausted!</p>");
173 return;
175 if (ab.activate(this, ply)) {
176 this.mana -= ab.manaCost
177 return;
180 cs.tryAttack(this, ply);
181 return;
183 public function addDick(type:String="human"):void {
186 public function addLust(amt:Number=1):void {
187 var adding2Lust:Number = (amt * getLustMult());
188 trace("Adding to lust ", adding2Lust);
189 lust += Math.ceil(adding2Lust);
192 private function getLustMult():Number {
193 var numballs:Number = balls.length;
194 var loadMultSum:Number = 0;
195 for (var i:int = 0; i < balls.length; i++) {
196 loadMultSum += (balls[i] as Testicle).loadMult/10;
198 return (numballs * (loadMultSum/numballs));
201 public function takeFromInventory(item:Item):void {
202 for (var i:int = 0; i < inventory.length; i++) {
203 if ((inventory[i] as Item).id == item.id) {
204 (inventory[i] as Item).amount -= item.amount;
205 if ((inventory[i] as Item).amount <= 0)
206 inventory.splice(i, 1);
207 return;
212 public function addToInventory(item:Item):void {
213 for (var i:int = 0; i < inventory.length; i++) {
214 if ((inventory[i] as Item).id == item.id) {
215 (inventory[i] as Item).amount += item.amount;
216 return;
219 if(inventory.length<11) {
220 inventory.push(item);
221 } else {
222 if (main != null)
223 main.showInventory(item);
227 public function combatDescr(subj:Creature):String {
228 if (getInterested(subj)) {
229 this.lust = 100;
231 var o:String = "<p>" + Utils.A(getTypeName(),true) + " "+getTypeName()+" leaps from the bushes and attacks!</p><p>Your attacker is ";
232 o += getDescription();
234 return o;
237 public function onEncounter(ply:Creature):Boolean { return false; }
239 public function onWin(ply:Creature):Boolean { return false; }
240 public function onLose(ply:Creature):Boolean { return false; }
242 protected function genName():void {
243 var firstNames:Array = [
244 "Andrew",
245 "Alex",
246 "Boris",
247 "Charles",
248 "Alexei",
249 "Drew",
250 "Scruffy",
251 "Gonnadi",
252 "Adolf",
253 "Albert",
254 "Bruno",
255 "Frederick",
256 "Ray"
259 var lastNames:Array = [
260 "Lenin",
261 "Hitler",
262 "Jenkins",
263 "Balboa",
264 "Nelson",
265 "O'Reilly",
266 "McDonald",
267 "Charles",
268 "Rubin",
269 "Schwarzeneggar"
271 ownName = MathUtils.getRandomArrayEntry(firstNames) + " " + MathUtils.getRandomArrayEntry(lastNames);
272 //trace(ownName);
276 * What am I?
277 * @return String Whatever it's called
279 public function getTypeName():String {
280 throw new Error("SOME DUMBASS DIDN'T GIVE THIS CREATURE A NAME");
281 return "NOT FUCKING NAMED YET";
285 * Do I have the option to run?
286 * @return Button visibility
288 public function canRun():Boolean { return true; }
290 public function getDescription():String {
291 var descr:String = "";
292 // a gay human male of average height and build. He also possesses a long, flowing mane of golden hair,
293 // which contrasts nicely with your blue eyes and light skin.
295 // In the equipment department, you're not too odd. You have two human testicles swinging between your legs, paired with
296 // a single, 5.5" human schlong. Your breasts are flat, but well-sculpted human pecs, and you have a standard-issue male
297 // ass with a standard-issue virgin male asshole between its buns. You've got two human arms, two human legs.
299 // In other words, you're an average human, which probably won't last long down here.
301 descr = Utils.A(sexualPreference.label)+" "+sexualPreference.label+ " " + gender.label + " " + getTypeName() + ", who " + build.getDescription()
302 +" %CSUB% also possesses " + hair.getDescription();
304 if (hair == Hair.BALD)
305 descr += ", %POS% glistening scalp distracting from %POS% ";
306 else
307 descr += ", which constrasts nicely with %POS% ";
308 if(eyes.length == 0)
309 descr += " complete lack of eyes (<b>and resulting blindness</b>)";
310 else
311 descr += getEyesDescr();
313 descr += " and " + skin.getDescr(0, this);
314 descr += "</p>";
316 descr += "<p>In the equipment department, ";
317 var haveBalls:Boolean = (balls.length > 0);
318 var haveDicks:Boolean = (dicks.length > 0);
319 var haveVags:Boolean = (vaginas.length > 0);
320 if (haveBalls && haveDicks)
321 descr += "%SUB% has " + getTesticleDescr() + " swinging between %POS% legs, paired with " + getDickDescr() + ".";
322 if (!haveBalls && haveDicks)
323 descr += "no testicles rub between %POS% thighs when %SUB% walks, but %SUB% does have " + getDickDescr() + ".";
324 if (haveBalls && !haveDicks)
325 descr += "%SUB% doesn't have a dick, but %SUB% does have " + getTesticleDescr() + ". %SUB% seems to get more horny as time passes.";
327 if (haveVags)
328 descr += " %CPOS% body possesses " + getVagDescr() + ".";
330 if (!haveBalls && !haveDicks && !haveVags)
331 descr += " %CSUB% doesn't have any sexual organs. At least you won't get raped.";
334 if (breasts.length > 0)
335 descr += " %CSUB% has " + getBreastDescr() + ", and wears ";
336 else
337 descr += " %CSUB% doesn't have any breasts, but does have ";
338 descr += getAssDescr() + ".";
340 if (arms.length > 0)
341 descr += " %CSUB% has "+getArmsDescr()+", ";
342 else
343 descr += " %CSUB% doesn't have any arms (<b>and therefore can't attack</b>), ";
345 if (legs.length > 0) {
346 if (arms.length == 0)
347 descr += "but %SUB% DOES have ";
348 else
349 descr += "and ";
350 descr += getLegsDescr()+".";
351 } else
352 descr += "and no legs (<b>so %SUB% can't dodge attacks</b>).";
354 if (wings.length > 0) {
355 descr += " %CSUB% also has " + getWingsDescr() + ".";
357 descr += "</p>";
359 return gender.doReplace(descr);
362 public function hasEnchantment(name:String):Boolean {
363 return Utils.objHas(enchantments,name);
366 public function levelUp(firstOne:Boolean = false):void {
367 _level++;
368 if(!firstOne)
369 InfoScreen.push("<h2>Levelled up!</h2><p>You are now level " + level + "!</p>");
370 recalcStrength();
371 //recalcSpeed();
374 public function onCombatInit():void {
375 HP = this.maxHP;
378 public function get maxMana():int {
379 return 100 + ((level-1) * 10);
382 public function get maxHP():int {
383 return 100 + ((level-1) * 10);
386 public function get maxXP():int {
387 return Math.max(1,50*(_level * 0.5));
390 public function getExplored(loc:String):Boolean {
391 for (var i:int = 0; i < explored.length; i++) {
392 if (explored[i] == loc)
393 return true;
395 return false;
398 public function setExplored(loc:String):void {
399 if (getExplored(loc)) return;
400 explored.push(loc);
403 public function recalcStrength():void {
404 //trace("height:", height);
405 var weight:Number = build.calculateWeight(height, 0.5)
406 //trace("weight:",weight);
407 var A:Number = Math.ceil((Math.pow(level, 2) * 0.01) - (Math.abs(17.5 - (weight * 0.1))) + 8);
408 if (level <= 1)
409 _strength = A;
410 var B:Number = Math.ceil((Math.pow(level-1,2) * 0.01) - (Math.abs(17.5 - (weight * 0.1))) + 8);
411 _strength = _strength + (A - B);
414 public function get strength():int { return _strength; }
415 public function set strength(str:int):void {
416 _strength = str;
417 doStatsUpdate();
420 public function get speed():int { return _speed; }
421 public function set speed(spd:int):void {
422 _speed = spd;
423 doStatsUpdate();
426 public function get lust():int { return _lust; }
427 public function set lust(lst:int):void
429 _lust = lst;
430 if (_lust > 100)
431 _lust = 100;
432 doStatsUpdate();
434 public function get gold():int { return _gold; }
435 public function set gold(value:int):void
437 if (value < 0)
438 value = 0;
439 _gold = value;
440 doStatsUpdate();
442 public function get intellect():int { return _intellect; }
443 public function set intellect(i:int):void
445 _intellect = i;
446 doStatsUpdate();
448 public function get mana():int { return _mana; }
449 public function set mana(i:int):void
451 _mana = i;
452 doStatsUpdate();
454 public function get sensitivity():int { return _sensitivity; }
455 public function set sensitivity(i:int):void
457 _sensitivity = i;
458 doStatsUpdate();
461 public function get assholes():Vector.<Asshole> { return this._assholes; }
462 public function set assholes(balls:Vector.<Asshole>):void { this._assholes=balls;
463 customized = true; }
465 public function get breasts():Vector.<Breast> { return this._breasts; }
466 public function set breasts(balls:Vector.<Breast>):void { this._breasts=balls;
467 customized = true; }
469 public function get eyes():Vector.<Eye> { return this._eyes; }
470 public function set eyes(balls:Vector.<Eye>):void { this._eyes=balls;
471 customized = true; }
473 public function get vaginas():Vector.<Vagina> { return this._vaginas; }
474 public function set vaginas(balls:Vector.<Vagina>):void { this._vaginas=balls;
475 customized = true; }
477 public function get arms():Vector.<Arm> { return _arms; }
478 public function set arms(arr:Vector.<Arm>):void {
479 _arms = arr;
480 customized = true;
483 public function get legs():Vector.<Leg>{ return _legs; }
484 public function set legs(arr:Vector.<Leg>):void { _legs = arr;
485 customized = true; }
487 public function get wings():Vector.<Wing> { return _wings; }
488 public function set wings(arr:Vector.<Wing>):void { _wings = arr;
489 customized = true; }
491 public function get balls():Vector.<Testicle> { return _balls; }
492 public function set balls(balls:Vector.<Testicle>):void { _balls=balls;
493 customized = true; }
495 public function get dicks():Vector.<Penis> { return _dicks; }
496 public function set dicks(balls:Vector.<Penis>):void { _dicks=balls;
497 customized = true; }
499 public function get abilities():Object { return _abilities; }
500 public function set abilities(arr:Object):void{ _abilities=arr; }
502 public function get gender():Gender { return _gender; }
503 public function set gender(value:Gender):void { _gender=value;
504 customized = true; }
506 public function get HP():int { return _HP; }
507 public function set HP(value:int):void {
508 _HP=value;
509 doStatsUpdate();
511 public function get XP():int { return _XP; }
512 public function set XP(value:int):void {
513 //trace("XP", value);
514 _XP = value;
515 if (_XP >= maxXP) {
516 _XP = 0;
517 levelUp();
519 doStatsUpdate();
523 public function setMain(main:AdventureController):void {
524 this.main = main;
527 private function doStatsUpdate():void {
528 if (main != null) {
529 main.refreshStats();
533 public function get level():int {
534 return _level;
537 private function getBodyPartDesc(collection:Vector.<IBodyPart>, singular:String):String {
539 if (collection.length== 0) {
540 return "no "+singular+"s";
542 var out:String = "";
543 var varying:Boolean = false;
544 var types:Object = new Object();
545 var lname:String = "";
546 var numtypes:Number = 0;
547 for each (var i:* in collection) {
548 var t:IBodyPart = i as IBodyPart;
549 if (t == null)
550 continue;
551 //trace(t);
552 lname = t.name;
553 if(!(lname in types)) {
554 types[lname] = 0;
555 numtypes++;
557 types[lname]++;
559 for (var k:String in types) {
560 trace(k + " = " + types[k]);
562 if(numtypes==1) {
563 for each (t in collection) {
564 if (t.name == lname)
565 return t.getDescr(types[lname], this);
567 } else {
568 var n:Number = 0;
569 for (var ot:* in types) {
570 var gotdescr:Boolean = false;
571 for each (t in collection) {
572 if (t.name == ot) {
573 if(!gotdescr) {
574 out += ", " + t.getDescr(types[ot] as Number, this);
575 gotdescr = true;
577 n += types[ot];
581 return collection.length + " "+singular+"s of varying types ("+out.substr(2)+")";
583 return "";
586 public function notifyEnchantments(e:*):Boolean {
587 var collection:Array = [];
588 for (var eID:String in enchantments) {
589 var ench:Enchantment = enchantments[eID];
590 if (e is CombatStartEvent) {
591 ench.onCombatInit(e.other);
593 if (e is CombatEndEvent) {
594 ench.onCombatComplete(e.won, e.other);
596 if (e is CombatTurnEvent) {
597 return ench.onMyCombatTurn(e.other);
600 return false;
603 public function getTesticleDescr():String {
604 return getBodyPartDesc(Vector.<IBodyPart>(balls),"ball");
607 public function getDickDescr():String {
608 return getBodyPartDesc(Vector.<IBodyPart>(dicks),"dick");
611 public function getVagDescr():String {
612 return getBodyPartDesc(Vector.<IBodyPart>(vaginas),"vag");
615 public function getBreastDescr():String {
616 return getBodyPartDesc(Vector.<IBodyPart>(breasts), "boob");
619 public function getAssDescr():String {
620 return getBodyPartDesc(Vector.<IBodyPart>(assholes),"asshole");
623 public function getArmsDescr():String {
624 return getBodyPartDesc(Vector.<IBodyPart>(arms), "arm");
627 public function getEyesDescr():String {
628 return getBodyPartDesc(Vector.<IBodyPart>(eyes), "eye");
631 public function getLegsDescr():String {
632 return getBodyPartDesc(Vector.<IBodyPart>(legs), "leg");
635 public function getWingsDescr():String {
636 return getBodyPartDesc(Vector.<IBodyPart>(wings), "wing");
640 * Wants your body
642 * I = Interested
643 * H = Hostile
644 * +---------------+---+---+
645 * | Type | I | H |
646 * +---------------+---+---+
647 * | Rape | T | T |
648 * | Fight | F | T |
649 * | Horny | T | F |
650 * | - | F | F |
651 * +---------------+---+---+
653 public function getInterested(subj:Creature):Boolean {
654 return sexualPreference.isOppositeGender(gender, subj.gender);
657 public function getHostile(subj:Creature):Boolean {
658 return false;
661 public function performConversion(oldMe:Creature):void {
665 public function changeFrom(f:Creature):void {
666 this._speed = f._speed;
667 this._strength = f._strength;
668 this.abilities = f.abilities;
669 this.enchantments = f.enchantments;
670 this.explored = f.explored;
671 this.gender = f.gender;
672 this.gold = f.gold;
673 this.height = f.height;
674 this.HP = f.maxHP;
675 this.mana = f.maxMana;
676 this.ownName = f.ownName;
677 this.sensitivity = f.sensitivity;
678 this.sexualPreference = f.sexualPreference;
679 this.inventory = f.inventory;
681 this.performConversion(f);
684 public function loseTurns(numturns:int):void {
685 turnsToLose += numturns;