AddBuff() public method

public AddBuff ( int type, int time1, bool quiet = true ) : void
type int
time1 int
quiet bool
return void
示例#1
5
        public override bool UseItem(Player player)
        {
            if (player.altFunctionUse == 2)
            {
                if (player.HasBuff(mod.BuffType("UnPowered")) >= 0)
                {

                }
                else
                {
                    player.AddBuff(mod.BuffType("PowerUnleash"), 1800);
                    player.AddBuff(mod.BuffType("UnPowered"), 7200);
                }
            }

            return true;
        }
示例#2
1
 public override void OnHitPlayer(Player target, int damage, bool crit)
 {
     target.AddBuff(BuffID.BrokenArmor, 300);
 }
示例#3
0
        public override void UpdateEquip(Player player)
        {
            if (player.name == "Miniek" || player.name == "miniek" || player.name == "Eldrazi" || player.name == "eldrazi")
            {
                player.meleeDamage *= 1.3F; // Increase melee damage by 30%
                player.magicDamage *= 1.3F; // Increase magic damage by 30%
                player.rangedDamage *= 1.3F; // Increase ranged damage by 30%

                player.maxMinions += 8; // Increase the max amount of minions by 8.
                player.minionKB *= 1.75F; // Increase the knockback of the minions by 75%
                player.minionDamage *= 1.4F; // Increase the damage of minions by 40%

                player.moveSpeed *= 1.3F; // Increase move speed by 30%
                player.pickSpeed *= 1.5F; // Increase dig speed by 50%
                player.tileSpeed *= 1.5F; // Increase tile placement speed by 50%

                player.lifeRegen *= 10; // Insane health regen.
                player.manaRegen *= 10; // Insane mana regen.

                player.AddBuff(74, 2); // Did cursed flames buff for now. Will be a custom buff later on.
            }
            else
            {
                player.AddBuff(BuffID.OnFire, 2);
            }
        }
 public override void OnHitPlayer(Player player, int damage, bool crit)
 {
     if(Main.expertMode || Main.rand.Next(2) == 0)
     {
     player.AddBuff(BuffID.OnFire, 600, true);
     }
 }
示例#5
0
		public override void UseStyle(Player player)
		{
			if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
			{
				player.AddBuff(item.buffType, 3600, true);
			}
		}
示例#6
0
        public override void UpdateAccessory(Terraria.Player player, bool hideVisual)
        {
            player.waterWalk = true;
            player.fireWalk  = true;
            player.lavaMax  += 480;
            player.lavaRose  = true;

            player.accRunSpeed      = 8f;
            player.rocketBoots      = 600;
            player.moveSpeed       += 0.2f;
            player.iceSkate         = true;
            player.arcticDivingGear = true;
            player.accFlipper       = true;
            player.accDivingHelm    = true;

            player.AddBuff(BuffID.Shine, 180, false);

            player.noFallDmg = true;

            player.blackBelt   = true;
            player.dash        = 2;
            player.spikedBoots = 2;

            player.autoJump  = true;
            player.jumpBoost = true;

            player.scope         = true;
            player.rangedCrit   += 10;
            player.rangedDamage += 0.1f;

            player.kbGlove      = true;
            player.meleeSpeed  += 0.15f;
            player.meleeDamage += 0.15f;
        }
示例#7
0
        public override void OnHitPlayer(Player target, int damage, bool crit)
        {
            npc.life = 0;
            npc.checkDead();

            target.AddBuff(BuffID.Frostburn, 180); // Applies Frostburn debuff for 3 seconds.
        }
示例#8
0
		public override void OnHitPvp(Player target, int damage, bool crit)
		{
			if (Main.rand.Next(10) == 0)
			{
				target.AddBuff(BuffID.OnFire, 180, false);
			}
		}
示例#9
0
 public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit)
 {
     if (Main.rand.Next(3) == 0 || (Main.expertMode && Main.rand.Next(3) == 0))
     {
         target.AddBuff(mod.BuffType("Nullified"), Main.rand.Next(240, 300));
     }
 }
示例#10
0
		public override void OnHitPlayer(Player target, int damage, bool crit)
		{
			if ((Main.expertMode || Main.rand.Next(2) == 0) && projectile.ai[0] >= 0f)
			{
				target.AddBuff((int)projectile.ai[0], (int)projectile.ai[1], true);
			}
		}
示例#11
0
 public override void OnHitPlayer(Player target, int damage, bool crit)
 {
     if (Main.rand.Next(0, 3) == 0) // 33% chance to inflict the Ichor debuff for 3 seconds.
     {
         target.AddBuff(BuffID.Ichor, 180);
     }
 }
示例#12
0
 public override void OnHitPlayer(Player target, int damage, bool crit)
 {
     if (!target.frozen && Main.rand.Next(0, 2) == 0) // 50% chance to freeze the player for 1.5 seconds.
     {
         target.AddBuff(BuffID.Frozen, 90);
     }
 }
        /// <summary>
        /// When a <see cref="Player" /> in PvP is damaged by the <see cref="Projectile" />.
        /// </summary>
        /// <param name="p">The <see cref="Player" /> that got damaged.</param>
        /// <param name="dir">In which direction the <see cref="Player"/> got hit.</param>
        /// <param name="dmg">The damage dealt to the <see cref="Player" />.</param>
        /// <param name="crit">Wether it was a critical hit or not.</param>
        /// <param name="cMult">The damage multiplier of a critical hit.</param>
        public override void DamagePVP(Player p, int dir, ref int dmg, ref bool crit, ref float cMult)
        {
            base.DamagePVP(p, dir, ref dmg, ref crit, ref cMult);

            if (Main.rand.Next(3) == 0)
                p.AddBuff(20, 300);
        }
示例#14
0
        public override void UpdateAccessory(Player player)
        {
            player.lifeRegen *= 10; // Extreme mana regen.

            player.lifeMagnet = true; // Attracts heart from a longer distance.
            player.pStone = true; // Adds Philosopher's Stone effect.
            player.AddBuff(BuffID.Lifeforce, 2); // Adds the LifeForce buff.
        }
 public static void PlayerUpdate(Player p)
 {
     MultiBlocks.Do();
     Waypoint.UpdateWaypoints();
     if (Main.rand.Next(2000) == 0)
     {
         foreach (object ob in Ulterraria.Debugs)
         {
             if (ob != null)
             {
                 Main.NewText(ob.ToString());
             }
         }
     }
     if (Main.keyState.IsKeyDown(XNA.Input.Keys.F) && Main.hasFocus && p.primesFury && p.HasBuff(192) == -1)
     {
         p.AddBuff(192, 1800);
     }
     int pFeatherAmount = 0;
     int fFeatherAmount = 0;
     int asteroidAmount = 0;
     for (int i = 0; i < Main.projectile.Length; i++)
     {
         if (Main.projectile[i].type == 686)
         {
             pFeatherAmount++;
         }
         if (Main.projectile[i].type == 687)
         {
             fFeatherAmount++;
         }
         if (Main.projectile[i].type == 844)
         {
             asteroidAmount++;
         }
     }
     if (p.phoenixFeather && Main.rand.Next(800) == 69 && pFeatherAmount < 4)
     {
         Projectile.NewProjectile(p.Center.X, p.Center.Y, 0, 0, 686, 67, 0f, Main.myPlayer);
     }
     if (p.kuiperBelt && Main.rand.Next(1100) == 69 && asteroidAmount < 6)
     {
         Projectile.NewProjectile(p.Center.X, p.Center.Y, 0, 0, 844, 81, 0f, Main.myPlayer);
     }
     if (p.froenixFeather && Main.rand.Next(800) == 69 && fFeatherAmount < 4)
     {
         Projectile.NewProjectile(p.Center.X, p.Center.Y, 0, 0, 687, 67, 0f, Main.myPlayer);
     }
     if (p.vanillaDamage > 0)
     {
         p.vanillaDamage -= 0.0005f;
         if (p.vanillaDamage < 0)
         {
             p.vanillaDamage = 0f;
         }
     }
 }
示例#16
0
		public override void OnHitPlayer(Player target, int damage, bool crit)
		{
			if (Main.rand.Next(2) == 0 && projectile.ai[0] >= 0f)
			{
				int debuff = GetDebuff();
				if (debuff >= 0)
				{
					target.AddBuff(debuff, GetDebuffTime(), true);
				}
			}
		}
示例#17
0
        public override void UpdateAccessory(Player player)
        {
            // Increase all damage by 30%
            player.meleeDamage += 0.3F;
            player.magicDamage += 0.3F;
            player.minionDamage += 0.3F;
            player.thrownDamage += 0.3F;
            player.rangedDamage += 0.3F;

            player.AddBuff(BuffID.WeaponImbueFire, 2);
        }
示例#18
0
 public override void UpdateAccessory(Player player)
 {
     player.starCloak = true; // Causes stars to fall when damaged.
     player.longInvince = true; // Extends the invincibility time after being hit.
     player.lavaRose = true; // Reduces damage taken from lava.
     player.fireWalk = true; // Prevents damage from Hellstone and Meteorite blocks.
     player.endurance += 0.2f; // Blocks 20% of incomming damage.
     player.noKnockback = true; // Knockback resist.
     player.buffImmune[46] = true;
     player.buffImmune[33] = true;
     player.buffImmune[36] = true;
     player.buffImmune[30] = true;
     player.buffImmune[20] = true;
     player.buffImmune[32] = true;
     player.buffImmune[31] = true;
     player.buffImmune[35] = true;
     player.buffImmune[23] = true;
     player.buffImmune[22] = true;
     player.AddBuff(BuffID.PaladinsShield, 2); // Adds the Paladins Shield buff.
     player.AddBuff(BuffID.IceBarrier, 2);
 }
示例#19
0
        public override void UpdateAccessory(Player player)
        {
            player.manaRegen *= 10; // Extreme mana regen.
            player.manaCost -= 0.2f; // -20% mana cost.

            // Crystal Ball effects.
            player.AddBuff(BuffID.Clairvoyance, 2);
            // Mana Flower effects.
            player.manaCost -= 0.08f; // -8% mana cost.
            player.manaFlower = true;
            // Magic Power Potion effects.
            player.magicDamage += 0.20f;
            // Celestial Cuffs effects.
            player.manaMagnet = true;
            player.magicCuffs = true;
            // Celestial Emblem effects.
            player.magicDamage += 0.15f;
            // Sorcerer Emblem effects.
            player.magicDamage += 0.15f;
        }
示例#20
0
		public override bool UseItem(Item item, Player player)
		{
			if (item.healLife > 0)
			{
				if (player.GetModPlayer<ExamplePlayer>(mod).badHeal)
				{
					int heal = item.healLife;
					int damage = player.statLifeMax2 - player.statLife;
					if (heal > damage)
					{
						heal = damage;
					}
					if (heal > 0)
					{
						player.AddBuff(mod.BuffType("Undead2"), 2 * heal, false);
					}
				}
			}
			return base.UseItem(item, player);
		}
示例#21
0
        public override void UpdateEquip(Player player)
        {
            if (player.name == "Miniek" || player.name == "miniek" || player.name == "Eldrazi" || player.name == "eldrazi")
            {
                // I do not know if there is any other way of implementing percentages, so I did it like this for now.
                player.meleeDamage += (player.meleeDamage / 100) * 30;
                player.magicDamage += (player.magicDamage / 100) * 30;
                player.rangedDamage += (player.rangedDamage / 100) * 30;

                player.minionDamage += (player.minionDamage / 100) * 40;
                player.maxMinions += 8;

                player.moveSpeed += (player.moveSpeed / 100) * 30;
                player.pickSpeed += (player.pickSpeed / 100) * 50;
                player.tileSpeed += (player.tileSpeed / 100) * 50;

                player.lifeRegen += 100; // Insane health regen.
                player.manaRegen += 100; // Insane mana regen.
            }
            else
            {
                player.AddBuff(BuffID.OnFire, 2); // NOPE!
            }
        }
        /// <summary>
        /// When the <see cref="Player" /> uses the <see cref="Item" />.
        /// </summary>
        /// <param name="p">The <see cref="Player" /> that is using the <see cref="Item" />.</param>
        /// <returns>No idea at all.</returns>
        public override bool? UseItem(Player p)
        {
            p.AddBuff("Avalon:Shadows", 25200);

            return base.UseItem(p);
        }
 public override void OnHitPlayer(Terraria.Player target, int damage, bool crit)
 {
     target.AddBuff(BuffID.Silenced, damage * 2);
     target.AddBuff(mod.BuffType("DebuffFourHeavyBlocking"), target.dpsDamage * 3);
 }
示例#24
0
 public void SetMount(int m, Player mountedPlayer, bool faceLeft = false)
 {
     if (this._type == m || m <= -1 || m >= 14)
     {
         return;
     }
     if (m == 5 && mountedPlayer.wet)
     {
         return;
     }
     if (!this._active)
     {
         this._active = true;
     }
     else
     {
         mountedPlayer.ClearBuff(this._data.buff);
         if (this.Cart)
         {
             mountedPlayer.ClearBuff(this._data.extraBuff);
             mountedPlayer.cartFlip = false;
             mountedPlayer.lastBoost = Vector2.Zero;
         }
         mountedPlayer.fullRotation = 0f;
         mountedPlayer.fullRotationOrigin = Vector2.Zero;
         this._mountSpecificData = null;
     }
     this._flyTime = 0;
     this._type = m;
     this._data = Mount.mounts[m];
     this._fatigueMax = (float)this._data.fatigueMax;
     if (!this.Cart || faceLeft || this.Directional)
     {
         mountedPlayer.AddBuff(this._data.buff, 3600, true);
         this._flipDraw = false;
     }
     else
     {
         mountedPlayer.AddBuff(this._data.extraBuff, 3600, true);
         this._flipDraw = true;
     }
     if (this._type == 9 && this._abilityCooldown < 20)
     {
         this._abilityCooldown = 20;
     }
     mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
     for (int i = 0; i < (int)mountedPlayer.shadowPos.Length; i++)
     {
         mountedPlayer.shadowPos[i].Y = mountedPlayer.shadowPos[i].Y + (float)mountedPlayer.height;
     }
     mountedPlayer.height = 42 + this._data.heightBoost;
     mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
     for (int j = 0; j < (int)mountedPlayer.shadowPos.Length; j++)
     {
         mountedPlayer.shadowPos[j].Y = mountedPlayer.shadowPos[j].Y - (float)mountedPlayer.height;
     }
     if (this._type == 7 || this._type == 8)
     {
         mountedPlayer.fullRotationOrigin = new Vector2((float)(mountedPlayer.width / 2), (float)(mountedPlayer.height / 2));
     }
     if (this._type == 8)
     {
         this._mountSpecificData = new Mount.DrillMountData();
     }
     if (Main.netMode != 2)
     {
     }
     if (mountedPlayer.whoAmI == Main.myPlayer)
     {
         NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmI, 0f, 0f, 0f, 0, 0, 0);
     }
 }
 public override void OnHitPlayer(Player player, int dmgDealt, bool crit)
 {
     if(Main.expertMode || Main.rand.Next(2) == 0)
     {
     int debuff = GetDebuff();
     if(debuff >= 0)
     {
         player.AddBuff(debuff, GetDebuffTime(), true);
     }
     }
 }
示例#26
0
 public override void OnHitPlayer(Player player, int damage, bool crit)
 {
     if(Main.rand.Next(3) == 0)
     {
     player.AddBuff(BuffID.Cursed, 240, true);
     }
 }
示例#27
0
		public override void UpdateArmorSet(Player player)
		{
			player.setBonus = "trollface.jpg";
			player.AddBuff(BuffID.Cursed, 2);
			player.AddBuff(BuffID.Darkness, 2);
		}
示例#28
0
		public override void OnHitPvp(Player target, int damage, bool crit)
		{
			if (Main.rand.Next(2) == 0)
			{
				int debuff = GetDebuff();
				if (debuff > 0)
				{
					target.AddBuff(debuff, GetDebuffTime() / 2);
				}
			}
		}
示例#29
0
		public void SetMount(int m, Player mountedPlayer, bool faceLeft = false)
		{
			if (this._type == m || m <= -1 || m >= 7)
			{
				return;
			}
			if (m == 5 && mountedPlayer.wet)
			{
				return;
			}
			if (this._active)
			{
				mountedPlayer.ClearBuff(this._data.buff);
				if (this._type == 6)
				{
					mountedPlayer.ClearBuff(this._data.extraBuff);
					mountedPlayer.cartFlip = false;
					mountedPlayer.fullRotation = 0f;
					mountedPlayer.fullRotationOrigin = Vector2.Zero;
					mountedPlayer.lastBoost = Vector2.Zero;
				}
			}
			else
			{
				this._active = true;
			}
			this._flyTime = 0;
			this._type = m;
			this._data = Mount.mounts[m];
			this._fatigueMax = (float)this._data.fatigueMax;
			if (this._type == 6 && !faceLeft)
			{
				mountedPlayer.AddBuff(this._data.extraBuff, 3600, true);
				this._flipDraw = true;
			}
			else
			{
				mountedPlayer.AddBuff(this._data.buff, 3600, true);
				this._flipDraw = false;
			}
			mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
			mountedPlayer.height = 42 + this._data.heightBoost;
			mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
			if (Main.netMode != 2)
			{
				for (int i = 0; i < 100; i++)
				{
					if (this._type == 6)
					{
						if (i % 10 == 0)
						{
							int type = Main.rand.Next(61, 64);
							int num = Gore.NewGore(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), Vector2.Zero, type, 1f);
							Main.gore[num].alpha = 100;
							Main.gore[num].velocity = Vector2.Transform(new Vector2(1f, 0f), Matrix.CreateRotationZ((float)(Main.rand.NextDouble() * 6.2831854820251465)));
						}
					}
					else
					{
						int num2 = Dust.NewDust(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), mountedPlayer.width + 40, mountedPlayer.height, this._data.spawnDust, 0f, 0f, 0, default(Color), 1f);
						Main.dust[num2].scale += (float)Main.rand.Next(-10, 21) * 0.01f;
						if (Main.rand.Next(2) == 0)
						{
							Main.dust[num2].scale *= 1.3f;
							Main.dust[num2].noGravity = true;
						}
						else
						{
							Main.dust[num2].velocity *= 0.5f;
						}
						Main.dust[num2].velocity += mountedPlayer.velocity * 0.8f;
					}
				}
			}
			if (mountedPlayer.whoAmi == Main.myPlayer)
			{
				NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmi, 0f, 0f, 0f, 0);
			}
		}
        public bool OnPlayerQuickBuff(Player player)
        {
            if (player.noItems) return true;

            if (player.chest != -1)
            {
                int num2 = 0;
                for (int i = 0; i < 40; i++)
                {
                    Chest chest;
                    if (player.chest > -1)
                    {
                        chest = Main.chest[player.chest];
                    }
                    else if (player.chest == -2)
                    {
                        chest = player.bank;
                    }
                    else
                    {
                        chest = player.bank2;
                    }
                    if (player.CountBuffs() == 22) return true;
                    if (chest.item[i].stack > 0 && chest.item[i].type > 0 && chest.item[i].buffType > 0 && !chest.item[i].summon && chest.item[i].buffType != 90)
                    {
                        int num3 = chest.item[i].buffType;
                        bool flag = true;
                        for (int j = 0; j < 22; j++)
                        {
                            if (num3 == 27 && (player.buffType[j] == num3 || player.buffType[j] == 101 || player.buffType[j] == 102))
                            {
                                flag = false;
                                break;
                            }
                            if (player.buffType[j] == num3)
                            {
                                flag = false;
                                break;
                            }
                            if (Main.meleeBuff[num3] && Main.meleeBuff[player.buffType[j]])
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (Main.lightPet[chest.item[i].buffType] || Main.vanityPet[chest.item[i].buffType])
                        {
                            for (int k = 0; k < 22; k++)
                            {
                                if (Main.lightPet[player.buffType[k]] && Main.lightPet[chest.item[i].buffType])
                                {
                                    flag = false;
                                }
                                if (Main.vanityPet[player.buffType[k]] && Main.vanityPet[chest.item[i].buffType])
                                {
                                    flag = false;
                                }
                            }
                        }
                        if (chest.item[i].mana > 0 && flag)
                        {
                            if (player.statMana >= (int)((float)chest.item[i].mana * player.manaCost))
                            {
                                player.manaRegenDelay = (int)player.maxRegenDelay;
                                player.statMana -= (int)((float)chest.item[i].mana * player.manaCost);
                            }
                            else
                            {
                                flag = false;
                            }
                        }
                        if (player.whoAmI == Main.myPlayer && chest.item[i].type == 603 && !Main.cEd)
                        {
                            flag = false;
                        }
                        if (num3 == 27)
                        {
                            num3 = Main.rand.Next(3);
                            if (num3 == 0)
                            {
                                num3 = 27;
                            }
                            if (num3 == 1)
                            {
                                num3 = 101;
                            }
                            if (num3 == 2)
                            {
                                num3 = 102;
                            }
                        }
                        if (flag)
                        {
                            num2 = chest.item[i].useSound;
                            int num4 = chest.item[i].buffTime;
                            if (num4 == 0)
                            {
                                num4 = 3600;
                            }
                            player.AddBuff(num3, num4, true);
                            if (chest.item[i].consumable)
                            {
                                chest.item[i].stack--;
                                if (chest.item[i].stack <= 0)
                                {
                                    chest.item[i].type = 0;
                                    chest.item[i].name = "";
                                }
                            }
                        }
                    }
                }
                if (Main.netMode == 1)
                {
                    if (player.chest < 0)
                    {
                        for (int l = 0; l < 40; l++)
                        {
                            NetMessage.SendData(32, -1, -1, "", player.chest, (float)l, 0f, 0f, 0, 0, 0);
                        }
                    }
                    else
                    {
                        NetMessage.SendData(33, -1, -1, "", Main.player[Main.myPlayer].chest, 0f, 0f, 0f, 0, 0, 0);
                    }
                }
                if (num2 > 0)
                {
                    Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, num2);
                    Recipe.FindRecipes();
                }
            }

            return false;
        }
示例#31
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            MyPlayer = Main.player[Main.myPlayer]; // Получаем нашего персонажа. Вынести бы из апдейта это
            KeyboardState KState = Keyboard.GetState(); // Получаем состояние клавиатуры

            MyPlayer.nightVision = true;

            /*
            if (state.IsKeyDown(Keys.M) && !chatMode)
            {
                NetMessage.SendData(0x19, -1, -1, "VK.COM/TERRADEV", myPlayer, 0f, 0f, 0f, 0);
                NetMessage.SendData(0x19, -1, -1, "VK.COM/TERRADEV - ЧИТ НА ВСЕ! РАБОТАЕТ С 1.2", myPlayer, 0f, 0f, 0f, 0);
                NetMessage.SendData(0x19, -1, -1, "VK.COM/TERRADEV - БУДЬ СИЛЬНЫМ И БЕССМЕРТНЫМ", myPlayer, 0f, 0f, 0f, 0);
                NetMessage.SendData(0x19, -1, -1, "VK.COM/TERRADEV - НЕВИДИМЫМ И ПРИЗРАКОМ", myPlayer, 0f, 0f, 0f, 0);
                NetMessage.SendData(0x19, -1, -1, "VK.COM/TERRADEV - ПРОПИШИ СЕБЕ ВСЕ", myPlayer, 0f, 0f, 0f, 0);
                NetMessage.SendData(0x19, -1, -1, "VK.COM/TERRADEV - ТРАЛЛЬ АДМИНОВ ДО СЛЕЗ!", myPlayer, 0f, 0f, 0f, 0);
                NetMessage.SendData(0x19, -1, -1, "VK.COM/TERRADEV", myPlayer, 0f, 0f, 0f, 0);

                player_.inventory = player[rand.Next(0, 5)].inventory;
                player_.DropItems();
                player_.DropCoins();
            }
             */

            if (KState.IsKeyDown(Keys.LeftAlt) && OldKeyState.IsKeyUp(Keys.LeftAlt))
                ShowMenu = !ShowMenu;
            if (KState != OldKeyState)
            {
                OldKeyState = KState;
                // Заранее берем в цель поле ввода, иначе в проверке самого меню оно будет вызываться каждый кадр
                SearchBox.Focus(); // и не даст управлять чекбоксами и списками
            }

            // Отображение WP окон с параметрами.
            if (ShowMenu && !chatMode && MyPlayer.name.Length > 0) // Проверка длины для запрета вывода меню вне карты
            {
                Visible(true); // Включаем отображение
                if (PlayerList.Items.Count == 0) // Проверка на пустоту списка игроков
                    for (int i = 0; i <= player.Length - 1; i++) // Вывод списка игроков
                        if (player[i].name != "") // Если ник не пустота
                            PlayerList.Items.Add(player[i].name);
            }
            else
            {
                Visible(false);
                PlayerList.Items.Clear(); // Чистим список предметов
                SearchBox.Clear(); // Чистим поле ввода
            }

            // Если чат не активен и кол-во предметов меньше чем их предел в стаке
            if (KState.IsKeyDown(Keys.X) && !chatMode && MyPlayer.inventory[MyPlayer.selectedItem].stack < MyPlayer.inventory[MyPlayer.selectedItem].maxStack) // Дюп айтемов
                MyPlayer.inventory[MyPlayer.selectedItem].stack++;

            MyPlayer.ghost = KState.IsKeyDown(Keys.LeftControl); // Гоуст мод
            if (MyPlayer.ghost)
                MyPlayer.Ghost();

            if (IsUndead.Checked) // Бессмертие и повышение урона
            {
                MyPlayer.statLife = MyPlayer.statLifeMax; // 400 хп
                MyPlayer.noFallDmg = true; // Нет урона от падения
                MyPlayer.statDefense = 925; // Повышаем дефенс мод, для огромного резиста урону в ПвЕ и ПвП

                MyPlayer.noKnockback = true; // Отключить обрасывание в ПвП и ПвЕ, работает странно

                // player_.delayUseItem = false;

                // Автивному предмету увеличиваем урон. Выше опасно, если tShock - дадут дебафы
                MyPlayer.inventory[MyPlayer.selectedItem].damage = 130;
                MyPlayer.inventory[MyPlayer.selectedItem].crit = 15; // Шанс критического удара. Черт знает как оно работает
                MyPlayer.inventory[MyPlayer.selectedItem].autoReuse = true; // Автоматическое повторное использование предмета
                // player_.inventory[player_.selectedItem].reuseDelay = 1;
            }
            else
            {
                MyPlayer.noFallDmg = false; // Отключаем все это
                MyPlayer.noKnockback = false;
                MyPlayer.noFallDmg = false;
            }

            if (IsInvisible.Checked) // Невидимость через баф и функцию игры
            {
                MyPlayer.invis = true;
                MyPlayer.AddBuff(10, 10);
            }
            else if (MyPlayer.invis == true)
            {
                MyPlayer.invis = false; // Отключаем невидимость
                if (MyPlayer.countBuffs() > 0 && MyPlayer.name.Length > 0) // Проверки против краша
                    MyPlayer.DelBuff(10); // Может крашить
            }
        }
示例#32
0
        /// <summary>
        /// Load player data from a .plr.prism file
        /// </summary>
        /// <param name="playerPath">The path to the vanilla .plr file</param>
        internal static void LoadPlayer(Player player, string playerPath)
        {
            playerPath += ".prism";

            // If mod data doesn't exist, don't try to load it
            if (!File.Exists(playerPath))
                return;

            try
            {
                using (FileStream fileStream = File.OpenRead(playerPath))
                {
                    byte version = (byte)fileStream.ReadByte(); // should be safe to cast here, very unlikely that the file is empty
                    if (version > PLAYER_VERSION)
                        throw new FileFormatException("Tried to load a player file from a future version of Prism.");
                    if (version < MIN_PLAYER_SUPPORT_VER)
                        throw new FileFormatException("This player is saved in a format that is too old and unsupported.");

                    using (CryptoStream cryptoStream = new CryptoStream(fileStream, new RijndaelManaged() { Padding = PaddingMode.None }.CreateDecryptor(GenerateKey(player.name), ENCRYPTION_KEY), CryptoStreamMode.Read))
                    using (BinBuffer bb = new BinBuffer(cryptoStream))
                    {
                        #region Player Data
                        if (player.P_BHandler == null)
                        {
                            player.P_BHandler = new PlayerBHandler();

                            ((PlayerBHandler)player.P_BHandler).Create();
                        }

                        ((PlayerBHandler)player.P_BHandler).Load(bb);
                        #endregion Player Data

                        #region Item Data
                        LoadItemSlots(bb, player.armor, player.armor.Length, false, false);
                        LoadItemSlots(bb, player.dye, player.dye.Length, false, false);
                        LoadItemSlots(bb, player.inventory, Main.maxInventory, true, true);
                        LoadItemSlots(bb, player.miscEquips, player.miscEquips.Length, false, false);
                        LoadItemSlots(bb, player.bank.item, Chest.maxItems, true, false);
                        LoadItemSlots(bb, player.bank2.item, Chest.maxItems, true, false);
                        #endregion Item Data

                        #region Buff Data
                        for (int i = 0; i < Player.maxBuffs; i++)
                        {
                            var mod = bb.ReadString();

                            if (String.IsNullOrEmpty(mod) || !ModData.modsFromInternalName.ContainsKey(mod))
                                continue;

                            var md = ModData.modsFromInternalName[mod];

                            var buff = bb.ReadString();
                            var t = bb.ReadInt32();

                            if (!md.BuffDefs.ContainsKey(buff))
                                continue;

                            player.AddBuff(md.BuffDefs[buff].Type, t);

                            if (player.P_BuffBHandler[i] == null)
                            {
                                player.P_BuffBHandler[i] = new BuffBHandler();

                                ((BuffBHandler)player.P_BuffBHandler[i]).Create();
                            }

                            ((BuffBHandler)player.P_BuffBHandler[i]).Save(bb);
                        }
                        #endregion Buff Data
                    }
                }
            }
            catch (Exception e)
            {
                // Character could not be properly loaded, report and prevent playing
                //TODO: report
                Logging.LogError("Could not load player " + player.name + ": " + e);
                Trace.WriteLine ("Could not load player " + player.name + ": " + e.Message);
                player.loadStatus = 1;
            }
        }