Advertisement
Guest User

Untitled

a guest
Jun 13th, 2011
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package otherlib.itemStuff {
  2.     import flash.display.MovieClip;
  3.     import flash.display.*;
  4.     import flash.utils.getDefinitionByName;
  5.     import flash.utils.Dictionary;
  6.     import otherlib.loaders.*;
  7.     import otherlib.core.*;
  8.     import flash.events.*;
  9.     import flash.utils.*;
  10.     import flash.net.*;
  11.     //so lets make some stuff for universally changing stats
  12.  
  13.     public class IChangeStat {
  14.        
  15.         //who anyone we care about most likely a direct pointer to a array
  16.         //stat string that is being changed
  17.         //hot much its changed
  18.         //is it an item or a normal base change
  19.         public static function addPoints(who, stat:String, changer:int, item:Boolean) {
  20.             stat = stat.toLowerCase();
  21.             if(stat == "health" || stat == "hp") {
  22.                 who.HP = who.HP + changer;
  23.                 if(who.HP > who.HPMax) {
  24.                     who.HP = who.HPMax;
  25.                 }
  26.                 if (who.HP < 0) {
  27.                     who.HP = 0;
  28.                 }
  29.             }
  30.             else if(stat == "special" || stat == "sp") {
  31.                 who.SP = who.SP + changer;
  32.                 if(who.SP > who.SPMax) {
  33.                     who.SP = who.SPMax;
  34.                 }
  35.                 if (who.SP < 0) {
  36.                     who.SP = 0;
  37.                 }
  38.             }
  39.             else if (stat == "lp") {
  40.                 if(item == true) {
  41.                     who.LPItem = who.LPItem + changer;
  42.                 }
  43.                 else {
  44.                     who.LP = who.LP + changer;
  45.                 }
  46.                 who.LPTotal = who.LP + who.LPItem;
  47.                 if(who.LPTotal > who.LPMax) {
  48.                     who.LPTotal = who.LPMax;
  49.                 }
  50.                 if (who.LPTotal < 0) {
  51.                     who.LPTotal = 0;
  52.                 }
  53.             }
  54.             else if (stat == "attack") {
  55.                 if(item == true) {
  56.                     who.AttackItem = who.AttackItem + changer;
  57.                 }
  58.                 else {
  59.                     who.Attack = who.Attack + changer;
  60.                 }
  61.                 who.AttackTotal = who.Attack + who.AttackItem;
  62.                 if(who.AttackTotal > who.AttackMax) {
  63.                     who.AttackTotal = who.AttackMax;
  64.                 }
  65.                 if (who.AttackTotal < 0) {
  66.                     who.AttackTotal = 0;
  67.                 }
  68.             }
  69.             else if (stat == "defense") {
  70.                 if(item == true) {
  71.                     who.DefenseItem = who.DefenseItem + changer;
  72.                 }
  73.                 else {
  74.                     who.Defense = who.Defense + changer;
  75.                 }
  76.                 who.DefenseTotal = who.Defense + who.DefenseItem;
  77.                 if(who.DefenseTotal > who.DefenseMax) {
  78.                     who.DefenseTotal = who.DefenseMax;
  79.                 }
  80.                 if (who.DefenseTotal < 0) {
  81.                     who.DefenseTotal = 0;
  82.                 }
  83.             }
  84.             else if (stat == "special") {
  85.                 if(item == true) {
  86.                     who.SpecialItem = who.SpecialItem + changer;
  87.                 }
  88.                 else {
  89.                     who.Special = who.Special + changer;
  90.                 }
  91.                 who.SpecialTotal = who.Special + who.SpecialItem;
  92.                 if(who.SpecialTotal > who.SpecialMax) {
  93.                     who.SpecialTotal = who.SpecialMax;
  94.                 }
  95.                 if (who.SpecialTotal < 0) {
  96.                     who.SpecialTotal = 0;
  97.                 }
  98.             }
  99.            
  100.         }
  101.         //a function that basically calls the other part over and over for each
  102.         //stat change of an item
  103.         public static function addPointsItem(who, item_object) {
  104.             var spot = Items.findItemInCompare(item_object);
  105.             for(var i:int = 0; i < Items.ItemCompareArray[spot].stats.length; i++) {
  106.                 addPoints(who,  Items.ItemCompareArray[spot].stats[i].type, Items.ItemCompareArray[spot].stats[i].change, true);
  107.             }
  108.         }
  109.        
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement