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);
        }
Ejemplo n.º 2
0
        public virtual void setOrbitMode(GameBase orbitObject, TransformF mat, float minDistance, float maxDistance, float curDistance, bool ownClientObject)
        {
            List <string> tmp_arg_list = new List <string> {
                "", ""
            };

            tmp_arg_list.Add(orbitObject.getId().ToString());
            tmp_arg_list.Add(mat.ToString());
            tmp_arg_list.Add(minDistance.ToString());
            tmp_arg_list.Add(maxDistance.ToString());
            tmp_arg_list.Add(curDistance.ToString());
            tmp_arg_list.Add(ownClientObject.ToString());
            InternalUnsafeMethods.setOrbitMode(ObjectPtr, tmp_arg_list.Count, tmp_arg_list.ToArray());
        }