public override void onRemove(GameBase obj)
        {
            for (int i = 0; i < this["numMountPoints"].AsInt(); i++)
            {
                if (obj.getMountNodeObject(i) == 0)
                {
                    continue;
                }

                Player passenger = obj.getMountNodeObject(i).AsString();

                //change to csharp
                ((TurretShapeData)passenger.getDataBlock()).call("doDismount", true.AsString());
            }
        }
Beispiel #2
0
 public override void onRemove(GameBase obj)
 {
     // if there are passengers/driver, kick them out
     for (int i = 0; i < ((VehicleData)obj.getDataBlock())["numMountPoints"].AsInt(); i++)
     {
         if (!((SimObject)obj.getMountNodeObject(i)).isMemberOfClass("Player"))
         {
             continue;
         }
         Player passenger = obj.getMountNodeObject(i);
         if (passenger != "0")
         {
             PlayerData passengerdatablock = passenger.getDataBlock();
             passengerdatablock.doDismount(passenger);
         }
     }
 }
        public override void damage(ShapeBase obj, Point3F position, GameBase source, float damage, string damagetype)
        {
            if (obj.getDamageState() == "Dead")
            {
                return;
            }

            obj.applyDamage(damage);

            for (int i = 0; i < this["numMountPoints"].AsInt(); i++)
            {
                Player player = obj.getMountNodeObject(i);
                if (player != 0)
                {
                    player.damage(source, position, 10000.0f, "");
                }
            }
        }
        public override void onAdd(GameBase obj)
        {
            ShapeBase sbobj = obj._ID;

            sbobj.setRechargeRate(this["rechargeRate"].AsFloat());
            sbobj.setEnergyLevel(this["MaxEnergy"].AsFloat());
            sbobj.setRepairRate(0);

            if (obj["mountable"] == "1" || obj["mountable"] == string.Empty)
            {
                this.isMountable((TurretShape)sbobj, true.AsString());
            }
            else
            {
                this.isMountable((TurretShape)sbobj, false.AsString());
            }

            if (this["nameTag"] != string.Empty)
            {
                sbobj.setShapeName(this["nameTag"]);
            }
            for (int i = 0; i < this["numWeaponMountPoints"].AsInt(); i++)
            {
                sbobj.incInventory(this["weapon[" + i + "]"], 1);
                ItemData weaponAmmo       = this["weaponAmmo[" + i + "]"];
                string   weaponAmmoAmount = this["weaponAmmoAmount[" + i + "]"];
                sbobj.incInventory(weaponAmmo, weaponAmmoAmount.AsInt());
                bool startLoaded = this["startLoaded"].AsBool();
                sbobj.mountImage(this["weapon[" + i + "].Image"], i, startLoaded, string.Empty);
                sbobj.setImageGenericTrigger(i, 0, false);
            }
            if (this["enterSequence"] != string.Empty)
            {
                obj["entranceThread"] = "0";
                int    et = obj["entranceThread"].AsInt();
                string es = this["enterSequence"];
                sbobj.playThread(et, es);
                sbobj.pauseThread(et);
            }
            else
            {
                obj["entranceThread"] = "-1";
            }
        }
        public override void onAdd(GameBase obj)
        {
            if (obj["exit"] == string.Empty)
            {
                obj["exit"] = "NameOfTeleporterExit";
            }

            if (obj["teleporterCooldown"] == string.Empty)
            {
                obj["teleporterCooldown"] = this["teleporterCooldown"];
            }

            if (obj["exitVelocityScale"] == string.Empty)
            {
                obj["exitVelocityScale"] = this["exitVelocityScale"];
            }

            if (obj["reorientPlayer"] == string.Empty)
            {
                obj["reorientPlayer"] = this["reorientPlayer"];
            }

            if (obj["oneSided"] == string.Empty)
            {
                obj["oneSided"] = this["oneSided"];
            }

            if (obj["entranceEffect"] == string.Empty)
            {
                obj["entranceEffect"] = this["entranceEffect"];
            }

            if (obj["exitEffect"] == string.Empty)
            {
                obj["exitEffect"] = this["exitEffect"];
            }
            // We do not want to save this variable between levels,
            // clear it out every time the teleporter is added
            // to the scene.

            obj["timeOfLastTeleport"] = string.Empty;
        }
        public override void onAdd(GameBase obj)
        {
            WheeledVehicle wheeledvehicle = obj._ID;

            base.onAdd(obj);
            //int nsd = (nameSpaceDepth + 1);
            //console.ParentExecute(thisobj, "onAdd", nsd, new string[] { thisobj, obj });
            // Setup the car with some tires & springs
            for (int i = wheeledvehicle.getWheelCount() - 1; i >= 0; i--)
            {
                wheeledvehicle.setWheelTire(i, "CheetahCarTire");
                wheeledvehicle.setWheelSpring(i, "CheetahCarSpring");
                wheeledvehicle.setWheelPowered(i, false);
            }
            // Steer with the front tires
            wheeledvehicle.setWheelSteering(0, 1);
            wheeledvehicle.setWheelSteering(1, 1);

            // Only power the two rear wheels... assuming there are only 4 wheels.
            wheeledvehicle.setWheelPowered(2, true);
            wheeledvehicle.setWheelPowered(3, true);
        }
        public override void onUnmount(GameBase obj, SceneObject mountObj, int node)
        {
            Player player = obj.getId();

            if (node != 0)
            {
                return;
            }

            player.mountImage(player["lastWeapon"], Constants.WeaponSlot, true, string.Empty);
            player.setControlObject(string.Empty);

            if (!player["lastperson"].AsBool())
            {
                return;
            }

            GameConnection client = player["client"];

            if (client.isObject())
            {
                client.setFirstPerson(player["lastperson"].AsBool());
            }
        }
Beispiel #8
0
 public virtual void onAdd(GameBase obj)
 {
     this.setMode(this["mode"]);
 }
 public override void onUnmount(GameBase obj, SceneObject mountObj, int node)
 {
     //todo change to csharp
     mountObj.call("RefreshVehicleHud", "0", string.Empty, string.Empty);
 }
 public override void onMount(GameBase obj, SceneObject mountObj, int node)
 {
     //todo change to csharp
     ((GameConnection)mountObj["client"]).call("RefreshVehicleHud", obj, this["reticle"], this["zoomReticle"]);
 }
 public override void damage(GameBase sourceobject, Point3F position, float damage, string damagetype)
 {
     ((TurretShapeData)(getDataBlock())).damage(this, position, sourceobject, damage, damagetype);
 }
Beispiel #12
0
 public override void onAdd(GameBase obj)
 {
     base.onAdd(obj);
     obj["mountable"] = false.AsString();
 }
Beispiel #13
0
        public void setDamageDirection(GameBase sourceObject, TransformF damagePos)
        {
            if (sourceObject.isObject())
            {
                damagePos = console.isField(sourceObject, "initialPosition") ? new TransformF(sourceObject["initialPosition"]) : sourceObject.getTransform();
            }

            TransformF dp  = damagePos;
            Point3F    wbc = getWorldBoxCenter();

            TransformF damagevec = dp - new TransformF(wbc);

            damagevec = damagevec.normalizeSafe();

            GameConnection client = this["client"];

            if (!client.isObject())
            {
                return;
            }

            ShapeBase cameraobject = client.getCameraObject();

            TransformF inverseTransform = cameraobject.getInverseTransform();

            damagevec = math.MatrixMulVector(inverseTransform, damagevec.GetPosition());

            float[]  components = new float[6];
            string[] directions = new string[6];
            directions[0] = "Left";
            directions[1] = "Right";
            directions[2] = "Bottom";
            directions[3] = "Front";
            directions[4] = "Bottom";
            directions[5] = "Top";

            components[0] = -damagevec.mPositionX;
            components[1] = damagevec.mPositionX;
            components[2] = -damagevec.mPositionY;
            components[3] = damagevec.mPositionY;
            components[4] = -damagevec.mPositionZ;
            components[5] = damagevec.mPositionZ;
            string damagedirection = string.Empty;
            float  max             = 0;

            for (int i = 0; i < 6; i++)
            {
                if (components[i] <= max)
                {
                    continue;
                }
                damagedirection = directions[i];
                max             = components[i];
            }

            if (console.isObject(client))
            {
                // Util._commandToClient(client, console.addTaggedString("setDamageDirection"), damagedirection);
                console.commandToClient(client, console.addTaggedString("setDamageDirection"), new[] { damagedirection });
            }
        }
Beispiel #14
0
        public virtual void onDeath(GameBase sourceobject, GameConnection sourceclient, string damagetype, string damloc)
        {
            if (this.isObject())
            {
                if (this["ownedTurrets"] == string.Empty)
                {
                    this["ownedTurrets"] = new ObjectCreator("SimSet").Create().AsString();
                }

                SimSet simSet = this["ownedTurrets"];

                for (uint i = 0; i < simSet.getCount(); i++)
                {
                    ((SimObject)simSet.getObject(i)).schedule("10", "delete");
                }
            }

            // clear the weaponHUD
            this.refreshWeaponHud(0, string.Empty, string.Empty, string.Empty, 0);

            Player player = this["player"];

            // Clear out the name on the corpse
            player.setShapeName(string.Empty);

            // Update the numerical Health HUD

            //PlayerUpdateHealth(player);

            // Switch the client over to the death cam and unhook the player object.
            Camera camera = this["camera"];

            if (camera.isObject() && player.isObject())
            {
                camera.setMode("Corpse", player, string.Empty, string.Empty);
                //camera.call("setMode", "Corpse", player, string.Empty, string.Empty);
                this.setControlObject(camera);
            }
            else
            {
                console.print("------------>Failed to Switch the client over to the death cam.");
            }

            this["player"] = "0";

            // Display damage appropriate kill message
            string sendMsgFunction = "sendMsgClientKilled_" + damagetype;

            //if (!console.isFunction(sendMsgFunction))
            //    {
            //    sendMsgFunction = "sendMsgClientKilled_Default";
            //    }

            console.Call(sendMsgFunction, new string[] { "MsgClientKilled", this, sourceclient, damloc });
            // Dole out points and check for win
            if ((damagetype == "Suicide") || (sourceclient == this))
            {
                IncDeaths(this, "1", "1");
                IncScore(this, "-1", "0");
            }
            else
            {
                IncDeaths(this, "1", "0");
                IncScore(sourceclient, "1", "1");
                IncKills(sourceclient, "1", "0");
            }

            if (iGlobal["$Game::EndGameScore"] > 0 && sourceclient["kills"].AsInt() >= iGlobal["$Game::EndGameScore"])
            {
                missionLoad.cycleGame();
            }
        }
        public virtual void teleFrag(GameBase player, Trigger exit)
        {
            // When a telefrag happens, there are two cases we have to consider.
            // The first case occurs when the player's bounding box is much larger than the exit location,
            // it is possible to have players colide even though a player is not within the bounds
            // of the trigger Because of this we first check a radius the size of a player's bounding
            // box around the exit location.

            // Get the bounding box of the player

            Point3F boundingBoxSize = new Point3F(((PlayerData)player.getDataBlock())["boundingBox"]);
            float   radius          = boundingBoxSize.x;
            float   boxSizeY        = boundingBoxSize.y;
            float   boxSizeZ        = boundingBoxSize.z;

            // Use the largest dimention as the radius to check
            if (boxSizeY > radius)
            {
                radius = boxSizeY;
            }
            if (boxSizeZ > radius)
            {
                radius = boxSizeZ;
            }

            Point3F position = exit.getTransform().GetPosition(); // new TransformF(con.getTransform(exit));
            uint    mask     = (uint)SceneObjectTypesAsUint.PlayerObjectType;

            // Check all objects within the found radius of the exit location, and telefrag
            // any players that meet the conditions.

            Dictionary <uint, float> r = console.initContainerRadiusSearch(position, radius, mask);

            foreach (ShapeBase objectNearExit in
                     r.Keys.Where(objectNearExit => ((ShapeBase)objectNearExit).isMemberOfClass("Player")).Where(objectNearExit => objectNearExit.AsString() != player))
            {
                objectNearExit.damage(player, exit.getTransform().GetPosition(), 10000, "Telefrag");
            }
            // The second case occurs when the bounds of the trigger are much larger
            // than the bounding box of the player. (So multiple players can exist within the
            // same trigger). For this case we check all objects contained within the trigger
            // and telefrag all players.

            int objectsInExit = exit.getNumObjects();

            // Loop through all objects in the teleporter exit
            // And kill any players
            for (int i = 0; i < objectsInExit; i++)
            {
                ShapeBase objectInTeleporter = console.Call(exit, "getObject", new[] { i.AsString() });
                if (objectInTeleporter.isMemberOfClass("Player"))
                {
                    continue;
                }
                // Avoid killing the player that is teleporting in the case of two
                // Teleporters near eachother.
                if (objectInTeleporter == player)
                {
                    continue;
                }

                objectInTeleporter.damage(player, exit.getTransform().GetPosition(), 10000, "Telefrag");
            }
        }
        public override void onEnterTrigger(Trigger trigger, GameBase obj)
        {
            //if (!console.isMemberOfClass(obj, "Player"))
            //    return;

            if (obj["isTeleporting"].AsBool())
            {
                return;
            }
            // Get the location of our target position
            Trigger exit = trigger["exit"];

            bool valid = verifyObject(obj, trigger, exit);

            if (!valid)
            {
                return;
            }

            teleFrag(obj, exit);
            // Create our entrance effects on all clients.

            SimObject entranceeffect = trigger["entranceEffect"];

            if (entranceeffect.isObject())
            {
                foreach (GameConnection client in ClientGroup)
                {
                    if (console.isObject(client))
                    {
                        console.commandToClient(client, "PlayTeleportEffect", new[] { trigger["position"], entranceeffect.getId().AsString() });
                    }
                }
            }

            teleportPlayer(obj, exit);
            // Create our exit effects on all clients.

            SimObject exitEffect = trigger["exitEffect"];

            if (exitEffect.isObject())
            {
                foreach (GameConnection client in ClientGroup)
                {
                    if (console.isObject(client))
                    {
                        console.commandToClient(client, "PlayTeleportEffect", new[] { trigger["position"], exitEffect.getId().AsString() });
                    }
                }
            }

            // Record what time we last teleported so we can determine if enough
            // time has elapsed to teleport again
            int tolt = console.getSimTime();

            trigger["timeOfLastTeleport"] = tolt.AsString();

            // If this is a bidirectional teleporter, log it's exit too.
            if (exit["exit"] == trigger["name"])
            {
                exit["timeOfLastTeleport"] = tolt.AsString();
            }

            // Tell the client to play the 2D sound for the player that teleported.
            if (((SimObject)this["teleportSound"]).isObject() && ((GameConnection)obj["client"]).isObject())
            {
                ((GameConnection)obj["client"]).play2D(this["teleportSound"]);
                //GameConnection.play2D(obj, thisobj["teleportSound"]);
            }
        }
 public override void onLeaveTrigger(Trigger trigger, GameBase obj)
 {
     obj["isTeleporting"] = false.AsString();
 }
 public virtual void damage(ShapeBase obj, Point3F position, GameBase source, float damage, string damagetype)
 {
     // Ignore damage by default. This empty method is here to
     // avoid console warnings.
 }