Exemple #1
0
 private static void playerDropBall(Entity player)
 {
     ballEnt.Origin = player.Origin;
     ballEnt.Show();
     ballEnt.SetField("parentEnt", level);
     ballEnt.SetField("lastThrow", GSCFunctions.GetTime());
     ballEnt.SetField("beingCarried", false);
     playBallFX();
     updateBallObjPoint();
     player.SetField("hasBall", false);
     if (player.IsAlive && player.Health > player.MaxHealth)
     {
         player.Health = player.MaxHealth;
     }
     player.EnableWeaponSwitch();
     player.EnableOffhandWeapons();
     player.EnableWeaponPickup();
     player.UnSetPerk("specialty_rof", true);
     player.SwitchToWeapon(player.GetField <string>("lastWeapon"));
     player.TakeWeapon(ballWeapon);
     AfterDelay(1000, () =>
     {
         OnInterval(50, () => monitorBallPickup(ballEnt));
         //ballEnt.SetField("carrier", level);//Keep this set as last play so that scores can be called remotely
     });
 }
Exemple #2
0
        private static bool monitorBallPickup(Entity ballTrigger)
        {
            if (ballTrigger.GetField <int>("lastThrow") + 25000 < GSCFunctions.GetTime())
            {
                ballTrigger.SetField("lastThrow", 999999999);
                respawnBall();
                return(true);
            }
            foreach (Entity player in Players)
            {
                if (!player.IsPlayer)
                {
                    continue;
                }
                if (player.CurrentWeapon == "none")
                {
                    continue;
                }

                bool isTouching = ballTrigger.Origin.DistanceTo(player.Origin) < 50;
                if (player.IsAlive && isTouching && !ballEnt.GetField <bool>("beingCarried"))
                {
                    ballEnt.SetField("beingCarried", true);
                    ballEnt.SetField("carrier", player);
                    player.SetField("hasBall", true);
                    player.Health += 100;
                    ballEnt.Hide();
                    ballEnt.Unlink();
                    Entity parent = ballEnt.GetField <Entity>("parentEnt");
                    if (parent != level)
                    {
                        parent.Delete();
                        ballEnt.SetField("parentEnt", level);
                    }
                    //detachBallFX();
                    updateBallObjPoint();
                    baseFX.Hide();
                    player.SetField("lastWeapon", player.CurrentWeapon);
                    player.GiveWeapon(ballWeapon);
                    player.SwitchToWeapon(ballWeapon);
                    player.DisableWeaponSwitch();
                    player.DisableOffhandWeapons();
                    player.DisableWeaponPickup();
                    player.SetPerk("specialty_rof", true, false);
                    return(false);
                }
            }

            if (gameEnded)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #3
0
 public static void AfterDelay(int delay, Action function)
 {
     _timers.Add(new ScriptTimer()
     {
         Func        = function,
         TriggerTime = GSCFunctions.GetTime() + delay,
         Interval    = -1,
     });
 }
Exemple #4
0
        private static void shThrusters(Entity player)
        {
            bool isGrounded       = !player.GetField <bool>("mayThrust");
            bool hasThrustJumped  = player.GetField <bool>("hasThrustJumped");
            bool hasThrusted      = player.GetField <bool>("hasThrustedForward");
            int  thrustsAvailable = player.GetField <int>("thrusterEnergy");

            if (!isGrounded && !hasThrustJumped && !hasThrusted && thrustsAvailable > 0 && player.IsAlive)
            {
                player.SetField("hasThrustJumped", true);
                player.SetField("thrusterEnergy", player.GetField <int>("thrusterEnergy") - 1);
                player.SetField("lastThrust", GSCFunctions.GetTime());
                AfterDelay(250, () => player.SetField("maySlam", true));
                if (player.HasPerk("specialty_quieter"))
                {
                    player.PlaySound("bullet_mega_flesh");
                }
                else
                {
                    player.PlaySound("weap_hind_rocket_fire");
                }
                shThrustRadarBlip(player);
                player.SetPerk("specialty_automantle", true, false);
                Vector3 currentVel = player.GetVelocity();
                float   velZ       = 500;
                player.SetVelocity(new Vector3(currentVel.X, currentVel.Y, velZ));
            }
            else if (!isGrounded && !hasThrustJumped && thrustsAvailable == 0 && player.IsAlive)
            {
                player.PlayLocalSound("weap_motiontracker_open_plr");
            }
            else
            {
                player.SetField("mayThrust", true);
                OnInterval(50, () =>
                {
                    bool grounded = player.IsOnGround();
                    if (grounded)
                    {
                        player.SetField("mayThrust", false);
                        player.SetField("maySlam", false);
                        player.SetField("hasThrustJumped", false);
                        player.SetField("hasThrustedForward", false);
                        player.UnSetPerk("specialty_automantle", true);
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                });
            }
        }
Exemple #5
0
        internal void ProcessTimers()
        {
            Function.SetEntRef(-1);
            _currentTime = GSCFunctions.GetTime();

            var timers = _timers.ToArray();

            foreach (var timer in timers)
            {
                if (_currentTime >= timer.TriggerTime)
                {
                    try
                    {
                        var    parameters  = timer.Func.Method.GetParameters();
                        var    returnType  = timer.Func.Method.ReturnType;
                        object returnValue = null;

                        if (parameters.Length > 0 && parameters[0].ParameterType == typeof(Entity))
                        {
                            returnValue = timer.Func.DynamicInvoke(this);
                        }
                        else
                        {
                            returnValue = timer.Func.DynamicInvoke();
                        }

                        if (returnType == typeof(bool) && (bool)returnValue == false)
                        {
                            _timers.Remove(timer);
                            continue;
                        }

                        if (timer.Interval != -1)
                        {
                            timer.TriggerTime = _currentTime + timer.Interval;
                        }
                        else
                        {
                            _timers.Remove(timer);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(LogLevel.Error, "Error during handling timer in script {0}: {1}", GetType().Name, (ex.InnerException != null) ? ex.InnerException.ToString() : ex.ToString());

                        _timers.Remove(timer);
                    }
                }
            }
        }
Exemple #6
0
 private void runSpecialistTimer(Entity player, float time)
 {
     OnInterval(50, () =>
     {
         if (player.IsPlayer)
         {
             if (!player.IsAlive)
             {
                 updateSpecialistTimer(player);
                 return(false);
             }
             else
             {
                 int charge     = player.GetField <int>("heroCharge");
                 int timePassed = GSCFunctions.GetTime();
                 if (charge == 1000 && player.GetField <int>("isUsingCharge") == 1)
                 {
                     int tick = charge--;
                     player.SetField("heroCharge", tick);
                     //try { player.SetField("heroCharge", tick); }
                     //catch { Log.Write(LogLevel.Error, "Error setting specialist timer tick in runSpecialistTimer()!"); }
                     updateSpecialistTimer(player);
                     return(true);
                 }
                 else if (charge == 0)
                 {
                     updateSpecialistTimer(player); return(false);
                 }
                 else
                 {
                     return(true);
                 }
             }
         }
         else
         {
             return(false);
         }
     });
 }
Exemple #7
0
 private static void monitorBallThrow(Entity carrier)
 {
     carrier.OnNotify("grenade_fire", (ent, grenade, weapon) =>
     {
         if ((string)weapon == ballWeapon)
         {
             ballEnt.Origin = grenade.As <Entity>().Origin;
             grenade.As <Entity>().EnableLinkTo();
             ballEnt.Show();
             //GSCFunctions.Objective_State(ballObjID, "active");
             ballEnt.Origin = grenade.As <Entity>().Origin;
             ballEnt.LinkTo(grenade.As <Entity>());
             ballEnt.SetField("parentEnt", grenade);
             ballEnt.SetField("lastThrow", GSCFunctions.GetTime());
             grenade.As <Entity>().Hide();
             ballEnt.SetField("beingCarried", false);
             playBallFX();
             updateBallObjPoint();
             carrier.SetField("hasBall", false);
             if (carrier.Health > carrier.MaxHealth)
             {
                 carrier.Health = carrier.MaxHealth;
             }
             carrier.EnableWeaponSwitch();
             carrier.EnableOffhandWeapons();
             carrier.EnableWeaponPickup();
             carrier.UnSetPerk("specialty_rof", true);
             carrier.SwitchToWeapon(carrier.GetField <string>("lastWeapon"));
             AfterDelay(1000, () =>
             {
                 carrier.TakeWeapon(ballWeapon);
                 OnInterval(50, () => monitorBallPickup(ballEnt));
                 //ballEnt.SetField("carrier", level);//Keep this set as last play so that scores can be called remotely
             });
         }
     });
 }
Exemple #8
0
    private static void update_ui_timers()
    {
        int nukeEndMilliseconds = (nukeTimer * 1000) + GSCFunctions.GetTime();

        GSCFunctions.SetDvar("ui_nuke_end_milliseconds", nukeEndMilliseconds);
    }
Exemple #9
0
        public static bool spawnBot(int spawnLoc, bool isCrawler)
        {
            if ((!isCrawler && botPool.Count == 0) || (isCrawler && crawlerPool.Count == 0))
            {
                return(true);                                                                            //True so in case all 30 have spawned, don't error out
            }
            Entity bot;

            if (isCrawler)
            {
                bot = crawlerPool[0];
            }
            else
            {
                bot = botPool[0];
            }

            if (botSpawns.Count == 0)
            {
                Utilities.PrintToConsole("No bot spawns available! Please have at least one \"zombiespawn\" in your map file.");
                GSCFunctions.Announcement("^1No bot spawns available! Check console for details");
                return(false);
            }

            int randomInt = g_AIZ.rng.Next(20);

            bot.Origin = botSpawns[spawnLoc] + new Vector3(randomInt, randomInt, 0);
            bot.Angles = spawnAngles[spawnLoc];
            bot.Show();
            bot.ShowAllParts();

            if (isCrawler)
            {
                playAnimOnBot(bot, crawlerAnim_idle);
            }
            else
            {
                playAnimOnBot(bot, anim_idle);
            }

            bot.SetField("state", "idle");
            if (!isCrawler && bot.HasField("head"))
            {
                Entity botHead = bot.GetField <Entity>("head");
                botHead.Show();
                //Remove helmet
                botHead.HidePart("j_head_end");
                botHead.HidePart("j_helmet");
                botHead.HidePart("j_collar_rear");
                Entity headHitbox = bot.GetField <Entity>("headHitbox");
                headHitbox.SetCanDamage(true);
            }
            bot.SetField("isAlive", true);
            bot.SetField("isAttacking", false);
            int time = GSCFunctions.GetTime();

            bot.SetField("lastActiveTime", time);
            spawnedBots++;
            Entity botHitbox = bot.GetField <Entity>("hitbox");

            if (isCrawler)
            {
                botHitbox.SetField("currentHealth", crawlerHealth);
            }
            else
            {
                botHitbox.SetField("currentHealth", health);
            }
            botHitbox.SetField("damageTaken", 0);
            botHitbox.SetCanDamage(true);
            botHitbox.SetCanRadiusDamage(true);
            //botHitbox.Show();
            botHitbox.SetModel("com_plasticcase_dummy");

            botsInPlay.Add(bot);
            if (isCrawler)
            {
                crawlerPool.Remove(bot);
            }
            else
            {
                botPool.Remove(bot);
            }

            onBotUpdate();

            OnInterval(100, () => botAI(bot, botHitbox, isCrawler, false));

            //Check for waypoints on spawn once
            foreach (Entity v in h_mapEdit.waypoints)
            {
                Vector3 botHeadTag    = bot.GetTagOrigin("j_head");
                bool    waypointTrace = GSCFunctions.SightTracePassed(botHeadTag, v.Origin, false, botHitbox);//Check for waypoints
                if (waypointTrace)
                {
                    bot.SetField("currentWaypoint", v);//Set the first seen one as current
                    bot.SetField("visibleWaypoints", new Parameter(v.GetField <List <Entity> >("visiblePoints")));
                    break;
                }
            }

            return(true);
        }
Exemple #10
0
        public static bool botAI(Entity ai, Entity botHitbox, bool isCrawler, bool isBoss)
        {
            if (!ai.GetField <bool>("isAlive") || !botsInPlay.Contains(ai) || botHitbox.GetField <int>("currentHealth") <= botHitbox.GetField <int>("damageTaken"))
            {
                return(false);
            }
            killBotIfUnderMap(ai);
            if (!ai.GetField <bool>("isAlive"))
            {
                return(false);                              //Do another check after height check
            }
            //check time inactivity
            int currentTime = GSCFunctions.GetTime();
            int lastTime    = ai.GetField <int>("lastActiveTime");

            if (currentTime > lastTime + 120000 && !isBoss && !freezerActivated)
            {
                killBotAndRespawn(ai);
                return(false);
            }

            Entity  target     = null;
            Vector3 botOrigin  = ai.Origin;
            Vector3 botHeadTag = ai.GetTagOrigin("j_head");// + new Vector3 (0, 0, 5);

            float Ground = GSCFunctions.GetGroundPosition(botOrigin).Z;

            #region targeting
            if (glowsticks.Count != 0)//Find a glowstick first
            {
                foreach (Entity g in glowsticks)
                {
                    if (freezerActivated)
                    {
                        break;
                    }
                    if (g_AIZ.isGlowstick(ai.GetField <Entity>("currentWaypoint")))
                    {
                        target = ai.GetField <Entity>("currentWaypoint"); continue;
                    }
                    if (botOrigin.DistanceTo(g.Origin) > 500)
                    {
                        continue;
                    }
                    bool tracePass = GSCFunctions.SightTracePassed(botHeadTag, g.Origin, false, botHitbox);
                    if (tracePass)
                    {
                        target = g;
                        //ai.ClearField("currentWaypoint");
                        ai.SetField("currentWaypoint", g);
                        ai.ClearField("visibleWaypoints");
                        break;
                    }
                    //else
                    //{
                    //Log.Write(LogLevel.All, "No trace available");
                    //}
                }
            }
            if (target == null && !freezerActivated)//If we haven't found a glowstick, find a real target
            {
                float dist;
                float tempDist = 999999999;
                foreach (Entity p in Players)//Find a player
                {
                    Vector3 playerOrigin = p.Origin;
                    dist = botOrigin.DistanceTo(playerOrigin);
                    if (p.SessionTeam != "allies" || !p.IsAlive || p.GetField <bool>("isDown") || p.GetField <bool>("isInHeliSniper") || dist > 600)
                    {
                        continue;
                    }
                    Vector3 playerHeadTag = p.GetTagOrigin("j_head");
                    bool    tracePass     = GSCFunctions.SightTracePassed(botHeadTag, playerHeadTag, false, botHitbox);
                    if (tracePass)
                    {
                        //Log.Write(LogLevel.All, "Traced {0}", p.Name);
                        //if (target != null)
                        {
                            bool isCloser = playerOrigin.DistanceTo(botOrigin) < tempDist;//GSCFunctions.Closer(botHeadTag, playerHeadTag, targetHeadTag);
                            if (isCloser)
                            {
                                tempDist = playerOrigin.DistanceTo(botOrigin);
                                target   = p;
                                //ai.ClearField("currentWaypoint");
                                ai.SetField("currentWaypoint", ai);
                                ai.ClearField("visibleWaypoints");
                                //Log.Write(LogLevel.All, "{0} is closer", target.Name);
                            }
                        }

                        /*
                         * else
                         * {
                         *  target = p;
                         *  //ai.ClearField("currentWaypoint");
                         *  ai.SetField("currentWaypoint", ai);
                         *  ai.ClearField("visibleWaypoints");
                         *  //Log.Write(LogLevel.All, "Target is null");
                         * }
                         */
                    }
                    //Attacking players
                    float attackDist = botHitbox.Origin.DistanceTo(playerOrigin);

                    if (attackDist <= 50 && !ai.GetField <bool>("isAttacking"))
                    {
                        ai.SetField("isAttacking", true);

                        updateBotLastActiveTime(ai);

                        if (ai.GetField <bool>("primedForNuke"))
                        {
                            playAnimOnBot(ai, anim_lose);
                        }
                        else if (isCrawler || ai.HasField("hasBeenCrippled"))
                        {
                            playAnimOnBot(ai, crawlerAnim_attack);
                        }
                        else
                        {
                            playAnimOnBot(ai, anim_attack);
                        }
                        AfterDelay(700, () =>
                        {
                            if ((isCrawler || ai.HasField("hasBeenCrippled")) && ai.GetField <bool>("isAlive"))
                            {
                                playAnimOnBot(ai, crawlerAnim_walk);
                            }
                            else if (isBoss && ai.GetField <bool>("isAlive"))
                            {
                                playAnimOnBot(ai, anim_run);
                            }
                            else
                            {
                                if (ai.GetField <bool>("isAlive"))
                                {
                                    if (isInPeril(botHitbox))
                                    {
                                        playAnimOnBot(ai, anim_run);
                                    }
                                    else
                                    {
                                        playAnimOnBot(ai, anim_walk);
                                    }
                                }
                            }
                            if (ai.GetField <bool>("isAlive"))
                            {
                                ai.SetField("isAttacking", false);
                            }
                        });

                        if (ai.GetField <bool>("primedForNuke"))
                        {
                            continue;
                        }

                        Vector3 dir = GSCFunctions.VectorToAngles(ai.Origin - p.Origin);
                        dir.Normalize();
                        float hitDir = dir.Y - p.GetPlayerAngles().Y;
                        //Log.Write(LogLevel.Debug, "Dir = {0}; Angle = {1}", dir.ToString(), angle);
                        AfterDelay(100, () =>
                        {
                            GSCFunctions.PlayFX(fx_blood, p.Origin + new Vector3(0, 0, 30));
                            if ((p.HasWeapon("riotshield_mp") || p.HasWeapon("iw5_riotshield_mp")) && ((p.CurrentWeapon != "riotshield_mp" && p.CurrentWeapon != "iw5_riotshield_mp" && hitDir > -80 && hitDir < 80) || (p.CurrentWeapon == "riotshield_mp" || p.CurrentWeapon == "iw5_riotshield_mp")))
                            {
                                p.PlaySound("melee_hit");
                                p.FinishPlayerDamage(null, null, dmg / 2, 0, "MOD_FALLING", "none", p.Origin, dir, "none", 0);
                            }
                            else
                            {
                                p.PlaySound("melee_punch_other");
                                p.FinishPlayerDamage(null, null, dmg, 0, "MOD_FALLING", "none", p.Origin, dir, "none", 0);
                            }
                            AfterDelay(8000, () => p.Health = p.MaxHealth);
                        });
                    }
                    //End attacking
                }
                if (target == null)//No players, find a waypoint
                {
                    if (ai.HasField("currentWaypoint") && ai.HasField("visibleWaypoints"))
                    {
                        //Entity currentWaypoint = ai.GetField<Entity>("currentWaypoint");
                        //if (currentWaypoint.HasField("visiblePoints") && !ai.HasField("visibleWaypoints")) ai.SetField("visibleWaypoints", new Parameter(currentWaypoint.GetField<List<Entity>>("visiblePoints")));
                        float waypointDist = botOrigin.DistanceTo(ai.GetField <Entity>("currentWaypoint").Origin);
                        if (ai.GetField <Entity>("currentWaypoint") == ai && ai.HasField("visibleWaypoints"))
                        {
                            List <Entity> visibleWaypoints = ai.GetField <List <Entity> >("visibleWaypoints");
                            int           randomWaypoint   = g_AIZ.rng.Next(visibleWaypoints.Count);
                            ai.SetField("currentWaypoint", visibleWaypoints[randomWaypoint]);
                        }
                        else if (waypointDist < 50)
                        {
                            ai.SetField("visibleWaypoints", new Parameter(ai.GetField <Entity>("currentWaypoint").GetField <List <Entity> >("visiblePoints")));
                            ai.SetField("currentWaypoint", ai);
                            //visibleWaypoints.Clear();
                            return(true);
                        }
                    }
                    else if (!ai.HasField("currentWaypoint") || !ai.HasField("visibleWaypoints"))//Recalculate point
                    {
                        foreach (Entity v in h_mapEdit.waypoints)
                        {
                            bool waypointTrace = GSCFunctions.SightTracePassed(botHeadTag, v.Origin, false, botHitbox);//Check for waypoints
                            if (waypointTrace)
                            {
                                ai.SetField("currentWaypoint", v);//Set the first seen one as current
                                ai.SetField("visibleWaypoints", new Parameter(v.GetField <List <Entity> >("visiblePoints")));
                                break;
                            }
                        }
                    }
                    if (ai.HasField("currentWaypoint") && ai.GetField <Entity>("currentWaypoint") != ai)
                    {
                        target = ai.GetField <Entity>("currentWaypoint");
                    }
                }
            }
            #endregion
            //Now we are done targeting, do the action for the target

            #region motion
            if (ai.GetField <bool>("isAttacking"))
            {
                return(true);                                 //Stop moving to attack. Prevent bots getting stuck into players
            }

            /*
             * foreach (Entity bot in botsInPlay)//Prevent bots from combining into each other
             * {
             *  if (ai == bot) continue;
             *  Vector3 closeOrigin = bot.Origin;
             *  if (botOrigin.DistanceTo(closeOrigin) < 10)//Move away from the bot and recalc
             *  {
             *      Vector3 dir = GSCFunctions.VectorToAngles(closeOrigin - botOrigin);
             *      Vector3 awayPos = botOrigin - dir * 100;
             *      ai.MoveTo(awayPos, botOrigin.DistanceTo(awayPos) / 120);
             *      ai.RotateTo(new Vector3(0, -dir.Y, 0), .3f, .1f, .1f);
             *      return true;
             *  }
             * }
             */

            if (target != null && glowsticks.Count == 0)//Move to our target if there are no glowsticks
            {
                Vector3 targetOrigin = target.Origin;
                //if (target.IsPlayer) targetHeadTag = target.GetTagOrigin("j_head");
                //else targetHeadTag = target.Origin;
                float angleY = GSCFunctions.VectorToAngles(targetOrigin - botOrigin).Y;
                ai.RotateTo(new Vector3(0, angleY, 0), .3f, .1f, .1f);

                if (botOrigin.DistanceTo2D(targetOrigin) < 100 || Ground == botOrigin.Z)
                {
                    Ground = targetOrigin.Z;
                }

                int   speed    = 100;
                float distance = botOrigin.DistanceTo(targetOrigin);

                if (((isInPeril(botHitbox) && !ai.HasField("hasBeenCrippled")) && !ai.HasField("hasBeenCrippled")) || isBoss)
                {
                    speed = 170;
                }
                else if (ai.HasField("hasBeenCrippled"))
                {
                    speed = 30;
                }
                float groundDist = Ground - botOrigin.Z;
                groundDist *= 8;//Overcompansate to move faster and track along ground in a better way
                if (Ground == targetOrigin.Z)
                {
                    groundDist = 0;                          //Fix 'jumping bots'
                }
                ai.MoveTo(new Vector3(targetOrigin.X, targetOrigin.Y, Ground + groundDist), distance / speed);

                string state = ai.GetField <string>("state");
                if ((state == "post_hurt" || state == "idle" || state == "dancing") && state != "hurt" && state != "attacking")
                {
                    if (isCrawler || ai.HasField("hasBeenCrippled"))
                    {
                        playAnimOnBot(ai, crawlerAnim_walk);
                    }
                    else if (isBoss)
                    {
                        playAnimOnBot(ai, anim_run);
                    }
                    else
                    {
                        if (isInPeril(botHitbox))
                        {
                            playAnimOnBot(ai, anim_run);
                        }
                        else
                        {
                            playAnimOnBot(ai, anim_walk);
                        }
                    }
                    ai.SetField("state", "moving");
                }
            }
            else if (target != null && (glowsticks.Count > 0 && g_AIZ.isGlowstick(target)))//Move towards a glowstick and dance
            {
                Vector3 targetOrigin = target.Origin;
                if (Ground == botOrigin.Z)
                {
                    Ground = targetOrigin.Z;
                }
                float angleY = GSCFunctions.VectorToAngles(targetOrigin - botOrigin).Y;
                ai.RotateTo(new Vector3(0, angleY, 0), .3f, .1f, .1f);
                float  randomX = g_AIZ.rng.Next(-100, 100);
                float  randomY = g_AIZ.rng.Next(-100, 100);
                string state   = ai.GetField <string>("state");

                if (botOrigin.DistanceTo(targetOrigin) > 50)
                {
                    int   speed    = 100;
                    float distance = botOrigin.DistanceTo(targetOrigin);

                    if (((isInPeril(botHitbox) && !ai.HasField("hasBeenCrippled")) && !ai.HasField("hasBeenCrippled")) || isBoss)
                    {
                        speed = 170;
                    }
                    else if (ai.HasField("hasBeenCrippled"))
                    {
                        speed = 30;
                    }
                    float groundDist = Ground - botOrigin.Z;
                    groundDist *= 8;//Overcompansate to move faster and track along ground in a better way
                    if (Ground == targetOrigin.Z)
                    {
                        groundDist = 0;                          //Fix 'jumping bots'
                    }
                    ai.MoveTo(new Vector3(targetOrigin.X + randomX, targetOrigin.Y + randomY, Ground + groundDist), distance / speed);
                }
                else if (state != "dancing")
                {
                    ai.Origin = botOrigin;
                    playAnimOnBot(ai, anim_lose);
                    ai.SetField("state", "dancing");
                    return(true);
                }
                if ((state == "post_hurt" || state == "idle") && state != "hurt" && state != "attacking")
                {
                    if (isCrawler)
                    {
                        playAnimOnBot(ai, crawlerAnim_walk);
                    }
                    else if (isBoss)
                    {
                        playAnimOnBot(ai, anim_run);
                    }
                    else
                    {
                        playAnimOnBot(ai, anim_walk);
                    }
                    ai.SetField("state", "moving");
                }
            }
            else if (target != null && (glowsticks.Count > 0 && !g_AIZ.isGlowstick(target)))//Move towards a player while a glowstick is out but not in sight
            {
                Vector3 targetOrigin = target.Origin;
                if (Ground == botOrigin.Z)
                {
                    Ground = targetOrigin.Z;
                }
                float angleY = GSCFunctions.VectorToAngles(targetOrigin - botOrigin).Y;
                ai.RotateTo(new Vector3(0, angleY, 0), .3f, .1f, .1f);

                int   speed    = 100;
                float distance = botOrigin.DistanceTo(targetOrigin);

                if (((isInPeril(botHitbox) && !ai.HasField("hasBeenCrippled")) && !ai.HasField("hasBeenCrippled")) || isBoss)
                {
                    speed = 170;
                }
                else if (ai.HasField("hasBeenCrippled"))
                {
                    speed = 30;
                }
                float groundDist = Ground - botOrigin.Z;
                groundDist *= 8;//Overcompansate to move faster and track along ground in a better way
                if (Ground == targetOrigin.Z)
                {
                    groundDist = 0;                          //Fix 'jumping bots'
                }
                ai.MoveTo(new Vector3(targetOrigin.X, targetOrigin.Y, Ground + groundDist), distance / speed);

                string state = ai.GetField <string>("state");
                if ((state == "post_hurt" || state == "idle" || state == "dancing") && state != "hurt" && state != "attacking")
                {
                    if (isCrawler || ai.HasField("hasBeenCrippled"))
                    {
                        playAnimOnBot(ai, crawlerAnim_walk);
                    }
                    else if (isBoss)
                    {
                        playAnimOnBot(ai, anim_run);
                    }
                    else
                    {
                        if (isInPeril(botHitbox))
                        {
                            playAnimOnBot(ai, anim_run);
                        }
                        else
                        {
                            playAnimOnBot(ai, anim_walk);
                        }
                    }
                    ai.SetField("state", "moving");
                }
            }
            else//failsafe, just stand still if there is no other options
            {
                ai.MoveTo(new Vector3(botOrigin.X, botOrigin.Y, Ground), 1);
                string state = ai.GetField <string>("state");
                if (state != "idle" && state != "hurt" && state != "attacking")
                {
                    if (isCrawler || ai.HasField("hasBeenCrippled"))
                    {
                        playAnimOnBot(ai, crawlerAnim_idle);
                    }
                    else
                    {
                        playAnimOnBot(ai, anim_idle);
                    }
                    ai.SetField("state", "idle");
                }
            }
            #endregion

            GSCFunctions.ResetTimeout();
            return(true);
        }
Exemple #11
0
 public override void OnStartGameType()
 {
     Log.Write(LogLevel.Info, "Gametype started at {0}", GSCFunctions.GetTime());
 }
Exemple #12
0
        public Class1()
        {
            Utilities.PrintToConsole(string.Format("Plugin loaded at {0}", GSCFunctions.GetTime()));
            //GSCFunctions.PreCacheString("Test String");
            //GSCFunctions.PreCacheStatusIcon("cardicon_iwlogo");
            //GSCFunctions.PreCacheMenu("kickplayer");
            //GSCFunctions.PreCacheMenu("elevator_floor_selector");
            //GSCFunctions.PreCacheShader("faction_128_gign");

            //Marshal.WriteInt32(new IntPtr(0x0585AE0C), 24);
            //Marshal.WriteInt32(new IntPtr(0x0585AE1C), 24);

            //working guns
            GSCFunctions.PreCacheItem("at4_mp");
            GSCFunctions.PreCacheItem("airdrop_mega_marker_mp");
            GSCFunctions.PreCacheItem("throwingknife_rhand_mp");
            GSCFunctions.PreCacheItem("iw5_mk12spr_mp");
            GSCFunctions.PreCacheItem("lightstick_mp");
            GSCFunctions.PreCacheItem("killstreak_double_uav_mp");
            GSCFunctions.PreCacheItem("strike_marker_mp");
            GSCFunctions.PreCacheItem("killstreak_helicopter_minigun_mp");
            GSCFunctions.PreCacheItem("airdrop_juggernaut_def_mp");
            GSCFunctions.PreCacheItem("uav_strike_missile_mp");
            GSCFunctions.PreCacheItem("uav_strike_projectile_mp");
            GSCFunctions.PreCacheItem("iw5_xm25_mp");
            GSCFunctions.PreCacheItem("iw5_riotshield_mp");
            GSCFunctions.PreCacheItem("harrier_missile_mp");

            //turret-only
            GSCFunctions.PreCacheTurret("manned_minigun_turret_mp");
            GSCFunctions.PreCacheTurret("manned_gl_turret_mp");
            GSCFunctions.PreCacheItem("remote_uav_weapon_mp");
            GSCFunctions.PreCacheItem("aamissile_projectile_mp");

            //Hacking in all fx
            //smoke

            /*
             * string[] smoke_fx;
             * smoke_fx = Directory.GetFiles(@"H:\USBFORMAT\MW3 GSCs\devraw\fx\smoke");
             * for (int i = 0; i < smoke_fx.Length; i++)
             * {
             *  GSCFunctions.LoadFX("smoke/" + smoke_fx[i].Split('\\')[6].Replace(".FXE", ""));
             * }
             * string[] prop_fx;
             * prop_fx = Directory.GetFiles(@"H:\USBFORMAT\MW3 GSCs\devraw\fx\props");
             * for (int i = 0; i < prop_fx.Length; i++)
             * {
             *  GSCFunctions.LoadFX("props/" + prop_fx[i].Split('\\')[6].Replace(".FXE", ""));
             * }
             * string[] dust_fx;
             * dust_fx = Directory.GetFiles(@"H:\USBFORMAT\MW3 GSCs\devraw\fx\dust");
             * for (int i = 0; i < dust_fx.Length; i++)
             * {
             *  GSCFunctions.LoadFX("dust/" + dust_fx[i].Split('\\')[6].Replace(".FXE", ""));
             * }
             * string[] exp_fx;
             * exp_fx = Directory.GetFiles(@"H:\USBFORMAT\MW3 GSCs\devraw\fx\explosions");
             * for (int i = 0; i < exp_fx.Length; i++)
             * {
             *  GSCFunctions.LoadFX("explosions/" + exp_fx[i].Split('\\')[6].Replace(".FXE", ""));
             * }
             * string[] impact_fx;
             * impact_fx = Directory.GetFiles(@"H:\USBFORMAT\MW3 GSCs\devraw\fx\impacts");
             * for (int i = 0; i < 100; i++)
             * {
             *  GSCFunctions.LoadFX("impacts/" + impact_fx[i].Split('\\')[6].Replace(".FXE", ""));
             * }
             * string[] shellejects_fx;
             * shellejects_fx = Directory.GetFiles(@"H:\USBFORMAT\MW3 GSCs\devraw\fx\shellejects");
             * for (int i = 0; i < shellejects_fx.Length; i++)
             * {
             *  GSCFunctions.LoadFX("shellejects/" + shellejects_fx[i].Split('\\')[6].Replace(".FXE", ""));
             * }
             * string[] fire_fx;
             * fire_fx = Directory.GetFiles(@"H:\USBFORMAT\MW3 GSCs\devraw\fx\fire");
             * for (int i = 0; i < fire_fx.Length; i++)
             * {
             *  GSCFunctions.LoadFX("fire/" + fire_fx[i].Split('\\')[6].Replace(".FXE", ""));
             * }
             */
            GSCFunctions.LoadFX("fire/jet_afterburner_harrier");
            GSCFunctions.LoadFX("smoke/jet_contrail");
            GSCFunctions.LoadFX("misc/aircraft_light_red_blink");
            GSCFunctions.LoadFX("misc/aircraft_light_wingtip_red");
            GSCFunctions.LoadFX("misc/aircraft_light_wingtip_green");

            _airdropCollision = GSCFunctions.GetEnt("care_package", "targetname");
            _airdropCollision = GSCFunctions.GetEnt(_airdropCollision.Target, "targetname");

            GSCFunctions.PreCacheMpAnim("viewmodel_airdrop_marker_sprint_loop");
            //GSCFunctions.PreCacheMpAnim("viewmodel_claymore_idle");

            string[] testAnims = new string[] { "pb_crouch_grenade_idle",
                                                "pb_crouch_stickgrenade_idle",
                                                "pb_crouch_grenade_pullpin",
                                                "pb_crouch_alert",
                                                "pb_crouch_ads",
                                                "pb_crouch_alert_pistol",
                                                "pb_crouch_ads_pistol",
                                                "pb_crouch_alert_unarmed",
                                                "pb_crouch_alert_akimbo",
                                                "pb_crouch_alert_shield",
                                                "pb_chicken_dance",
                                                "pb_chicken_dance_crouch",
                                                "pb_crouch_bombplant",
                                                "pb_crouch_remotecontroller",
                                                "pb_hold_idle",
                                                "pb_crouch_hold_idle",
                                                "pb_crouch_alert_RPG",
                                                "pb_crouch_ads_RPG" };

            //foreach (string anim in testAnims)
            //GSCFunctions.PreCacheMpAnim(anim);

            fx_eyes = GSCFunctions.LoadFX("misc/aircraft_light_wingtip_red");

            PlayerConnected += OnPlayerConnected;

            //GSCFunctions.SetDvar("scr_diehard", 2);
            GSCFunctions.SetDevDvar("developer", 2);
            GSCFunctions.SetDevDvar("developer_script", 1);
            GSCFunctions.SetDvarIfUninitialized("scr_showNotifyMessages", 1);
            GSCFunctions.SetDvar("scr_game_playerwaittime", 0);
            GSCFunctions.SetDvar("scr_game_matchstarttime", 0);

            Notified += new Action <int, string, Parameter[]>((ent, message, parameters) =>
            {
                //if (message == "trigger") return;
                if (GSCFunctions.GetDvarInt("scr_showNotifyMessages") == 0)
                {
                    return;
                }
                if (parameters.Length > 0)
                {
                    foreach (string p in parameters)
                    {
                        Utilities.PrintToConsole(ent.ToString() + ": " + message + ":" + p);
                    }
                }
                else
                {
                    Utilities.PrintToConsole(string.Format("{0} Notified " + message, ent));
                }
            });

            level = Entity.GetEntity(2046);

            /*
             * GSCFunctions.SetSunlight(new Vector3(0, 0, 1));
             * GSCFunctions.VisionSetNaked("cobra_sunset3");
             * for (int i = 18; i < 2000; i++)
             * {
             *  Entity ent = GSCFunctions.GetEntByNum(i);
             *  if (ent == null) continue;
             *  string entModel = ent.Model;
             *
             *  if (entModel == "vehicle_hummer_destructible")
             *      ent.SetModel("com_satellite_dish_big");
             *  else if (ent.TargetName == "explodable_barrel")
             *  {
             *      Entity col = GSCFunctions.GetEnt(ent.Target, "targetname");
             *      if (col != null) col.Delete();
             *      ent.Delete();
             *  }
             *  else if (ent.TargetName == "animated_model")
             *  {
             *      ent.ScriptModelClearAnim();
             *      ent.Delete();
             *      Entity placeholder = GSCFunctions.Spawn("script_model", Vector3.Zero);
             *  }
             * }
             */
            //StartAsync(testFunc());
            //StartAsync(dumpHud());
        }
Exemple #13
0
        private static void treyarchThrusters(Entity player)
        {
            bool isGrounded = player.GetField <int>("mayThrust") == 0;

            if (!isGrounded)
            {
                player.SetField("thrustersActive", 1);
                Entity thrusterSound = null;
                if (!player.HasPerk("specialty_quieter") && player.GetField <int>("thrusterEnergy") > 0)
                {
                    thrusterSound = GSCFunctions.Spawn("script_origin", player.Origin);
                    //thrusterSound.LinkTo(player);
                    thrusterSound.PlayLoopSound("weap_hind_rocket_loop_dist");

                    player.SetPerk("specialty_radarblip", true, false);
                }

                OnInterval(50, () =>
                {
                    int thrusterEnergy = player.GetField <int>("thrusterEnergy");
                    if (thrusterEnergy <= 0)
                    {
                        player.SetField("thrustersActive", 0);
                        return(true);
                    }
                    Vector3 currentVel = player.GetVelocity();
                    float vel          = currentVel.Z += 75;
                    if (vel > 200)
                    {
                        vel = 200;
                    }
                    player.SetVelocity(new Vector3(currentVel.X, currentVel.Y, vel));
                    player.SetField("thrusterEnergy", thrusterEnergy - 1);
                    updateThrusterBar(player, thrusterEnergy - 1);

                    if (thrusterSound != null)
                    {
                        thrusterSound.Origin = player.Origin;
                    }

                    //Log.Write(LogLevel.All, "Energy {0}", bird.GetField<int>("thrusterEnergy"));
                    thrusterEnergy = player.GetField <int>("thrusterEnergy");
                    int time       = GSCFunctions.GetTime();
                    player.SetField("lastThrust", time);
                    bool stopFlying = (thrusterEnergy == 0 || player.GetField <int>("thrustersActive") == 0);
                    if (stopFlying)
                    {
                        if (!player.HasPerk("specialty_quieter") && thrusterSound != null)
                        {
                            thrusterSound.StopLoopSound();
                            thrusterSound.Delete();
                            player.UnSetPerk("specialty_radarblip", true);
                        }
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                });
            }
            else
            {
                player.SetField("mayThrust", 1);
                OnInterval(50, () =>
                {
                    bool grounded = player.IsOnGround();
                    if (grounded)
                    {
                        player.SetField("mayThrust", 0);
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                });
            }
        }
Exemple #14
0
        private static void shThrustersDirectional(Entity player)
        {
            bool    isGrounded       = !player.GetField <bool>("mayThrust");
            bool    hasThrusted      = player.GetField <bool>("hasThrustedForward");
            int     thrustsAvailable = player.GetField <int>("thrusterEnergy");
            int     lastThrustTime   = player.GetField <int>("lastThrust");
            int     time             = GSCFunctions.GetTime();
            Vector3 movement         = player.GetNormalizedMovement();

            if (!isGrounded && !hasThrusted && thrustsAvailable > 0 && time > (lastThrustTime + 200) && player.IsAlive && movement.X > 0)
            {
                player.SetField("hasThrustedForward", true);
                player.SetPerk("specialty_automantle", true, false);
                player.SetField("thrusterEnergy", player.GetField <int>("thrusterEnergy") - 1);
                if (player.HasPerk("specialty_quieter"))
                {
                    player.PlaySound("bullet_mega_flesh");
                }
                else
                {
                    player.PlaySound("weap_hind_rocket_fire");
                }
                shThrustRadarBlip(player);
                Vector3 currentVel = player.GetVelocity();
                Vector3 angles     = player.GetPlayerAngles();
                Vector3 forward    = GSCFunctions.AnglesToForward(angles);
                //Log.Debug("X: {0}, Y: {1}, Z: {2}", forward.X, forward.Y, forward.Z);
                Vector3 newVel = new Vector3(currentVel.X + (forward.X * 250), currentVel.Y + (forward.Y * 250), currentVel.Z);

                player.SetVelocity(newVel);
            }
            else if (!hasThrusted && thrustsAvailable > 0 && time > (lastThrustTime + 200) && player.IsAlive && movement.Y != 0 && movement.X == 0)//Dodge
            {
                player.SetField("hasThrustedForward", true);
                player.SetPerk("specialty_automantle", true, false);
                player.SetField("thrusterEnergy", player.GetField <int>("thrusterEnergy") - 1);
                if (player.HasPerk("specialty_quieter"))
                {
                    player.PlaySound("bullet_mega_flesh");
                }
                else
                {
                    player.PlaySound("weap_hind_rocket_fire");
                }
                shThrustRadarBlip(player);
                Vector3 currentVel = player.GetVelocity();
                Vector3 angles     = player.GetPlayerAngles();
                Vector3 right      = GSCFunctions.AnglesToRight(angles);
                //Log.Debug("X: {0}, Y: {1}, Z: {2}", forward.X, forward.Y, forward.Z);
                Vector3 newVel;
                if (movement.Y > 0)
                {
                    newVel = new Vector3(currentVel.X + (right.X * 300), currentVel.Y + (right.Y * 300), currentVel.Z);
                }
                else
                {
                    newVel = new Vector3(currentVel.X + (-right.X * 300), currentVel.Y + (-right.Y * 300), currentVel.Z);
                }

                player.SetVelocity(newVel);
                player.SlideVelocity += newVel;
                AfterDelay(1000, () => player.SetField("hasThrustedForward", false));
            }
            else if (!hasThrusted && thrustsAvailable == 0)
            {
                player.PlayLocalSound("weap_motiontracker_open_plr");
            }
        }
Exemple #15
0
        private static void initThrusterBehavior(Entity player)
        {
            if (GSCFunctions.GetDvar("g_thrusterType") == "1")
            {
                player.SetField("thrustersActive", 0);
                player.SetField("thrusterEnergy", 25);
                player.SetField("lastThrust", 0);
                player.SetField("mayThrust", 0);
                player.NotifyOnPlayerCommand("deactivateThrust", "-gostand");
                player.OnNotify("jumped", treyarchThrusters);
                thrusterHUD(player);

                player.OnNotify("deactivateThrust", (p) =>
                                p.SetField("thrustersActive", 0));

                OnInterval(50, () =>
                {
                    if (!player.IsAlive)
                    {
                        return(true);
                    }

                    int lastThrust     = player.GetField <int>("lastThrust");
                    int time           = GSCFunctions.GetTime();
                    int thrusterEnergy = player.GetField <int>("thrusterEnergy");
                    if (time > lastThrust + 1500 && lastThrust != 0 && thrusterEnergy < 25)
                    {
                        if (player.GetField <int>("thrustersActive") == 1)
                        {
                            return(true);
                        }
                        player.SetField("thrusterEnergy", thrusterEnergy + 1);
                        updateThrusterBar(player, thrusterEnergy + 1);
                        //Log.Write(LogLevel.All, "Thruster energy updated to {0}", thrusterEnergy + 1);
                        return(true);
                    }
                    else
                    {
                        return(true);
                    }
                });
            }
            else if (GSCFunctions.GetDvar("g_thrusterType") == "0")
            {
                player.OnNotify("jumped", shThrusters);
                player.OnNotify("hold_breath", shThrustersDirectional);
                player.OnNotify("adjustedStance", shThrusterSlam);
                player.SetField("hasThrustJumped", false);
                player.SetField("hasThrustedForward", false);
                player.SetField("mayThrust", false);
                player.SetField("maySlam", false);
                player.SetField("lastThrust", 0);
                player.SetField("thrusterEnergy", 3);

                OnInterval(1500, () =>
                {
                    int energy = player.GetField <int>("thrusterEnergy");
                    if (energy < 3)
                    {
                        player.SetField("thrusterEnergy", energy + 1);
                    }
                    if (player.IsPlayer)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });
            }
        }