Esempio n. 1
0
        public void ObserverObserverOnTrigger(coCameraData cameradata, coCamera camera, string trigger, bool state)
        {
            // state = 0 means that a trigger key was released
            if (state == false)
            {
                return;
            }

            // Default player triggers: 0=fire 1=altFire 2=jump
            coGameConnection client = camera.getControllingClient();
            string           mode   = camera["mode"];

            switch (mode)
            {
            case "Observer":
                // Do something interesting.
                break;

            case "Corpse":
                //Here is a winner... if you send the prepare too soon, it will crash out the client.  The GameConnectionOnControlObjectChange needs
                //time to run, and since it's still processing the first change (Switch to camera) this second change (Camera->player) will crash
                //out the client.
                //ServerCmdSetEditorCameraStandard(client);
                //ServerCmdDropCameraAtPlayer(client);
                camera.setFlyMode();
                client.setControlObject(camera);
                GameConnectiOnPreparePlayer(client);
                break;
            }
        }
Esempio n. 2
0
        public void ServerCmdCycleCameraFlyType(coGameConnection client)
        {
            coCamera camera = client["camera"];

            if (camera.getMode() != Camera__CameraMotionMode.FlyMode)
            {
                return;
            }
            if (camera["newtonMode"].AsBool() == false)
            {
                camera["newtonMode"]     = true.AsString();
                camera["newtonRotation"] = false.AsString();
                camera.setVelocity(new Point3F("0 0 0"));
            }
            else if (camera["newtonRotation"].AsBool() == false)
            {
                camera["newtonMode"]     = true.AsString();
                camera["newtonRotation"] = true.AsString();
                camera.setAngularVelocity(new Point3F("0 0 0"));
            }
            else
            {
                camera["newtonMode"]     = false.AsString();
                camera["newtonRotation"] = false.AsString();
            }
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 3
0
        public void ServerCmdTogglePathCamera(coGameConnection client, bool val)
        {
            string control = val ? client["PathCamera"] : client["camera"];

            client.setControlObject(control);

            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 4
0
        public void ServerCmdEditorCameraAutoFit(coGameConnection client, float radius)
        {
            coCamera camera = client["camera"];

            camera.autoFitRadius(radius);
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 5
0
        public void ServerCmdSetEditorFlyCamera(coGameConnection client)
        {
            coCamera camera = client["camera"];

            camera.setFlyMode();
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 6
0
 public void ServerCmdSetEditorCameraPlayerThird(coGameConnection client)
 {
     ((coPlayer)client["player"]).setVelocity(new Point3F("0 0 0"));
     client.setControlObject(client["player"]);
     client.setFirstPerson(false);
     bGlobal["$isFirstPersonVar"] = false;
     console.Call("clientCmdSyncEditorGui");
 }
Esempio n. 7
0
        public void ServerCmdDropCameraAtPlayer(coGameConnection client)
        {
            coPlayer player = client["player"];

            ((coCamera)client["camera"]).setTransform(player.getTransform());
            ((coCamera)client["camera"]).setVelocity(new Point3F("0 0 0"));
            client.setControlObject(client["camera"]);
            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 8
0
        public void ServerCmddismountVehicle(coGameConnection client)
        {
            coPlayer  player    = client["player"];
            coVehicle car       = player.getControlObject();
            coPlayer  passenger = car.getMountNodeObject(0);

            ((coSimDataBlock)passenger.getDataBlock()).call("doDismount", passenger, true.AsString());
            client.setControlObject(player);
        }
Esempio n. 9
0
        public void ServerCmdSetEditorCameraStandard(coGameConnection client)
        {
            coCamera camera = client["camera"];

            camera.setFlyMode();
            camera["newtonMode"]     = true.AsString();
            camera["newtonRotation"] = false.AsString();
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 10
0
        public void ServerCmdSetEditorCameraNewtonDamped(coGameConnection client)
        {
            coCamera camera = client["camera"];

            camera.setFlyMode();
            camera["newtonMode"]     = true.AsString();
            camera["newtonRotation"] = true.AsString();
            camera.setVelocity(new Point3F("0 0 0"));
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 11
0
        public void ServerCmdToggleCamera(coGameConnection client)
        {
            string control;

            if (client.getControlObject() == client["player"])
            {
                ((coCamera)client["camera"]).setVelocity(new Point3F("0 0 0"));
                control = client["camera"];
            }
            else
            {
                ((coCamera)client["player"]).setVelocity(new Point3F("0 0 0"));
                control = client["player"];
            }
            client.setControlObject(control);

            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 12
0
        public void ServerCmdDropPlayerAtCamera(coGameConnection client)
        {
            // If the player is mounted to something (like a vehicle) drop that at the
            // camera instead. The player will remain mounted.
            coPlayer    player = client["player"];
            coShapeBase obj    = null;

            obj = player.getObjectMount();
            if (!console.isObject(obj))
            {
                obj = client["player"];
            }

            obj.setTransform(((coCamera)client["Camera"]).getTransform());
            obj.setVelocity(new Point3F("0 0 0"));
            client.setControlObject(player);
            console.Call("clientCmdSyncEditorGui");
        }
Esempio n. 13
0
        public void GameConnectionSpawnCamera(coGameConnection client, string spawnPoint)
        {
            coCamera camera = client["camera"];

            //string camera = console.GetVarString(thisobj + ".camera");

            // Set the control object to the default camera
            if (!camera.isObject())
            {
                camera           = Util._spawnObject(Game__DefaultCameraClass, Game__DefaultCameraDataBlock);
                client["camera"] = camera;
            }

            // If we have a camera then set up some properties
            if (!camera.isObject())
            {
                return;
            }

            ((coSimSet)"MissionCleanup").pushToBack(camera);

            camera.scopeToClient(client);

            client.setControlObject(camera);

            if (spawnPoint == "")
            {
                return;
            }

            // Attempt to treat %spawnPoint as an object


            if (Util.getWordCount(spawnPoint) == 1 && console.isObject(spawnPoint))
            {
                camera.setTransform(((coMarker)spawnPoint).getTransform());
            }
            else
            {
                camera.setTransform(new TransformF(spawnPoint));
            }
        }
Esempio n. 14
0
        public bool SpawnPlayer(coGameConnection client, string spawnpoint, bool nocontrol)
        {
            coPlayer player = client["player"];


            if (player.isObject())
            {
                console.error("Attempting to create a player for a client that already has one!");
                return(false);
            }

            if ((spawnpoint.Split(' ').GetUpperBound(0) == 0) && (spawnpoint.isObject()))
            {
                // Attempt to treat %spawnPoint as an object
                string spawnclass     = Game__DefaultPlayerClass;
                string spawndatablock = Game__DefaultPlayerDataBlock;

                coSimObject ospawnpoint = spawnpoint;


                // Overrides by the %spawnPoint
                if (ospawnpoint["spawnClass"] != "")
                {
                    spawnclass     = ospawnpoint["spawnClass"];
                    spawndatablock = ospawnpoint["spawnDataBlock"];
                }

                else if (ospawnpoint["spawnDatablock"] != "")
                {
                    // This may seem redundant given the above but it allows
                    // the SpawnSphere to override the datablock without
                    // overriding the default player class
                    spawndatablock = ospawnpoint["spawnDatablock"];
                }
                string spawnproperties = ospawnpoint["spawnProperties"];
                string spawnScript     = ospawnpoint["spawnScript"];

                // Spawn with the engine's Sim::spawnObject() function
                player = console.SpawnObject(spawnclass, spawndatablock, "", spawnproperties, spawnScript);
                // If we have an object do some initial setup
                if (console.isObject(player))
                {
                    // Pick a location within the spawn sphere.
                    player.setTransform(PointInSpawnSphere(player, ((coSpawnSphere)spawnpoint)));
                }
                else
                {
                    // If we weren't able to create the player object then warn the user
                    // When the player clicks OK in one of these message boxes, we will fall through
                    // to the "if (!isObject(%player))" check below.
                    if (console.GetVarString(spawndatablock).Trim() != "")
                    {
                        console.Call("MessageBoxOK", new[] { "Spawn Player Failed", "Unable to create a player with class " + spawnclass + " and datablock " + spawndatablock + ".\n\nStarting as an Observer instead.", "" });
                    }
                    else
                    {
                        console.Call("MessageBoxOK", new[] { "Spawn Player Failed", "Unable to create a player with class " + spawnclass + ".\n\nStarting as an Observer instead.", "" });
                    }
                }
            }
            else
            {
                // Create a default player
                player = console.SpawnObject(Game__DefaultPlayerClass, Game__DefaultPlayerDataBlock, "", "", "");

                if (player.isMemberOfClass("Player"))
                {
                    //if (SimObject.SimObject_isMemberOfClass(player, "Player"))
                    console.warn("Trying to spawn a class that does not derive from player!!!!!");
                }
                // Treat %spawnPoint as a transform
                player.setTransform(new TransformF(spawnpoint));
            }

            // Update the default camera to start with the player
            if (!console.isObject(player))
            {
                client["spawnCamera"] = spawnpoint;
                return(false);
            }

            ((coSimSet)"MissionCleanup").pushToBack(player);
            // Update the default camera to start with the player


            // Store the client object on the player object for
            // future reference
            player["client"] = client;

            // If the player's client has some owned turrets, make sure we let them
            // know that we're a friend too.

            if (client["ownedTurrets"].AsInt() >= 1)
            {
                coSimSet turrets = client["ownedTurrets"];
                for (uint i = 0; i < turrets.getCount(); i++)
                {
                    ((coTurretShape)turrets.getObject(i)).call("addToIgnoreList", player);
                }
            }

            player.setShapeName(client["playerName"]);

            player.setEnergyLevel(((coPlayerData)player.getDataBlock())["maxEnergy"].AsFloat());

            if (client["skin"] != "")
            {
                string availableSkins = ((coPlayerData)player.getDataBlock())["availableSkins"];
                foreach (coGameConnection other in ClientGroup.Where(other => other != client))
                {
                    availableSkins = availableSkins.Replace(console.GetVarString(other + ".skin"), " ");

                    availableSkins = availableSkins.Replace("  ", " ");
                }
                List <string> availskin = availableSkins.Split('\t').ToList();
                if (availskin.Count > 0)
                {
                    int r = new Random().Next(0, availskin.Count - 1);
                    client["skin"] = availskin[r];
                }
            }

            player.setSkinName(client["skin"]);
            client["player"] = player;

            coSimObject control = null;

            if (console.GetVarString("$startWorldEditor") == "1")
            {
                control = client["camera"];
                console.Call("EditorGui", "syncCameraGui");
            }
            else
            {
                control = player;
            }

            if (!nocontrol)
            {
                client.setControlObject(control);
            }

            int team = new Random().Next(1, 2);

            AddObjectTo_MobSearchGroup(player, team);

            MessageClient(client, "System", "Your on Team " + team);

            console.error(DateTime.Now + " --- PLAYER JOIN::Name '" + Util.StripMLControlChars(player.getShapeName()) + "'::ID '" + player + "'");
            return(true);
        }
Esempio n. 15
0
        public void GameConnectionOnDeath(coGameConnection client, coPlayer sourceobject, coGameConnection sourceclient, string damagetype, string damloc)
        {
            if (client.isObject())
            {
                if (client["ownedTurrets"] == "")
                {
                    client["ownedTurrets"] = new Torque_Class_Helper("SimSet").Create().AsString();
                }

                coSimSet simSet = client["ownedTurrets"];

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


            // clear the weaponHUD

            GameConnectionRefreshWeaponHud(client, 0, "", "", "", 0);

            coPlayer player = client["player"];

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

            // Update the numerical Health HUD

            //PlayerUpdateHealth(player);


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

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

            client["player"] = "0";

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

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

            console.Call(sendMsgFunction, new string[] { "MsgClientKilled", client, sourceclient, damloc });
            // Dole out points and check for win
            if ((damagetype == "Suicide") || (sourceclient == client))
            {
                IncDeaths(client, "1", "1");
                IncScore(client, "-1", "0");
            }
            else
            {
                IncDeaths(client, "1", "0");
                IncScore(sourceclient, "1", "1");
                IncKills(sourceclient, "1", "0");
            }
        }
Esempio n. 16
0
        public void ServerCmdsetPlayerControl(coGameConnection client)
        {
            coPlayer player = client["player"];

            client.setControlObject(player);
        }