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;
        }
Example #2
0
 public virtual void damage(GameBase sourceobject, Point3F position, float damage, string damagetype)
 {
     if (!isObject())
         return;
     ShapeBaseData datablock = getDataBlock();
     datablock.damage(this, position, sourceobject, damage, damagetype);
 }
        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";
        }
Example #4
0
 public override void onAdd(GameBase obj)
 {
     Player player = obj.getId();
     player["mountVehicle"] = true.AsString();
     player.setRechargeRate(this["rechargeRate"].AsFloat());
     player.setRepairRate(0);
 }
 public override void onEnterTrigger(Trigger trigger, GameBase obj)
 {
     if (obj["client"].isObject() && obj["client.welcomed"].AsBool())
         {
         message.MessageClient(obj["client"], "MsgItemPickup", "\\c1There\'s a platform in-front of you...Jump on.");
         obj["client.welcomed"] = "true";
         }
 }
 public override void onRemove(GameBase obj)
 {
     ShapeBase sb = (ShapeBase) obj;
     sb.unmountImage(sb["platform"].AsInt());
     if (sb["platform"].isObject())
         sb["platform"].delete();
     base.onRemove(obj);
 }
Example #7
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);
             }
         }
 }
Example #8
0
        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());
            }
        }
Example #9
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);
         }
     }
 }
Example #10
0
        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";
            }
        }
Example #11
0
        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, "");
                }
            }
        }
Example #12
0
        public override void onAdd(GameBase obj)
        {
            Vehicle vehicle = obj._ID;
            vehicle.setRechargeRate(this["rechargeRate"].AsFloat());
            vehicle.setEnergyLevel(this["MaxEnergy"].AsFloat());
            vehicle.setRepairRate(0);

            {
            if (obj["mountable"].AsBool() || (obj["mountable"] == string.Empty))
                isMountable(vehicle, true);
            else
                isMountable(vehicle, false);
            }

            string nametag = this["nameTag"];

            if (nametag.Trim() != string.Empty)
                vehicle.setShapeName(nametag);
        }
 public override void onAdd(GameBase obj)
 {
     ShapeBase sb = (ShapeBase) obj;
     // Do standard cheetah init
     base.onAdd(obj);
     // Remove the turret from the roof
     sb.unmountImage(this.turretSlot);
     ObjectCreator ocplatform = new ObjectCreator("WalkableShape", "CarPlatform", typeof (CarPlatform));
     ocplatform["UseAutoAttach"] = 1;
     ocplatform["RayLength"] = 1.5f;
     ocplatform["shapeName"] = "art/shapes/rocks/boulder.dts";
     ocplatform["scale"] = "1 1 0.1";
     // Create our walkable platform
     CarPlatform platform = (CarPlatform) ocplatform.Create();
     sb["platform"] = platform;
     platform["car"] = sb;
     // Mount the platform to the Turret slot
     sb.mountImage(platform, this.turretSlot);
 }
        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);
        }
Example #16
0
        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);
        }
Example #17
0
        public static void RadiusDamage(GameBase sourceobject, Point3F position, float radius, float damage, string damageType, float impulse)
        {
            // Use the container system to iterate through all the objects
            // within our explosion radius.  We'll apply damage to all ShapeBase
            // objects.
            Dictionary<uint, float> r = tst.console.initContainerRadiusSearch(position, radius, (uint) SceneObjectTypesAsUint.ShapeBaseObjectType);
            float halfRadius = radius/(float) 2.0;
            foreach (ShapeBase targetObject in r.Keys)
                {
                // Calculate how much exposure the current object has to
                // the explosive force.  The object types listed are objects
                // that will block an explosion.  If the object is totally blocked,
                // then no damage is applied.

                UInt32 mask = (uint) SceneObjectTypesAsUint.TerrainObjectType | (uint) SceneObjectTypesAsUint.StaticShapeObjectType | (uint) SceneObjectTypesAsUint.VehicleObjectType;

                float coverage = tst.Util.calcExplosionCoverage(new Point3F(position), targetObject, mask);
                if (!coverage.AsBool())
                    continue;
                float dist = r[targetObject];
                // Calculate a distance scale for the damage and the impulse.
                // Full damage is applied to anything less than half the radius away,
                // linear scale from there.
                float distScale = (float) ((dist < halfRadius) ? 1.0 : 1 - ((dist - halfRadius)/halfRadius));
                // Apply the damage

                targetObject.damage(sourceobject, position, (((damage)*coverage*distScale)), damageType);

                // Apply the impulse
                if (!impulse.AsBool())
                    continue;
                TransformF impulseVec = new TransformF(targetObject.getWorldBoxCenter()) - new TransformF(position);
                impulseVec = impulseVec.normalizeSafe();
                impulseVec = impulseVec.vectorScale(impulse*distScale);
                targetObject.applyImpulse(new Point3F(position), impulseVec.GetPosition());
                }
        }
Example #18
0
        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());
            }
        }
Example #19
0
 public override void onMount(GameBase obj, SceneObject mountObj, int node)
 {
     Player player = obj.getId();
     VehicleData vehicleDataBlock = mountObj.getDataBlock();
     if (node == 0)
         {
         player.setTransform(new TransformF("0 0 0 0 0 1 0"));
         string mountPose = vehicleDataBlock["mountPose[" + node + "]"];
         player.setActionThread(mountPose, true, true);
         player["lastWeapon"] = player.getMountedImage(Constants.WeaponSlot).AsString();
         GameConnection client = player["client"];
         if (client.isObject())
             player["lastperson"] = client.isFirstPerson().AsString();
         player.unmountImage(Constants.WeaponSlot);
         player.setControlObject(mountObj);
         if (player.getClassName() == "Player")
             console.commandToClient(player["client"], console.addTaggedString("toggleVehicleMapToggle"), new[] {"true"});
         }
     else
         {
         string pose = vehicleDataBlock["mountPose[" + node + "]"];
         player.setActionThread(pose != string.Empty ? pose : "root", false, true);
         }
 }
Example #20
0
 public override void damage(GameBase sourceobject, Point3F position, float damage, string damagetype)
 {
     ((TurretShapeData) (getDataBlock())).damage(this, position, sourceobject, damage, damagetype);
 }
Example #21
0
 public override void onMount(GameBase obj, SceneObject mountObj, int node)
 {
     WheeledVehicle vehicle = obj._ID;
     vehicle.setImageAmmo(node, true);
 }
Example #22
0
        public override void onAdd(GameBase obj)
        {
            WheeledVehicle vehicle = obj._ID;
            base.onAdd(obj);

            WheeledVehicleTire CheetahCarTire = "CheetahCarTire";
            WheeledVehicleTire CheetahCarTireRear = "CheetahCarTireRear";
            WheeledVehicleSpring CheetahCarSpring = "CheetahCarSpring";

            //int nsd = (nameSpaceDepth.AsInt() + 1);
            //console.ParentExecute(datablock, "onAdd", nsd, new string[] { datablock, vehicle.ID });
            vehicle.setWheelTire(0, CheetahCarTire);
            vehicle.setWheelTire(1, CheetahCarTire);
            vehicle.setWheelTire(2, CheetahCarTireRear);
            vehicle.setWheelTire(3, CheetahCarTireRear);

            // Setup the car with some tires & springs
            for (int i = vehicle.getWheelCount() - 1; i >= 0; i--)
                {
                vehicle.setWheelPowered(i, true);
                vehicle.setWheelSpring(i, CheetahCarSpring);
                }
            // Steer with the front tires
            vehicle.setWheelSteering(0, 1);
            vehicle.setWheelSteering(1, 1);

            // Add tail lights
            ObjectCreator tc = new ObjectCreator("PointLight", "");
            tc["radius"] = 1;
            tc["isEnabled"] = false;
            tc["color"] = new ColorF(1, 0, 0.141176f, 1); // , @"""1 0 0.141176 1""");
            tc["brightness"] = 2;
            tc["castShadows"] = true;
            tc["priority"] = 1;
            tc["animate"] = false;
            tc["animationPeriod"] = 1;
            tc["animationPhase"] = 1;
            tc["flareScale"] = 1;
            tc["attenuationRatio"] = new Point3F(0, 1, 1); //, @"""0 1 1""");
            tc["shadowType"] = "\"DualParaboloidSinglePass\"";
            tc["texSize"] = 512;
            tc["overDarkFactor"] = new Point4F(2000, 1000, 500, 100); //, @"""2000 1000 500 100""");
            tc["shadowDistance"] = 400; // "400");
            tc["shadowSoftness"] = 0.15;
            tc["numSplits"] = 1; //, "1");
            tc["logWeight"] = 0.91;
            tc["fadeStartDistance"] = 0; //, "0");
            tc["lastSplitTerrainOnly"] = false;
            tc["representedInLightmap"] = false; //, "0");
            tc["shadowDarkenColor"] = new ColorF(0, 0, 0, -1); //, @"""0 0 0 -1""");
            tc["includeLightmappedGeometryInShadow"] = false; //, "0");
            tc["rotation"] = new AngAxisF(1, 0, 0, 0); //, @"""1 0 0 0 """);
            tc["canSave"] = true; //, "1");
            tc["canSaveDynamicFields"] = true; //, "1");
            tc["splitFadeDistances"] = "10 20 30 40";

            vehicle["rightBrakeLight"] = ((PointLight) tc.Create());
            vehicle["leftBrakeLight"] = ((PointLight) tc.Create());
            vehicle["inv[BulletAmmo]"] = "1000";

            // Mount a ShapeBaseImageData
            vehicle.mountImage("TurretImage", this["turretSlot"].AsInt(), true, string.Empty);

            // Mount the brake lights
            vehicle.mountObject(vehicle["rightBrakeLight"], this["rightBrakeSlot"].AsInt(), new TransformF());
            vehicle.mountObject(vehicle["leftbrakelight"], this["leftBrakeSlot"].AsInt(), new TransformF());
        }
Example #23
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 });
            }
        }
        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 damage(ShapeBase obj, Point3F position, GameBase source, float damage, string damagetype)
 {
     // Explode if any damage is applied to the mine
     int r = 50 + (new Random().Next(0, 50));
     schedule(r.AsString(), "explode");
 }
Example #26
0
 public override void onAdd(GameBase obj)
 {
     base.onAdd(obj);
     obj["mountable"] = false.AsString();
 }
public virtual  void onNewDataBlock(GameBase obj){}
public virtual  void onAdd(GameBase obj){}
public virtual  void onRemove(GameBase obj){}
Example #30
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});
        }
public virtual  void onUnmount(GameBase obj, SceneObject mountObj, int node){}
        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 virtual void teleportPlayer(GameBase gplayer, SceneObject exit)
 {
     Player player = gplayer._ID;
     TransformF targetPosition;
     if (exit["reorientPlayer"].AsBool())
         targetPosition = exit.getTransform();
     else
         {
         targetPosition = exit.getTransform();
         TransformF playerrot = player.getTransform();
         targetPosition.mOrientationX = playerrot.mOrientationX;
         targetPosition.mOrientationY = playerrot.mOrientationY;
         targetPosition.mOrientationZ = playerrot.mOrientationZ;
         targetPosition.MAngle = playerrot.MAngle;
         }
     player.setTransform(targetPosition);
     Point3F playervelocity = player.getVelocity();
     playervelocity = playervelocity.vectorScale(exit["exitVelocityScale"].AsFloat());
     player.setVelocity(playervelocity);
     // Prevent the object from doing an immediate second teleport
     // In the case of a bidirectional teleporter
     player["isTeleporting"] = true.AsString();
 }
 public virtual void onDeath(GameBase sourceobject, GameConnection sourceclient, string damagetype, string damloc)
 {
 }
Example #35
0
 public override void onUnmount(GameBase obj, SceneObject mountObj, int node)
 {
     //todo change to csharp
     mountObj.call("RefreshVehicleHud", "0", string.Empty, string.Empty);
 }
Example #36
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();
            }
        }
Example #37
0
 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 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.
 }
Example #39
0
 public override void damage(GameBase sourceobject, Point3F position, float damage, string damagetype)
 {
     ((TurretShapeData)(getDataBlock())).damage(this, position, sourceobject, damage, damagetype);
 }
Example #40
0
 public virtual void onDeath(GameBase sourceobject, GameConnection sourceclient, string damagetype, string damloc)
 {
 }
Example #41
0
 public override void onRemove(GameBase obj)
 {
     WheeledVehicle vehicle = obj._ID;
     base.onRemove(obj);
     //int nsd = (nameSpaceDepth.AsInt() + 1);
     //console.ParentExecute(datablock, "onRemove", nsd, new[] { datablock.ID, vehicle.ID });
     if ((vehicle["rightBrakeLight"]).isObject())
         (vehicle["rightBrakeLight"]).delete();
     if ((vehicle["leftBrakeLight"]).isObject())
         (vehicle["leftBrakeLight"]).delete();
     if ((vehicle["turret"]).isObject())
         (vehicle["turret"]).delete();
 }
 public override void onLeaveTrigger(Trigger trigger, GameBase obj)
 {
     obj["isTeleporting"] = false.AsString();
 }
        public virtual bool verifyObject(GameBase gobj, SceneObject entrance, SceneObject exit)
        {
            ShapeBase obj = gobj._ID;

            // Bail out early if we couldn't find an exit for this teleporter.
            if (!exit.isObject())
                {
                console.error(string.Format("Cound not find an exit for {0}", console.GetVarString(entrance + ".name")));
                return false;
                }

            if (!obj.isMemberOfClass("Player"))
                return false;

            // If the entrance is once sided, make sure the object
            // approached it from it's front.
            if (entrance["oneSided"].AsBool())
                {
                TransformF forwardvector = new TransformF(entrance.getForwardVector());

                Point3F velocity = obj.getVelocity();
                float dotProduct = TransformF.vectorDot(forwardvector, velocity);
                if (dotProduct > 0)
                    return false;
                // If we are coming directly from another teleporter and it happens
                // to be bidirectional, We need to avoid ending sending objects through
                // an infinite loop.

                if (obj["isTeleporting"].AsBool())
                    return false;
                // We only want to teleport players
                // So bail out early if we have found any 
                // other object.

                if (entrance["timeOfLastTeleport"].AsInt() > 0 && entrance["teleporterCooldown"].AsInt() > 0)
                    {
                    int currentTime = console.getSimTime();
                    int timedifference = currentTime - entrance["timeOfLastTeleport"].AsInt();
                    SimDataBlock db = console.getDatablock(entrance);
                    if (timedifference <= db["teleporterCooldown"].AsInt())
                        return false;
                    }
                }
            return true;
        }
        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");
            }
        }
Example #45
0
 public virtual void onAdd(GameBase obj)
 {
     this.setMode(this["mode"]);
 }
        public override void damage(GameBase sourceobject, Point3F position, float damage, string damagetype)
            {
            if (!isObject())
                return;
            if (getState() == "Dead")
                return;
            if (damage == 0.0)
                return;


            applyDamage(damage);

            if (getState() == "Dead")
                return;

            Point3F ejectvel = getVelocity();

            if (ejectvel.z <= 0)
                {
                ejectvel += new Point3F(0, 0, 5);
                SimDataBlock d = getDataBlock();
                if (d.isObject())
                    ejectvel = ejectvel.vectorScale(d["mass"].AsFloat());
                applyImpulse(getPosition(), ejectvel);
                }


            Point3F currentpos = getPosition();
            currentpos.x += r.Next(-5, 5);
            currentpos.y += r.Next(-5, 5);

            if (getDamageLevel() > 50)
                {
                currentpos.x += r.Next(-50, 50);
                currentpos.y += r.Next(-50, 50);
                }


            setMoveDestination(currentpos, false);
            }
 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.
 }
        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"]);
                }
        }