Exemplo n.º 1
0
 public override void TakeHit(Entity source, int damage = 1, DamageCause cause = DamageCause.Unknown)
 {
     base.TakeHit(source, 0, cause);
 }
Exemplo n.º 2
0
		public PetHealthManager(Entity entity) : base(entity)
		{
		}
Exemplo n.º 3
0
 public NoDamageHealthManager(Entity entity)
     : base(entity)
 {
 }
Exemplo n.º 4
0
		public override void TakeHit(Entity source, int damage = 1, DamageCause cause = DamageCause.Unknown)
		{
			if (!(source is Player)) return;

			// Pets must die in void or they get stuck forever :-(
			if (cause == DamageCause.Void)
			{
				base.TakeHit(source, damage, cause);
				return; // Love denied!
			}

			int size = Entity.Level.Random.Next(0, 3); // The size of the hearts

			Pet pet = Entity as Pet;
			if (pet != null)
			{
				if (pet.AttackTarget != null) return;

				// He is still angry, better not pet him right now.
				if (!pet.IsInRage && IsOnFire && pet.Level.Random.Next(10) == 0)
				{
					pet.AttackTarget = (Player) source;
					pet.RageTick = 20*3;
					return;
				}

				// Only owner do petting with my pet!
				if (pet.Owner == source)
				{
					// Don't trust animals!
					if (pet.Level.Random.Next(500) == 0)
					{
						pet.AttackTarget = (Player) source;
						pet.RageTick = 20*2;
						return;
					}

					pet.Level.RelayBroadcast(new McpeLevelEvent
					{
						eventId = 0x4000 | 14,
						x = Entity.KnownPosition.X,
						y = Entity.KnownPosition.Y + 0.85f,
						z = Entity.KnownPosition.Z,
						data = size
					});
				}
				else
				{
					// HAHA Steal IT!
					if (pet.Level.Random.Next(50) == 0)
					{
						pet.Owner = (Player) source;
						pet.AttackTarget = null;
						pet.RageTick = 0;
						return;
					}

					// Don't trust animals!
					if (pet.Level.Random.Next(30) == 0)
					{
						pet.AttackTarget = (Player) source;
						pet.RageTick = 20*3;
						return;
					}
				}
			}
		}