Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 that is being changed
- //hot much its changed
- //is it an item or a normal base change
- public static function addPoints(who, stat:String, changer:int, item:Boolean) {
- stat = stat.toLowerCase();
- if(stat == "health" || stat == "hp") {
- who.HP = who.HP + changer;
- if(who.HP > who.HPMax) {
- who.HP = who.HPMax;
- }
- if (who.HP < 0) {
- who.HP = 0;
- }
- }
- else if(stat == "special" || stat == "sp") {
- who.SP = who.SP + changer;
- if(who.SP > who.SPMax) {
- who.SP = who.SPMax;
- }
- if (who.SP < 0) {
- who.SP = 0;
- }
- }
- else if (stat == "lp") {
- if(item == true) {
- who.LPItem = who.LPItem + changer;
- }
- else {
- who.LP = who.LP + changer;
- }
- who.LPTotal = who.LP + who.LPItem;
- if(who.LPTotal > who.LPMax) {
- who.LPTotal = who.LPMax;
- }
- if (who.LPTotal < 0) {
- who.LPTotal = 0;
- }
- }
- else if (stat == "attack") {
- if(item == true) {
- who.AttackItem = who.AttackItem + changer;
- }
- else {
- who.Attack = who.Attack + changer;
- }
- who.AttackTotal = who.Attack + who.AttackItem;
- if(who.AttackTotal > who.AttackMax) {
- who.AttackTotal = who.AttackMax;
- }
- if (who.AttackTotal < 0) {
- who.AttackTotal = 0;
- }
- }
- else if (stat == "defense") {
- if(item == true) {
- who.DefenseItem = who.DefenseItem + changer;
- }
- else {
- who.Defense = who.Defense + changer;
- }
- who.DefenseTotal = who.Defense + who.DefenseItem;
- if(who.DefenseTotal > who.DefenseMax) {
- who.DefenseTotal = who.DefenseMax;
- }
- if (who.DefenseTotal < 0) {
- who.DefenseTotal = 0;
- }
- }
- else if (stat == "special") {
- if(item == true) {
- who.SpecialItem = who.SpecialItem + changer;
- }
- else {
- who.Special = who.Special + changer;
- }
- who.SpecialTotal = who.Special + who.SpecialItem;
- if(who.SpecialTotal > who.SpecialMax) {
- who.SpecialTotal = who.SpecialMax;
- }
- if (who.SpecialTotal < 0) {
- who.SpecialTotal = 0;
- }
- }
- }
- //a function that basically calls the other part over and over for each
- //stat change of an item
- public static function addPointsItem(who, item_object) {
- var spot = Items.findItemInCompare(item_object);
- for(var i:int = 0; i < Items.ItemCompareArray[spot].stats.length; i++) {
- addPoints(who, Items.ItemCompareArray[spot].stats[i].type, Items.ItemCompareArray[spot].stats[i].change, true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement