1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Weapon Dice System 2015-02-22

Adds UOR-based dice for 42 weapons, converts all others to Dice equivalents

  1. Lokai
    This idea came from Moody and The Real Keith.

    See original idea source:

    http://www.servuo.com/threads/integ...misable-attributes-for-objects-c-basics.2455/

    WHAT IS IT?

    What this System does is create a registry of sorts for weapons, adding Dice values for insertion into Min and Max Damage calculations. The core dice values come from the UOR values found on Stratics and various other places. The 42 core weapons are stored as an XML file in the Data folder. In order to work, this system requires an edit to BaseWeapon, but I made it so that none of the changes need to be Serialized. In addition, you don't have to override the values in new weapons that you create. There are 317 weapon types in ServUO, 11 of which are "Base" types, so will not be included since they cannot be constructed directly. Of the other 306 types, only 42 are in the core XML file, leaving 264 weapon types that will use AosMinimum and AosMaximum damage values - converted using a single die formula.

    HOW TO USE:

    In game, examine any weapon by hovering the mouse over it, and you will see Min/Max damage values. If the weapon is "registered" in the System, that value will be based on the Dice calculation: Dice_Num x Dice_Sides + Dice_Offset. If you "[props" any weapon, you will see those 3 values as editable values. When you change them, it updates the Registry. If you change any of the 3 values for a weapon that is not yet registered, it will Register the weapon, adding it to the System.

    Several constants are defined in the System:
    Code (C#):
    1.  
    2.      private static bool AUTO_LOAD_DEFAULTS = true; // Default dice values are loaded on Server startup.
    3.      private static bool AUTO_SAVE_DEFAULTS = true; // Default dice values are saved during World Save.
    4.      private static string DEFAULT_DICE_XML = "Data/weapondice.xml";
    5.   private static AccessLevel DEFAULT_ACCESS_LEVEL = AccessLevel.Administrator;
    6.  
    These are pretty well self-explanatory.

    In addition to Auto-loading and saving values, you can manually save and load weapon values using the commands "[SaveWD <filename>" and "[LoadWD <filename>"

    "filename" should be an XML file that you have saved or modified with more values.

    Again, values are NOT serialized, so the built-in Load feature and the XML files are the only ways that values are added to the system.


    INSTALLATION:

    Instructions are included, but I will copy them here:

    Copy WeaponDice.xml to your Data folder.

    AND

    Copy WeaponDiceDefaults.cs to your Scripts/Custom Systems folder.
    AND

    Overwrite your BaseWeapon.cs with mine, or make the following changes:


    NEW PROPERTIES/METHODS/MOD MinDamage/MaxDamage:
    Code (C#):
    1.  
    2.   //DICE-DAMAGE Mod
    3.   private static int m_DiceNum, m_DiceSides, m_DiceOffset;
    4.   //DICE-DAMAGE Mod
    5.  
    6.  
    7.   //DICE-DAMAGE Mod
    8.  
    9.   [CommandProperty(AccessLevel.GameMaster)]
    10.   public int Dice_Num
    11.   {
    12.     get
    13.     {
    14.         try
    15.         {
    16.             return WeaponDiceDefaults.GetDice(this.GetType()).getNum;
    17.         }
    18.         catch
    19.         {
    20.             if (m_DiceNum == 0)
    21.                 return (1);
    22.             return m_DiceNum;
    23.         }
    24.     }
    25.     set
    26.     {
    27.         try
    28.         {
    29.             WeaponDiceDefaults.ReplaceDice(this.GetType(), value, Dice_Sides, Dice_Offset);
    30.             InvalidateProperties();
    31.         }
    32.         catch
    33.         {
    34.             m_DiceNum = value;
    35.             InvalidateProperties();
    36.         }
    37.     }
    38.   }
    39.  
    40.     [CommandProperty(AccessLevel.GameMaster)]
    41.     public int Dice_Sides
    42.     {
    43.         get
    44.         {
    45.             try
    46.             {
    47.                 return WeaponDiceDefaults.GetDice(this.GetType()).getSides;
    48.             }
    49.             catch
    50.             {
    51.                 if (m_DiceSides == 0)
    52.                     return (AosMaxDamage - AosMinDamage + 1);
    53.                 return m_DiceSides;
    54.             }
    55.         }
    56.         set
    57.         {
    58.          try
    59.             {
    60.                 WeaponDiceDefaults.ReplaceDice(this.GetType(), Dice_Num, value, Dice_Offset);
    61.                 InvalidateProperties();
    62.             }
    63.             catch
    64.             {
    65.                 m_DiceSides = value;
    66.                 InvalidateProperties();
    67.             }
    68.         }
    69.     }
    70.  
    71.     [CommandProperty(AccessLevel.GameMaster)]
    72.     public int Dice_Offset
    73.     {
    74.         get
    75.         {
    76.             try
    77.             {
    78.                 return WeaponDiceDefaults.GetDice(this.GetType()).getOffset;
    79.             }
    80.             catch
    81.             {
    82.                 if (m_DiceOffset == 0)
    83.                     return (AosMinDamage - 1);
    84.                 return m_DiceOffset;
    85.             }
    86.         }
    87.         set
    88.         {
    89.             try
    90.             {
    91.                 WeaponDiceDefaults.ReplaceDice(this.GetType(), Dice_Num, Dice_Sides, value);
    92.                 InvalidateProperties();
    93.             }
    94.             catch
    95.             {
    96.                 m_DiceOffset = value;
    97.                 InvalidateProperties();
    98.             }
    99.         }
    100.     }
    101.  
    102.     [CommandProperty(AccessLevel.GameMaster)]
    103.   public int MinDamage
    104.   {
    105.     get { return (Dice_Num + Dice_Offset); }
    106.   }
    107.  
    108.   [CommandProperty(AccessLevel.GameMaster)]
    109.   public int MaxDamage
    110.   {
    111.     get { return (Dice_Num * Dice_Sides + Dice_Offset); }
    112.    }
    113.   //DICE-DAMAGE Mod
    114.  
    MODIFIED GetBaseDamage(Mobile attacker)
    Code (C#):
    1.  
    2.   //DICE-DAMAGE Mod
    3.   public virtual double GetBaseDamage(Mobile attacker)
    4. {
    5.         int min, max, damage;
    6.     GetBaseDamageRange(attacker, out min, out max);
    7.  
    8.        if (Core.AOS)
    9.        {
    10.         if (attacker is BaseCreature)
    11.         {
    12.             damage = Utility.RandomMinMax(min, max);
    13.         }
    14.         else
    15.         {
    16.             damage = Utility.Dice(Dice_Num, Dice_Sides, Dice_Offset);
    17.         }
    18.             return damage;
    19.        }
    20.  
    21.     damage = Utility.RandomMinMax(min, max);
    22.        if (m_DamageLevel != WeaponDamageLevel.Regular)
    23.        {
    24.             damage += (2 * (int)m_DamageLevel) - 1;
    25.        }
    26.  
    27.        return damage;
    28.   }
    29. //DICE-DAMAGE Mod
    30.  

    IN CONSTRUCTOR public BaseWeapon(int itemID):
    Code (C#):
    1.  
    2.   //DICE-DAMAGE Mod
    3.        // This is just for error catching. These values are not Serialized.
    4.     m_DiceNum = 0;
    5.     m_DiceSides = 0;
    6.     m_DiceOffset = 0;
    7.     //DICE-DAMAGE Mod
    8.  


    -- OR --


    Copy/Paste Data and Scripts folder to yours, overwriting existing files. WARNING, if you made changes to BaseWeapon.cs beforehand, or if you are NOT using a recent ServUO version, you might lose those changes and/or the scripts may not compile.
    Kilra Yan likes this.