Exemple #1
0
        public ball()
        {
            string gametype = GSCFunctions.GetDvar("g_gametype");

            if (gametype != "ctf")
            {
                Log.Write(LogLevel.Info, "Gametype must be set to CTF for Uplink. Restarting...");
                GSCFunctions.SetDvar("g_gametype", "ctf");
                Utilities.ExecuteCommand("map_restart");
                return;
            }

            GSCFunctions.PreCacheItem(ballWeapon);
            GSCFunctions.PreCacheShader("waypoint_defend");
            GSCFunctions.PreCacheShader("waypoint_target");
            GSCFunctions.PreCacheShader("waypoint_kill");
            GSCFunctions.PreCacheShader("waypoint_targetneutral");
            GSCFunctions.PreCacheShader("equipment_emp_grenade");

            ballGlow      = GSCFunctions.LoadFX("misc/aircraft_light_wingtip_green");
            ballSiteFX    = GSCFunctions.LoadFX("misc/ui_flagbase_gold");
            alliesSiteFX  = GSCFunctions.LoadFX("misc/ui_flagbase_red");
            axisSiteFX    = GSCFunctions.LoadFX("misc/ui_flagbase_silver");
            ballContrail  = GSCFunctions.LoadFX("misc/light_semtex_geotrail");
            ballExplodeFX = GSCFunctions.LoadFX("explosions/emp_grenade");

            GSCFunctions.SetDevDvarIfUninitialized("scr_ball_scorelimit", 10);
            //GSCFunctions.SetDevDvarIfUninitialized("scr_ball_halftime", 0);
            //GSCFunctions.SetDevDvarIfUninitialized("scr_ball_overtime", 0);
            StartAsync(setGameScoreLimit());
            StartAsync(setGameHalftimeSetting());
            Log.Debug(isHalftime.ToString());

            //Delete flags
            Entity obj = GSCFunctions.GetEnt("ctf_zone_axis", "targetname");

            axisSite = obj.Origin;
            //obj.Delete();
            axisFlagBase = Entity.GetEntity(obj.EntRef);
            Entity flag = GSCFunctions.GetEnt("ctf_flag_axis", "targetname");

            //flag.Delete();
            axisFlag = Entity.GetEntity(flag.EntRef);
            Entity trig = GSCFunctions.GetEnt("ctf_trig_axis", "targetname");

            axisFlagTrig = Entity.GetEntity(trig.EntRef);
            obj          = GSCFunctions.GetEnt("ctf_zone_allies", "targetname");
            alliesSite   = obj.Origin;
            //obj.Delete();
            alliesFlagBase = Entity.GetEntity(obj.EntRef);
            flag           = GSCFunctions.GetEnt("ctf_flag_allies", "targetname");
            //flag.Delete();
            alliesFlag     = Entity.GetEntity(flag.EntRef);
            trig           = GSCFunctions.GetEnt("ctf_trig_allies", "targetname");
            alliesFlagTrig = Entity.GetEntity(trig.EntRef);

            StartAsync(getFlagTriggers());

            //Teleport flags under map and hide them
            axisFlagBase.Origin -= new Vector3(0, 0, 1000);
            axisFlagBase.Hide();
            axisFlag.Origin -= new Vector3(0, 0, 1000);
            axisFlag.Hide();
            axisFlagTrig.Origin   -= new Vector3(0, 0, 1000);
            alliesFlagBase.Origin -= new Vector3(0, 0, 1000);
            alliesFlagBase.Hide();
            alliesFlag.Origin -= new Vector3(0, 0, 1000);
            alliesFlag.Hide();
            alliesFlagTrig.Origin -= new Vector3(0, 0, 1000);

            //Init stations and ball locations
            site = GSCFunctions.GetEnt("sab_bomb", "targetname").Origin;
            spawnBall(site);
            StartAsync(spawnStations(alliesSite, axisSite));

            OnNotify("game_ended", (reason) =>
            {
                gameEnded = true;

                if ((int)GSCFunctions.GetMatchData("alliesScore") == 1)
                {
                    //GSCFunctions.SetDvar("scr_ball_halftime", 0);//Reset dvar if it's set
                    GSCFunctions.SetMatchData("alliesScore", 0);
                }

                if ((string)reason == "halftime")
                {
                    //GSCFunctions.SetDvar("scr_ball_halftime", 1);
                    GSCFunctions.SetMatchData("alliesScore", 1);
                }
            });
            OnNotify("prematch_over", () => prematchOver = true);

            //Set ball throw time
            GSCFunctions.SetDvar("perk_weapRateMultiplier", 0.3f);

            PlayerConnected += onPlayerConnect;
            Notified        += onNotify;

            StartAsync(initGameHud());
        }
Exemple #2
0
        private static IEnumerator setGameHalftimeSetting()
        {
            yield return(WaitForFrame());

            isHalftime = (int)GSCFunctions.GetMatchData("alliesScore") == 1;
        }