Full Version : Optional mods
xmlspawner >>XMLSiege Releases and Updates >>Optional mods


<< Prev | Next >>

ArteGordon- 03-19-2006
This is a suggested mod that supports disabling use of siege-damaged doors. That way if you put an XmlSiege attachment onto a door and the Hits go to zero, it will not be usable until repaired.

In BaseDoor.cs around line 448 in the Use method, add the lines in red

QUOTE

  public virtual void Use( Mobile from )
  {

  // ARTEGORDONMOD
  // block use of doors destroyed with the XmlSiege system
  if(XmlSiege.GetHits(this) == 0) return;

  if ( m_Locked && !m_Open && UseLocks() )
  {


and around line 227
QUOTE

  [CommandProperty( AccessLevel.GameMaster )]
  public bool Open
  {
  get
  {
    return m_Open;
  }
  set
  {
    // ARTEGORDONMOD
    // prevent doors with modified itemids through XmlSiege from being opened
    if(ItemID != m_OpenedID && ItemID != m_ClosedID) return;

    if ( m_Open != value )
    {


and add this to the beginning of BaseDoor.cs

CODE

using Server.Engines.XmlSpawner2;


Ok, so I forgot my keys. This works too...
user posted image

ArteGordon- 03-25-2006
just a note for those of you that might be trying to mount cannons on boats. You need to add a fix to baseboat.cs to properly deal with addons. The default code doesnt move addons properly so they end up being shifted off the boat.

Just make the following changes to the Teleport method around line 1492 in baseboat.cs

QUOTE

  public void Teleport( int xOffset, int yOffset, int zOffset )
  {
  MultiComponentList mcl = Components;

  ArrayList toMove = new ArrayList();

  IPooledEnumerable eable = this.Map.GetObjectsInBounds( new Rectangle2D( X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height ) );

  foreach ( object o in eable )
  {
    // ARTEGORDONMOD
    // deal with addons.  Just move the addon, not the components.  That gets taken care of
    // automatically when you move the addon itself.
    if ( o != this && !(o is TillerMan || o is Hold || o is Plank || o is AddonComponent) )
    toMove.Add( o );
  }

  eable.Free();

  for ( int i = 0; i < toMove.Count; ++i )
  {
    object o = toMove[i];

    if ( o is Item )
    {
    Item item = (Item)o;

    // ARTEGORDONMOD
    // deal with addons that would have invisible handles but you still
    // want them to be moved with the boat.
    if ( Contains( item ) && (item.Visible || item is BaseAddon) && item.Z >= Z )
      item.Location = new Point3D( item.X + xOffset, item.Y + yOffset, item.Z + zOffset );
    }
    else if ( o is Mobile )
    {
    Mobile m = (Mobile)o;

    if ( Contains( m ) )
      m.Location = new Point3D( m.X + xOffset, m.Y + yOffset, m.Z + zOffset );
    }
  }

  Location = new Point3D( X + xOffset, Y + yOffset, Z + zOffset );
  }


and to properly handle repositioning addons and siege weapons when turning, make these changes in the SetFacing method in BaseBoat.cs around line 1584

QUOTE

  foreach ( object o in eable )
  {
    if ( o is Item )
    {
    Item item = (Item)o;

    // ARTEGORDONMOD
    // deal with addons that would have invisible handles but you still
    // want them to be moved with the boat.
    // Just move the addon, not the components.  That gets taken care of
    // automatically when you move the addon itself.
    if (item != this && Contains(item) && (item.Visible || item is BaseAddon) && item.Z >= Z && !(item is TillerMan || item is Hold || item is Plank || item is AddonComponent))
      toMove.Add( item );

    // support rotation of siege weapons when turning boats
    if (item is BaseSiegeWeapon)
    {
      ((BaseSiegeWeapon)item).Facing = ((int)((BaseSiegeWeapon)item).Facing - ((int)old - (int)facing)/2);
    }

    }
    else if ( o is Mobile && Contains( (Mobile)o ) )
    {
    toMove.Add( o );

    ((Mobile)o).Direction = (Direction)((int)((Mobile)o).Direction - (int)old + (int)facing);
    }
  }

ArteGordon- 04-07-2006
QUOTE (Anvil @ April 06, 2006 09:47 pm)
Question, in the main post you mention this:

CODE
Permanent destruction
If you change DestroyedItemID setting to zero, then when the Hits of the object reach zero the object will be permanently destroyed - gone, no repair, never to return. Use this with care. Any other setting of DestroyedItemID is fully reversable and will not lead to any permanent changes to the target.
You might want to apply this setting for objects like cannons to allow them to be actually destroyed.


How would one go about setting cannons and catapults destroyable for peranent descruction within their scripts so that when they're created this setting is already in place?  Or are they setup like that now (didn't get that take from this comment).  I'd prefer the objects used for fighting can be destroyed.  Thanks.

Anvil

you can call the xmlsiege constructor with an argument that sets the destroyeditemid.

QUOTE

public XmlSiege(int hitsmax, int resistfire, int resistphysical, int wood, int iron, int stone, int destroyeditemid)


so you would just modify this line in the constructors in siegecatapult.cs and siegecannon.cs like this

QUOTE

  [Constructable]
  public SiegeCatapult(int facing)
  {
  // addon the components
  for (int i = 0; i < CatapultNorth.Length; i++)
  {
    AddComponent(new SiegeComponent(0, Name), 0, 0, 0);
  }

  // assign the facing
  if (facing < 0) facing = 3;
  if (facing > 3) facing = 0;
  Facing = facing;

  // set the default props
  Name = "Siege Catapult";
  Weight = 50;

  // make them siegable by default
  // XmlSiege( hitsmax, resistfire, resistphysical, wood, iron, stone)
  // call the XmlSiege constructor with the DestroyedItemID arg with a value of 0
  // to have them deleted on destruction

  XmlAttach.AttachTo(this, new XmlSiege(100, 10, 10, 20, 30, 0, 0));

  // and draggable
  XmlAttach.AttachTo(this, new XmlDrag());

  // undo the temporary hue indicator that is set when the xmlsiege attachment is added
  Hue = 0;

  }

ArteGordon- 04-08-2006

To set up any object to automatically have the xmlsiege attachment attached whenever the object is added, such as houses or boats, you can just add an XmlAttach.AttachTo call into the constructor for whatever object class that you want to have automatically tagged with the xmlsiege attachment.

For example, to set it up so that all new houses are damageable you could make this change in BaseHouse.cs

CODE

 public BaseHouse( int multiID, Mobile owner, int MaxLockDown, int MaxSecure ) : base( multiID | 0x4000 )
 {
.
.
.

  // automatically add an xmlsiege attachment to this object
  XmlAttach.AttachTo(this, new XmlSiege());
 }


and then add this at the top of the script

CODE

using Server.Engines.XmlSpawner2;


also note that when you create the XmlSiege attachment with 'new XmlSiege()' you can also call the constructors that accept various arguments to set the number of hits, or the resistances, etc.

CODE

// add a siege attachment with 500 hits, 60% fire resistance, 20% physical resistance
  XmlAttach.AttachTo(this, new XmlSiege(500,60,20));