public string RocketLauncherImageOnAltFire(coItem thisobj, coPlayer obj, string slot)
            {
            int currentAmmo = ShapeBaseShapeBaseGetInventory(obj, (thisobj["ammo"]));
            if (currentAmmo < thisobj["loadCount"].AsInt())
                thisobj["loadCount"] = currentAmmo.AsString();
            coProjectile projectile = null;
            for (int shotCount = 0; shotCount < thisobj["loadCount"].AsInt(); shotCount++)
                {
                // Decrement inventory ammo. The image's ammo state is updated
                // automatically by the ammo inventory hooks.
                ShapeBaseShapeBaseDecInventory(obj, (thisobj["ammo"]), 1);
                // We fire our weapon using the straight ahead aiming point of the gun
                // We'll need to "skew" the projectile a little bit.  We start by getting
                // the straight ahead aiming point of the gun
                Point3F vec = obj.getMuzzleVector(slot.AsInt());
                Random r = new Random();
                TransformF matrix = new TransformF();
                matrix.MPosition.x = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                matrix.MPosition.y = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                matrix.MPosition.z = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                TransformF mat = math.MatrixCreateFromEuler(matrix);

                // Which we'll use to alter the projectile's initial vector with
                TransformF muzzleVector = math.MatrixMulVector(mat, vec);

                // Get the player's velocity, we'll then add it to that of the projectile
                TransformF objectVelocity = new TransformF(obj.getVelocity());

                muzzleVector = muzzleVector.vectorScale(thisobj["projectile.muzzleVelocity"].AsFloat());
                objectVelocity = objectVelocity.vectorScale(thisobj["projectile.velInheritFactor"].AsFloat());
                TransformF muzzleVelocity = muzzleVector + objectVelocity;

                Torque_Class_Helper tch = new Torque_Class_Helper(thisobj["projectileType"], "");
                tch.Props.Add("dataBlock", thisobj["projectile"]);
                tch.Props.Add("initialVelocity", '"' + muzzleVelocity.ToString() + '"');
                tch.Props.Add("initialPosition", '"' + obj.getMuzzlePoint(slot.AsInt()).AsString() + '"');
                tch.Props.Add("sourceObject", obj);
                tch.Props.Add("sourceSlot", slot);
                tch.Props.Add("client", obj["client"]);


                projectile = tch.Create();
                ((coSimSet) "MissionCleanup").pushToBack(projectile);
                }
            return projectile;
            }
Пример #2
0
        public void AmmoClipOnPickup(coItem thisobj, string obj, coPlayer shape, string amount, int nameSpaceDepth)
            {
            int nsd = nameSpaceDepth + 1;

            if (!console.ParentExecute(thisobj, "onPickup", nsd, new string[] { thisobj, obj, shape, amount }).AsBool())
                return;

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

            coItemData image = shape.getMountedImage(WeaponSlot);

            if (image == 0)
                return;

            if (!console.isField(image, "clip") || console.Call(string.Format("{0}.clip", image), "getID") != console.Call(thisobj, "getID"))
                return;

            bool outOfAmmo = !shape.getImageAmmo(WeaponSlot);

            int amountInClips = 0;

            int currentAmmo = ShapeBaseShapeBaseGetInventory(shape, image["ammo"]);

            if (console.isObject(image["clip"]))
                amountInClips = ShapeBaseShapeBaseGetInventory(shape, image["clip"]);

            int t = console.GetVarInt(string.Format("{0}.ammo.maxInventory", image));

            amountInClips *= t;

            int amountloadedingun = console.GetVarInt(string.Format("{0}.remaining{1}", obj, console.GetVarString(string.Format("{0}.ammo", this))));

            amountInClips += amountloadedingun;



            GameConnectionSetAmmoAmountHud(shape["client"], currentAmmo, amountInClips);

            if (outOfAmmo)
                console.Call(image, "onClipEmpty", new string[] { shape, WeaponSlot.AsString() });
            }
 public void RocketLauncherImageReadyLoad(coItem thisobj)
     {
     thisobj["loadCount"] = "1";
     }
 public void RocketLauncerincLoad(coItem thisobj)
     {
     thisobj["loadCount"] = (thisobj["loadCount"].AsInt() + 1).AsString();
     }
Пример #5
0
        public void ItemRespawn(coItem item)
            {
            // This method is used to respawn static ammo and weapon items
            // and is usually called when the item is picked up.
            // Instant fade...
            item.startFade(0, 0, true);
            item.setHidden(true);

            item.schedule(ItemRespawnTime.AsString(), "setHidden", "false");
            item.schedule((ItemRespawnTime + 100).AsString(), "startFade", "1000", "0", "false");
            }
Пример #6
0
 public void ItemschedulePop(coItem item)
     {
     // This method deletes the object after a default duration. Dynamic
     // items such as thrown or drop weapons are usually popped to avoid
     // world clutter.
     item.schedule((ItemPopTime - 1000).AsString(), "startFade", "1000", "0", "true");
     item.schedule(ItemPopTime.AsString(), "delete");
     }
Пример #7
0
        public void ServerCmdUse(coGameConnection client, coItem data)
            {
            if (((coPlayer)client.getControlObject()).isObject())
                ((coPlayer)client.getControlObject()).call("use", data);

            }
Пример #8
0
        public bool ItemDataOnPickUp(coItemData datablock, coItem item, coPlayer player, string amount)
            {
            int count = item["count"].AsInt();

            //string count = console.GetVarString(item + ".count");

            if (count == 0)
                {
                count = datablock["count"].AsInt();
                if (count == 0)
                    {
                    if (datablock["maxInventory"] != "")
                        {
                        if (count != datablock["maxInventory"].AsInt())
                            return false;
                        }
                    else
                        count = 1;
                    }
                }
            ShapeBaseShapeBaseIncInventory(player, (((coItemData)datablock).getName()), count);


            coGameConnection client = player["client"];
            if (client.isObject())
                MessageClient(client, "MsgItemPickup", console.ColorEncode(@"\c0You picked up %1"), datablock["pickupName"]);


            // If the item is a static respawn item, then go ahead and
            // respawn it, otherwise remove it from the world.
            // Anything not taken up by inventory is lost.

            if (item.isStatic())
                item.call("respawn");
            else
                item.delete();


            return true;
            }
Пример #9
0
        public void ShapeBaseShapeBaseThrowObject(coShapeBase thisobj, coItem obj)
            {
            // Throw the given object in the direction the shape is looking.
            // The force value is hardcoded according to the current default
            // object mass and mission gravity (20m/s^2).

            float throwforce = (( coSimDataBlock)thisobj.getDataBlock())["throwForce"].AsFloat();
            if (throwforce == 0)
                throwforce = 20;

            // Start with the shape's eye vector...

            Point3F eye = thisobj.getEyeVector();
            Point3F vec = eye.vectorScale(throwforce);

            // Add a vertical component to give the object a better arc
            double verticalForce = throwforce / 2.0;
            float dot = Point3F.vectorDot(new Point3F("0 0 1"), eye);
            if (dot < 0)
                dot = dot * -1;

            vec = vec + Point3F.vectorScale(new Point3F(string.Format("0 0 {0}", verticalForce)), 1 - dot);
            vec = vec + thisobj.getVelocity();

            // Set the object's position and initial velocity
            TransformF pos = new TransformF(Util.getBoxCenter(thisobj.getWorldBox()));

            obj.setTransform(pos);

            obj.applyImpulse(pos.MPosition, vec);

            // Since the object is thrown from the center of the shape,
            // the object needs to avoid colliding with it's thrower.

            obj.setCollisionTimeout(thisobj);


            if ((obj.getClassName() != "AITurretShape") && (obj.getClassName() != "ProximityMine"))

                obj.schedule(ItemPopTime.AsString(), "delete");
            }
Пример #10
0
 public string ShapeBaseDataShapeBaseDataOnPickup(coShapeBaseData thisobj, coItem obj, coPlayer user, int amount)
     {
     // Invoked when the user attempts to pickup this datablock object.
     // The %amount argument is the space in the user's inventory for
     // this type of datablock.  This method is responsible for
     // incrementing the user's inventory is something is addded.
     // Should return true if something was added to the inventory.
     return "0";
     }
Пример #11
0
 public string ShapeBaseShapeBaseOnInventory(coShapeBase thisobj, coItem data, string value)
     {
     // Invoked on ShapeBase objects whenever their inventory changes
     // for the given datablock.
     return "0";
     }
Пример #12
0
 public bool ShapeBaseShapeBaseHasAmmo(coShapeBase thisob, coItem weapon)
     {
     coItemData weaponimageammo = weapon["image.ammo"];
     if (weaponimageammo == "")
         return true;
     return ShapeBaseShapeBaseGetInventory(thisob, weaponimageammo) > 0;
     }
Пример #13
0
        public bool ShapeBaseShapeBasePickup(coShapeBase thisobj, coItem obj, int amount)
            {
            coItemData data = obj.getDataBlock();

            if (amount == 0)
                {
                int maxamount = ShapeBaseShapeBaseMaxInventory(thisobj, data);

                int curamount = ShapeBaseShapeBaseGetInventory(thisobj, data);

                amount = (maxamount - curamount);
                }

            if (amount > 0)
                return data.call("onPickUp", obj, thisobj, amount.AsString()).AsBool();

            return false;
            }