Esempio n. 1
0
        /// <summary>
        /// Try to give damage to a monster
        /// </summary>
        private void DoDamage(bool criticalFist = false)
        {
            Rectangle        effectiveArea = this.follower.GetBoundingBox();
            Rectangle        enemyBox      = this.leader.GetBoundingBox();
            Rectangle        companionBox  = this.follower.GetBoundingBox();
            WeaponAttributes attrs         = new WeaponAttributes();

            if (!criticalFist && this.weapon != null)
            {
                attrs.SetFromWeapon(this.weapon);
            }

            if (criticalFist)
            {
                attrs.knockBack   *= 4;
                attrs.smashAround /= 2f;
            }

            companionBox.Inflate(8, 8); // Personal space
            effectiveArea.Inflate((int)(effectiveArea.Width * attrs.smashAround + attrs.addedEffectiveArea), (int)(effectiveArea.Height * attrs.smashAround + attrs.addedEffectiveArea));

            if (!criticalFist && !this.defendFistUsed && companionBox.Intersects(enemyBox))
            {
                this.ai.Monitor.Log("Critical dangerous: Using defense fists!");
                this.defendFistUsed = true;
                this.DoFightSpeak();
                this.DoDamage(true); // Force fist when no damage given to a monster with weapon
                return;
            }

            if (this.follower.currentLocation.damageMonster(effectiveArea, attrs.minDamage, attrs.maxDamage, false, attrs.knockBack, attrs.addedPrecision, attrs.critChance, attrs.critMultiplier, !criticalFist, this.realLeader as Farmer))
            {
                this.follower.currentLocation.playSound("clubhit");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Try to give damage to a monster
        /// </summary>
        private void DoDamage(bool criticalFist = false)
        {
            Rectangle        effectiveArea = this.follower.GetBoundingBox();
            Rectangle        enemyBox      = this.leader.GetBoundingBox();
            Rectangle        companionBox  = this.follower.GetBoundingBox();
            WeaponAttributes attrs         = new WeaponAttributes();

            if (!criticalFist && this.weapon != null)
            {
                attrs.SetFromWeapon(this.weapon);
            }

            if (criticalFist)
            {
                attrs.knockBack   *= 2.7f;
                attrs.smashAround /= 2f;
            }

            if (criticalFist && this.follower.FacingDirection != 0)
            {
                this.follower.currentLocation.playSound("clubSmash");
                this.follower.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("TileSheets\\animations", new Microsoft.Xna.Framework.Rectangle(0, 960, 128, 128), 60f, 4, 0, this.follower.Position, false, this.follower.FacingDirection == 3, 1f, 0.0f, Color.White, .5f, 0.0f, 0.0f, 0.0f, false));
            }

            companionBox.Inflate(8, 8); // Personal space
            effectiveArea.Inflate((int)(effectiveArea.Width * attrs.smashAround + attrs.addedEffectiveArea), (int)(effectiveArea.Height * attrs.smashAround + attrs.addedEffectiveArea));

            if (!criticalFist && !this.defendFistUsed && this.ai.Csm.HasSkill("warrior") && companionBox.Intersects(enemyBox) && Game1.random.NextDouble() < .33f)
            {
                this.ai.Monitor.Log("Critical dangerous: Using defense fists!");
                this.defendFistUsed = true;
                this.DoDamage(true); // Force fist when no damage given to a monster with weapon
                return;
            }

            if (this.follower.currentLocation.damageMonster(effectiveArea, attrs.minDamage, attrs.maxDamage, false, attrs.knockBack, attrs.addedPrecision, attrs.critChance, attrs.critMultiplier, !criticalFist, this.realLeader as Farmer))
            {
                this.follower.currentLocation.playSound("clubhit");
                if (criticalFist || (Game1.random.NextDouble() > .7f && Game1.random.NextDouble() < .3f))
                {
                    this.DoFightSpeak();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Try to give damage to a monster
        /// </summary>
        private void DoDamage(bool criticalFist = false)
        {
            if (this.leader == null)
            {
                return;
            }

            Rectangle        effectiveArea = this.follower.GetBoundingBox();
            Rectangle        enemyBox      = this.leader.GetBoundingBox();
            Rectangle        companionBox  = this.follower.GetBoundingBox();
            WeaponAttributes attrs         = new WeaponAttributes();

            if (!criticalFist && this.weapon != null)
            {
                attrs.SetFromWeapon(this.weapon);
            }

            if (criticalFist)
            {
                attrs.knockBack   *= 3.6f;
                attrs.smashAround /= 2f;
            }

            if (this.ai.Csm.HasSkill("warrior"))
            {
                // Enhanced skills ONLY for WARRIORS
                attrs.minDamage          += (int)Math.Round(attrs.minDamage * .03f);           // 3% added min damage
                attrs.knockBack          += attrs.knockBack * (Game1.random.Next(2, 5) / 100); // 2-5% added knock back
                attrs.addedEffectiveArea += (int)Math.Round(attrs.addedEffectiveArea * .01f);  // 1% added effective area
                attrs.critChance         += Math.Max(0, (float)Game1.player.DailyLuck / 2);    // added critical chance is half of daily luck. If luck is negative, no added critical chance
            }

            if (criticalFist && this.follower.FacingDirection != 0)
            {
                this.follower.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("TileSheets\\animations", new Rectangle(0, 960, 128, 128), 60f, 4, 0, this.follower.Position, false, this.follower.FacingDirection == 3, 1f, 0.0f, Color.White, .5f, 0.0f, 0.0f, 0.0f, false));
            }

            companionBox.Inflate(4, 4); // Personal space
            effectiveArea.Inflate((int)(effectiveArea.Width * attrs.smashAround + attrs.addedEffectiveArea), (int)(effectiveArea.Height * attrs.smashAround + attrs.addedEffectiveArea));

            if (!criticalFist && !this.defendFistUsed && this.ai.Csm.HasSkill("warrior") && companionBox.Intersects(enemyBox) && this.weaponSwingCooldown == this.CooldownTimeout)
            {
                this.ai.Monitor.Log("Critical dangerous: Using defense fists!");
                this.defendFistUsed = true;
                this.DoDamage(true); // Force fist when no damage given to a monster with weapon
                return;
            }

            if (this.follower.currentLocation.damageMonster(effectiveArea, attrs.minDamage, attrs.maxDamage, false, attrs.knockBack, attrs.addedPrecision, attrs.critChance, attrs.critMultiplier, !criticalFist, this.realLeader as Farmer))
            {
                if (criticalFist)
                {
                    this.follower.currentLocation.playSound("clubSmash");
                    this.ai.Csm.CompanionManager.Hud.GlowSkill("warrior", Color.Red, 1);
                }
                else
                {
                    this.follower.currentLocation.playSound("clubhit");
                }

                if (criticalFist || (Game1.random.NextDouble() > .7f && Game1.random.NextDouble() < .3f))
                {
                    this.DoFightSpeak();
                }
            }
        }