Ejemplo n.º 1
0
        public void WeaponOnUser(coScriptObject data, coPlayer obj)
            {
            if (obj.getMountedImage(WeaponSlot) == data["image"].AsInt())
                return;

            AudioServerPlay3D("WeaponUseSound", obj.getTransform());


            obj.mountImage(data["image"], WeaponSlot, true, "");

            if (obj["client"].AsBool())
                {
                if (data["description"] != "")

                    MessageClient(obj["client"], "MsgWeaponUsed", "\\c3%1 \\c5 selected.", data["description"]);
                else
                    MessageClient(obj["client"], "MsgWeaponUsed", console.addTaggedString(@"\c0Weapon selected"));
                }

            if (obj.isInNamespaceHierarchy("Player"))
                return;

            obj.allowAllPoses();
            coSimObject image = data["image"];

            if (image["jumpingDisallowed"].AsBool())
                obj.allowJumping(false);

            if (image["jetJumpingDisallowed"].AsBool())
                obj.allowJetJumping(false);

            if (image["sprintDisallowed"].AsBool())
                obj.allowSprinting(false);

            if (image["crouchDisallowed"].AsBool())
                obj.allowCrouching(false);

            if (image["proneDisallowed"].AsBool())
                obj.allowProne(false);

            if (image["swimmingDisallowed"].AsBool())
                obj.allowSwimming(false);
            }
Ejemplo n.º 2
0
 public void WeaponImageOnClipEmpty(coScriptObject thisobj, coPlayer obj, int slot)
     {
     thisobj.schedule("0", "reloadAmmoClip", obj, slot.AsString());
     }
Ejemplo n.º 3
0
        public void WeaponImageonWetFire(coScriptObject thisobj, coPlayer obj, int slot)
            {
            if (!thisobj["projectile"].isObject())
                {
                console.error("WeaponImage::onFire() - Invalid projectile datablock");
                return;
                }
            // Decrement inventory ammo. The image's ammo state is updated
            // automatically by the ammo inventory hooks.
            if (!thisobj["infiniteAmmo"].AsBool())
                ShapeBaseShapeBaseDecInventory(obj, thisobj["ammo"], 1);

            // Get the player's velocity, we'll then add it to that of the projectile
            int numProjectiles = thisobj["projectileNum"].AsInt();
            if (numProjectiles == 0)
                numProjectiles = 1;
            TransformF muzzleVector = new TransformF();

            for (int i = 0; i < numProjectiles; i++)
                {
                if (thisobj["wetProjectileSpread"].AsBool())
                    {
                    // We'll need to "skew" this projectile a little bit.  We start by
                    // getting the straight ahead aiming point of the gun
                    Point3F vec = obj.getMuzzleVector(slot);
                    // Then we'll create a spread matrix by randomly generating x, y, and z
                    // points in a circle
                    Random r = new Random();
                    TransformF matrix = new TransformF();
                    matrix.MPosition.x = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat());
                    matrix.MPosition.y = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat());
                    matrix.MPosition.z = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat());
                    TransformF mat = math.MatrixCreateFromEuler(matrix);

                    muzzleVector = math.MatrixMulVector(mat, vec);
                    }
                else
                    {
                    muzzleVector = new TransformF(obj.getMuzzleVector(slot));
                    }
                Point3F objectVelocity = obj.getVelocity();

                muzzleVector = muzzleVector.vectorScale(thisobj["wetProjectile.muzzleVelocity"].AsFloat());

                objectVelocity = objectVelocity.vectorScale(thisobj["wetProjectile.velInheritFactor"].AsFloat());
                Point3F muzzleVelocity = muzzleVector.MPosition + objectVelocity;

                Torque_Class_Helper tch = new Torque_Class_Helper(thisobj["projectileType"]);


                tch.Props.Add("dataBlock", thisobj["wetProjectile"]);
                tch.Props.Add("initialVelocity", '"' + muzzleVelocity.AsString() + '"');
                tch.Props.Add("initialPosition", '"' + obj.getMuzzlePoint(slot).AsString() + '"');
                tch.Props.Add("sourceObject", obj);
                tch.Props.Add("sourceSlot", slot.AsString());
                tch.Props.Add("client", obj["client"]);
                tch.Props.Add("sourceClass", obj.getClassName());

                coItem projectile = tch.Create();
                ((coSimSet)"MissionCleanup").pushToBack(projectile);
                }
            }
Ejemplo n.º 4
0
 public void WeaponImageOnUnmount(coScriptObject thisobj, coPlayer player, int slot)
     {
     coGameConnection client = player["client"];
     if (client != "" && player["isAiControlled"].AsBool())
         GameConnectionRefreshWeaponHud(client, 0, "", "", "", 0);
     }
Ejemplo n.º 5
0
        public void WeaponImageOnMount(coScriptObject thisobj, coPlayer player, int slot)
            {
            coGameConnection client = player["client"];

            string ammoName = "";
            ammoName = ((coItemData)thisobj["ammo"]).getName();


            int currentammo = 0;
            int ammountinClips = 0;
            if (thisobj.isField("clip"))
                {
                if (ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]).AsBool())
                    {
                    player.setImageAmmo(slot, true);
                    currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]);
                    }
                else if (ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]) > 0)
                    {
                    ShapeBaseShapeBaseSetInventory(player, thisobj["ammo"], thisobj["ammo.maxInventory"].AsInt());
                    player.setImageAmmo(slot, true);

                    currentammo = thisobj["ammo.maxInventory"].AsInt();
                    ammountinClips += player["remaining" + ammoName].AsInt();
                    }
                else
                    {
                    ammountinClips += player["remaining" + ammoName].AsInt();
                    }

                ammountinClips = ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]);
                ammountinClips *= thisobj["ammo.maxInventory"].AsInt();

                if ((player["client"] != "") && !player["isAiControlled"].AsBool())
                    {
                    GameConnectionRefreshWeaponHud(client, currentammo, thisobj["item.previewImage"], thisobj["item.reticle"], thisobj["item.zoomReticle"], ammountinClips);
                    }
                }
            else if (thisobj["ammo"] != "")
                {
                if (ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]).AsBool())
                    {
                    player.setImageAmmo(slot, true);
                    currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]);
                    }
                else
                    currentammo = 0;


                if (player["client"] != "" && !player["isAiControlled"].AsBool())
                    GameConnectionRefreshWeaponHud(client, 1, thisobj["item.previewImage"], thisobj["item.reticle"], thisobj["item.zoomReticle"], currentammo);
                }
            }
Ejemplo n.º 6
0
 public void WeaponOnInventory(coScriptObject thisobj, coShapeBase obj, int amount)
     {
     if (amount != 0 || !obj.isMethod("getMountSlot"))
         return;
     int slot = obj.getMountSlot(thisobj["image"]);
     obj.unmountImage(slot);
     }
Ejemplo n.º 7
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);
            }