Ejemplo n.º 1
0
        /// <summary>
        /// Finds the closest player within 16 blocks to attack, or null if this Entity isn't interested in attacking
        /// (Animals, Spiders at day, peaceful PigZombies).
        /// </summary>
        protected override Entity FindPlayerToAttack()
        {
            EntityPlayer entityplayer = WorldObj.GetClosestVulnerablePlayerToEntity(this, 16);

            if (entityplayer != null && CanEntityBeSeen(entityplayer))
            {
                return(entityplayer);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Finds the closest player within 16 blocks to attack, or null if this Entity isn't interested in attacking
        /// (Animals, Spiders at day, peaceful PigZombies).
        /// </summary>
        protected override Entity FindPlayerToAttack()
        {
            float f = GetBrightness(1.0F);

            if (f < 0.5F)
            {
                float d = 16F;
                return(WorldObj.GetClosestVulnerablePlayerToEntity(this, d));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public override void UpdateEntityActionState()
        {
            DespawnEntity();
            EntityPlayer entityplayer = WorldObj.GetClosestVulnerablePlayerToEntity(this, 16);

            if (entityplayer != null)
            {
                FaceEntity(entityplayer, 10F, 20F);
            }

            if (OnGround && SlimeJumpDelay-- <= 0)
            {
                SlimeJumpDelay = Func_40131_af();

                if (entityplayer != null)
                {
                    SlimeJumpDelay /= 3;
                }

                IsJumping = true;

                if (Func_40133_ao())
                {
                    WorldObj.PlaySoundAtEntity(this, Func_40138_aj(), GetSoundVolume(), ((Rand.NextFloat() - Rand.NextFloat()) * 0.2F + 1.0F) * 0.8F);
                }

                Field_40139_a = 1.0F;
                MoveStrafing  = 1.0F - Rand.NextFloat() * 2.0F;
                MoveForward   = 1 * GetSlimeSize();
            }
            else
            {
                IsJumping = false;

                if (OnGround)
                {
                    MoveStrafing = MoveForward = 0.0F;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Finds the closest player within 16 blocks to attack, or null if this Entity isn't interested in attacking
        /// (Animals, Spiders at day, peaceful PigZombies).
        /// </summary>
        protected override Entity FindPlayerToAttack()
        {
            EntityPlayer entityplayer = WorldObj.GetClosestVulnerablePlayerToEntity(this, 64);

            if (entityplayer != null)
            {
                if (ShouldAttackPlayer(entityplayer))
                {
                    if (Field_35185_e++ == 5)
                    {
                        Field_35185_e = 0;
                        return(entityplayer);
                    }
                }
                else
                {
                    Field_35185_e = 0;
                }
            }

            return(null);
        }
        public override void UpdateEntityActionState()
        {
            if (!WorldObj.IsRemote && WorldObj.DifficultySetting == 0)
            {
                SetDead();
            }

            DespawnEntity();
            PrevAttackCounter = AttackCounter;
            float d  = WaypointX - PosX;
            float d1 = WaypointY - PosY;
            float d2 = WaypointZ - PosZ;
            float d3 = (float)MathHelper2.Sqrt_double(d * d + d1 * d1 + d2 * d2);

            if (d3 < 1.0D || d3 > 60D)
            {
                WaypointX = PosX + ((Rand.NextFloat() * 2.0F - 1.0F) * 16F);
                WaypointY = PosY + ((Rand.NextFloat() * 2.0F - 1.0F) * 16F);
                WaypointZ = PosZ + ((Rand.NextFloat() * 2.0F - 1.0F) * 16F);
            }

            if (CourseChangeCooldown-- <= 0)
            {
                CourseChangeCooldown += Rand.Next(5) + 2;

                if (IsCourseTraversable(WaypointX, WaypointY, WaypointZ, d3))
                {
                    MotionX += (d / d3) * 0.10000000000000001F;
                    MotionY += (d1 / d3) * 0.10000000000000001F;
                    MotionZ += (d2 / d3) * 0.10000000000000001F;
                }
                else
                {
                    WaypointX = PosX;
                    WaypointY = PosY;
                    WaypointZ = PosZ;
                }
            }

            if (TargetedEntity != null && TargetedEntity.IsDead)
            {
                TargetedEntity = null;
            }

            if (TargetedEntity == null || AggroCooldown-- <= 0)
            {
                TargetedEntity = WorldObj.GetClosestVulnerablePlayerToEntity(this, 100);

                if (TargetedEntity != null)
                {
                    AggroCooldown = 20;
                }
            }

            double d4 = 64D;

            if (TargetedEntity != null && TargetedEntity.GetDistanceSqToEntity(this) < d4 * d4)
            {
                float d5 = TargetedEntity.PosX - PosX;
                float d6 = (TargetedEntity.BoundingBox.MinY + TargetedEntity.Height / 2.0F) - PosY + (Height / 2.0F);
                float d7 = TargetedEntity.PosZ - PosZ;
                RenderYawOffset = RotationYaw = (-(float)Math.Atan2(d5, d7) * 180F) / (float)Math.PI;

                if (CanEntityBeSeen(TargetedEntity))
                {
                    if (AttackCounter == 10)
                    {
                        WorldObj.PlayAuxSFXAtEntity(null, 1007, (int)PosX, (int)PosY, (int)PosZ, 0);
                    }

                    AttackCounter++;

                    if (AttackCounter == 20)
                    {
                        WorldObj.PlayAuxSFXAtEntity(null, 1008, (int)PosX, (int)PosY, (int)PosZ, 0);
                        EntityFireball entityfireball = new EntityFireball(WorldObj, this, d5, d6, d7);
                        float          d8             = 4;
                        Vec3D          vec3d          = GetLook(1.0F);
                        entityfireball.PosX = PosX + (float)vec3d.XCoord * d8;
                        entityfireball.PosY = PosY + (Height / 2.0F) + 0.5F;
                        entityfireball.PosZ = PosZ + (float)vec3d.ZCoord * d8;
                        WorldObj.SpawnEntityInWorld(entityfireball);
                        AttackCounter = -40;
                    }
                }
                else if (AttackCounter > 0)
                {
                    AttackCounter--;
                }
            }
            else
            {
                RenderYawOffset = RotationYaw = (-(float)Math.Atan2(MotionX, MotionZ) * 180F) / (float)Math.PI;

                if (AttackCounter > 0)
                {
                    AttackCounter--;
                }
            }

            if (!WorldObj.IsRemote)
            {
                byte byte0 = DataWatcher.GetWatchableObjectByte(16);
                byte byte1 = (byte)(AttackCounter <= 10 ? 0 : 1);

                if (byte0 != byte1)
                {
                    DataWatcher.UpdateObject(16, byte1);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Finds the closest player within 16 blocks to attack, or null if this Entity isn't interested in attacking
        /// (Animals, Spiders at day, peaceful PigZombies).
        /// </summary>
        protected override Entity FindPlayerToAttack()
        {
            float d = 8;

            return(WorldObj.GetClosestVulnerablePlayerToEntity(this, d));
        }