示例#1
0
        private void onObjectShot(Entity player, Entity grenade, string weapon)
        {
            switch (weapon)
            {
            case "uav_strike_marker_mp":
                Entity trigger = GSCFunctions.Spawn("trigger_radius", grenade.Origin, 0, 32, 32);
                trigger.SetField("owner", player);
                trigger.LinkTo(grenade);
                trigger.SetField("chainCount", 0);
                OnInterval(50, () =>
                {
                    foreach (Entity triggerer in Players)
                    {
                        bool isTouching  = triggerer.IsTouching(trigger);
                        bool isEnemy     = triggerer.SessionTeam == trigger.GetField <Entity>("owner").SessionTeam;
                        bool isTeamBased = GSCFunctions.GetDvar("g_gametype") != "dm";

                        if (isTouching && (isEnemy || !isTeamBased) && triggerer != trigger.GetField <Entity>("owner"))
                        {
                            triggerer.PlayFX(tempestFX, triggerer.Origin);
                            //Vector3 dir = Call<Vector3>("vectortoangles", trig.Origin - triggerer.As<Entity>().Origin);
                            //triggerer.As<Entity>().Call(33340, trig, trig.GetField<Entity>("owner"), 125, 0, "MOD_EXPLOSIVE_BULLET", "uav_strike_marker_mp", player.Origin, dir, "none", 0, 0);
                            GSCFunctions.RadiusDamage(trigger.Origin, 32, 125, 100, player);
                            trigger.Unlink();
                            trigger.Origin = triggerer.Origin;
                            trigger.LinkTo(triggerer);
                            int chainCount = trigger.GetField <int>("chainCount");
                            chainCount++;
                            trigger.SetField("chainCount", chainCount);
                            AfterDelay(3000, () =>
                            {
                                if (chainCount == trigger.GetField <int>("chainCount"))
                                {
                                    //trigger.SetField("doneChaining", true);
                                    trigger.ClearField("chainCount");
                                    trigger.ClearField("owner");
                                    //trigger.Notify("delete");
                                    trigger.Delete();
                                    return;
                                }
                            });
                        }
                        if (!Utilities.isEntDefined(trigger))
                        {
                            return(false);
                        }
                    }
                    return(true);
                });
                break;

            case "m320_mp":
                Log.Write(LogLevel.All, "Running Hives");
                Entity hive = grenade;
                hive.SetModel("projectile_m67fraggrenade");
                hive.SetField("owner", player);
                hive.EnableLinkTo();
                Entity enemyModel = GSCFunctions.Spawn("script_model", grenade.Origin);
                enemyModel.SetModel("projectile_m67fraggrenade_bombsquad");
                enemyModel.Hide();
                foreach (Entity players in Players)
                {
                    if (players.IsPlayer && players.SessionTeam != player.SessionTeam)
                    {
                        enemyModel.ShowToPlayer(players);
                    }
                }
                enemyModel.LinkTo(hive);
                hive.OnNotify("missile_stuck", (g, a) =>    //Notify for impact, find a way to setup as semtex calls
                {
                    Log.Write(LogLevel.All, "Hive stuck");
                    //Entity trig = GSCFunctions.Spawn("trigger_radius", g.Origin, 0, 128, 128);
                    Entity visual = GSCFunctions.Spawn("script_model", g.Origin);
                    visual.SetField("owner", g.GetField <Entity>("owner"));
                    visual.SetModel("projectile_m67fraggrenade_bombsquad");
                    //FX here
                    OnInterval(50, () =>
                    {
                        foreach (Entity triggerer in Players)
                        {
                            //if (!GSCFunctions.IsDefined(trig)) return false;
                            bool isTouching  = visual.Origin.DistanceTo(triggerer.Origin) < 120;       //triggerer.IsTouching(trig);
                            bool isEnemy     = triggerer.SessionTeam == visual.GetField <Entity>("owner").SessionTeam;
                            bool isTeamBased = GSCFunctions.GetDvar("g_gametype") != "dm";

                            if (isTouching && (isEnemy || !isTeamBased) && triggerer != visual.GetField <Entity>("owner"))
                            {
                                Log.Write(LogLevel.All, "Hive triggered");
                                OnInterval(250, () =>
                                {
                                    Vector3 dir = Vector3.RandomXY();
                                    triggerer.FinishPlayerDamage(visual, visual.GetField <Entity>("owner"), 25, 0, "MOD_SUICIDE", "trophy_mp", triggerer.Origin, dir, "none", 0);
                                    if (!triggerer.IsAlive)
                                    {
                                        return(false);
                                    }
                                    else
                                    {
                                        return(true);
                                    }
                                });

                                //trig.Notify("delete");
                                visual.Delete();
                                return(false);
                            }
                            else
                            {
                                return(true);
                            }
                        }
                        return(true);
                    });
                });
                break;
            }
        }