Notice something wrong, missing, or inadequate? Feel free to edit pages yourself and make use of discussion pages.
Wiki content is created, maintained, and administrated by players. Learn how you can help!

Spells/Parsing/code:Tables.java

From SoDWiki
Jump to navigationJump to search
package com.zak.sod.extractor;

/******************************************************************************
* This class is simply a pure java switch/case version of the OpenSpell.xml file.
* For some the pure XML is more useful, but for my purposes I found this easier
* then writing up a parser. I got the XML file from the OpenSpell 1.1, written
* in Pascal, available at - http://www.eqemulator.net/wiki/wikka.php?wakka=SpellsUsTxt
* I don't know if Windcatcher wrote it or not, but his name is on it, so gets the
* credit for it.
*
* The Main.java calls these classes from a static context. They are in a separate
* class for readability. You shouldn't need to edit the switch statements that much.
*
* There is some info on the table lookup thats specific to the SOD Wiki formatting.
* It has been labeled so you can edit it back.
*
*     The MIT License
*   
*    Copyright (c) 2008 Zak-Corps.
*   
*    Permission is hereby granted, free of charge, to any person obtaining a copy
*    of this software and associated documentation files (the "Software"), to deal
*    in the Software without restriction, including without limitation the rights
*    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*    copies of the Software, and to permit persons to whom the Software is
*    furnished to do so, subject to the following conditions:
*
*    1) Credit given in derivative works
*    2) Notification prior to distribution of derivative works
*   
*    The above copyright notice and this permission notice shall be included in
*    all copies or substantial portions of the Software.
*   
*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*    THE SOFTWARE.
*
*    Now that the legal stuff is out of the way, enjoy.
*
*    @author Tyrsell
*    @author [email protected]
*
*    Based on the work by:
*    @author Windcatcher from EQEmulator Forums
*             (http://www.eqemulator.net/forums/index.php )
*
*    @version 1.5 release 1/09/2008
*
******************************************************************************/

public class Tables {
   
    static String getResistances(String resistToken){
       
        String resistType = "N/A";
        int decodedInteger = (Integer.decode( resistToken )).intValue();
       
        switch( decodedInteger ){
            case 1: resistType = "Magic"; break;
            case 2: resistType = "Fire"; break;
            case 3: resistType = "Ice"; break;
            case 4: resistType = "Poison"; break;
            case 5: resistType = "Disease"; break;
            default: resistType = "N/A"; break;
        }
       
        return resistType;
    }//getResistances
   
    /**
     * getClass couldn't be generalized very well. You'll likely have to make
     * your own
     *
     * @param    classToken - A string representation of all the classes and their
     *                         min level for this spell ex:
     *                         "255^1^9^9^255^255^255^255^255^255^255^255^255^255^255"
     *                         Would represent a spell clerics get at level 1, paladins
     *                         at level 9, rangers at level 9, and no one else can cast
     *                         at all.
     */
    static String getClass(String classToken){
       
        String[] results = classToken.split("\\^");
       
        String classType = "";
   
        for( int i = 0; i < results.length; i++ ){
            int minLvl = (Integer.decode( results[i] )).intValue();
           
            switch( i ){
                case 0: if(minLvl < 255)
                        classType = classType + " [[Spells: Warrior#Level "+minLvl+"|WAR("+minLvl+")]] ";
                        break;
                case 1: if(minLvl < 255)
                        classType = classType + " [[Spells: Cleric#Level "+minLvl+"|CLR("+minLvl+")]] ";
                        break;
                case 2: if(minLvl < 255)
                        classType = classType + " [[Spells: Paladin#Level "+minLvl+"|PAL("+minLvl+")]] ";
                        break;
                case 3:if(minLvl < 255)
                        classType = classType + " [[Spells: Ranger#Level "+minLvl+"|RNG("+minLvl+")]] ";
                        break;
                case 4: if(minLvl < 255)
                        classType = classType + " [[Spells: Shadowknight#Level "+minLvl+"|SHD("+minLvl+")]] ";
                        break;
                case 5: if(minLvl < 255)
                        classType = classType + " [[Spells: Druid#Level "+minLvl+"|DRU("+minLvl+")]] ";
                        break;
                case 6: if(minLvl < 255)
                        classType = classType + " [[Spells: Monk#Level "+minLvl+"|MNK("+minLvl+")]] ";
                        break;
                case 7: if(minLvl < 255)
                        classType = classType + " [[Spells: Bard#Level "+minLvl+"|BRD("+minLvl+")]] ";
                        break;
                case 8: if(minLvl < 255)
                        classType = classType + " [[Spells: Rogue#Level "+minLvl+"|ROG("+minLvl+")]] ";
                        break;
                case 9: if(minLvl < 255)
                        classType = classType + " [[Spells: Shaman#Level "+minLvl+"|SHM("+minLvl+")]] ";
                        break;
                case 10:if(minLvl < 255)
                        classType = classType + " [[Spells: Necromancer#Level "+minLvl+"|NEC("+minLvl+")]] ";
                        break;
                case 11:if(minLvl < 255)
                        classType = classType + " [[Spells: Wizard#Level "+minLvl+"|WIZ("+minLvl+")]] ";
                        break;
                case 12:if(minLvl < 255)
                        classType = classType + " [[Spells: Magician#Level "+minLvl+"|MAG("+minLvl+")]] ";
                        break;
                case 13:if(minLvl < 255)
                        classType = classType + " [[Spells: Enchanter#Level "+minLvl+"|ENC("+minLvl+")]] ";
                        break;
                case 14:if(minLvl < 255)
                        classType = classType + " [[Spells: Beastlord#Level "+minLvl+"|BST("+minLvl+")]] ";
                        break;
                default: classType = "N/A"; break;
            }
        }
       
        return classType;
    }//getClass
   
   
    static String getZoneType( String zoneToken ){
        String zoneType = "none";
        if( zoneToken.equals("0") ){
            //I don't think any indoor only spells exist
            zoneType = "Indoor";
        }
        else if( zoneToken.equals("1") ){
            zoneType = "Outdoor";
        }
       
        return zoneType;
    }
   
   
    static String getSkill(String skillToken){
       
        String skillType = "N/A";
        int decodedInteger = (Integer.decode( skillToken )).intValue();
       
        switch( decodedInteger ){
          case 0: skillType = "1H Blunt"; break;
          case 1: skillType = "1H Slashing"; break;
          case 2: skillType = "2H Blunt"; break;
          case 3: skillType = "2H Slashing"; break;
          case 4: skillType = "Abjuration"; break;
          case 5: skillType = "Alteration"; break;
          case 6: skillType = "Apply Poison"; break;
          case 7: skillType = "Archery"; break;
          case 8: skillType = "Backstab"; break;
          case 9: skillType = "Bind Wound"; break;
          case 10: skillType = "Bash"; break;
          case 11: skillType = "Block"; break;
          case 12: skillType = "Brass Instruments"; break;
          case 13: skillType = "Channeling"; break;
          case 14: skillType = "Conjuration"; break;
          case 15: skillType = "Defense"; break;
          case 16: skillType = "Disarm"; break;
          case 17: skillType = "Disarm Traps"; break;
          case 18: skillType = "Divination"; break;
          case 19: skillType = "Dodge"; break;
          case 20: skillType = "Double Attack"; break;
          case 21: skillType = "Dragon Punch"; break;
          case 22: skillType = "Dual Wield"; break;
          case 23: skillType = "Eagle Strike"; break;
          case 24: skillType = "Evocation"; break;
          case 25: skillType = "Feign Death"; break;
          case 26: skillType = "Flying Kick"; break;
          case 27: skillType = "Forage"; break;
          case 28: skillType = "Hand To Hand"; break;
          case 29: skillType = "Hide"; break;
          case 30: skillType = "Kick"; break;
          case 31: skillType = "Meditate"; break;
          case 32: skillType = "Mend"; break;
          case 33: skillType = "Offense"; break;
          case 34: skillType = "Parry"; break;
          case 35: skillType = "Pick Lock"; break;
          case 36: skillType = "Piercing"; break;
          case 37: skillType = "Riposte"; break;
          case 38: skillType = "Round Kick"; break;
          case 39: skillType = "Safe Fall"; break;
          case 40: skillType = "Sense Heading"; break;
          case 41: skillType = "Sing"; break;
          case 42: skillType = "Sneak"; break;
          case 43: skillType = "Specialize Abjure"; break;
          case 44: skillType = "Specialize Alteration"; break;
          case 45: skillType = "Specialize Conjuration"; break;
          case 46: skillType = "Specialize Divinatation"; break;
          case 47: skillType = "Specialize Evocation"; break;
          case 48: skillType = "Pick Pockets"; break;
          case 49: skillType = "Stringed Instruments"; break;
          case 50: skillType = "Swimming"; break;
          case 51: skillType = "Throwing"; break;
          case 52: skillType = "Tiger Claw/Instantaneous"; break;
          case 53: skillType = "Tracking"; break;
          case 54: skillType = "Wind Instruments"; break;
          case 55: skillType = "Fishing"; break;
          case 56: skillType = "Make Poison"; break;
          case 57: skillType = "Tinkering"; break;
          case 58: skillType = "Research"; break;
          case 59: skillType = "Alchemy"; break;
          case 60: skillType = "Baking"; break;
          case 61: skillType = "Tailoring"; break;
          case 62: skillType = "Sense Traps"; break;
          case 63: skillType = "Blacksmithing"; break;
          case 64: skillType = "Fletching"; break;
          case 65: skillType = "Brewing"; break;
          case 66: skillType = "Alcohol Tolerance"; break;
          case 67: skillType = "Begging"; break;
          case 68: skillType = "Jewelry Making"; break;
          case 69: skillType = "Pottery"; break;
          case 70: skillType = "Percussion Instruments"; break;
          case 71: skillType = "Intimidation"; break;
          case 72: skillType = "Berserking"; break;
          case 73: skillType = "Taunt"; break;
          default: skillType = "N/A"; break;
        }
        return skillType;
    }//getSkill
   
    static String getTargets( String targetToken ){
       
        String targetType = "N/A";
        int decodedInteger = (Integer.decode( targetToken )).intValue();
       
        switch(decodedInteger){
            case 1: targetType = "Projectile Aim"; break;
            case 2: targetType = "AE PC v1"; break;
            case 3: targetType = "Self Based AoE"; break;
            case 4: targetType = "Point Blank AoE"; break;
            case 5: targetType = "All"; break;
            case 6: targetType = "Self"; break;
            case 8: targetType = "Target Based AoE"; break;
            case 9: targetType = "Animals"; break;
            case 10: targetType = "Undead"; break;
            case 11: targetType = "Summoned"; break;
            case 13: targetType = "Lifetap"; break;
            case 14: targetType = "Pet"; break;
            case 15: targetType = "Corpse"; break;
            case 16: targetType = "Plant"; break;
            case 17: targetType = "Giant"; break;
            case 18: targetType = "Dragon"; break;
            case 20: targetType = "Targeted AE (Tap)"; break;
            case 24: targetType = "AE Undead"; break;
            case 25: targetType = "AE Summoned"; break;
            case 33: targetType = "NPC Hatelist (!?)"; break;
            case 34: targetType = "Dungeon Object"; break;
            case 36: targetType = "Area - PC Only"; break;
            case 40: targetType = "AE PC v2"; break;
            case 41: targetType = "Group Buff"; break;
            default: targetType = "N/A"; break;
        }
   
        return targetType;
    }//targetType
   
    
    /**
     * Look up table associated with the formula used for spells whose effects
     * vary by level. Only really useful on low level spells. Original formulas
     * are found on the 'effect_formula' table of OpenSpell.xml
     * 
     * @param effectsToken
     * @param minLevel
     * @param maxLevel
     * @return
     */
    static String getEffectsFormula( String formulaToken, String min, String max ){
    	
    	int finalAnswer = 0;
    	String finalAnswerString = "";
    	
        int forumlaType = (Integer.decode( formulaToken )).intValue();
        int minValue = (Integer.decode( min )).intValue();
        int maxValue = (Integer.decode( max )).intValue();
        
        switch( forumlaType ){
        	
        	case 100: finalAnswer = minValue; break;
        	case 101: finalAnswer = minValue + (maxValue / 2); break;
        	case 103: finalAnswer = minValue + (maxValue * 2); break;
        	case 104: finalAnswer = minValue + (maxValue * 3); break;
        	case 109: finalAnswer = minValue + (maxValue / 4); break;
        	case 110: finalAnswer = minValue + (maxValue / 5); break;
        	case 119: finalAnswer = minValue + (maxValue / 8); break;
        	default: finalAnswer = -1;
        }
        
        if( finalAnswer > 0 )
        	finalAnswerString = finalAnswer + "";
       
    	return finalAnswerString;
    }
    
   
    static String getEffects( String effectsToken ){
       
        String effectsType = "N/A";
        int decodedInteger = (Integer.decode( effectsToken )).intValue();
       
        switch( decodedInteger ){
          case 0: effectsType = "HP (per Tick)"; break;
          case 1: effectsType = "Armor Class"; break;
          case 2: effectsType = "ATK"; break;
          case 3: effectsType = "Movement"; break;
          case 4: effectsType = "STR"; break;
          case 5: effectsType = "DEX"; break;
          case 6: effectsType = "AGI"; break;
          case 7: effectsType = "STA"; break;
          case 8: effectsType = "INT"; break;
          case 9: effectsType = "WIS"; break;
          case 10: effectsType = "CHA"; break;
          case 11: effectsType = "Attack Speed"; break;
          case 12: effectsType = "Invisibility"; break;
          case 13: effectsType = "See Invis"; break;
          case 14: effectsType = "Waterbreathing"; break;
          case 15: effectsType = "Current mana"; break;
          case 18: effectsType = "Lull"; break;
          case 19: effectsType = "Faction (Alliance)"; break;
          case 20: effectsType = "Blindness"; break;
          case 21: effectsType = "Stun"; break;
          case 22: effectsType = "Charm"; break;
          case 23: effectsType = "Fear"; break;
          case 24: effectsType = "Stamina Regen."; break;
          case 25: effectsType = "Bind Affinity"; break;
          case 26: effectsType = "Gate"; break;
          case 27: effectsType = "Cancel Magic"; break;
          case 28: effectsType = "Invis to Undead"; break;
          case 29: effectsType = "Invis to Animals"; break;
          case 30: effectsType = "Frenzy Range"; break;
          case 31: effectsType = "Mezmerise"; break;
          case 32: effectsType = "Summon Item"; break;
          case 33: effectsType = "Summon Pet"; break;
          case 34: effectsType = "Disease Counters"; break;
          case 35: effectsType = "Poison Counters"; break;
          case 36: effectsType = "Poison Counter"; break;
          case 37: effectsType = "Sense Magic"; break;
          case 40: effectsType = "Divine Aura"; break;
          case 41: effectsType = "Destroy Target"; break;
          case 42: effectsType = "Shadow Step"; break;
          case 44: effectsType = "Lycanthropy"; break;
          case 46: effectsType = "Resist Fire"; break;
          case 47: effectsType = "Resist Cold"; break;
          case 48: effectsType = "Resist Poison"; break;
          case 49: effectsType = "Resist Disease"; break;
          case 50: effectsType = "Resist Magic"; break;
          case 52: effectsType = "Sense Undead"; break;
          case 53: effectsType = "Sense Summoned"; break;
          case 54: effectsType = "Sense Animals"; break;
          case 55: effectsType = "Rune"; break;
          case 56: effectsType = "True North"; break;
          case 57: effectsType = "Levitate"; break;
          case 58: effectsType = "Illusion"; break;
          case 59: effectsType = "Damage Shield"; break;
          case 61: effectsType = "Identify"; break;
          case 63: effectsType = "Wipe Hatelist"; break;
          case 64: effectsType = "Spin Target"; break;
          case 65: effectsType = "Infravision"; break;
          case 66: effectsType = "Ultravision"; break;
          case 67: effectsType = "Eye of Zomm"; break;
          case 68: effectsType = "Reclaim Pet"; break;
          case 69: effectsType = "Total HP"; break;
          case 71: effectsType = "Create necro pet"; break;
          case 73: effectsType = "Bind Sight"; break;
          case 74: effectsType = "Feign Death"; break;
          case 75: effectsType = "Voice Graft"; break;
          case 76: effectsType = "Sentinel"; break;
          case 77: effectsType = "Locate Corpse"; break;
          case 78: effectsType = "Absorb Magic Attacks"; break;
          case 79: effectsType = "HP (Once)"; break;
          case 81: effectsType = "Revive"; break;
          case 82: effectsType = "Summon Player"; break;
          case 83: effectsType = "Teleport"; break;
          case 84: effectsType = "Throw Into Air"; break;
          case 85: effectsType = "Weapon Proc"; break;
          case 86: effectsType = "Harmony"; break;
          case 87: effectsType = "Magnification"; break;
          case 88: effectsType = "Evacuate"; break;
          case 89: effectsType = "Shrink/Growth"; break;
          case 90: effectsType = "Cloak"; break;
          case 91: effectsType = "Summon Corpse"; break;
          case 92: effectsType = "Modify Hate"; break;
          case 93: effectsType = "Stop Rain"; break;
          case 94: effectsType = "Fragile (Combat cancels this spell)"; break;
          case 95: effectsType = "Sacrifice"; break;
          case 96: effectsType = "Silence"; break;
          case 97: effectsType = "Mana Drain"; break;
          case 98: effectsType = "Haste (Above Cap)"; break;
          case 99: effectsType = "Root"; break;
          case 100: effectsType = "Heal Over Time"; break;
          case 101: effectsType = "Complete Heal"; break;
          case 102: effectsType = "Fearless"; break;
          case 103: effectsType = "Summon Companion"; break;
          case 104: effectsType = "Translocate"; break;
          case 105: effectsType = "Interrupt Gate"; break;
          case 106: effectsType = "Summon BST Pet"; break;
          case 107: effectsType = "Summon Companion (max. Level)"; break;
          case 108: effectsType = "Summon Familiar"; break;
          case 109: effectsType = "Summon Item Into Backpack"; break;
          case 110: effectsType = "Increase Archery"; break;
          case 111: effectsType = "All resists"; break;
          case 112: effectsType = "Modify Cast Skill"; break;
          case 113: effectsType = "Summon Horse"; break;
          case 114: effectsType = "Change Aggro"; break;
          case 115: effectsType = "Resplenish Hunger"; break;
          case 116: effectsType = "Add Curse Counter"; break;
          case 117: effectsType = "Make Weapon Magic"; break;
          case 118: effectsType = "Amplification"; break;
          case 119: effectsType = "Haste"; break;
          case 120: effectsType = "Reduce Healing"; break;
          case 121: effectsType = "Reverse Damage Shield"; break;
          case 123: effectsType = "Screech"; break;
          case 124: effectsType = "Increase Spell Damage"; break;
          case 125: effectsType = "Increase Spell Healing"; break;
          case 127: effectsType = "Increase Spell Haste"; break;
          case 128: effectsType = "Increase Spell Duration"; break;
          case 129: effectsType = "Increase Spell Range"; break;
          case 130: effectsType = "Furious Bash"; break;
          case 131: effectsType = "Conserve Spell Reagent"; break;
          case 132: effectsType = "Decrease Mana Cost"; break;
          case 134: effectsType = "Effect Max Level Limit"; break;
          case 135: effectsType = "Effect Resist Limit"; break;
          case 136: effectsType = "Exclude Target Type"; break;
          case 137: effectsType = "Exclude Spell Type"; break;
          case 138: effectsType = "Limit to Spell Type"; break;
          case 139: effectsType = "Exclude Spell"; break;
          case 140: effectsType = "Minimum Duration"; break;
          case 141: effectsType = "Instant Spells Only"; break;
          case 142: effectsType = "Effect Min Level Limit"; break;
          case 143: effectsType = "Minimum Casting Time"; break;
          case 145: effectsType = "Teleport V2"; break;
          case 147: effectsType = "Heal HP Percentage"; break;
          case 148: effectsType = "Stacking 1"; break;
          case 149: effectsType = "Stacking 2"; break;
          case 150: effectsType = "Death Save"; break;
          case 151: effectsType = "Suspend Minion"; break;
          case 152: effectsType = "Summon Pets"; break;
          case 153: effectsType = "Balance Party Health"; break;
          case 154: effectsType = "Remove Detrimental"; break;
          case 156: effectsType = "Illusion: Target"; break;
          case 157: effectsType = "Spell-Damage Shield"; break;
          case 158: effectsType = "Chance to Reflect Spell Percentage"; break;
          case 159: effectsType = "Increase/Decrease Stats"; break;
          case 161: effectsType = "Absorb spell damage"; break;
          case 162: effectsType = "Absorb melee damage"; break;
          case 167: effectsType = "Increase pet power"; break;
          case 168: effectsType = "Melee Mitigation"; break;
          case 169: effectsType = "Chance to Crit Percentage"; break;
          case 170: effectsType = "Chance to critical cast Percentage"; break;
          case 171: effectsType = "Chance to Crippling Blow"; break;
          case 172: effectsType = "Chance to Avoid Melee Percentage"; break;
          case 173: effectsType = "Chance to Riposte Percentage"; break;
          case 174: effectsType = "Chance to Dodge Percentage"; break;
          case 175: effectsType = "Chance to Parry Percentage"; break;
          case 176: effectsType = "Dual Wield Percentage"; break;
          case 177: effectsType = "Double Attack Percentage"; break;
          case 178: effectsType = "Lifetap from Weapon Damage"; break;
          case 179: effectsType = "Instrument Modifier"; break;
          case 180: effectsType = "Chance to Resist Spell"; break;
          case 181: effectsType = "Chance to Resist Fear Pecentage"; break;
          case 182: effectsType = "Hundred Hands Effect"; break;
          case 183: effectsType = "Melee Skill Check Percentage"; break;
          case 184: effectsType = "Chance to Hit Percentage"; break;
          case 185: effectsType = "Damage Modifier"; break;
          case 186: effectsType = "Minimum Damage Modifier"; break;
          case 188: effectsType = "Chance to Block Percentage"; break;
          case 189: effectsType = "Endurance Regen"; break;
          case 192: effectsType = "Modify Hate"; break;
          case 193: effectsType = "Skill Attack"; break;
          case 194: effectsType = "Fade???"; break;
          case 195: effectsType = "Stun Resist"; break;
          case 196: effectsType = "Strikethrough"; break;
          case 197: effectsType = "Skill Damage Taken???"; break;
          case 198: effectsType = "Endurance"; break;
          case 199: effectsType = "Redirect Hate"; break;
          default: effectsType = "N/A"; break;
        }
       
        return effectsType;
    }//getEffects
   
 }//Tables