msi.php

/* Yet Another MSI NPC v08_1 By Splizes Originally developed for ForestStory although it was never used :P http://foreststory.zapto.org/?page=home (Splizes) v00 initial release (Splizes) v01 disallowed getting a max stat item if your equip inventory has 0 slots. This is probably useless but it might prevent some problems. (Splizes) v02 fixed a problem with the stat editor. (Splizes) v03 added forcezeroslots which gets rid of upgrade slots possibly preventing negative stats. (Splizes) v04 added stat randomization option (credits VincentOL of ForestStory for idea). (Splizes) v04_1 added signItem boolean. v05 added stat randomization for individual stats (Edited by VincentOL) This npc will probably be used in Foreststory. (VincentOL) v06 fixed individual stat randomization, fixed bugs, optimized individual stat randomization. (Splizes & VincentOL) v07 slight optimization (movement of permenant watk variable to temporal version in script) and renaming of variables. (Splizes) v08 fixed a major bug that occured when the player had no equipment. (Splizes) v08_1 fixed a bug due to v08. (Splizes) v09 added both hands and avoidability (Splizes) v10 added individual item-based 0slotification lol (Splizes) */ importPackage(Packages.client); var status; var MSI_serverName = "ForestStory"; ////// Requirements: ////// var MSI_statRequired = 32767; var MSI_itemIds = Array(4003005,4001006,4000485,4000484,4000001,4001021,4001009,4001011,4001012,4001013,4001014); var MSI_itemAmounts = Array(1,1,1,1,1,1,1,1,1,1,1); /////////////////////////// var MSI_forbiddenItems = Array(1902007,1902039,1912032,1902018,1902017,1912005,1812003,1812002,1812001,1812000,01802004,01802005,01802006,01802007,01802008,01802009,01802010); var MSI_statRandomization = true; var MSI_individualRandomization = true; var MSI_statMin = 25000; var MSI_statMax = MSI_statRequired; var MSI_useWatk = true; var MSI_watkMin = 20; var MSI_watkMax = 50; var MSI_useVotePoints = false; var MSI_votePoints = 4; //required points var MSI_forceZeroSlots = false; var MSI_selectiveForceZeroSlots = false; var MSI_weaponsForceZero = false; //01302000-01702251 var MSI_armorForceZero = false; var MSI_accessoryForceZero = false; var MSI_signItem = true; var MSI_addHands = true; var MSI_hands = 1000; var MSI_addAvoid = true; var MSI_avoid = 999; var player_slotsavaiable = 0; function start() { if (cm.getPlayer().getMapId() == 102000000) { cm.getPlayer().getStorage().sendStorage(cm.getClient(), 1022005); cm.dispose(); } else { status = -1; action(1, 0, 0); } } function action(mode, type, selection) { if (mode == 1) { status++; } else { status = -1; cm.dispose(); } if (status == 0) { var msi_player_hasItems = true; var requirement = 1; var buffer = "#bHey, welcome to #r"+MSI_serverName+"'s#b #kMax-Stat-Item NPC!\r\n\r\nTo get a MSI please meet the following requirements:\r\n#b"+requirement+". "+ MSI_statRequired +" AP in all stats\r\n"; requirement++; if (MSI_useVotePoints == 1) { var tmpplayerVP = cm.getPlayer().getVotePoints(); buffer += "#b"+requirement+". "+ MSI_votePoints +" Vote Point"; if (MSI_votePoints != 1) buffer += "s"; if (tmpplayerVP >= MSI_votePoints ) { buffer += " #g(You Have: "+tmpplayerVP+")"; } else { buffer += " #r(You Have: "+tmpplayerVP+")"; msi_player_hasItems = false; } buffer += "\r\n"; requirement++; } for (var i = 0; i < MSI_itemIds.length; i++) { var tmpitemcheck = cm.getPlayer().getItemQuantity(MSI_itemIds[i], false); buffer += "#b"+requirement+". "+MSI_itemAmounts[i]+" #t"+MSI_itemIds[i]+"#"; if (MSI_itemAmounts[i] > 1) buffer += "s "; if (tmpitemcheck >= MSI_itemAmounts[i]) { buffer += "#g"; } else { buffer += "#r"; msi_player_hasItems = false; } buffer += "#v"+MSI_itemIds[i]+"# (You Have: "+tmpitemcheck+")"; buffer += "\r\n"; requirement++; } if (msi_player_hasItems && cm.getPlayer().getStr() == MSI_statRequired && cm.getPlayer().getDex() == MSI_statRequired && cm.getPlayer().getInt() == MSI_statRequired && cm.getPlayer().getLuk() == MSI_statRequired) { cm.sendNext(buffer); } else { cm.sendOk(buffer); cm.dispose(); } } else if (status == 1) { var slotmax = cm.getPlayer().getInventory(MapleInventoryType.EQUIP).getSlotLimit(); var buffer = "Which Item would you like to turn into a MSI?\r\n"; for (var i = 0; i < slotmax; i++) { var tmpitem = cm.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(i); if (tmpitem != null) { var tmpitemstr; var tmpitemcnt = 0; tmpitemstr = tmpitem.getStr(); tmpitem = tmpitem.getItemId(); if (tmpitem != 0) { var isForbidden = false; for (var x = 0; x < MSI_forbiddenItems.length; x++) { if (tmpitem == MSI_forbiddenItems[x]) isForbidden = true; } if (MSI_statRandomization) { if (!isForbidden && tmpitemstr < MSI_statMin) buffer += "#L"+i+"##v"+tmpitem+"##l"; tmpitemcnt++; } else { if (!isForbidden && tmpitemstr != MSI_statRequired) buffer += "#L"+i+"##v"+tmpitem+"##l"; tmpitemcnt++; } } } else { player_slotsavaiable++; } } if (tmpitemcnt > 0) { buffer += "\r\n\r\n "; cm.sendSimple(buffer); } else { cm.sendOk("I'm sorry but you have no equipment that meets the requirements. Please try again with a clean piece of equipment that does not have max stats."); cm.dispose(); } } else if (status == 2) { if (player_slotsavaiable == 0) { cm.sendOk("You have 0 item spots available please clear up some inventory space before trying again."); cm.dispose(); } else { var itemid = cm.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(selection).getItemId(); var buffer = "Click on the item again to turn it into a MSI:\r\n\r\n"; buffer += "#L" + selection + "##t" + itemid + "# - #v" + itemid + "#"; cm.sendSimple(buffer); } } else if (status == 3) { var item = cm.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(selection); if (!MSI_statRandomization) { var tmpstat = Array(MSI_statRequired,MSI_statRequired,MSI_statRequired,MSI_statRequired); } else if (MSI_individualRandomization) { var tmpstat = Array(MSI_statMin + Math.floor(Math.random()*(MSI_statMax - MSI_statMin + 1)),MSI_statMin + Math.floor(Math.random()*(MSI_statMax - MSI_statMin + 1)),MSI_statMin + Math.floor(Math.random()*(MSI_statMax - MSI_statMin + 1)),MSI_statMin + Math.floor(Math.random()*(MSI_statMax - MSI_statMin + 1))); } else { var randomstat = MSI_statMin + Math.floor(Math.random()*(MSI_statMax - MSI_statMin + 1)); var tmpstat = Array(randomstat,randomstat,randomstat,randomstat); } cm.getPlayer().setLuk(4); cm.getPlayer().setDex(4); cm.getPlayer().setStr(4); cm.getPlayer().setInt(4); item.setStr(tmpstat[0]); item.setDex(tmpstat[1]); item.setLuk(tmpstat[2]); item.setInt(tmpstat[3]); if (MSI_useWatk) var tmpwatk = MSI_watkMin + Math.floor(Math.random()*(MSI_watkMax - MSI_watkMin + 1)); item.setWatk(tmpwatk); if (MSI_useVotePoints) cm.getPlayer().setVotePoints(cm.getPlayer().getVotePoints() - MSI_votePoints); if (MSI_forceZeroSlots || MSI_selectiveForceZeroSlots) { var itemid = item.getItemId(); if (itemid >= 1302000 && itemid = 1010000 && itemid = 1122000) && (itemid = 0020000) && (itemid = 1070000 && itemid = 1000000) && (itemid = 1102000 && itemid = 1040000 && itemid = 1080000 && itemid = 1050000 && itemid = 1060000 && itemid = 1092000 && itemid = 1092000 && itemid
Powered by Gewgley