Resource icon

Weapon Dice System 2015-02-22

Author
Lokai
Downloads
47
Views
1,436
First release
Last update
Rating
0.00 star(s) 0 ratings
No permission to download Join the discussion

More resources from 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:
     private static bool AUTO_LOAD_DEFAULTS = true; // Default dice values are loaded on Server startup.
     private static bool AUTO_SAVE_DEFAULTS = true; // Default dice values are saved during World Save.
     private static string DEFAULT_DICE_XML = "Data/weapondice.xml";
  private static AccessLevel DEFAULT_ACCESS_LEVEL = AccessLevel.Administrator;

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:
  //DICE-DAMAGE Mod
  private static int m_DiceNum, m_DiceSides, m_DiceOffset;
  //DICE-DAMAGE Mod


  //DICE-DAMAGE Mod

  [CommandProperty(AccessLevel.GameMaster)]
  public int Dice_Num
  {
  	get
  	{
  		try
  		{
  			return WeaponDiceDefaults.GetDice(this.GetType()).getNum;
  		}
  		catch
	 	{
  			if (m_DiceNum == 0)
  				return (1);
  			return m_DiceNum;
  		}
  	}
  	set
  	{
  		try
  		{
  			WeaponDiceDefaults.ReplaceDice(this.GetType(), value, Dice_Sides, Dice_Offset);
  			InvalidateProperties();
  		}
  		catch
  		{
  			m_DiceNum = value;
  			InvalidateProperties();
  		}
  	}
  }

    [CommandProperty(AccessLevel.GameMaster)]
    public int Dice_Sides
    {
    	get
    	{
    		try
    		{
    			return WeaponDiceDefaults.GetDice(this.GetType()).getSides;
    		}
    		catch
    		{
    			if (m_DiceSides == 0)
    				return (AosMaxDamage - AosMinDamage + 1);
    			return m_DiceSides;
    		}
    	}
    	set
    	{
   		 try
    		{
    			WeaponDiceDefaults.ReplaceDice(this.GetType(), Dice_Num, value, Dice_Offset);
    			InvalidateProperties();
    		}
    		catch
    		{
    			m_DiceSides = value;
    			InvalidateProperties();
    		}
    	}
    }

    [CommandProperty(AccessLevel.GameMaster)]
    public int Dice_Offset
    {
    	get
    	{
    		try
    		{
    			return WeaponDiceDefaults.GetDice(this.GetType()).getOffset;
    		}
    		catch
    		{
    			if (m_DiceOffset == 0)
    				return (AosMinDamage - 1);
    			return m_DiceOffset;
    		}
    	}
    	set
    	{
    		try
    		{
    			WeaponDiceDefaults.ReplaceDice(this.GetType(), Dice_Num, Dice_Sides, value);
    			InvalidateProperties();
    		}
    		catch
    		{
    			m_DiceOffset = value;
    			InvalidateProperties();
    		}
    	}
    }

    [CommandProperty(AccessLevel.GameMaster)]
  public int MinDamage
  {
  	get { return (Dice_Num + Dice_Offset); }
  }

  [CommandProperty(AccessLevel.GameMaster)]
  public int MaxDamage
  {
  	get { return (Dice_Num * Dice_Sides + Dice_Offset); }
   }
  //DICE-DAMAGE Mod

MODIFIED GetBaseDamage(Mobile attacker)
Code:
  //DICE-DAMAGE Mod
  public virtual double GetBaseDamage(Mobile attacker)
{
      	int min, max, damage;
  	GetBaseDamageRange(attacker, out min, out max);

       if (Core.AOS)
       {
  		if (attacker is BaseCreature)
  		{
  			damage = Utility.RandomMinMax(min, max);
  		}
  		else
  		{
  			damage = Utility.Dice(Dice_Num, Dice_Sides, Dice_Offset);
  		}
         	return damage;
       }
  
  	damage = Utility.RandomMinMax(min, max);
       if (m_DamageLevel != WeaponDamageLevel.Regular)
       {
         	damage += (2 * (int)m_DamageLevel) - 1;
       }

       return damage;
  }
//DICE-DAMAGE Mod


IN CONSTRUCTOR public BaseWeapon(int itemID):
Code:
  //DICE-DAMAGE Mod
       // This is just for error catching. These values are not Serialized.
  	m_DiceNum = 0;
  	m_DiceSides = 0;
  	m_DiceOffset = 0;
  	//DICE-DAMAGE Mod



-- 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.
  • Like
Reactions: Oreo and Kilra Yan

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back