Inheritance: MonoBehaviour, IDamaging
Ejemplo n.º 1
0
        public static void GiveItem(BasePlayer player, int itemid, Inventory.AInventory.ETypeInventory type = Inventory.AInventory.ETypeInventory.Main, int min_condition = 100, int max_condition = 100, int min_count = 1, int max_count = 1, int min_ammo = 0, int max_ammo = 1)
        {
            Item item = ItemManager.CreateByItemID(itemid, UnityEngine.Random.Range(min_count, max_count));

            item.condition = UnityEngine.Random.Range((item.maxCondition / 100 * min_condition), (item.maxCondition / 100 * max_condition));
            BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile;

            if (weapon != null)
            {
                weapon.primaryMagazine.contents = UnityEngine.Random.Range(min_ammo, max_ammo);
            }
            switch (type)
            {
            case Inventory.AInventory.ETypeInventory.Main:
                player.inventory.GiveItem(item, player.inventory.containerMain);
                break;

            case Inventory.AInventory.ETypeInventory.Belt:
                player.inventory.GiveItem(item, player.inventory.containerBelt);
                break;

            case Inventory.AInventory.ETypeInventory.Wear:
                player.inventory.GiveItem(item, player.inventory.containerWear);
                break;
            }
        }
Ejemplo n.º 2
0
 protected void SetProjectileInitPosition(BaseProjectile projectile, Vector3 pos)
 {
     projectile.transform.localPosition = Vector3.zero;
     projectile.transform.localRotation = Quaternion.identity;
     projectile.transform.SetParent(null);
     projectile.transform.localScale = Vector3.one;
 }
Ejemplo n.º 3
0
        static private LoadoutItem ProcessItem(Item item, string container)
        {
            LoadoutItem iItem = new LoadoutItem();

            iItem.amount    = item.amount;
            iItem.mods      = new List <int>();
            iItem.container = container;
            iItem.skinid    = Convert.ToInt32(item.skin);
            iItem.itemid    = item.info.itemid;
            iItem.weapon    = false;
            iItem.slot      = item.position;

            if (item.info.category.ToString() == "Weapon")
            {
                BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile;
                if (weapon != null)
                {
                    if (weapon.primaryMagazine != null)
                    {
                        iItem.weapon = true;
                        if (item.contents != null)
                        {
                            foreach (var mod in item.contents.itemList)
                            {
                                if (mod.info.itemid != 0)
                                {
                                    iItem.mods.Add(mod.info.itemid);
                                }
                            }
                        }
                    }
                }
            }
            return(iItem);
        }
        private static Item FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum from, NPCPlayerApex.WeaponTypeEnum to, NPCHumanContext c)
        {
            Item           item           = null;
            BaseProjectile baseProjectile = null;

            Item[] itemArray = c.Human.inventory.AllItems();
            for (int i = 0; i < (int)itemArray.Length; i++)
            {
                Item item1 = itemArray[i];
                if (item1.info.category == ItemCategory.Weapon && !item1.isBroken)
                {
                    BaseProjectile heldEntity = item1.GetHeldEntity() as BaseProjectile;
                    if (heldEntity != null && heldEntity.effectiveRangeType <= to && heldEntity.effectiveRangeType > from)
                    {
                        if (item == null)
                        {
                            item           = item1;
                            baseProjectile = heldEntity;
                        }
                        else if (heldEntity.hostileScore > baseProjectile.hostileScore)
                        {
                            item           = item1;
                            baseProjectile = heldEntity;
                        }
                    }
                }
            }
            return(item);
        }
Ejemplo n.º 5
0
        public static void Reload(NPCHumanContext c)
        {
            if (c == null)
            {
                return;
            }
            AttackEntity heldEntity = c.Human.GetHeldEntity() as AttackEntity;

            if (Object.op_Equality((Object)heldEntity, (Object)null))
            {
                return;
            }
            BaseProjectile baseProjectile = heldEntity as BaseProjectile;

            if (!Object.op_Implicit((Object)baseProjectile) || !baseProjectile.primaryMagazine.CanAiReload((BasePlayer)c.Human))
            {
                return;
            }
            baseProjectile.ServerReload();
            if (c.Human.OnReload == null)
            {
                return;
            }
            c.Human.OnReload();
        }
Ejemplo n.º 6
0
    private void Parrying(BaseProjectile proj, Collider other)
    {
        Tower      t  = proj.TowerFiredFrom.GetComponent <Tower>();
        GameObject go = other.gameObject;

        Debug.LogFormat("Parry to {0}!", proj.TowerFiredFrom.name);

        go.GetComponent <Rigidbody>().velocity        = Vector3.zero;
        go.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;


        Vector3 lookTarget = proj.TowerFiredFrom.transform.position;

        lookTarget.y += 1.15f; // reflect back, but just a bit lower (hopefully avoid some collisions (this is dumb))
        Vector3    relativePos = lookTarget - transform.position;
        Quaternion rotation    = Quaternion.LookRotation(relativePos, Vector3.up);

        go.transform.rotation = rotation;
        proj.HasBeenParried   = true;

        //go.transform.LookAt(proj.TowerFiredFrom.transform);
        go.GetComponent <Rigidbody>().AddForce(go.transform.forward * t.ProjectileSpeed * 110.0f);
        Destroy(go, 5.0f);
        HoldingPlayer.SuccessfulParry();
    }
Ejemplo n.º 7
0
    public virtual bool Fire(GetTarget targetFunc)
    {
        if (!reloading)
        {
            if (!OnCooldown)
            {
                if (Magazine > 0)
                {
                    for (int i = 0; i < ProjectilesPerShot; ++i)
                    {
                        Vector3 bulletEndPos = targetFunc();
                        bulletEndPos += ((isAimed) ? AimedSpread : Spread) * Random.insideUnitSphere;

                        BaseProjectile nProjectile = Instantiate <BaseProjectile>(Resources.Load <BaseProjectile>("Projectiles/" + BulletType.ToString()));
                        nProjectile.transform.position = Muzzle.position;
                        nProjectile.transform.LookAt(bulletEndPos);
                        nProjectile.SetUpProjectile(MuzzleVelocity, Damage);
                    }
                    FiredGun();
                    return(true);
                }
                else
                {
                    Reload();
                }
            }
        }
        return(false);
    }
Ejemplo n.º 8
0
        public override void RangeAttack(Vector3 point)
        {
            if (Time.time - lastRangeAttackTime < rangeAttackCooldown)
            {
                return;
            }
            EnterCombat();

            //TODO rework
            lastRangeAttackTime = Time.time;

            aimTime = Mathf.Min(aimTime, 1);
            Vector3 pos = transform.position;

            pos.y += .7f;
            GameObject     gameObject = (GameObject)Instantiate(Resources.Load("Projectiles/ArrowE"), pos, Quaternion.identity);
            BaseProjectile projectile = gameObject.GetComponent <BaseProjectile>();
            Damage         damage     = stats.GetDamageValue(false, false, rangeDamageMultiplier);

            projectile.angleSpeed = 0;
            projectile.Launch(damage);
            gameObject.transform.LookAt(point);
            aimTime = 0;
            onAimEnd?.Invoke();
        }
Ejemplo n.º 9
0
        protected void InstantiateAndShootProjectile(GameObject projectile, Transform source, Transform target)
        {
            BaseProjectile baseProjectile = Instantiate(projectile, source.position, new Quaternion())
                                            .GetComponent <BaseProjectile>();

            baseProjectile.Shoot(target.position);
        }
Ejemplo n.º 10
0
    protected virtual BaseProjectile Fire()
    {
        GameObject     bullet       = (GameObject)Instantiate(bulletPrefab, transform.position, transform.rotation);
        BaseProjectile bulletScript = bullet.GetComponent <BaseProjectile>();

        bulletScript.shooter       = shooter;
        bulletScript.shooterScript = this;

        //TODO: Put bullets in a dynamic object store
        //bullet.transform.parent = ObjectManager.Instance.dynamicObjects.transform;

        Rigidbody2D bulletRB = bullet.GetComponent <Rigidbody2D>();

        float rotationAdjust = Random.Range(bulletRotationRange.x, bulletRotationRange.y);

        bulletRB.rotation += rotationAdjust;

        //bulletRB.velocity = transform.forward * bulletSpeed;

        Vector2 bulletDirection = new Vector2(1.0f, 0.0f);

        float bulletSpeed = Random.Range(bulletMinMaxForce.x, bulletMinMaxForce.y);

        Vector2 bulletVelocity = bulletDirection * bulletSpeed;

        //bulletScript.Initialize(bulletVelocity);

        bulletRB.AddRelativeForce(bulletVelocity);

        return(bulletScript);

        //DebugLogger.Log("Fire() pv=" + previousVelocity + " v=" + bulletRB.velocity);
    }
Ejemplo n.º 11
0
        private static Item FindBestProjInRange(
            NPCPlayerApex.WeaponTypeEnum from,
            NPCPlayerApex.WeaponTypeEnum to,
            NPCHumanContext c)
        {
            Item           obj            = (Item)null;
            BaseProjectile baseProjectile = (BaseProjectile)null;

            foreach (Item allItem in c.Human.inventory.AllItems())
            {
                if (allItem.info.category == ItemCategory.Weapon && !allItem.isBroken)
                {
                    BaseProjectile heldEntity = allItem.GetHeldEntity() as BaseProjectile;
                    if (Object.op_Inequality((Object)heldEntity, (Object)null) && heldEntity.effectiveRangeType <= to && heldEntity.effectiveRangeType > from)
                    {
                        if (obj == null)
                        {
                            obj            = allItem;
                            baseProjectile = heldEntity;
                        }
                        else if ((double)heldEntity.hostileScore > (double)baseProjectile.hostileScore)
                        {
                            obj            = allItem;
                            baseProjectile = heldEntity;
                        }
                    }
                }
            }
            return(obj);
        }
        private void FillContainer(StoredData.LootSpawn.ItemData[] items, StorageContainer container)
        {
            for (int i = 0; i < items.Length; i++)
            {
                StoredData.LootSpawn.ItemData itemData = items[i];
                Item item = ItemManager.CreateByItemID(itemData.itemid, itemData.amount, itemData.skin);
                item.condition = itemData.condition;

                BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile;
                if (weapon != null)
                {
                    if (!string.IsNullOrEmpty(itemData.ammotype))
                    {
                        weapon.primaryMagazine.ammoType = ItemManager.FindItemDefinition(itemData.ammotype);
                    }
                    weapon.primaryMagazine.contents = itemData.ammo;
                }
                if (itemData.contents != null)
                {
                    foreach (var contentData in itemData.contents)
                    {
                        var newContent = ItemManager.CreateByItemID(contentData.itemid, contentData.amount);
                        if (newContent != null)
                        {
                            newContent.condition = contentData.condition;
                            newContent.MoveToContainer(item.contents);
                        }
                    }
                }
                item.MoveToContainer(container.inventory);
            }
        }
Ejemplo n.º 13
0
        void OnWeaponFired(BaseProjectile projectile, BasePlayer player, ItemModProjectile itemProjectile, ProtoBuf.ProjectileShoot projectiles)
        {
            string bullet = "Unknown", weapon = (player.GetActiveItem() != null ? player.GetActiveItem().info.displayName.english : "Unknown");

            try
            {
                bullet = projectile.primaryMagazine.ammoType.displayName.english;
            }
            catch (Exception ex)
            {
                Puts("Problem getting bullet! " + ex.StackTrace);
                if (projectile == null)
                {
                    Puts("!!!WRONG!!! projectile is NULL!");
                }
                else if (projectile.primaryMagazine == null)
                {
                    Puts("!!!WRONG!!! projectile.primaryMagazine is NULL!");
                }
                else if (projectile.primaryMagazine.ammoType == null)
                {
                    Puts("!!!WRONG!!! projectile.primaryMagazine.ammoType is NULL!");
                }
            }
            executeQuery("INSERT INTO stats_player_fire_bullet (player, bullet, weapon, date) VALUES (@0, @1, @2, @3)" +
                         "ON DUPLICATE KEY UPDATE count = count + 1", player.userID, bullet, weapon, getDate());
        }
Ejemplo n.º 14
0
        object OnReloadWeapon(BasePlayer player, BaseProjectile projectile)
        {
#if DEBUG
            Puts("OnReloadWeapon called!");
#endif
            Item item = projectile.GetItem();
            Dictionary <string, object> weaponStats = null;

            if (weaponContainer.ContainsKey(item.info.shortname))
            {
#if DEBUG
                Puts("OnReloadWeapon: Adding weapon ");
#endif
                weaponStats = weaponContainer[item.info.shortname] as Dictionary <string, object>;
            }
            if (!(bool)weaponStats["settingactive"])
            {
#if DEBUG
                Puts($"OnReloadWeapon: Weapon type {item.info.shortname} inactive.");
#endif
                return(null);
            }

            if (hasRight(player, "maxammo") || hasRight(player, "all"))
            {
#if DEBUG
                Puts($"OnReloadWeapon: Weapon type {item.info.shortname} active - giving maxammo.");
#endif
                projectile.primaryMagazine.capacity = (int)weaponStats["maxammo"];
                projectile.SendNetworkUpdate();
            }
            return(null);
        }
Ejemplo n.º 15
0
        public void Shoot(Vector2 targetPosition)
        {
            shooting = true;
            if (delayLeft > 0 || IsReloading())
            {
                return;
            }
            BaseProjectile projectile =
                currentClip.GetProjectile(parent.transform);

            if (projectile == null)
            {
                return;
            }

            ShootSoundComponent.SoundEffect = projectile.shootSound;

            GameManager.SpawnObject(projectile);
            projectile.Start(targetPosition, parent);

            ShootSoundComponent.Play();

            OnAmmoChange?.Invoke(this);

            delayLeft = ammoClips[currentClipIndex].fireDelay;
            if (currentClip.GetAmmoInfo().loaded == 0)
            {
                StopShooting();
            }
        }
Ejemplo n.º 16
0
    private void BasicTower()
    {
        //Debug.LogFormat("{0} is in range of pizza! ({1})", transform.name, distToPizza);
        GameObject     projGO = Instantiate(Projectile, ProjectileHolder.transform.position, Quaternion.identity);
        BaseProjectile proj   = projGO.GetComponent <BaseProjectile>();

        proj.TowerFiredFrom = this.gameObject;

        Vector3 targetLoc = PredictedPizzaTarget();

        projGO.transform.LookAt(targetLoc);

        float rand = Random.Range(0.0f, 1.0f);

        if (rand <= 0.5f)
        {
            proj.Parryable = true;
            projGO.GetComponent <Rigidbody>().AddForce(projGO.transform.forward * ProjectileSpeed * 90);
            projGO.GetComponentInChildren <MeshRenderer>().material.color = Color.red;
            shotCount = 0;
            projGO.GetComponentInChildren <MeshRenderer>().sharedMaterial.SetColor("albedo_", new Color(0.8679245f, 0.05322179f, 0.4156687f, 1.0f));
        }
        else
        {
            proj.Parryable = false;
            projGO.GetComponent <Rigidbody>().AddForce(projGO.transform.forward * ProjectileSpeed * 90);
            shotCount++;
        }

        Destroy(projGO, 4.0f); //TODO: add better cleanup
    }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            HTNPlayer htnPlayer = npc as HTNPlayer;

            if (Object.op_Equality((Object)htnPlayer, (Object)null))
            {
                return;
            }
            FireTactic   fireTactic = FireTactic.Single;
            AttackEntity heldEntity = htnPlayer.GetHeldEntity() as AttackEntity;

            if (Object.op_Implicit((Object)heldEntity))
            {
                BaseProjectile baseProjectile = heldEntity as BaseProjectile;
                float          num            = float.MaxValue;
                if (Object.op_Inequality((Object)npcContext.PrimaryEnemyPlayerInLineOfSight.Player, (Object)null))
                {
                    num = npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance;
                    if (Mathf.Approximately(num, 0.0f))
                    {
                        num = float.MaxValue;
                    }
                }
                fireTactic = (double)heldEntity.attackLengthMin <0.0 || (double)num> (double) npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm((AttackEntity)baseProjectile) ? ((double)heldEntity.attackLengthMin <0.0 || (double)num> (double) npcContext.Body.AiDefinition.Engagement.SqrMediumRangeFirearm((AttackEntity)baseProjectile) ? FireTactic.Single : FireTactic.Burst) : FireTactic.FullAuto;
            }
            npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.FireTactic, fireTactic, true, true, true);
        }
Ejemplo n.º 18
0
        private KitItem ProcessItem(Item playerItem)
        {
            KitItem item = new KitItem();

            item.Amount = playerItem.amount;
            item.Mods   = new List <string>();
            item.Name   = playerItem.info.shortname;
            item.Weapon = false;

            if (playerItem.info.category.ToString() == "Weapon")
            {
                BaseProjectile weapon = playerItem.GetHeldEntity() as BaseProjectile;

                if (weapon != null)
                {
                    if (weapon.primaryMagazine != null)
                    {
                        item.Weapon = true;

                        if (playerItem.contents != null)
                        {
                            foreach (var mod in playerItem.contents.itemList)
                            {
                                if (mod.info.itemid != 0)
                                {
                                    item.Mods.Add(mod.info.shortname);
                                }
                            }
                        }
                    }
                }
            }
            return(item);
        }
Ejemplo n.º 19
0
 void OnWeaponFired(BaseProjectile projectile,
                    BasePlayer player,
                    ItemModProjectile mod,
                    ProtoBuf.ProjectileShoot projectiles)
 {
     RunWeaponFired(projectile, player, mod, projectiles);
 }
Ejemplo n.º 20
0
 void OnWeaponFired(BaseProjectile projectile, BasePlayer player, ItemModProjectile mod, ProtoBuf.ProjectileShoot projectiles)
 {
     Puts("------------START!-----------");
     Puts("projectile: " + projectile.ToString());
     Puts("projectile.NoiseRadius: " + projectile.NoiseRadius.ToString());
     Puts("------------------------------");
     Puts("player: " + player.ToString());
     Puts("------------------------------");
     Puts("mod: " + mod.ToString());
     Puts("mod.projectileObject: " + mod.projectileObject.ToString());
     Puts("mod.numProjectiles: " + mod.numProjectiles.ToString());
     Puts("mod.projectileVelocity: " + mod.projectileVelocity.ToString());
     Puts("mod.category: " + mod.category);
     Puts("mod.mods: " + mod.mods.ToString());
     Puts("mod.ammoType: " + mod.ammoType.ToString());
     Puts("mod.projectileSpread: " + mod.projectileSpread.ToString());
     Puts("mod.projectileVelocitySpread: " + mod.projectileVelocitySpread.ToString());
     Puts("mod.useCurve: " + mod.useCurve.ToString());
     Puts("mod.spreadScalar: " + mod.spreadScalar.ToString());
     Puts("mod.attackEffectOverride: " + mod.attackEffectOverride.ToString());
     Puts("mod.barrelConditionLoss: " + mod.barrelConditionLoss.ToString());
     Puts("------------------------------");
     Puts("projectiles: " + projectiles.ToString());
     Puts("projectiles.ammoType: " + projectiles.ammoType.ToString());
     Puts("------------END!-----------");
 }
Ejemplo n.º 21
0
    private void Awake()
    {
        rb         = GetComponent <Rigidbody2D>();
        projectile = GetComponent <BaseProjectile>();

        hookComplete = false;
    }
Ejemplo n.º 22
0
        private void OnWeaponFired(BaseProjectile projectile, BasePlayer player, ItemModProjectile mod)
        {
            if (!permission.UserHasPermission(player.UserIDString, permission_use))
            {
                return;
            }
            if (!_data.PlayerData.ContainsKey(player.UserIDString))
            {
                _data.PlayerData.Add(player.UserIDString, new PlayerData());
            }
            var PlayerData = _data.PlayerData[player.UserIDString];

            if (!PlayerData.Enabled)
            {
                return;
            }
            var Hit = ReturnAimbotPlayer(player, PlayerData);

            if (Hit == null)
            {
                return;
            }

            var proj = mod.projectileObject.Get().GetComponent <Projectile>();
            var num  = proj.damageTypes.Sum(damageTypeEntry => damageTypeEntry.amount);

            player.Hurt(num * projectile.damageScale, DamageType.Bullet, Hit);
        }
Ejemplo n.º 23
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("shield collided with " + other.transform.name);
        BaseProjectile proj = other.GetComponent <BaseProjectile>();

        if (proj)
        {
            switch (CurrentState)
            {
            case ShieldState.Inactive:
                return;

            case ShieldState.Blocking:
                Blocking(proj, other);
                break;

            case ShieldState.Parrying:
                if (proj.Parryable)
                {
                    Parrying(proj, other);
                }
                else
                {
                    Blocking(proj, other);
                }
                break;
            }
        }
    }
Ejemplo n.º 24
0
        private bool IsAmmoBlocked(BasePlayer owner, BaseProjectile proj)
        {
            List <Item> currentAmmo = owner.inventory.FindItemIDs(proj.primaryMagazine.ammoType.itemid).ToList();
            Item        newAmmo     = null;

            if (currentAmmo.Count == 0)
            {
                List <Item> newAmmoList = new List <Item>();
                owner.inventory.FindAmmo(newAmmoList, proj.primaryMagazine.definition.ammoTypes);
                if (newAmmoList.Count == 0)
                {
                    return(false);
                }
                newAmmo = newAmmoList[0];
                if (config.BlockedAmmo.Contains(newAmmo.info.displayName.english) || config.BlockedAmmo.Contains(newAmmo.info.shortname))
                {
                    return(true);
                }
            }
            newAmmo = currentAmmo[0];
            if (config.BlockedAmmo.Contains(newAmmo.info.displayName.english) || config.BlockedAmmo.Contains(newAmmo.info.shortname))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 25
0
            private void GiveSlasherWeapon(EventManager.BaseEventPlayer eventPlayer)
            {
                Item item = ItemManager.Create(slasherWeapon);

                if (item.contents != null && item.contents.availableSlots.Count > 0)
                {
                    Item attachment = ItemManager.CreateByName(WEAPON_FLASHLIGHT_ITEM);
                    if (!attachment.MoveToContainer(item.contents))
                    {
                        attachment.Remove();
                    }
                    else
                    {
                        item.GetHeldEntity()?.SendMessage("SetLightsOn", true, SendMessageOptions.DontRequireReceiver);
                    }
                }

                item.MoveToContainer(eventPlayer.Player.inventory.containerBelt);

                BaseProjectile baseProjectile = item.GetHeldEntity() as BaseProjectile;

                if (baseProjectile != null)
                {
                    Item ammo = ItemManager.Create(baseProjectile.primaryMagazine.ammoType, baseProjectile.primaryMagazine.capacity * 5);
                    ammo.MoveToContainer(eventPlayer.Player.inventory.containerMain);
                }
            }
Ejemplo n.º 26
0
        private Item CreateItem(RewardInfo.ItemData itemData)
        {
            Item item = ItemManager.CreateByItemID(itemData.itemid, itemData.amount, itemData.skin);

            item.condition = itemData.condition;

            if (itemData.instanceData != null)
            {
                itemData.instanceData.Restore(item);
            }

            BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile;

            if (weapon != null)
            {
                if (!string.IsNullOrEmpty(itemData.ammotype))
                {
                    weapon.primaryMagazine.ammoType = ItemManager.FindItemDefinition(itemData.ammotype);
                }
                weapon.primaryMagazine.contents = itemData.ammo;
            }
            if (itemData.contents != null)
            {
                foreach (var contentData in itemData.contents)
                {
                    var newContent = ItemManager.CreateByItemID(contentData.itemid, contentData.amount);
                    if (newContent != null)
                    {
                        newContent.condition = contentData.condition;
                        newContent.MoveToContainer(item.contents);
                    }
                }
            }
            return(item);
        }
Ejemplo n.º 27
0
        private void SaveWeapon(BasePlayer player, int rank, int ammo = 1)
        {
            RankItem weaponEntry = new RankItem();
            Item     item        = player.GetActiveItem();

            if (item != null)
            {
                if (item.info.category.ToString() == "Weapon")
                {
                    BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile;
                    if (weapon != null)
                    {
                        if (weapon.primaryMagazine != null)
                        {
                            List <string> mods = new List <string>();
                            if (item.contents != null)
                            {
                                foreach (var mod in item.contents.itemList)
                                {
                                    if (mod.info.itemid != 0)
                                    {
                                        mods.Add(mod.info.shortname);
                                    }
                                }
                            }
                            if (mods != null)
                            {
                                weaponEntry.contents = mods.ToArray();
                            }

                            weaponEntry.ammoType = weapon.primaryMagazine.ammoType.shortname;
                            weaponEntry.ammo     = ammo;
                        }
                    }

                    weaponEntry.amount    = item.amount;
                    weaponEntry.container = "belt";
                    weaponEntry.name      = item.info.displayName.english;
                    weaponEntry.shortname = item.info.shortname;
                    weaponEntry.skin      = item.skin;

                    if (rank > configData.Weapons.Count)
                    {
                        rank = configData.Weapons.Count + 1;
                    }
                    if (!configData.Weapons.ContainsKey(rank))
                    {
                        configData.Weapons.Add(rank, weaponEntry);
                    }
                    else
                    {
                        configData.Weapons[rank] = weaponEntry;
                    }
                    SaveConfig(configData);
                    SendReply(player, string.Format("You have successfully added <color=orange>{0}</color> as the weapon for Rank <color=orange>{1}</color>", weaponEntry.name, rank));
                    return;
                }
            }
            SendReply(player, "<color=orange>Unable to save item.</color> You must put a weapon in your hands");
        }
Ejemplo n.º 28
0
    void GenerateProjectileRep(Vector3 startPoint, Quaternion startRotation)
    {
        GameObject     proj       = Instantiate(projectilePrefab, startPoint, startRotation) as GameObject;
        BaseProjectile projScript = proj.GetComponent <BaseProjectile>();

        projScript.damage = new BaseDamage(damageAmount);
        projScript.owner  = owner.gameObject;
    }
Ejemplo n.º 29
0
    public virtual BaseProjectile FireProjectile(BaseActor owner, GameObject projectilePrefab, Vector3 startPos, Vector3 dir, float speed, Quaternion rotation, bool optAddTorque = true)
    {
        GameObject     projectileObj = GameManager.Instance.SpawnPrefab(projectilePrefab, startPos, rotation);
        BaseProjectile projectile    = projectileObj.GetComponent <BaseProjectile>();

        projectile.Throw(owner, startPos, dir, speed, optAddTorque);
        return(projectile);
    }
Ejemplo n.º 30
0
 public void DropProjectile()
 {
     if(mCurrentProjectile != null)
     {
         mCurrentProjectile.Drop();
     }
     mCurrentProjectile = null;
 }
Ejemplo n.º 31
0
 public void DropProjectile()
 {
     if (mCurrentProjectile != null)
     {
         mCurrentProjectile.Drop();
     }
     mCurrentProjectile = null;
 }
Ejemplo n.º 32
0
    public void ReadyProjectile()
    {
        //Debug.Log("Readying Projectile");
        mHand.localPosition = mOriginalHandPos;
        GameObject obj = Instantiate(mProjectilePrefab, mHand.position, mHand.rotation) as GameObject;
        mCurrentProjectile = obj.GetComponent<BaseProjectile>();
        mCurrentProjectile.transform.parent = mHand;

        mAttackTellTimer = mAttackTellTime;
    }
Ejemplo n.º 33
0
 public override void Init()
 {
     base.Init ();
     tileCheckFlags = EnumHelper.CombineFlags<TileCheckFlags>(TileCheckFlags.agentOccupied);
     projectile = null;
     castingStart = false;
     castingFinished = false;
     projectileMade = false;
     projectileHit = false;
     waitOver = false;
     castOver = false;
 }
Ejemplo n.º 34
0
 protected virtual void CreateProjectile()
 {
     projectile = (BaseProjectile)Instantiate(projectilePrefab, BattleManager.singleton.selectedAgent.transform.position, Quaternion.identity);
     if (projectile == null) {
         Debug.LogError("Error saving projectile instance!");
         return;
     }
     projectileMade = true;
     projectile.action = this;
     projectile.target = BattleManager.singleton.targetTile.entityOnTile.transform;
     projectile.damage = damage;
 }
Ejemplo n.º 35
0
 public static void OnShoot(BaseProjectile baseProjectile, BaseEntity.RPCMessage msg)
 {
     OnShooting.OnNext(new ShootEvent(baseProjectile, msg));
 }
Ejemplo n.º 36
0
 private void OnWeaponFired(BaseProjectile projectile, BasePlayer player)
 {
     projectile.GetItem().condition = projectile.GetItem().info.condition.max;
     projectile.SendNetworkUpdateImmediate();
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Called from <c>BaseProjectile.CLProject(BaseEntity.RPCMessage)</c> .
 /// </summary>
 public static void On_PlayerShoot(BaseProjectile baseProjectile, BaseEntity.RPCMessage msg)
 {
     OnNext("On_PlayerShoot", new ShootEvent(baseProjectile, msg));
 }
Ejemplo n.º 38
0
 public void FireProjectileAt(Vector3 pos)
 {
     //Debug.Log("Firing Projectile");
     mCurrentProjectile.LaunchToward(pos);
     mCurrentProjectile = null;
 }
Ejemplo n.º 39
0
 private object IOnWeaponFired(BaseProjectile projectile, BaseEntity.RPCMessage msg, ItemModProjectile component, ProjectileShoot projectiles)
 {
     return Interface.CallHook("OnWeaponFired", projectile, msg.player, component, projectiles);
 }
Ejemplo n.º 40
0
 public ShootEvent(BaseProjectile baseProjectile, BaseEntity.RPCMessage msg)
 {
     BaseProjectile = baseProjectile;
     Player = Server.GetPlayer(msg.player);
 }
Ejemplo n.º 41
0
 public ShootEvent(BaseProjectile baseProjectile, BaseEntity.RPCMessage msg)
 {
     _player = Server.GetPlayer(msg.player);
     _rpcMessage = msg;
     _projectile = baseProjectile;
 }