include library.utils; include java.util.StringTokenizer; const string[] HELP_TEXT = { "=========================================", "USAGE: ShieldRing [Armor Effectiveness 1-100] (default effectiveness is 20)", "ShieldRing [Armor Effectiveness 1-100] [Armor Rating 0-3] (default armor rating is 1)", "ShieldRing [Armor Effectiveness 1-100] [Armor Rating 0-3] [Armor Vulnerability 0-511] (default vulnerability is 0, none)", "Note: Armor Vulnerabilities use 9 bits. If you don't know what this means and need to be vulnerable to something see Mark.", "Saying \"detach\" will automatically detach this script.", "=========================================" }; trigger OnAttach() { /*--- Ensure player is a God and is at least admin level 15 or more ---*/ if(!isPlayer(self)) detachScript(self, "event.shield_ring"); if(!isGod(self)) { detachScript(self, "event.shield_ring"); sendSystemMessage(self, "You must be in God Mode for this script to take hold.", null); return SCRIPT_CONTINUE; } if(isGod(self)) { int godLevel = getGodLevel(self); if(godLevel < 15) { detachScript(self, "event.shield_ring"); sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null); return SCRIPT_CONTINUE; } } sendSystemMessage(self, "Say \"Help\" for usage and options.", null); return SCRIPT_CONTINUE; } trigger OnLogin() { /*--- Ensure player is a God and is at least admin level 15 or more ---*/ if(!isGod(self)) { detachScript(self, "event.shield_ring"); sendSystemMessage(self, "You must be in God Mode to use this script.", null); } if(isGod(self)) { int godLevel = getGodLevel(self); if(godLevel < 15) { detachScript(self, "event.shield_ring"); sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null); return SCRIPT_CONTINUE; } } return SCRIPT_CONTINUE; } trigger OnHearSpeech(obj_id objSpeaker, string strText) { if(objSpeaker!=self) { return SCRIPT_CONTINUE; } /*--- Restrict use of this script to level 15 or higher. ---*/ if(isGod(self)) { int godLevel = getGodLevel(self); if(godLevel < 15) { detachScript(self, "event.shield_ring"); sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null); return SCRIPT_CONTINUE; } } if(!isGod(self)) { detachScript(self, "event.shield_ring"); sendSystemMessage(self, "You must be in God Mode to use this script.", null); return SCRIPT_CONTINUE; } if(strText.startsWith("ShieldRing")) { sendSystemMessage(self, "This command has been temporarily disabled. See S. Jakab or T. Blair", null); /* int armorEffectiveness = 20; int armorIntegrity = 900000; int armorRating = 1; int armorVulnerability = 0; int healthEncumbrance = 0; int mindEncumbrance = 0; int actionEncumbrance = 0; StringTokenizer st = new StringTokenizer(strText); if(st.countTokens() == 2) { string command = st.nextToken(); string armorEffectivenessStr = st.nextToken(); armorEffectiveness = utils.stringToInt(armorEffectivenessStr); if(armorEffectiveness > 100 || armorEffectiveness < 1) { sendSystemMessage(self, "Armor effectiveness must be a value between 1 and 100.", null); return SCRIPT_CONTINUE; } sendSystemMessage(self, "Effectiveness: " + armorEffectiveness + " Rating: " + armorRating + " Vuln: " + armorVulnerability, null); } if(st.countTokens() == 3) { string command = st.nextToken(); string armorEffectivenessStr = st.nextToken(); string armorRatingStr = st.nextToken(); armorEffectiveness = utils.stringToInt(armorEffectivenessStr); armorRating = utils.stringToInt(armorRatingStr); if( armorEffectiveness > 100 || armorEffectiveness < 1 || armorRating > 3 || armorRating < 0) { sendSystemMessage(self, "Invalid range somewhere, check your numbers. Armor effectiveness 1-100. Armor rating 0-3.", null); return SCRIPT_CONTINUE; } } if(st.countTokens() == 4) { string command = st.nextToken(); string armorEffectivenessStr = st.nextToken(); string armorRatingStr = st.nextToken(); string armorVulnerabilityStr = st.nextToken(); armorEffectiveness = utils.stringToInt(armorEffectivenessStr); armorRating = utils.stringToInt(armorRatingStr); armorVulnerability = utils.stringToInt(armorVulnerabilityStr); if( armorEffectiveness > 100 || armorEffectiveness < 1 || armorRating > 3 || armorRating < 0 || armorVulnerability > 511 || armorVulnerability < 0) { sendSystemMessage(self, "Invalid range somewhere, check your numbers. Armor effectiveness 1-100. Armor rating 0-3. Armor vulnerability 0-511.", null); return SCRIPT_CONTINUE; } } obj_id objInventory = utils.getInventoryContainer(objSpeaker); obj_id magicRing = createObjectOverloaded("object/tangible/wearables/ring/ring_s01.iff", objInventory); setName(magicRing, "***INTERNAL USE ONLY: Event Shield Ring"); if ( armorRating >= 0 ) { if (!hasArmorLayer(magicRing, armorRating)) { boolean[] currentLayers = hasArmorLayers(magicRing); if ( currentLayers != null ) { for ( int i = 0; i < currentLayers.length; ++i ) { if ( currentLayers[i] ) removeArmorLayer(magicRing, i); } } //This never seems to happen yet for some reason the script doesn't work without it. Clearly voodoo. if (!addArmorLayer(magicRing, armorRating)) sendSystemMessage(self, "Mystical Voodoo alert! A little something something.", null); } setArmorData(magicRing, armorRating, armorEffectiveness, armorIntegrity); int [] encumbrance = new int[3]; encumbrance[0] = healthEncumbrance; encumbrance[1] = actionEncumbrance; encumbrance[2] = mindEncumbrance; setArmorEncumbrance(magicRing, armorRating, encumbrance); } if(armorVulnerability != 0) setArmorVulnerability(magicRing, armorVulnerability); float creationTime = getGameTime(); setObjVar(magicRing, "event.creationTime", creationTime); setArmorShield(magicRing, true); attachScript(magicRing, "event.no_rent"); sendSystemMessage(self, "Creating Shield Ring with Effectiveness: " + armorEffectiveness + " Rating: " + armorRating + " Vuln: " + armorVulnerability, null); */ } if(toLower(strText).equals("detach")) { detachScript(self, "event.shield_ring"); return SCRIPT_CONTINUE; } if(toLower(strText).equals("help")) { for(int i = 0; i < HELP_TEXT.length; i++) { sendSystemMessage(self, HELP_TEXT[i], null); } return SCRIPT_CONTINUE; } return SCRIPT_CONTINUE; }