Exemplo n.º 1
0
        public void WeaponImageReloadAmmoClip(coItemData thisobj, coShapeBase obj, int slot)
            {
            string ammoname = ((coItemData)thisobj["ammo"]).getName();

            if (thisobj != obj.getMountedImage(slot))
                return;

            if (!thisobj.isField("clip"))
                return;
            if (ShapeBaseShapeBaseGetInventory(obj, thisobj["clip"]) > 0)
                {
                ShapeBaseShapeBaseDecInventory(obj, thisobj["clip"], 1);

                ShapeBaseShapeBaseSetInventory(obj, thisobj["ammo"], thisobj["ammo.maxInventory"].AsInt());

                obj.setImageAmmo(slot, true);
                }
            else
                {
                int amountInPocket = obj["remaining" + ((coItem)thisobj["ammo"]).getName()].AsInt();
                if (amountInPocket > 0)
                    {
                    obj["remaining" + ((coItem)thisobj["ammo"]).getName()] = "0";

                    ShapeBaseShapeBaseSetInventory(obj, thisobj["ammo"], amountInPocket);
                    obj.setImageAmmo(slot, true);
                    }
                }
            }
Exemplo n.º 2
0
        public void ShapeBaseCycleWeapon(coShapeBase thisobj, string direction)
            {
            //I sure seem to retrieve "thisobj.totalCycledWeapons" alot,
            //So to save so work, I'm just gonna grab it here.
            int totalCycledWeapons = thisobj["totalCycledWeapons"].AsInt();


            // Can't cycle what we don't have
            if (totalCycledWeapons == 0)
                return;
            // Find out the index of the current weapon, if any (not all
            // available weapons may be part of the cycle)
            int currentIndex = -1;


            coItemData mountedimage = thisobj.getMountedImage(WeaponSlot);

            if (mountedimage.isObject())
                {
                string curWeapon = mountedimage["item"];
                for (int i = 0; i < totalCycledWeapons; i++)
                    {
                    if (thisobj["cycleWeapon[" + i + "]"] != curWeapon)
                        continue;
                    currentIndex = i;
                    break;
                    }
                }



            int nextIndex = 0;
            int dir = 1;
            if (currentIndex != -1)
                {
                if (direction == "prev")
                    {
                    dir = -1;
                    nextIndex = currentIndex - 1;
                    if (nextIndex < 0)
                        {
                        nextIndex = totalCycledWeapons - 1;
                        }
                    }
                else
                    {
                    nextIndex = currentIndex + 1;
                    if (nextIndex >= totalCycledWeapons)
                        {
                        nextIndex = 0;
                        }
                    }
                }
            bool found = false;
            coItemData weapon = null;
            for (int i = 0; i < totalCycledWeapons; i++)
                {
                weapon = thisobj["cycleWeapon[" + i + "]"];
                if ((weapon != 0) && (ShapeBaseShapeBaseHasInventory(thisobj, weapon)))
                    {
                    found = true;
                    break;
                    }
                nextIndex = nextIndex + dir;
                if (nextIndex < 0)
                    nextIndex = totalCycledWeapons - 1;
                else if (nextIndex >= totalCycledWeapons)
                    nextIndex = 0;
                }
            if (!found)
                return;
            weapon = thisobj["cycleWeapon[" + nextIndex + "]"];
            ShapeBaseShapeBaseUse(thisobj, weapon);
            }
Exemplo n.º 3
0
        public void WeaponOnPickup(coScriptObject thisobj, string obj, coShapeBase shape, int amount, int nameSpaceDepth)
            {
            int nsd = (nameSpaceDepth + 1);
            if (!console.ParentExecute(thisobj, "onPickup", nsd, new string[] { thisobj, obj, shape, amount.AsString() }).AsBool())
                return;


            AudioServerPlay3D("WeaponPickupSound", shape.getTransform());

            if (shape.getClassName() == "Player" && shape.getMountedImage(WeaponSlot) == 0)
                shape.call("use", thisobj);
            }