Exemplo n.º 1
0
 public override void onCollision(Projectile proj, SceneObject col, float fade, Point3F pos, Point3F normal)
 {
     // Apply damage to the object all shape base objects
     if (this["directDamage"].AsFloat() > 0)
     {
         if ((console.getTypeMask(col) & (uint)SceneObjectTypesAsUint.ShapeBaseObjectType) == (uint)SceneObjectTypesAsUint.ShapeBaseObjectType)
         {
             ShapeBase shapebase = col._ID;
             shapebase.damage(proj, pos, this["directDamage"].AsFloat(), this["damageType"]);
         }
     }
 }
        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");
            }
        }