Пример #1
0
        public void AiPlayerFollowPath(coAIPlayer npc, coSimSet path, int node)
        {
            npc.stopThread(0);

            if (!console.isObject(path))
            {
                npc["path"] = "";
                return;
            }

            if (node > path.getCount() - 1)
            {
                npc["targetNode"] = (path.getCount() - 1).AsString();
            }
            else
            {
                npc["targetNode"] = node.AsString();
            }

            if (((coSimSet)npc["path"]) == path)
            {
                AiPlayerMoveToNode(npc, npc["currentNode"].AsUint());
            }

            else
            {
                npc["path"] = path;
                AiPlayerMoveToNode(npc, 0);
            }
        }
Пример #2
0
 public void sfxResume(coSimSet pauseSet)
 {
     if (!console.isObject(pauseSet))
     {
         pauseSet = sGlobal["SFXPausedSet"];
     }
     for (uint i = 0; i < pauseSet.getCount(); i++)
     {
         ((coSFXSource)pauseSet.getObject(i)).play(-1);
     }
     pauseSet.clear();
 }
Пример #3
0
        public coAIPlayer AiPlayerSpawnOnPath(string ainame, coSimSet path)
        {
            if (!console.isObject(path))
            {
                return(null);
            }

            coMarker node = path.getObject((uint)r.Next(0, path.getCount() - 1));

            TransformF transform = node.getTransform();

            return(AiPlayerSpawn(ainame, transform));
        }
Пример #4
0
        public void AudioStateExclusiveonActivate(coSimObject thisobj)
        {
            console.ParentExecute(thisobj.ID, "onActivate", 1, new[] { thisobj.ID });
            coSimSet group = thisobj["parentGroup"];

            for (uint i = 0; i < group.getCount(); i++)
            {
                coSFXState obj = group.getObject(i);
                if (obj != thisobj && obj.isMemberOfClass("SFXState") && obj.isActive())
                {
                    obj.deactivate();
                }
            }
        }
Пример #5
0
        public void sfxStopAll(coSimSet channel)
        {
            channel = sfxOldChannelToGroup(channel);

            if (!channel.isObject())
            {
                return;
            }

            for (uint i = 0; i < channel.getCount(); i++)
            {
                ((coSFXSource)channel.getObject(i)).stop(-1);
            }
            //SFXSource.stop(channel.getObject(i), -1);
        }
Пример #6
0
        public coGuiControl sfxGetActiveStateInGroup(coSimSet group)
        {
            for (uint i = 0; i < group.getCount(); i++)
            {
                coGuiControl obj = group.getObject(i);
                if (obj.isMemberOfClass("SFXState"))
                {
                    continue;
                }

                if (obj.isActive())
                {
                    return(obj);
                }
            }
            return("");
        }
Пример #7
0
        public void sfxPause(coSimSet channels, coSimSet pauseSet)
        {
            if (!console.isObject(pauseSet))
            {
                pauseSet = sGlobal["SFXPausedSet"];
            }

            coSimSet SFXSourceSet = sGlobal["SFXSourceSet"];

            for (uint i = 0; i < SFXSourceSet.getCount(); i++)
            {
                coSimObject source  = SFXSourceSet.getObject(i);
                string      channel = sfxGroupToOldChannel(source.getGroup());

                //console.Call(source, "getGroup"));
                throw new Exception("The find word function doesn't exists... wtf?");
                //if (channel != "" && console.Call("findWord", new string[] { channels, channel }).AsInt() == -1)
                //    continue;
                ////SFXSource.pause(source, -1);
                //pauseSet.pushToBack(source);
            }
        }
Пример #8
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);
        }
Пример #9
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");
            }
        }
Пример #10
0
        public string AiTurretShapeDataOnThrow(coAITurretShapeData thisobj, coPlayer user, int amount)
        {
            if (amount == 0)
            {
                amount = 1;
            }

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

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

            ShapeBaseShapeBaseDecInventory(user, thisobj, amount);
            //console.Call(user, "decInventory", new[] {thisobj, amount});
            TransformF rot = new TransformF(user.getEulerRotation());

            Torque_Class_Helper tc_obj = new Torque_Class_Helper("AITurretShape", "");

            tc_obj.Props.Add("datablock", thisobj);
            tc_obj.Props.Add("rotation", string.Format("{0}0 0 1 {1}{0}", '"', rot.MPosition.z));
            tc_obj.Props.Add("count", "1");
            tc_obj.Props.Add("sourceObject", user);
            tc_obj.Props.Add("client", console.GetVarString(string.Format("{0}.client", user)));
            tc_obj.Props.Add("isAiControlled", "1");

            coAITurretShape obj = tc_obj.Create();

            ((coSimSet)"MissionGroup").pushToBack(obj);
            obj.call("addToIgnoreList", user);


            coGameConnection client = user["client"];

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

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

            return(obj);
        }