include library.static_item; include library.utils; include library.beast_lib; include library.buff; include library.armor; include library.proc; const string_id SID_ITEM_LEVEL_TOO_LOW = new string_id("base_player", "level_too_low"); const string_id SID_ITEM_NOT_ENOUGH_SKILL = new string_id("base_player", "not_correct_skill"); const string_id SID_ITEM_MUST_NOT_BE_EQUIP = new string_id("base_player", "not_while_equipped"); const string_id SID_ITEM_NO_UNIQUE_TRANSFER = new string_id("base_player", "unique_no_transfer"); trigger OnInitialize() { dictionary itemData = static_item.getMasterItemDictionary(self); if ( itemData == null || itemData == "" ) return SCRIPT_CONTINUE; int masterVersion = itemData.getInt("version"); int currentVersion = getStaticItemVersion(self); //check our version if we do not match if(currentVersion != masterVersion) { //Has to be done as a messageTo, otherwise scripts/objvars wont clean up properly //needs to happen one frame after initialize messageTo(self, "handlerVersionUpdate", itemData, 0.1f, true); return SCRIPT_CONTINUE; } else { static_item.initializeObject(self, itemData); } return SCRIPT_CONTINUE; } trigger OnAboutToBeTransferred(obj_id destContainer, obj_id transferer) { boolean canTransfer = true; if (isPlayer(destContainer) || isAPlayerAppearanceInventoryContainer(destContainer)) { dictionary itemData = static_item.getMasterItemDictionary(self); // if transferer is invalid, it must be CTS trying to equip the item // so just assume the transferer is the owner (if owner is the player). if (!isIdValid(transferer)) { obj_id owner = getOwner(self); if (destContainer == owner) { transferer = owner; } else if (isAPlayerAppearanceInventoryContainer(destContainer)) { transferer = getContainedBy(destContainer); } } int requiredLevel = itemData.getInt("required_level"); string requiredSkill = itemData.getString("required_skill"); if(!static_item.validateLevelRequired(transferer,requiredLevel)) { sendSystemMessage(transferer, SID_ITEM_LEVEL_TOO_LOW); canTransfer = false; } if ( requiredSkill != null && requiredSkill != "" ) { string classTemplate = getSkillTemplate(transferer); if ( classTemplate != null && classTemplate != "" ) { if (!classTemplate.startsWith(requiredSkill)) { sendSystemMessage(transferer, SID_ITEM_NOT_ENOUGH_SKILL); canTransfer = false; } } } //If we're fake armor that looks like the real thing, require wear armor skill. if(hasObjVar(self, "armor.fake_armor")) { int ohMyGOT = getGameObjectType(self); if(!hasCommand(transferer, "wear_all_armor") && isGameObjectTypeOf(ohMyGOT, GOT_armor) ) { sendSystemMessage(transferer, SID_ITEM_NOT_ENOUGH_SKILL); canTransfer = false; } } } else { //unique static items can be equipped, or placed in the bank.You can not put them in sub containers or houses. if (static_item.isUniqueStaticItem(self)) { obj_id owner = getOwner(self); obj_id inv = utils.getInventoryContainer(owner); obj_id bank = utils.getPlayerBank(owner); if(!isIdValid(inv) || ((destContainer != inv) && (destContainer != bank))) { sendSystemMessage(transferer, SID_ITEM_NO_UNIQUE_TRANSFER); canTransfer = false; } } } if (static_item.isUniqueStaticItem(self)) { obj_id[] destContents = getContents(destContainer); if (destContents != null && destContents.length > 0) { for (int i=0;i