Example #1
0
 public static bool HasLightSource(this ReferenceHub rh)
 {
     if (rh.inventory != null && rh.inventory.curItem == ItemType.Flashlight)
     {
         return(true);
     }
     if (rh.inventory == null || rh.weaponManager == null || !rh.weaponManager.NetworksyncFlash ||
         rh.weaponManager.curWeapon < 0 ||
         rh.weaponManager.curWeapon >= rh.weaponManager.weapons.Length)
     {
         return(false);
     }
     WeaponManager.Weapon   weapon     = rh.weaponManager.weapons[rh.weaponManager.curWeapon];
     Inventory.SyncItemInfo itemInHand = rh.inventory.GetItemInHand();
     if (weapon == null || itemInHand.modOther < 0 || itemInHand.modOther >= weapon.mod_others.Length)
     {
         return(false);
     }
     WeaponManager.Weapon.WeaponMod modOther = weapon.mod_others[itemInHand.modOther];
     if (modOther != null && !string.IsNullOrEmpty(modOther.name) && (modOther.name.ToLower().Contains("flashlight") || modOther.name.Contains("night")))
     {
         return(true);
     }
     return(false);
 }
Example #2
0
        /// <summary>
        /// Sets other modification of the weapon.
        /// </summary>
        /// <param name="player">The player instance.</param>
        /// <param name="weapon">The weapon with attachment.</param>
        /// <param name="type">Type of the other.</param>
        public static void SetOther(this Player player, Inventory.SyncItemInfo weapon, OtherType type)
        {
            WeaponManager wmanager = player.ReferenceHub.weaponManager;

            if (weapon.id.IsWeapon())
            {
                WeaponManager.Weapon wep = wmanager.weapons.FirstOrDefault(wp => wp.inventoryID == weapon.id);
                if (wep != null)
                {
                    string name = type.ToString("g").SplitCamelCase();

                    int weaponMod = wep.mod_others.Select((s, i) => new { s, i }).Where(e => e.s.name == name).Select(e => e.i).FirstOrDefault();
                    int weaponId  = player.Inventory.items.FindIndex(s => s == weapon);
                    weapon.modOther = weaponMod;
                    if (weaponId > -1)
                    {
                        player.Inventory.items[weaponId] = weapon;
                    }
                }
            }
        }
Example #3
0
 public static bool HasSmallScope(this ReferenceHub rh)
 {
     if (rh.inventory == null || rh.weaponManager == null || !rh.weaponManager.NetworksyncFlash ||
         rh.weaponManager.curWeapon < 0 ||
         rh.weaponManager.curWeapon >= rh.weaponManager.weapons.Length)
     {
         return(false);
     }
     WeaponManager.Weapon   weapon     = rh.weaponManager.weapons[rh.weaponManager.curWeapon];
     Inventory.SyncItemInfo itemInHand = rh.inventory.GetItemInHand();
     if (weapon == null || itemInHand.modSight < 0 || itemInHand.modSight >= weapon.mod_sights.Length)
     {
         return(false);
     }
     WeaponManager.Weapon.WeaponMod modScope = weapon.mod_sights[itemInHand.modSight];
     if (modScope != null && !string.IsNullOrEmpty(modScope.name) && (modScope.name.ToLower().Contains("dot") || modScope.name.Contains("holo")))
     {
         return(true);
     }
     return(false);
 }
Example #4
0
        /// <summary>
        /// Gets other modification of the weapon.
        /// </summary>
        /// <param name="player">The player instance.</param>
        /// <param name="weapon">The weapon with attachment.</param>
        /// <returns>Returns <see cref="OtherType"/>.</returns>
        public static OtherType GetOther(this Player player, Inventory.SyncItemInfo weapon)
        {
            WeaponManager wmanager = player.ReferenceHub.weaponManager;

            if (weapon.id.IsWeapon())
            {
                WeaponManager.Weapon wep = wmanager.weapons.FirstOrDefault(wp => wp.inventoryID == weapon.id);
                if (wep != null)
                {
                    try
                    {
                        string name = wep.mod_others[weapon.modOther].name.RemoveSpaces();
                        return((OtherType)Enum.Parse(typeof(OtherType), name));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(OtherType.None);
        }
Example #5
0
 protected void WeaponInformation()
 {
     weapon = GameManager.instance.weaponScript.weaponList.Find(i => i.weaponId == equippedWeaponId);
 }
Example #6
0
 protected int GetWeaponRange()
 {
     WeaponManager.Weapon weapon = new WeaponManager.Weapon();
     weapon = GameManager.instance.weaponScript.weaponList.Find(i => i.weaponId == equippedWeaponId);
     return(weapon.range);
 }
Example #7
0
        private IEnumerable <float> TimingSpawnUsps(float delay, IEnumerable <Vector3> spawns, Inventory inventory, WeaponManager.Weapon usp)
        {
            yield return(delay);

            plugin.Server.Map.AnnounceCustomMessage("U S P NOW AVAILABLE");

            // Spawn USPs with random sight, heavy barrel, and flashlight :ok_hand:
            foreach (Vector3 spawn in spawns)
            {
                inventory.SetPickup((int)ItemType.USP, usp.maxAmmo, spawn, Quaternion.Euler(0, 0, 0), Random.Range(0, usp.mod_sights.Length), 2, 1);
            }
        }
Example #8
0
    protected override void Attack <T>(T component)
    {
        Enemy   target         = component as Enemy;
        Vector3 targetLocation = target.transform.position;

        WeaponManager.Weapon weapon = new WeaponManager.Weapon();
        weapon = GameManager.instance.weaponScript.weaponList.Find(i => i.weaponId == equippedWeaponId);

        if (CheckIfInRange(transform.position, targetLocation, weapon.range))
        {
            int modifier = 0;
            if (weapon.attribute == "str")
            {
                modifier = str;
            }
            if (weapon.attribute == "dex")
            {
                modifier = dex;
            }
            int attack = UnityEngine.Random.Range(1, 20);
            attack += modifier;

            print("You attack " + component.name + ". Your attack score is " + attack + " vs target armor of " + target.baseArmor);

            Vector3 offset = new Vector3();
            if (attack >= target.baseArmor)
            {
                int damage = UnityEngine.Random.Range(weapon.minDamage, weapon.maxDamage);
                damage  += modifier;
                offset.x = 0;
                offset.y = 0;
                print("You score a hit for " + damage + " damage!");
                target.LoseHealth(damage);
            }
            else
            {
                if (weapon.weaponId == 0)
                {
                    int randX = 0;
                    int randY = 0;
                    while (randX == 0 && randY == 0)
                    {
                        randX = UnityEngine.Random.Range(-1, 1);
                        randY = UnityEngine.Random.Range(-1, 1);
                    }
                    offset.x = 0 + randX;
                    offset.y = 0 + randY;
                }
                print("Your attack missed.");
                FloatingTextController.CreateFloatingText("Miss", target.transform);
            }

            //SPAWN ARROW
            if (weapon.weaponId == 0)
            {
                Vector3 location = targetLocation + offset;
                float   angle    = Vector3.Angle(new Vector3(0, 1, 0), location - transform.position);
                if (location.x > transform.position.x)
                {
                    angle = -angle;
                }
                GameObject arrow = Instantiate(GameManager.instance.weaponScript.arrowPrefab, transform.position, Quaternion.Euler(new Vector3(0, 0, angle)));
                arrow.GetComponent <Arrow>().target = location;
            }

            action = false;
        }
        else
        {
            print("Target is out of range.");
        }
    }
    public static string GetCause(PlayerStats.HitInfo info, bool ragdoll)
    {
        string result = TranslationReader.Get("Death_Causes", 11);
        int    num    = -1;

        if (info.tool == "NUKE")
        {
            result = TranslationReader.Get("Death_Causes", 0);
        }
        else if (info.tool == "FALLDOWN")
        {
            result = TranslationReader.Get("Death_Causes", 1);
        }
        else if (info.tool == "LURE")
        {
            result = TranslationReader.Get("Death_Causes", 2);
        }
        else if (info.tool == "POCKET")
        {
            result = TranslationReader.Get("Death_Causes", 3);
        }
        else if (info.tool == "CONTAIN")
        {
            result = TranslationReader.Get("Death_Causes", 4);
        }
        else if (info.tool == "TESLA")
        {
            result = TranslationReader.Get("Death_Causes", 5);
        }
        else if (info.tool == "WALL")
        {
            result = TranslationReader.Get("Death_Causes", 6);
        }
        else if (info.tool.Length > 7 && info.tool.Substring(0, 7) == "Weapon:" && int.TryParse(info.tool.Remove(0, 7), out num) && num != -1)
        {
            GameObject           gameObject = GameObject.Find("Host");
            WeaponManager.Weapon weapon     = gameObject.GetComponent <WeaponManager>().weapons[num];
            AmmoBox component = gameObject.GetComponent <AmmoBox>();
            result = TranslationReader.Get("Death_Causes", 7).Replace("[ammotype]", component.types[weapon.ammoType].label);
        }
        else if (info.tool.Length > 4 && info.tool.Substring(0, 4) == "SCP:" && int.TryParse(info.tool.Remove(0, 4), out num) && num != -1)
        {
            if (num == 173)
            {
                result = TranslationReader.Get("Death_Causes", 8);
            }
            else if (num == 106)
            {
                result = TranslationReader.Get("Death_Causes", 9);
            }
            else if (num == 96)
            {
                result = TranslationReader.Get("Death_Causes", 13);
            }
            else if (num == 49 || num == 492)
            {
                result = TranslationReader.Get("Death_Causes", 10);
            }
        }
        return(result);
    }