Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //to make this work the stats attribute from Items.ItemCompareArray[spot].stats
- //must be changed to a nested object instead of an array.
- //the problem then is that every item will have a bunch of attributes defaulted to 0
- package otherlib.itemStuff {
- import flash.display.MovieClip;
- import flash.display.*;
- import flash.utils.getDefinitionByName;
- import flash.utils.Dictionary;
- import otherlib.loaders.*;
- import otherlib.core.*;
- import flash.events.*;
- import flash.utils.*;
- import flash.net.*;
- //so lets make some stuff for universally changing stats
- public class IChangeStat {
- //who anyone we care about most likely a direct pointer to a array
- //stat string changed to a stat object
- //is it an item or a normal base change
- public static function addPoints(who, stat, item:Boolean) {
- who.HP = who.HP + stat.HPchanger;
- if(who.HP > who.HPMax) {
- who.HP = who.HPMax;
- }
- if (who.HP < 0) {
- who.HP = 0;
- }
- who.SP = who.SP + stat.SPchanger;
- if(who.SP > who.SPMax) {
- who.SP = who.SPMax;
- }
- if (who.SP < 0) {
- who.SP = 0;
- }
- if(item == true) {
- who.LPItem = who.LPItem + stat.LPchanger;
- }
- else {
- who.LP = who.LP + stat.LPchanger;
- }
- who.LPTotal = who.LP + who.LPItem;
- if(who.LPTotal > who.LPMax) {
- who.LPTotal = who.LPMax;
- }
- if (who.LPTotal < 0) {
- who.LPTotal = 0;
- }
- if(item == true) {
- who.AttackItem = who.AttackItem + stat.ATKchanger;
- }
- else {
- who.Attack = who.Attack + stat.ATKchanger;
- }
- who.AttackTotal = who.Attack + who.AttackItem;
- if(who.AttackTotal > who.AttackMax) {
- who.AttackTotal = who.AttackMax;
- }
- if (who.AttackTotal < 0) {
- who.AttackTotal = 0;
- }
- if(item == true) {
- who.DefenseItem = who.DefenseItem + stat.DEFchanger;
- }
- else {
- who.Defense = who.Defense + stat.DEFchanger;
- }
- who.DefenseTotal = who.Defense + who.DefenseItem;
- if(who.DefenseTotal > who.DefenseMax) {
- who.DefenseTotal = who.DefenseMax;
- }
- if (who.DefenseTotal < 0) {
- who.DefenseTotal = 0;
- }
- if(item == true) {
- who.SpecialItem = who.SpecialItem + stat.SPEchanger;
- }
- else {
- who.Special = who.Special + stat.SPEchanger;
- }
- who.SpecialTotal = who.Special + who.SpecialItem;
- if(who.SpecialTotal > who.SpecialMax) {
- who.SpecialTotal = who.SpecialMax;
- }
- if (who.SpecialTotal < 0) {
- who.SpecialTotal = 0;
- }
- }
- //now you don't need to repeat over and over.
- public static function addPointsItem(who, item_object) {
- var spot = Items.findItemInCompare(item_object);
- addPoints(who, Items.ItemCompareArray[spot].stats, true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement