コード例 #1
0
        private void doRecipe(Smod2.API.Item item, Scp914 objectOfType, Smod2.API.Player player, Smod2.API.KnobSetting knobSetting)
        {
            sbyte outputitem = -2;

            try
            {
                outputitem = (sbyte)(objectOfType.recipes[(byte)item.ItemType].outputs[(byte)knobSetting].outputs[getrandom.Next(0, objectOfType.recipes[(byte)item.ItemType].outputs[(byte)knobSetting].outputs.Count)]);
            }
            catch (System.Exception)
            {
                if (outputitem >= 0)
                {
                    this.plugin.Error("Recipe for " + item.ItemType + "does not exist!  Ask the game devs to add a recipe for it!");
                }
            }
            if (outputitem != -2)
            {
                item.Remove();
                this.plugin.Debug(item.ItemType + " ==> " + (ItemType)outputitem);
            }
            if (outputitem >= 0)
            {
                player.GiveItem((ItemType)outputitem);
            }
        }
コード例 #2
0
ファイル: ChangeSpyRole.cs プロジェクト: Cyanox62/SpyCup
        public ChangeSpyRole(SpyCup sc, Player player, bool delaySpawn)
        {
            float time = sc.GetConfigFloat("spycup_cooldown") * 1000;

            if (delaySpawn)
            {
                System.Threading.Thread.Sleep(25);
                player.ChangeRole(sc.RoleDict[player.SteamId]);
                //plugin.Info("Changed player " + player.Name + "'s role to " + sc.RoleDict[player.SteamId]);
            }
            System.Threading.Thread.Sleep((int)time);

            List <Smod2.API.Item> inv = player.GetInventory();

            if (inv.Count > 7 && !player.HasItem(ItemType.CUP))
            {
                Smod2.API.Item lastItem = inv[7];
                foreach (Smod2.API.Item item in player.GetInventory())
                {
                    if (item.ItemType == lastItem.ItemType)
                    {
                        item.Remove();
                        break;
                    }
                }
                sc.pluginManager.Server.Map.SpawnItem(lastItem.ItemType, player.GetPosition(), Vector.Zero);
            }
            if (!player.IsHandcuffed())
            {
                player.GiveItem(ItemType.CUP);
            }
        }
コード例 #3
0
        public void OnSCP914Activate(SCP914ActivateEvent ev)
        {
            if (!enabled)
            {
                return;
            }
            object[] inputs       = ev.Inputs;
            Scp914   objectOfType = UnityEngine.Object.FindObjectOfType <Scp914>();

            if ((UnityEngine.Object)objectOfType == (UnityEngine.Object)null)
            {
                this.plugin.Error("Couldnt find SCP-914");
                return;
            }
            //            string[] strArray = new string[5] { "Very Rough", "Rough", "1 to 1", "Fine", "Very Fine" };
            //            for (byte index1 = 0; index1 < objectOfType.recipes.Length; ++index1) //item id
            //            {
            //                this.plugin.Debug("==== Recipe for: " + component.availableItems[index1].label + " ====");
            //                for (byte index2 = 0; index2 < objectOfType.recipes[index1].outputs.Count; ++index2) //knob setting id
            //                {
            //                    foreach(sbyte itm in objectOfType.recipes[index1].outputs[index2].outputs) //output item id
            //                    {
            //                        this.plugin.Debug(strArray[index2] + ": " + (itm == -1 ? "NULL" : component.availableItems[itm].label));
            //                    }
            //                }
            //            }
            foreach (UnityEngine.Collider collider in inputs)
            {
                Pickup component1 = collider.GetComponent <Pickup>();
                if ((UnityEngine.Object)component1 == (UnityEngine.Object)null)
                {
                    NicknameSync          component2 = collider.GetComponent <NicknameSync>();
                    CharacterClassManager component3 = collider.GetComponent <CharacterClassManager>();
                    PlyMovementSync       component4 = collider.GetComponent <PlyMovementSync>();
                    PlayerStats           component5 = collider.GetComponent <PlayerStats>();
                    if ((UnityEngine.Object)component2 != (UnityEngine.Object)null && (UnityEngine.Object)component3 != (UnityEngine.Object)null && ((UnityEngine.Object)component4 != (UnityEngine.Object)null && (UnityEngine.Object)component5 != (UnityEngine.Object)null) && (UnityEngine.Object)collider.gameObject != (UnityEngine.Object)null)
                    {
                        UnityEngine.GameObject    gameObject = collider.gameObject;
                        ServerMod2.API.SmodPlayer player     = new ServerMod2.API.SmodPlayer(gameObject);
                        if (player.TeamRole.Team != Smod2.API.Team.SCP && player.TeamRole.Team != Smod2.API.Team.NONE && player.TeamRole.Team != Smod2.API.Team.SPECTATOR)
                        {
                            if (currentonly)
                            {
                                Smod2.API.Item item = player.GetCurrentItem();
                                doRecipe(item, objectOfType, player, ev.KnobSetting);
                            }
                            else
                            {
                                foreach (Smod2.API.Item item in player.GetInventory())
                                {
                                    doRecipe(item, objectOfType, player, ev.KnobSetting);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public override void EventStart(RoundStartEvent ev)
        {
            List <Smod2.API.Door> doors = ev.Server.Map.GetDoors();

            doors.Find(x => x.Name == "CHECKPOINT_LCZ_A").Locked = true;
            doors.Find(x => x.Name == "CHECKPOINT_LCZ_B").Locked = true;
            foreach (Smod2.API.Door door in doors)
            {
                Vector vec = door.Position;
                int    rng = random.Next(0, 6);
                for (int i = 0; i < rng; i++)
                {
                    int    x         = random.Next(Convert.ToInt32(vec.x - 15f), Convert.ToInt32(vec.x + 15f));
                    int    z         = random.Next(Convert.ToInt32(vec.z - 15f), Convert.ToInt32(vec.z + 15f));
                    int    y         = Convert.ToInt32(vec.y + 1);
                    Vector spanw_pos = new Vector(x, y, z);

                    Array values            = Enum.GetValues(typeof(Props));
                    Smod2.API.ItemType item = (Smod2.API.ItemType)values.GetValue(random.Next(values.Length));
                    ev.Server.Map.SpawnItem(item, spanw_pos, Vector.Zero);
                }
            }
            actualHunters = GetHunterId();
            foreach (Player player in ev.Server.GetPlayers())
            {
                if (!actualHunters.Contains(player.PlayerId))
                {
                    player.ChangeRole(Smod2.API.RoleType.CLASSD);
                    player.SetGhostMode(true, visibleWhenTalking: false);
                    player.SetHealth(50);
                    Array values = Enum.GetValues(typeof(Props));
                    Smod2.API.ItemType itemtype = (Smod2.API.ItemType)values.GetValue(random.Next(values.Length));
                    Smod2.API.Item     item     = ev.Server.Map.GetItems(itemtype, true)[0];
                    tasks.Add(Follow(player, item));
                }
            }
            tasks.ForEach(x => x.GetAwaiter());
            HuntersWait().GetAwaiter();
        }
コード例 #5
0
 private async Task Follow(Player player, Smod2.API.Item item)
 {
     player.GiveItem(Smod2.API.ItemType.MEDKIT).Drop();
     item.SetKinematic(false);
     while (true)
     {
         if (Vector.Distance(item.GetPosition(), player.GetPosition()) > 1f)
         {
             if (item.GetKinematic())
             {
                 item.SetKinematic(false);
             }
             Vector vector = new Vector(player.GetPosition().x, player.GetPosition().y - 0.5f, player.GetPosition().z);
             item.SetPosition(vector);
         }
         else if (!item.GetKinematic())
         {
             item.SetKinematic(true);
         }
         await Task.Delay(1000 / 8);
     }
 }
コード例 #6
0
ファイル: Logic.cs プロジェクト: steven4547466/scp035
        private void InfectPlayer(Player player, Smod2.API.Item pItem)
        {
            List <Player> pList = instance.Server.GetPlayers().Where(x => x.TeamRole.Team == Smod2.API.Team.SPECTATOR && !x.OverwatchMode).ToList();

            if (pList.Count > 0 && scpPlayer == null)
            {
                pItem.Remove();
                Player p035 = pList[rand.Next(pList.Count)];
                p035.ChangeRole(player.TeamRole.Role);
                p035.Teleport(player.GetPosition());
                foreach (Smod2.API.Item item in player.GetInventory())
                {
                    p035.GiveItem(item.ItemType);
                }
                p035.SetHealth(scpHealth);
                p035.SetAmmo(AmmoType.DROPPED_5, player.GetAmmo(AmmoType.DROPPED_5));
                p035.SetAmmo(AmmoType.DROPPED_7, player.GetAmmo(AmmoType.DROPPED_7));
                p035.SetAmmo(AmmoType.DROPPED_9, player.GetAmmo(AmmoType.DROPPED_9));
                p035.SetRank("red", "SCP-035");
                p035.PersonalBroadcast(10, $"You are <color=\"red\">SCP-035!</color> You have infected a body and have gained control over it, use it to help the other SCPs!", false);
                scpPlayer  = p035;
                isRotating = false;

                player.ChangeRole(Role.SPECTATOR);
                player.PersonalBroadcast(10, $"You have picked up <color=\"red\">SCP-035.</color> He has infected your body and is now in control of you.", false);

                if (spawnNewItems)
                {
                    RemovePossessedItems();
                }
                else
                {
                    ResetItemDurability();
                }
            }
        }