Esempio n. 1
0
 public override void OnFired(Npc npc)
 {
     if (Team == Respawning.SpawnableTeamType.NineTailedFox)
     {
         npc.FireEvent(new NPCCustomEvent(npc, null, "NPCNTFRespawnEvent"));
     }
     else
     {
         npc.FireEvent(new NPCCustomEvent(npc, null, "NPCCIRespawnEvent"));
     }
 }
Esempio n. 2
0
        public override void Process(Npc npc, Player player, Dictionary <string, string> args)
        {
            NPCCustomEvent ev = new NPCCustomEvent(npc, player, args["event_name"]);

            if (bool.Parse(args["global"]))
            {
                foreach (Npc n in Npc.List)
                {
                    n.FireEvent(ev);
                }
            }
            else
            {
                npc.FireEvent(ev);
            }
        }
Esempio n. 3
0
        public override float Process(Npc npc)
        {
            if (!npc.NPCPlayer.ReferenceHub.characterClassManager.IsAnyScp())
            {
                if (npc.AvailableWeapons.Count > 0)
                {
                    if (!npc.ItemHeld.IsWeapon(false))
                    {
                        npc.ItemHeld = npc.AvailableWeapons.Keys.ElementAt(0);
                        return(0.5f);
                    }

                    npc.Stop();
                    Vector3    heading = (npc.CurrentAIPlayerTarget.Position - npc.NPCPlayer.Position);
                    Quaternion lookRot = Quaternion.LookRotation(heading.normalized);
                    npc.NPCPlayer.Rotations = new Vector2(lookRot.eulerAngles.x, lookRot.eulerAngles.y);
                    bool       miss         = Plugin.Random.Next(0, 100) >= accuracy;
                    int        hitbox_value = Plugin.Random.Next(0, 100);
                    HitBoxType hitbox       = HitBoxType.NULL;
                    int        min          = int.MaxValue;
                    foreach (HitBoxType box in hitboxes.Keys)
                    {
                        if (hitbox_value < hitboxes[box] && hitboxes[box] <= min)
                        {
                            min    = hitboxes[box];
                            hitbox = box;
                        }
                    }

                    npc.NPCPlayer.ReferenceHub.weaponManager.CallCmdShoot(miss ? npc.gameObject : npc.CurrentAIPlayerTarget.GameObject, hitbox, npc.NPCPlayer.CameraTransform.forward, npc.NPCPlayer.Position, npc.CurrentAIPlayerTarget.Position);

                    bool end = !npc.CurrentAIPlayerTarget.IsAlive;

                    if (use_ammo)
                    {
                        npc.AvailableWeapons[npc.ItemHeld]--;
                        if (npc.AvailableWeapons[npc.ItemHeld] <= 0)
                        {
                            npc.NPCPlayer.ReferenceHub.weaponManager.RpcReload(npc.NPCPlayer.ReferenceHub.weaponManager.curWeapon);
                            npc.AvailableWeapons[npc.ItemHeld] = (int)npc.NPCPlayer.ReferenceHub.weaponManager.weapons[npc.NPCPlayer.ReferenceHub.weaponManager.curWeapon].maxAmmo;
                            if (end)
                            {
                                npc.FireEvent(new Events.NPCTargetKilledEvent(npc, npc.CurrentAIPlayerTarget));
                                IsFinished = true;
                            }
                            return(npc.NPCPlayer.ReferenceHub.weaponManager.weapons[npc.NPCPlayer.ReferenceHub.weaponManager.curWeapon].reloadingTime);
                        }
                    }


                    if (end)
                    {
                        npc.FireEvent(new Events.NPCTargetKilledEvent(npc, npc.CurrentAIPlayerTarget));
                        IsFinished = true;
                        return(0f);
                    }
                }
                else
                {
                    IsFinished = true;
                    return(0f);
                }
                return(firerate * Plugin.Instance.Config.NpcFireCooldownMultiplier * npc.NPCPlayer.ReferenceHub.weaponManager._fireCooldown);
            }
            else
            {
                float cd = 0f;
                npc.OnTargetLostBehaviour = Npc.TargetLostBehaviour.STOP;
                npc.Follow(npc.CurrentAIPlayerTarget);
                if (Vector3.Distance(npc.CurrentAIPlayerTarget.Position, npc.NPCPlayer.Position) <= 1.5f)
                {
                    if (npc.NPCPlayer.Role.Is939())
                    {
                        npc.NPCPlayer.GameObject.GetComponent <Scp939PlayerScript>().CallCmdShoot(npc.CurrentAIPlayerTarget.GameObject);
                    }
                    else
                    {
                        switch (npc.NPCPlayer.Role)
                        {
                        case RoleType.Scp106:
                            npc.NPCPlayer.GameObject.GetComponent <Scp106PlayerScript>().CallCmdMovePlayer(npc.CurrentAIPlayerTarget.GameObject, ServerTime.time);
                            cd = 2f;
                            break;

                        case RoleType.Scp173:
                            npc.NPCPlayer.GameObject.GetComponent <Scp173PlayerScript>().CallCmdHurtPlayer(npc.CurrentAIPlayerTarget.GameObject);
                            break;

                        case RoleType.Scp049:
                            npc.CurrentAIPlayerTarget.Hurt(99999f, DamageTypes.Scp049, npc.NPCPlayer.Nickname);
                            cd = PlayableScps.Scp049.KillCooldown;
                            break;

                        case RoleType.Scp0492:
                            npc.NPCPlayer.GameObject.GetComponent <Scp049_2PlayerScript>().CallCmdShootAnim();
                            npc.NPCPlayer.GameObject.GetComponent <Scp049_2PlayerScript>().CallCmdHurtPlayer(npc.CurrentAIPlayerTarget.GameObject);
                            cd = 1f;
                            break;

                        case RoleType.Scp096:
                            npc.CurrentAIPlayerTarget.Hurt(99999f, DamageTypes.Scp096, npc.NPCPlayer.Nickname, npc.NPCPlayer.Id);
                            break;
                        }
                    }
                    if (!npc.CurrentAIPlayerTarget.IsAlive)
                    {
                        npc.AttachedCoroutines.Add(MEC.Timing.CallDelayed(0.1f, () =>
                        {
                            npc.FireEvent(new Events.NPCTargetKilledEvent(npc, npc.CurrentAIPlayerTarget));
                        }));

                        npc.Stop();

                        Player target = npc.CurrentAIPlayerTarget;

                        npc.CurrentAIPlayerTarget = null;

                        if (npc.ProcessSCPLogic && npc.NPCPlayer.Role == RoleType.Scp049)
                        {
                            npc.AttachedCoroutines.Add(Timing.RunCoroutine(ReviveCoroutine(npc, target)));
                            IsFinished = true;
                            return(PlayableScps.Scp049.TimeToRevive + 0.5f);
                        }
                    }
                }
                return(cd);
            }
        }