public void PlayerSetDamageDirection(coPlayer player, coPlayer sourceObject, TransformF damagePos)
            {
            if (sourceObject.isObject())
                damagePos = console.isField(sourceObject, "initialPosition") ? new TransformF(sourceObject["initialPosition"]) : sourceObject.getTransform();


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

            TransformF damagevec = dp - new TransformF(wbc);
            damagevec = damagevec.normalizeSafe();

            coGameConnection client = player["client"];
            if (!client.isObject())
                return;


            coCamera cameraobject = client.getCameraObject();

            TransformF inverseTransform = cameraobject.getInverseTransform();
            damagevec = math.MatrixMulVector(inverseTransform, damagevec.MPosition);

            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.MPosition.x;
            components[1] = damagevec.MPosition.x;
            components[2] = -damagevec.MPosition.y;
            components[3] = damagevec.MPosition.y;
            components[4] = -damagevec.MPosition.z;
            components[5] = damagevec.MPosition.z;
            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))
                console.commandToClient(client, console.addTaggedString("setDamageDirection"), new[] { damagedirection });
            }
        public void ArmorDamage(coPlayerData datablock, coPlayer player, TransformF position, coPlayer sourceobject, float damage, string damageType)
            {
            if (!player.isObject())
                return;
            if (player.getState() == "Dead")
                return;
            if (damage == 0.0)
                return;


            player.applyDamage(damage);

            const string location = "Body";

            //PlayerUpdateHealth(player);

            coGameConnection client = player["client"];
            //Only continue if it is a player, if it is an AI return.
            if (!client.isObject())
                return;


            coGameConnection sourceClient = null;
            if (sourceobject != 0)
                sourceClient = sourceobject["client"];


            if (player.getDamageLevel() >= 99)
                player.unmountImage(0);

            // Determine damage direction
            if (damageType != "Suicide")
                PlayerSetDamageDirection(player, sourceobject, position);

            if (player.getState() == "Dead")
                GameConnectionOnDeath(client, sourceobject, sourceClient, damageType, location);
            }