Exemplo n.º 1
0
        public InventoryObjectItem GetAmmoFor(InventoryObjectItem wpn)
        {
            VBWeaponItemType asWeapon = wpn.ItemType as VBWeaponItemType;

            if (asWeapon == null)
            {
                return(null);
            }

            foreach (InventoryObject.InventoryObjectItem itm in Inventory)
            {
                AmmoItemType amType = itm.ItemType as AmmoItemType;
                if (amType != null && asWeapon.UsableAmmoList.Contains(amType))
                {
                    return(itm);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public virtual void TryReload()
        {
            if (Owner.Intellect.InCombatAndActive() && !Owner.Intellect.HasActionPoints(GetCurActionMode().ActionPoints))
            {
                return;
            }

            if (CanReload())
            {
                foreach (InventoryObject.InventoryObjectItem itm in Owner.Inventory)
                {
                    AmmoItemType amType = itm.ItemType as AmmoItemType;
                    if (amType != null && Type.UsableAmmoList.Contains(amType))
                    {
                        ActionMode = Type.ActionModes.IndexOf(GetActionMode("reload"));

                        if (Juice + itm.Juice > Type.MaxJuice)
                        {
                            int juiceToAdd = Type.MaxJuice - Juice;

                            Juice     += juiceToAdd;
                            itm.Juice -= juiceToAdd;
                        }
                        else
                        {
                            Juice    += itm.Juice;
                            itm.Juice = 0;
                            Owner.DropItem(itm);
                        }

                        AmmoTypeLoaded = amType;
                        SoundPlay3D(GetCurActionMode().PlaySound, .5f, true);
                        IncActMode();
                        Owner.Intellect.IncActionPts(-GetCurActionMode().ActionPoints);
                        break;
                    }
                }
            }
        }