Exemplo n.º 1
0
        public static void sendMsgClientKilled_Impact(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
        {
            if (client.isObject())

                message.MessageAll(msgtype, "%1 fell to his death!", client["playerName"]);
            // console.GetVarString(string.Format("{0}.playerName", client)));
        }
Exemplo n.º 2
0
        public void playDeathAnimation()
        {
            int numDeathAnimations = getNumDeathAnimations();

            if (numDeathAnimations <= 0)
            {
                return;
            }

            GameConnection client = this["client"];

            if (client.isObject())
            {
                int deathidx = client["deathIdx"].AsInt();
                if ((deathidx > numDeathAnimations) || (deathidx == 0))
                {
                    deathidx = 1;
                }
                setActionThread("Death" + deathidx, false, true);
                deathidx++;
                client["deathIdx"] = deathidx.AsString();
            }
            else
            {
                int r = new Random().Next(1, numDeathAnimations);
                setActionThread("Death" + r, false, true);
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        public override void onDisabled(ShapeBase obj, string lastState)
        {
            Player player = obj.getId();

            player.setImageTrigger(0, false);
            GameBaseData item = (((GameBaseData)(player.getMountedImage(Constants.WeaponSlot)))["item"]);

            if (item.isObject())
            {
                int amount = player.getInventory(item["image.ammo"]);

                if (amount.AsBool())
                {
                    player.Throw(item["image.clip"], 1);
                }
            }
            player.tossPatch();
            player.playDeathCry();
            player.playDeathAnimation();

            //If it's a player check.....
            GameConnection client = player["client"];

            if (client.isObject())
            {
                //todo Remove the console.commandToClient since the default one now shows in the Util class.
                console.commandToClient(client, console.addTaggedString("toggleVehicleMapToggle"), new[] { "false" });
            }
            //Util._commandToClient(client, "toggleVehicleMap", false.AsString());

            int ctov = iGlobal["$CorpseTimeoutValue"];

            player.schedule((ctov - 1000).AsString(), "startFade", "1000", "0", "true");
            player.schedule(ctov.AsString(), "delete");
        }
Exemplo n.º 5
0
        public override void damage(ShapeBase obj, Point3F position, GameBase sourceobject, float damage, string damagetype)
        {
            Player pobj = obj._ID;

            if (!pobj.isObject() || pobj.getState() == "Dead" || !damage.AsBool())
            {
                return;
            }

            obj.applyDamage(damage);

            GameConnection client = obj["client"];

            if (!client.isObject())
            {
                return;
            }
            if (damagetype != "Suicide")
            {
                pobj.setDamageDirection(sourceobject, new TransformF(position));
            }

            if (pobj.getState() == "Dead")
            {
                client.onDeath(sourceobject, sourceobject["client"].isObject() ? sourceobject["client"] : "0", damagetype, "Body");
            }
        }
Exemplo n.º 6
0
        public static void sendMsgClientKilled_Default(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
        {
            if (!client.isObject())
                return;
            if (sourceclient == client)
                sendMsgClientKilled_Suicide(msgtype, client, sourceclient, damloc);

            else if (omni.console.GetVarString(sourceclient["team"]) != string.Empty && sourceclient["team"] != client["team"])
                message.MessageAll(msgtype, "%1 killed by %2 - friendly fire!", client["playerName"], sourceclient["playerName"]);
            else
                message.MessageAll(msgtype, "%1 gets nailed by %2!", client["playerName"], sourceclient.isObject() ? sourceclient["playerName"] : "a Bot!");
        }
Exemplo n.º 7
0
        public override void onInventory(ShapeBase obj, int amount)
        {
            GameConnection client = obj["client"];

            if (client.isObject())
            {
                client.setAmmoAmountHud(1, amount);
            }

            //todo Something funny here, probally should look at it.
            if (amount == 0)
            {
                obj.cycleWeapon("prev");
            }
        }
Exemplo n.º 8
0
        public override bool onPickup(Item obj, ShapeBase user, int amount)
        {
            int count = obj["count"].AsInt();

            //string count = console.GetVarString(item + ".count");

            if (count == 0)
            {
                count = this["count"].AsInt();
                if (count == 0)
                {
                    if (this["maxInventory"] != string.Empty)
                    {
                        if (count != this["maxInventory"].AsInt())
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        count = 1;
                    }
                }
            }
            user.incInventory(((this).getName()), count);

            GameConnection client = user["client"];

            if (client.isObject())
            {
                message.MessageClient(client, "MsgItemPickup", console.ColorEncode(@"\c0You picked up %1"), this["pickupName"]);
            }

            // If the item is a static respawn item, then go ahead and
            // respawn it, otherwise remove it from the world.
            // Anything not taken up by inventory is lost.

            if (obj.isStatic())
            {
                obj.Respawn();
            }
            else
            {
                obj.delete();
            }

            return(true);
        }
Exemplo n.º 9
0
        public virtual bool Use(ItemData data)
        {
            GameConnection client = getControllingClient();

            if (client.isObject())
            {
                double defaultfov = client.getControlCameraDefaultFov();
                double fov        = client.getControlCameraFov();
                if (defaultfov != fov)
                {
                    return(false);
                }
            }
            if (getInventory(data) > 0)
            {
                return(data.onUse(_ID));
            }

            return(false);
        }
Exemplo n.º 10
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());
            }
        }
Exemplo n.º 11
0
        public override int onThrow(ShapeBase player, int amount)
        {
            if (amount == 0)
            {
                amount = 1;
            }

            if (this["maxInventory"] != string.Empty)
            {
                if (amount > this["maxInventory"].AsInt())
                {
                    amount = this["maxInventory"].AsInt();
                }
            }

            if (amount == 0)
            {
                return(0);
            }

            player.decInventory(this, amount);
            TransformF rot = new TransformF(player.getEulerRotation());

            ObjectCreator tc_obj = new ObjectCreator("AITurretShape", string.Empty);

            tc_obj["datablock"]      = this.getName();
            tc_obj["rotation"]       = "0 0 1 " + rot.mPositionZ;
            tc_obj["count"]          = "1";
            tc_obj["sourceObject"]   = player;
            tc_obj["client"]         = player["client"];
            tc_obj["isAiControlled"] = true;

            AITurretShape obj = tc_obj.Create();

            ((SimSet)"MissionGroup").pushToBack(obj);

            //todo change to csharp
            obj.addToIgnoreList(player);

            GameConnection client = player["client"];

            if (client.isObject())
            {
                if (client["ownedTurrets"] == string.Empty)
                {
                    client["ownedTurrets"] = new ObjectCreator("SimSet", string.Empty).Create().AsString();
                }

                SimSet SimSet_id    = client["ownedTurrets"];
                int    countofitems = SimSet_id.getCount();
                for (uint i = 0; i < countofitems; i++)
                {
                    AITurretShape turret = SimSet_id.getObject(i);
                    turret.addToIgnoreList(obj);
                    obj.addToIgnoreList(turret);
                }
                SimSet_id.pushToBack(obj);
            }

            return(obj);
        }
Exemplo n.º 12
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 });
            }
        }
Exemplo n.º 13
0
        public static void sendMsgClientKilled_Suicide(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
        {
            if (client.isObject())

                message.MessageAll(msgtype, "%1 takes his own life!", client["playerName"]);
        }
Exemplo n.º 14
0
        public override void onCollision(ShapeBase obj, SceneObject col, Point3F vec, float len)
        {
            Player player = obj.getId();

            if (player.getState() == "Dead")
            {
                return;
            }
            // Try and pickup all items
            if (col.getClassName() == "Item")
            {
                player.pickup(col.ID, 1);
                return;
            }

            if (col.GetType() != typeof(WheeledVehicle))
            {
                return;
            }

            WheeledVehicle vcol = (WheeledVehicle)col;

            //AI are not allowed to drive they are lousey drivers....
            GameConnection client = player["client"];

            if (!client.isObject())
            {
                return;
            }
            //Mount Vehicle.
            if ((console.getTypeMask(col) & (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) != (UInt32)SceneObjectTypesAsUint.GameBaseObjectType)
            {
                return;
            }
            VehicleData db = vcol.getDataBlock();

            if (!(((db.getClassName() == "WheeledVehicleData") || player["mountVehicle"].AsBool() || player.getState() == "Move" || col["mountable"].AsBool())))
            {
                return;
            }
            // Only mount drivers for now.

            // For this specific example, only one person can fit
            // into a vehicle
            int mount = vcol.getMountNodeObject(0);

            if (mount > 0)
            {
                try
                {
                    Player p = mount;
                    return;
                }
                catch (Exception err)
                {
                    //Water particle emitters seem to take up the seat when the vehicle is in water.
                    vcol.unmountObject(mount.AsString());
                    vcol.mountObject(player, 0, new TransformF());
                    ((GameConnection)player["client"]).setFirstPerson(false);
                    console.commandToClient(client, "PushVehicleMap");
                }
            }
            else
            {
                vcol.mountObject(player, 0, new TransformF());
                ((GameConnection)player["client"]).setFirstPerson(false);
                console.commandToClient(client, "PushVehicleMap");
            }
            //if (mount > 0)
            //return;
            // For this specific FPS Example, always mount the player to node 0

            player["mVehicle"] = col;
        }