Exemplo n.º 1
0
    // If you want to do magic fancy stuff or calculations when your projectile leaves the gun,
    // just do it here.
    public override void PostProcessProjectile(Projectile projectile)
    {
        PlayerController player = gun.CurrentOwner as PlayerController;

        if (player == null)
        {
            return;
        }

        // Random chance for the gun to "shoot everything at once".
        if (Mathf.Lerp(0.005f, 0.002f, gun.ammo / 300f) < Random.value)
        {
            return;
        }
        // We clear all projectile modules. As we want to shoot everything at once,
        // not in a random sequence, we re-add all gun projectile MODULES.
        gun.Volley.projectiles.Clear();
        gun.RuntimeModuleData.Clear();
        for (int i = 0; i < ETGMod.Databases.Items.Count; i++)
        {
            Gun other = ETGMod.Databases.Items[i] as Gun;
            if (other == null)
            {
                continue;                // Watch out for null entries in the database! Those are WIP / removed guns.
            }
            ProjectileModule module = gun.AddProjectileModuleFrom(other, clonedProjectiles: false);
            // We don't want to eat more ammo than required.
            module.ammoCost            = 0;
            module.numberOfShotsInClip = gun.CurrentAmmo;
            ModuleShootData moduleData = new ModuleShootData();
            gun.RuntimeModuleData[module] = moduleData;
        }
        // We refill the gun and make it only deplete ammo on the first module.
        gun.ammo = gun.GetBaseMaxAmmo();
        gun.DefaultModule.ammoCost = 1;

        // Finally, the player looses the gun with 0 ammo after 3 seconds.
        StartCoroutine(EjectFrom(player));
    }
Exemplo n.º 2
0
        protected void Update()
        {
            if (gun.CurrentOwner)
            {
                if (!gun.PreventNormalFireAudio)
                {
                    this.gun.PreventNormalFireAudio = true;
                }
                if (!gun.IsReloading && !HasReloaded)
                {
                    this.HasReloaded = true;
                }
                float FacingDirection = gun.CurrentOwner.FacingDirection;
                if (FacingDirection <= 89 && FacingDirection >= -89)
                {
                    gun.carryPixelOffset = new IntVector2(-4, 17);
                }
                else
                {
                    gun.carryPixelOffset = new IntVector2(12, 17);
                }
                //upgrades gun based on synergies.
                var p = gun.CurrentOwner as PlayerController;
                if (p.PlayerHasActiveSynergy("who even needs money."))
                {
                    if (hasBeenUpgraded == false)
                    {
                        gun.SetBaseMaxAmmo(50);
                        gun.CurrentAmmo = 50;
                        gun.DefaultModule.chargeProjectiles[0].Projectile.baseData.damage = 10;
                        hasBeenUpgraded = true;
                    }
                }
                else
                {
                    if (hasBeenUpgraded == true)
                    {
                        gun.SetBaseMaxAmmo(1);
                        gun.CurrentAmmo = 1;
                        gun.DefaultModule.chargeProjectiles[0].Projectile.baseData.damage = 300;
                        hasBeenUpgraded = false;
                    }
                }

                if (p.PlayerHasActiveSynergy("what could be in here?"))
                {
                    if (hasBeenUpgraded2 == false)
                    {
                        //stolen from test gun
                        gun.Volley.projectiles.Clear();
                        gun.RuntimeModuleData.Clear();
                        for (int i = 0; i < ETGMod.Databases.Items.Count; i++)
                        {
                            Gun other = ETGMod.Databases.Items[i] as Gun;
                            if (other == null)
                            {
                                continue;                                            // Watch out for null entries in the database! Those are WIP / removed guns.
                            }
                            ProjectileModule module = gun.AddProjectileModuleFrom(other, clonedProjectiles: false);
                            // We don't want to eat more ammo than required.
                            module.ammoCost            = 0;
                            module.numberOfShotsInClip = gun.CurrentAmmo;
                            ModuleShootData moduleData = new ModuleShootData();
                            gun.RuntimeModuleData[module] = moduleData;
                        }
                        hasBeenUpgraded2 = true;
                    }
                }
            }
        }