Example #1
0
        /// <summary>
        /// Copy a piece of Gear.
        /// </summary>
        /// <param name="objGear">Gear object to copy.</param>
        /// <param name="objNode">TreeNode created by copying the item.</param>
        /// <param name="objWeapons">List of Weapons created by copying the item.</param>
        /// <param name="objWeaponNodes">List of Weapon TreeNodes created by copying the item.</param>
        public void Copy(Commlink objGear, TreeNode objNode, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes)
        {
            _strName = objGear.Name;
            _strCategory = objGear.Category;
            _intMaxRating = objGear.MaxRating;
            _intMinRating = objGear.MinRating;
            _intRating = objGear.Rating;
            _intQty = objGear.Quantity;
            _strCapacity = objGear.Capacity;
            _strArmorCapacity = objGear.ArmorCapacity;
            _strAvail = objGear.Avail;
            _strAvail3 = objGear.Avail3;
            _strAvail6 = objGear.Avail6;
            _strAvail10 = objGear.Avail10;
            _intCostFor = objGear.CostFor;
            _strOverclocked = objGear.Overclocked;
            _intDeviceRating = objGear.DeviceRating;
            _intAttack = objGear.Attack;
            _intDataProcessing = objGear.DataProcessing;
            _intFirewall = objGear.Firewall;
            _intSleaze = objGear.Sleaze;
            _strCost = objGear.Cost;
            _strCost3 = objGear.Cost3;
            _strCost6 = objGear.Cost6;
            _strCost10 = objGear.Cost10;
            _strSource = objGear.Source;
            _strPage = objGear.Page;
            _strExtra = objGear.Extra;
            _blnBonded = objGear.Bonded;
            _blnEquipped = objGear.Equipped;
            _blnHomeNode = objGear.HomeNode;
            _nodBonus = objGear.Bonus;
            _nodWeaponBonus = objGear.WeaponBonus;
            _guiWeaponID = Guid.Parse(objGear.WeaponID);
            _strNotes = objGear.Notes;
            _strLocation = objGear.Location;

            objNode.Text = DisplayName;
            objNode.Tag = _guiID.ToString();

            foreach (Gear objGearChild in objGear.Children)
            {
                TreeNode objChildNode = new TreeNode();
                Gear objChild = new Gear(_objCharacter);
                if (objGearChild.GetType() == typeof(Commlink))
                {
                    Commlink objCommlink = new Commlink(_objCharacter);
                    objCommlink.Copy(objGearChild, objChildNode, objWeapons, objWeaponNodes);
                    objChild = objCommlink;
                }
                else
                    objChild.Copy(objGearChild, objChildNode, objWeapons, objWeaponNodes);
                _objChildren.Add(objChild);

                objNode.Nodes.Add(objChildNode);
                objNode.Expand();
            }
        }
Example #2
0
        private void cmdReloadWeapon_Click(object sender, EventArgs e)
        {
            List<Gear> lstAmmo = new List<Gear>();
            List<string> lstCount = new List<string>();
            bool blnExternalSource = false;

            Gear objExternalSource = new Gear(_objCharacter);
            objExternalSource.Name = "External Source";

            // Locate the selected Weapon.
            Weapon objWeapon = new Weapon(_objCharacter);
            foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
            {
                if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                {
                    objWeapon = objCharacterWeapon;
                    break;
                }
                if (objCharacterWeapon.UnderbarrelWeapons.Count > 0)
                {
                    foreach (Weapon objUnderbarrelWeapon in objCharacterWeapon.UnderbarrelWeapons)
                    {
                        if (objUnderbarrelWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                        {
                            objWeapon = objUnderbarrelWeapon;
                            break;
                        }
                    }
                }
            }

            string ammoString = objWeapon.CalculatedAmmo(true);
            // Determine which loading methods are available to the Weapon.
            if (ammoString.Contains(" or ") || ammoString.Contains("x") || ammoString.Contains("Special") || ammoString.Contains("+"))
            {
                string strWeaponAmmo = ammoString.ToLower();
                if (strWeaponAmmo.Contains("external source"))
                    blnExternalSource = true;
                // Get rid of external source, special, or belt, and + energy.
                strWeaponAmmo = strWeaponAmmo.Replace("external source", "100");
                strWeaponAmmo = strWeaponAmmo.Replace("special", "100");
                strWeaponAmmo = strWeaponAmmo.Replace(" + energy", "");
                strWeaponAmmo = strWeaponAmmo.Replace(" or belt", " or 250(belt)");

                string[] strAmmos = strWeaponAmmo.Split( new []{" or "}, StringSplitOptions.RemoveEmptyEntries);

                foreach (string strAmmo in strAmmos)
                {
                    string strThisAmmo = strAmmo;
                    if (strThisAmmo.StartsWith("2x") || strThisAmmo.StartsWith("3x") || strThisAmmo.StartsWith("4x"))
                        strThisAmmo = strThisAmmo.Substring(2, strThisAmmo.Length - 2);
                    if (strThisAmmo.EndsWith("x2") || strThisAmmo.EndsWith("x3") || strThisAmmo.EndsWith("x4"))
                        strThisAmmo = strThisAmmo.Substring(0, strThisAmmo.Length - 2);

                    if (strThisAmmo.Contains("("))
                        strThisAmmo = strThisAmmo.Substring(0, strThisAmmo.IndexOf("("));

                    lstCount.Add(strThisAmmo);
                }
            }
            else
            {
                // Nothing weird in the ammo string, so just use the number given.
                string strAmmo = ammoString;
                if (strAmmo.Contains("("))
                    strAmmo = strAmmo.Substring(0, strAmmo.IndexOf("("));
                lstCount.Add(strAmmo);
            }

            // Find all of the Ammo for the current Weapon that the character is carrying.
            if (objWeapon.AmmoCategory != "Grenade Launchers" && objWeapon.AmmoCategory != "Missile Launchers" && objWeapon.AmmoCategory != "Mortar Launchers")
            {
                // This is a standard Weapon, so consume traditional Ammunition.
                foreach (Gear objAmmo in _objCharacter.Gear)
                {
                    if (objAmmo.Quantity > 0)
                    {
                        if (objAmmo.Category == "Ammunition" && objAmmo.Extra == objWeapon.AmmoCategory)
                            lstAmmo.Add(objAmmo);
                    }
                    foreach (Gear objChild in objAmmo.Children)
                    {
                        if (objChild.Quantity > 0)
                        {
                            if (objChild.Category == "Ammunition" && objChild.Extra == objWeapon.AmmoCategory)
                                lstAmmo.Add(objChild);
                        }
                    }
                }
            }
            else
            {
                if (objWeapon.AmmoCategory == "Grenade Launchers")
                {
                    // Grenade Launchers can only use Grenades.
                    foreach (Gear objAmmo in _objCharacter.Gear)
                    {
                        if (objAmmo.Quantity > 0)
                        {
                            if (objAmmo.Category == "Ammunition" && objAmmo.Name.StartsWith("Minigrenade:"))
                                lstAmmo.Add(objAmmo);
                        }
                        foreach (Gear objChild in objAmmo.Children)
                        {
                            if (objChild.Quantity > 0)
                            {
                                if (objChild.Category == "Ammunition" && objChild.Name.StartsWith("Minigrenade:"))
                                    lstAmmo.Add(objChild);
                            }
                        }
                    }
                }
                if (objWeapon.AmmoCategory == "Missile Launchers")
                {
                    // Missile Launchers can only use Missiles and Rockets.
                    foreach (Gear objAmmo in _objCharacter.Gear)
                    {
                        if (objAmmo.Quantity > 0)
                        {
                            if (objAmmo.Category == "Ammunition" && (objAmmo.Name.StartsWith("Missile:") || objAmmo.Name.StartsWith("Rocket:")))
                                lstAmmo.Add(objAmmo);
                        }
                        foreach (Gear objChild in objAmmo.Children)
                        {
                            if (objChild.Quantity > 0)
                            {
                                if (objChild.Category == "Ammunition" && (objChild.Name.StartsWith("Missile:") || objChild.Name.StartsWith("Rocket:")))
                                    lstAmmo.Add(objChild);
                            }
                        }
                    }
                }
                if (objWeapon.AmmoCategory == "Mortar Launchers")
                {
                    // Mortar Launchers can only use Mortars.
                    foreach (Gear objAmmo in _objCharacter.Gear)
                    {
                        if (objAmmo.Quantity > 0)
                        {
                            if (objAmmo.Category == "Ammunition" && objAmmo.Name.StartsWith("Mortar Round:"))
                                lstAmmo.Add(objAmmo);
                        }
                        foreach (Gear objChild in objAmmo.Children)
                        {
                            if (objChild.Quantity > 0)
                            {
                                if (objChild.Category == "Ammunition" && objChild.Name.StartsWith("Mortar Round:"))
                                    lstAmmo.Add(objChild);
                            }
                        }
                    }
                }
            }

            // If the Weapon is allowed to use an External Source, put in an External Source item.
            if (blnExternalSource)
                lstAmmo.Add(objExternalSource);

            // Make sure the character has some form of Ammunition for this Weapon.
            if (lstAmmo.Count == 0 && objWeapon.RequireAmmo)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_OutOfAmmoType").Replace("{0}", objWeapon.DisplayAmmoCategory), LanguageManager.Instance.GetString("MessageTitle_OutOfAmmo"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (!objWeapon.RequireAmmo)
            {
                // If the Weapon does not require Ammo, clear the Ammo list and just use External Source.
                lstAmmo.Clear();
                lstAmmo.Add(objExternalSource);
            }

            // Show the Ammunition Selection window.
            frmReload frmReloadWeapon = new frmReload();
            frmReloadWeapon.Ammo = lstAmmo;
            frmReloadWeapon.Count = lstCount;
            frmReloadWeapon.ShowDialog(this);

            if (frmReloadWeapon.DialogResult == DialogResult.Cancel)
                return;

            // Return any unspent rounds to the Ammo.
            if (objWeapon.AmmoRemaining > 0)
            {
                bool blnBreak = false;
                foreach (Gear objAmmo in _objCharacter.Gear)
                {
                    if (objAmmo.InternalId == objWeapon.AmmoLoaded)
                    {
                        objAmmo.Quantity += objWeapon.AmmoRemaining;

                        // Refresh the Gear tree.
                        foreach (TreeNode objNode in treGear.Nodes[0].Nodes)
                        {
                            if (objAmmo.InternalId == objNode.Tag.ToString())
                            {
                                objNode.Text = objAmmo.DisplayName;
                                break;
                            }
                        }

                        break;
                    }
                    foreach (Gear objChild in objAmmo.Children)
                    {
                        if (objChild.InternalId == objWeapon.AmmoLoaded)
                        {
                            // If this is a plugin for a Spare Clip, move any extra rounds to the character instead of messing with the Clip amount.
                            if (objChild.Parent.Name.StartsWith("Spare Clip") || objChild.Parent.Name.StartsWith("Speed Loader"))
                            {
                                TreeNode objNewNode = new TreeNode();
                                List<Weapon> lstWeapons = new List<Weapon>();
                                List<TreeNode> lstWeaponNodes = new List<TreeNode>();
                                Gear objNewGear = new Gear(_objCharacter);
                                objNewGear.Copy(objChild, objNewNode, lstWeapons, lstWeaponNodes);
                                objNewGear.Quantity = objWeapon.AmmoRemaining;
                                objNewNode.Text = objNewGear.DisplayName;
                                _objCharacter.Gear.Add(objNewGear);
                                treGear.Nodes[0].Nodes.Add(objNewNode);
                                blnBreak = true;
                                break;
                            }
                            else
                                objChild.Quantity += objWeapon.AmmoRemaining;

                            // Refresh the Gear tree.
                            foreach (TreeNode objNode in treGear.Nodes[0].Nodes)
                            {
                                foreach (TreeNode objChildNode in objNode.Nodes)
                                {
                                    if (objChild.InternalId == objChildNode.Tag.ToString())
                                    {
                                        objChildNode.Text = objChild.DisplayName;
                                        break;
                                    }
                                }
                            }
                            break;
                        }
                    }
                    if (blnBreak)
                        break;
                }
            }

            Gear objSelectedAmmo = new Gear(_objCharacter);
            int intQty = frmReloadWeapon.SelectedCount;
            // If an External Source is not being used, consume ammo.
            if (frmReloadWeapon.SelectedAmmo != objExternalSource.InternalId)
            {
                foreach (Gear objGear in _objCharacter.Gear)
                {
                    if (objGear.InternalId == frmReloadWeapon.SelectedAmmo)
                    {
                        objSelectedAmmo = objGear;
                        break;
                    }
                    foreach (Gear objChild in objGear.Children)
                    {
                        if (objChild.InternalId == frmReloadWeapon.SelectedAmmo)
                        {
                            objSelectedAmmo = objChild;
                            break;
                        }
                    }
                }

                if (objSelectedAmmo.Quantity == intQty && objSelectedAmmo.Parent != null)
                {
                    // If the Ammo is coming from a Spare Clip, reduce the container quantity instead of the plugin quantity.
                    if (objSelectedAmmo.Parent.Name.StartsWith("Spare Clip") || objSelectedAmmo.Parent.Name.StartsWith("Speed Loader"))
                    {
                        if (objSelectedAmmo.Parent.Quantity > 0)
                            objSelectedAmmo.Parent.Quantity--;
                        TreeNode objNode = _objFunctions.FindNode(objSelectedAmmo.Parent.InternalId, treGear);
                        objNode.Text = objSelectedAmmo.Parent.DisplayName;
                    }
                }
                else
                {
                    // Deduct the ammo qty from the ammo. If there isn't enough remaining, use whatever is left.
                    if (objSelectedAmmo.Quantity > intQty)
                        objSelectedAmmo.Quantity -= intQty;
                    else
                    {
                        intQty = objSelectedAmmo.Quantity;
                        objSelectedAmmo.Quantity = 0;
                    }
                }

                // Refresh the Gear tree.
                foreach (TreeNode objNode in treGear.Nodes[0].Nodes)
                {
                    if (objSelectedAmmo.InternalId == objNode.Tag.ToString())
                    {
                        objNode.Text = objSelectedAmmo.DisplayName;
                        break;
                    }
                    foreach (TreeNode objChildNode in objNode.Nodes)
                    {
                        if (objSelectedAmmo.InternalId == objChildNode.Tag.ToString())
                        {
                            objChildNode.Text = objSelectedAmmo.DisplayName;
                            break;
                        }
                    }
                }
            }
            else
            {
                objSelectedAmmo = objExternalSource;
            }

            objWeapon.AmmoRemaining = intQty;
            objWeapon.AmmoLoaded = objSelectedAmmo.InternalId;
            lblWeaponAmmoRemaining.Text = intQty.ToString();

            RefreshSelectedWeapon();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Example #3
0
        private void cmdGearMoveToVehicle_Click(object sender, EventArgs e)
        {
            frmSelectItem frmPickItem = new frmSelectItem();
            frmPickItem.Vehicles = _objCharacter.Vehicles;
            frmPickItem.ShowDialog(this);

            if (frmPickItem.DialogResult == DialogResult.Cancel)
                return;

            // Locate the selected Vehicle.
            Vehicle objVehicle = new Vehicle(_objCharacter);
            foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
            {
                if (objCharacterVehicle.InternalId == frmPickItem.SelectedItem)
                {
                    objVehicle = objCharacterVehicle;
                    break;
                }
            }

            Gear objSelectedGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
            int intMove = 0;
            if (objSelectedGear.Quantity == 1)
                intMove = 1;
            else
            {
                frmSelectNumber frmPickNumber = new frmSelectNumber();
                frmPickNumber.Minimum = 1;
                frmPickNumber.Maximum = objSelectedGear.Quantity;
                frmPickNumber.Description = LanguageManager.Instance.GetString("String_MoveGear");
                frmPickNumber.ShowDialog(this);

                if (frmPickNumber.DialogResult == DialogResult.Cancel)
                    return;

                intMove = frmPickNumber.SelectedValue;
            }

            // See if the Vehicle already has a matching piece of Gear.
            bool blnMatch = false;
            Gear objFoundGear = new Gear(_objCharacter);
            foreach (Gear objVehicleGear in objVehicle.Gear)
            {
                if (objVehicleGear.Name == objSelectedGear.Name && objVehicleGear.Category == objSelectedGear.Category && objVehicleGear.Rating == objSelectedGear.Rating && objVehicleGear.Extra == objSelectedGear.Extra && objVehicleGear.GearName == objSelectedGear.GearName && objVehicleGear.Notes == objSelectedGear.Notes)
                {
                    blnMatch = true;
                    objFoundGear = objVehicleGear;
                    if (objVehicleGear.Children.Count == objSelectedGear.Children.Count)
                    {
                        for (int i = 0; i <= objVehicleGear.Children.Count - 1; i++)
                        {
                            if (objVehicleGear.Children[i].Name != objSelectedGear.Children[i].Name || objVehicleGear.Children[i].Extra != objSelectedGear.Children[i].Extra || objVehicleGear.Children[i].Rating != objSelectedGear.Children[i].Rating)
                            {
                                blnMatch = false;
                                break;
                            }
                        }
                    }
                    else
                        blnMatch = false;
                }
            }

            if (!blnMatch)
            {
                // Create a new piece of Gear.
                TreeNode objGearNode = new TreeNode();
                List<Weapon> lstWeapons = new List<Weapon>();
                List<TreeNode> lstWeaponNodes = new List<TreeNode>();
                Gear objGear = new Gear(_objCharacter);
                if (objSelectedGear.GetType() == typeof(Commlink))
                {
                    Commlink objCommlink = new Commlink(_objCharacter);
                    objCommlink.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
                    objGear = objCommlink;
                }
                else
                    objGear.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);

                objGear.Parent = null;
                objGear.Quantity = intMove;
                objGear.Location = string.Empty;
                objGearNode.Text = objGear.DisplayName;
                objGearNode.ContextMenuStrip = cmsVehicleGear;

                // Locate the Node for the selected Vehicle.
                TreeNode nodParent = new TreeNode();
                foreach (TreeNode nodNode in treVehicles.Nodes[0].Nodes)
                {
                    if (nodNode.Tag.ToString() == objVehicle.InternalId)
                    {
                        nodParent = nodNode;
                        break;
                    }
                }

                nodParent.Nodes.Add(objGearNode);
                objVehicle.Gear.Add(objGear);
            }
            else
            {
                // Everything matches up, so just increase the quantity.
                objFoundGear.Quantity += intMove;
                foreach (TreeNode nodVehicle in treVehicles.Nodes[0].Nodes)
                {
                    if (nodVehicle.Tag.ToString() == objVehicle.InternalId)
                    {
                        foreach (TreeNode nodGear in nodVehicle.Nodes)
                        {
                            if (nodGear.Tag.ToString() == objFoundGear.InternalId)
                                nodGear.Text = objFoundGear.DisplayName;
                        }
                    }
                }
            }

            // Update the selected item.
            objSelectedGear.Quantity -= intMove;
            if (objSelectedGear.Quantity == 0)
            {
                if (objSelectedGear.Parent != null)
                    objSelectedGear.Parent.Children.Remove(objSelectedGear);
                else
                    _objCharacter.Gear.Remove(objSelectedGear);
                _objFunctions.DeleteGear(objSelectedGear, treWeapons, _objImprovementManager);
                treGear.SelectedNode.Remove();
                UpdateCharacterInfo();
            }
            else
            {
                treGear.SelectedNode.Text = objSelectedGear.DisplayName;
            }

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Example #4
0
        private void cmdGearSplitQty_Click(object sender, EventArgs e)
        {
            // This can only be done with the first level of Nodes.
            try
            {
                if (treGear.SelectedNode.Level != 1)
                    return;
            }
            catch
            {
                return;
            }

            Gear objSelectedGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);

            // Cannot split a stack of 1 item.
            if (objSelectedGear.Quantity == 1)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotSplitGear"), LanguageManager.Instance.GetString("MessageTitle_CannotSplitGear"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            frmSelectNumber frmPickNumber = new frmSelectNumber();
            frmPickNumber.Minimum = 1;
            frmPickNumber.Maximum = objSelectedGear.Quantity - 1;
            frmPickNumber.Description = LanguageManager.Instance.GetString("String_SplitGear");
            frmPickNumber.ShowDialog(this);

            if (frmPickNumber.DialogResult == DialogResult.Cancel)
                return;

            // Create a new piece of Gear.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
            XmlNode objNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSelectedGear.Name + "\" and category = \"" + objSelectedGear.Category + "\"]");

            TreeNode objGearNode = new TreeNode();
            List<Weapon> lstWeapons = new List<Weapon>();
            List<TreeNode> lstWeaponNodes = new List<TreeNode>();
            Gear objGear = new Gear(_objCharacter);
            if (objSelectedGear.GetType() == typeof(Commlink))
            {
                Commlink objCommlink = new Commlink(_objCharacter);
                objCommlink.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
                objGear = objCommlink;
            }
            else
                objGear.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);

            objGear.Quantity = frmPickNumber.SelectedValue;
            objGear.Equipped = objSelectedGear.Equipped;
            objGear.Location = objSelectedGear.Location;
            objGear.Notes = objSelectedGear.Notes;
            objGearNode.Text = objGear.DisplayName;
            objGearNode.ContextMenuStrip = treGear.SelectedNode.ContextMenuStrip;

            // Update the selected item.
            objSelectedGear.Quantity -= frmPickNumber.SelectedValue;
            treGear.SelectedNode.Text = objSelectedGear.DisplayName;

            treGear.SelectedNode.Parent.Nodes.Add(objGearNode);
            _objCharacter.Gear.Add(objGear);

            // Create any Weapons that came with this Gear.
            foreach (Weapon objWeapon in lstWeapons)
                _objCharacter.Weapons.Add(objWeapon);

            foreach (TreeNode objWeaponNode in lstWeaponNodes)
            {
                objWeaponNode.ContextMenuStrip = cmsWeapon;
                treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                treWeapons.Nodes[0].Expand();
            }

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Example #5
0
        private void cmdVehicleMoveToInventory_Click(object sender, EventArgs e)
        {
            // Locate the selected Weapon.
            bool blnFound = false;
            Weapon objWeapon = new Weapon(_objCharacter);
            Vehicle objVehicle = new Vehicle(_objCharacter);
            VehicleMod objMod = new VehicleMod(_objCharacter);

            foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
            {
                foreach (Weapon objVehicleWeapon in objCharacterVehicle.Weapons)
                {
                    if (objVehicleWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
                    {
                        objWeapon = objVehicleWeapon;
                        objVehicle = objCharacterVehicle;
                        blnFound = true;
                        break;
                    }
                }
                foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
                {
                    foreach (Weapon objVehicleWeapon in objVehicleMod.Weapons)
                    {
                        if (objVehicleWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            objWeapon = objVehicleWeapon;
                            objVehicle = objCharacterVehicle;
                            objMod = objVehicleMod;
                            blnFound = true;
                            break;
                        }
                    }
                }
            }

            if (blnFound){
                // Move the Weapons from the Vehicle Mod (or Vehicle) to the character.
                if (objMod.InternalId != Guid.Empty.ToString())
                    objMod.Weapons.Remove(objWeapon);
                else
                    objVehicle.Weapons.Remove(objWeapon);

                _objCharacter.Weapons.Add(objWeapon);

                TreeNode objNode = new TreeNode();
                objNode = treVehicles.SelectedNode;

                treVehicles.SelectedNode.Remove();
                treWeapons.Nodes[0].Nodes.Add(objNode);
                objWeapon.VehicleMounted = false;
                objNode.Expand();
            }
            else
            {
                // Locate the selected Gear.
                Vehicle objSelectedVehicle = new Vehicle(_objCharacter);
                Gear objSelectedGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objSelectedVehicle);

                int intMove = 0;
                if (objSelectedGear.Quantity == 1)
                    intMove = 1;
                else
                {
                    frmSelectNumber frmPickNumber = new frmSelectNumber();
                    frmPickNumber.Minimum = 1;
                    frmPickNumber.Maximum = objSelectedGear.Quantity;
                    frmPickNumber.Description = LanguageManager.Instance.GetString("String_MoveGear");
                    frmPickNumber.ShowDialog(this);

                    if (frmPickNumber.DialogResult == DialogResult.Cancel)
                        return;

                    intMove = frmPickNumber.SelectedValue;
                }

                // See if the character already has a matching piece of Gear.
                bool blnMatch = false;
                Gear objFoundGear = new Gear(_objCharacter);
                foreach (Gear objCharacterGear in _objCharacter.Gear)
                {
                    if (objCharacterGear.Name == objSelectedGear.Name && objCharacterGear.Category == objSelectedGear.Category && objCharacterGear.Rating == objSelectedGear.Rating && objCharacterGear.Extra == objSelectedGear.Extra && objCharacterGear.GearName == objSelectedGear.GearName && objCharacterGear.Notes == objSelectedGear.Notes)
                    {
                        blnMatch = true;
                        objFoundGear = objCharacterGear;
                        if (objCharacterGear.Children.Count == objSelectedGear.Children.Count)
                        {
                            for (int i = 0; i <= objCharacterGear.Children.Count - 1; i++)
                            {
                                if (objCharacterGear.Children[i].Name != objSelectedGear.Children[i].Name || objCharacterGear.Children[i].Extra != objSelectedGear.Children[i].Extra || objCharacterGear.Children[i].Rating != objSelectedGear.Children[i].Rating)
                                {
                                    blnMatch = false;
                                    break;
                                }
                            }
                        }
                        else
                            blnMatch = false;
                    }
                }

                if (!blnMatch)
                {
                    // Create a new piece of Gear.
                    TreeNode objGearNode = new TreeNode();
                    List<Weapon> lstWeapons = new List<Weapon>();
                    List<TreeNode> lstWeaponNodes = new List<TreeNode>();
                    Gear objGear = new Gear(_objCharacter);
                    if (objSelectedGear.GetType() == typeof(Commlink))
                    {
                        Commlink objCommlink = new Commlink(_objCharacter);
                        objCommlink.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
                        objGear = objCommlink;
                    }
                    else
                        objGear.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);

                    objGear.Parent = null;
                    objGear.Quantity = intMove;
                    objGearNode.Text = objGear.DisplayName;
                    objGearNode.ContextMenuStrip = cmsGear;

                    treGear.Nodes[0].Nodes.Add(objGearNode);
                    _objCharacter.Gear.Add(objGear);

                    // Create any Weapons that came with this Gear.
                    foreach (Weapon objGearWeapon in lstWeapons)
                        _objCharacter.Weapons.Add(objGearWeapon);

                    foreach (TreeNode objWeaponNode in lstWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }

                    AddGearImprovements(objGear);
                    UpdateCharacterInfo();
                }
                else
                {
                    // Everything matches up, so just increase the quantity.
                    objFoundGear.Quantity += intMove;
                    foreach (TreeNode nodGear in treGear.Nodes[0].Nodes)
                    {
                        if (nodGear.Tag.ToString() == objFoundGear.InternalId)
                            nodGear.Text = objFoundGear.DisplayName;
                    }
                }

                // Update the selected item.
                objSelectedGear.Quantity -= intMove;
                if (objSelectedGear.Quantity == 0)
                {
                    // The quantity has reached 0, so remove it entirely.
                    treVehicles.SelectedNode.Remove();
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                        objCharacterVehicle.Gear.Remove(objSelectedGear);
                }
                else
                    treVehicles.SelectedNode.Text = objSelectedGear.DisplayName;
            }

            _blnIsDirty = true;
            UpdateWindowTitle();
        }