Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //to make this work the stats attribute from Items.ItemCompareArray[spot].stats
  2. //must be changed to a nested object instead of an array.
  3. //the problem then is that every item will have a bunch of attributes defaulted to 0
  4.  
  5. package otherlib.itemStuff {
  6.     import flash.display.MovieClip;
  7.     import flash.display.*;
  8.     import flash.utils.getDefinitionByName;
  9.     import flash.utils.Dictionary;
  10.     import otherlib.loaders.*;
  11.     import otherlib.core.*;
  12.     import flash.events.*;
  13.     import flash.utils.*;
  14.     import flash.net.*;
  15.     //so lets make some stuff for universally changing stats
  16.  
  17.     public class IChangeStat {
  18.        
  19.         //who anyone we care about most likely a direct pointer to a array
  20.         //stat string changed to a stat object
  21.         //is it an item or a normal base change
  22.         public static function addPoints(who, stat, item:Boolean) {
  23.             who.HP = who.HP + stat.HPchanger;
  24.             if(who.HP > who.HPMax) {
  25.                 who.HP = who.HPMax;
  26.             }
  27.             if (who.HP < 0) {
  28.                 who.HP = 0;
  29.             }
  30.             who.SP = who.SP + stat.SPchanger;
  31.             if(who.SP > who.SPMax) {
  32.                 who.SP = who.SPMax;
  33.             }
  34.             if (who.SP < 0) {
  35.                 who.SP = 0;
  36.             }
  37.             if(item == true) {
  38.                 who.LPItem = who.LPItem + stat.LPchanger;
  39.             }
  40.             else {
  41.                 who.LP = who.LP + stat.LPchanger;
  42.             }
  43.             who.LPTotal = who.LP + who.LPItem;
  44.             if(who.LPTotal > who.LPMax) {
  45.                 who.LPTotal = who.LPMax;
  46.             }
  47.             if (who.LPTotal < 0) {
  48.                 who.LPTotal = 0;
  49.             }
  50.             if(item == true) {
  51.                 who.AttackItem = who.AttackItem + stat.ATKchanger;
  52.             }
  53.             else {
  54.                 who.Attack = who.Attack + stat.ATKchanger;
  55.             }
  56.             who.AttackTotal = who.Attack + who.AttackItem;
  57.             if(who.AttackTotal > who.AttackMax) {
  58.                 who.AttackTotal = who.AttackMax;
  59.             }
  60.             if (who.AttackTotal < 0) {
  61.                 who.AttackTotal = 0;
  62.             }
  63.             if(item == true) {
  64.                 who.DefenseItem = who.DefenseItem + stat.DEFchanger;
  65.             }
  66.             else {
  67.                 who.Defense = who.Defense + stat.DEFchanger;
  68.             }
  69.             who.DefenseTotal = who.Defense + who.DefenseItem;
  70.             if(who.DefenseTotal > who.DefenseMax) {
  71.                 who.DefenseTotal = who.DefenseMax;
  72.             }
  73.             if (who.DefenseTotal < 0) {
  74.                 who.DefenseTotal = 0;
  75.             }
  76.             if(item == true) {
  77.                 who.SpecialItem = who.SpecialItem + stat.SPEchanger;
  78.             }
  79.             else {
  80.                 who.Special = who.Special + stat.SPEchanger;
  81.             }
  82.             who.SpecialTotal = who.Special + who.SpecialItem;
  83.             if(who.SpecialTotal > who.SpecialMax) {
  84.                 who.SpecialTotal = who.SpecialMax;
  85.             }
  86.             if (who.SpecialTotal < 0) {
  87.                 who.SpecialTotal = 0;
  88.             }
  89.            
  90.         }
  91.         //now you don't need to repeat over and over.
  92.         public static function addPointsItem(who, item_object) {
  93.             var spot = Items.findItemInCompare(item_object);
  94.             addPoints(who,  Items.ItemCompareArray[spot].stats, true);
  95.         }
  96.        
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement