Example #1
0
    def func(self):
        combatant = Combatant(self.caller)

        if not self.args:
            self.msg("|430Usage: cleave <target>|n")
            return

        if combatant.cantFight:
            combatant.message("|400You are too injured to act.|n")
            return

        # Check for and error handle designated target
        target = self.caller.search(self.target)

        # Pass all checks now execute command.
        # Use parsed args in combat loop. Handles turn order in combat.
        if not target:
            combatant.message("|430Please designate an appropriate target.|n")
            return

        victim = combatant.getVictim(self.target)

        if not target.db.bleed_points:
            combatant.message(f"{victim.name} |400is dead. You only further mutiliate their body.|n")
            combatant.broadcast(f"{combatant.name} |025further mutilates the corpse of|n {victim.name}|025.|n")
            return

        loop = CombatLoop(combatant.caller, target)
        loop.resolveCommand()

        if combatant.hasTurn(f"|430You need to wait until it is your turn before you are able to act.|n"):
            if combatant.isArmed(f"|430Before you attack you must equip a weapon using the command equip <weapon>.|n"):
                if not combatant.hasWeakness(f"|400You are too weak to use this attack.|n"):
                        if combatant.hasCleavesRemaining(
                                f"|400You have 0 cleaves remaining or do not have the skill.\nPlease choose another action."):
                            if combatant.hasTwoHandedWeapon(
                                    f"|430Before you attack you must equip a two handed weapon using the command equip <weapon>.|n"):
                                maneuver_difficulty = 0
                                attack_result = combatant.rollAttack(maneuver_difficulty)
                                if attack_result >= victim.av:
                                    shot_location = combatant.determineHitLocation(victim)
                                    if not victim.blocksWithShield(shot_location):
                                        combatant.decreaseCleaves(1)
                                        if not victim.resistsAttack():
                                            skip_av_damage = True
                                            combatant.broadcast(f"{combatant.name} |025strikes|n (|020{attack_result}|n) |025with great ferocity and cleaves|n {victim.name}|025's {shot_location}|n (|400{victim.av}|n)|025, dealing|n (|430{combatant.getDamage()}|n) |025damage|n.")
                                            victim.takeDamage(combatant, combatant.getDamage(), shot_location, skip_av_damage)
                                        else:
                                            combatant.broadcast(
                                                f"{combatant.name} |025strikes|n (|020{attack_result}|n) |025with great ferocity and cleaves|n {victim.name}|025's {shot_location} but|n {victim.name} |025resists the attack with grim determination.|n")
                                    else:
                                        combatant.broadcast(
                                            f"{combatant.name} |025strikes|n (|020{attack_result}|n) |025with great ferocity and cleaves {victim.name}'s {shot_location}|n (|400{victim.av}|n)|025, however |n{victim.name} |025manages to block the blow with their shield!|n.")
                                else:
                                    combatant.broadcast(f"{combatant.name} |025swings ferociously|n (|030{attack_result}|n) |025at|n {victim.name} (|400{victim.av}|n)|025, but misses.|n")

                                # Clean up
                                # Set self.caller's combat_turn to 0. Can no longer use combat commands.
                                loop.combatTurnOff(self.caller)
                                loop.cleanup()
Example #2
0
    def func(self):
        combatant = Combatant(self.caller)

        if not self.args:
            self.caller.msg("|430Usage: disarm <target>|n")
            return

        if combatant.cantFight:
            combatant.message("|400You are too injured to act.|n")
            return

        # Check for and error handle designated target
        target = self.caller.search(self.target)

        # Pass all checks now execute command.
        # Use parsed args in combat loop. Handles turn order in combat.
        if not target:
            combatant.message("|430Please designate an appropriate target.|n")
            return

        if not target.db.bleed_points:
            combatant.message(
                f"{victim.name} |400is dead. You only further mutiliate their body.|n"
            )
            combatant.broadcast(
                f"{combatant.name} |025further mutilates the corpse of|n {victim.name}|025.|n"
            )
            return

        victim = combatant.getVictim(self.target)
        loop = CombatLoop(combatant.caller, target)
        loop.resolveCommand()

        #TODO: Right now the loop on Disarm and Sunder look almost identical.  I feel like you probably want something different?
        if combatant.hasTurn(
                f"|430You need to wait until it is your turn before you are able to act.|n"
        ):
            if combatant.isArmed(
                    f"|430Before you attack you must equip a weapon using the command equip <weapon>.|n"
            ):
                if not combatant.hasWeakness(
                        f"|400You are too weak to use this attack.|n"):
                    if combatant.hasDisarmsRemaining(
                            f"|400You have 0 disarms remaining or do not have the skill.\nPlease choose another action.|n"
                    ):
                        if not combatant.inventory.hasBow(
                        ) or combatant.hasSniper():
                            if not victim.hasTwoHandedWeapon():
                                if victim.isAlive:
                                    maneuver_difficulty = 2
                                    attack_result = combatant.rollAttack(
                                        maneuver_difficulty)
                                    if attack_result >= victim.av:
                                        # Check for NPC calling the command and pick a new command if so.
                                        # TODO: Spence - Why shouldn't NPCs use Disarm?
                                        if utils.inherits_from(
                                                self.caller, Npc
                                        ) and combatant.isTwoHanded():
                                            self.caller.execute_cmd(
                                                f"strike {target.key}")
                                            return

                                        combatant.decreaseDisarms(1)

                                        shot_location = combatant.determineHitLocation(
                                            victim)

                                        if not victim.resistsAttack():
                                            victim.message(
                                                f"|430You have been disarmed. Your next turn will be skipped.|n"
                                            )
                                            victim.disarm()
                                            combatant.broadcast(
                                                f"{combatant.name} |025nimbly strikes|n (|020{attack_result}|n) |025with a deft maneuver and disarms|n {victim.name} (|400{victim.av}|n)|025, striking them in the {shot_location} and dealing|n (|430{combatant.getDamage()}|n) |025damage|n."
                                            )
                                            victim.takeDamage(
                                                combatant,
                                                combatant.getDamage(),
                                                shot_location)
                                            victim.reportAv()
                                        else:
                                            combatant.broadcast(
                                                f"{combatant.name} |025nimbly strikes|n (|020{attack_result}|n)|025, striking them in the {shot_location} and dealing|n (|430{combatant.getDamage()}|n) |025damage|n. {combatant.name} |025attempts to disarm|n {victim.name}|025, but|n {victim.name} |025Resists the attempt.|n"
                                            )

                                    else:
                                        combatant.broadcast(
                                            f"{combatant.name} |025swings deftly,|n (|020{attack_result}|n) |025attempting to disarm|n {victim.name}|025, but misses|n (|400{victim.av}|n)|025.|n"
                                        )
                                else:
                                    combatant.message(
                                        f"{victim.name} |430is dead. You only further mutilate their body.|n"
                                    )
                                    combatant.broadcast(
                                        f"{combatant.name} |025further mutilates the corpse of|n {victim.name}.|n"
                                    )
                            else:
                                combatant.message(
                                    f"|430You cannot disarm a two-handed weapon. Please try another attack.|n"
                                )
                                combatant.broadcast(
                                    f"{combatant.name} |025tries to disarm|n {victim.name}|025, but cannot disarm a 2-handed weapon!|n"
                                )
                            # Clean up
                            # Set self.caller's combat_turn to 0. Can no longer use combat commands.
                            loop.combatTurnOff(self.caller)
                            loop.cleanup()
                        else:
                            combatant.message(
                                f"|430To use Disarm with a bow equipped you must have the Sniper skill|n"
                            )
Example #3
0
    def func(self):
        combatant = Combatant(self.caller)
        # Check for correct command
        # Target handling

        # Check for correct command
        # Target handling
        if not self.args:
            self.msg("|430Usage: shoot <target>|n")
            return
        elif self.args == self.caller:
            self.msg("|400You can't do that.|n")
            return
        elif combatant.cantFight:
            combatant.message("|400You are too injured to act.|n")
            return
        elif not combatant.inventory.hasArrowsEquipped:
            combatant.message("|430Please equip arrows to use your bow.|n")
            return
        elif not combatant.inventory.hasArrowsLeft:
            combatant.message("|400You are all out of arrows.|n")
            return

        # Check for and error handle designated target
        target = self.caller.search(self.target)

        # Pass all checks now execute command.
        # Use parsed args in combat loop. Handles turn order in combat.
        if not target:
            combatant.message("|430Please designate an appropriate target.|n")
            return

        if not target.db.bleed_points:
            combatant.message(
                f"{victim.name} |400is dead. You only further mutiliate their body.|n"
            )
            combatant.broadcast(
                f"{combatant.name} |025further mutilates the corpse of|n {victim.name}|025.|n"
            )
            return

        victim = combatant.getVictim(self.target)
        loop = CombatLoop(combatant.caller, combatant.target)
        loop.resolveCommand()

        if combatant.hasTurn(
                f"|430You need to wait until it is your turn before you are able to act.|n"
        ):
            if combatant.inventory.hasBow(
                    "|430You need to equip a bow before you are able to shoot, using the command equip <bow name>.|n"
            ):
                if victim.isAlive:
                    bow_penalty = 2
                    bow_damage = 1

                    attack_result = combatant.rollAttack(bow_penalty)
                    shot_location = combatant.determineHitLocation(victim)

                    if attack_result >= victim.av:
                        combatant.inventory.useArrows(1)

                        if not victim.blocksWithShield(shot_location):
                            # Get damage result and damage for weapon type
                            skip_av_damage = True
                            victim.takeDamage(combatant, combatant.getDamage(),
                                              shot_location, skip_av_damage)
                            combatant.broadcast(
                                f"{combatant.name} |025lets loose an arrow|n (|020{attack_result}|n)|025 straight for|n {victim.name}|025's {shot_location} and hits|n (|400{victim.av}|n), |025dealing|n (|430{bow_damage}|n) |025damage!|n"
                            )
                        else:
                            combatant.broadcast(
                                f"{combatant.name} |025lets loose an arrow|n (|020{attack_result}|n)|025 straight for|n {victim.name}'s |025{shot_location} and hits|n (|400{victim.av}|n)|025, but|n {victim.name} |025is able to raise their shield to block!|n"
                            )

                        combatant.message(
                            f"|430You have {combatant.inventory.arrowQuantity} arrows left."
                        )
                        # Clean up
                        # Set self.caller's combat_turn to 0. Can no longer use combat commands.
                        loop.combatTurnOff(self.caller)
                        loop.cleanup()

                else:
                    combatant.message(
                        f"{victim.name} |400is dead. You only further mutiliate their body.|n"
                    )
                    combatant.broadcast(
                        f"{combatant.name} |025further mutilates the corpse of|n {victim.name}|025.|n"
                    )
Example #4
0
    def func(self):
        combatant = Combatant(self.caller)

        # Check for correct command
        # Target handling
        if not self.args:
            self.msg("|430Usage: strike <target>|n")
            return
        elif self.args == self.caller:
            self.msg("|400You can't do that.|n")
            return
        elif combatant.cantFight:
            combatant.message("|400You are too injured to act.|n")
            return

        target = self.caller.search(self.target)

        # Pass all checks now execute command.
        # Use parsed args in combat loop. Handles turn order in combat.
        if not target:
            combatant.message("|430Please designate an appropriate target.|n")
            return

        victim = combatant.getVictim(self.target)

        if not target.db.bleed_points:
            combatant.message(
                f"{victim.name} |400is dead. You only further mutiliate their body.|n"
            )
            combatant.broadcast(
                f"{combatant.name} |025further mutilates the corpse of|n {victim.name}|025.|n"
            )
            return

        loop = CombatLoop(combatant.caller, combatant.target)
        loop.resolveCommand()

        if combatant.hasTurn(
                f"|430You need to wait until it is your turn before you are able to act.|n"
        ):
            if combatant.isArmed(
                    f"|430Before you strike you must equip a melee weapon using the command equip <weapon name>.|n"
            ):
                # Check if damage bonus comes from fayne or master_of_arms
                attack_result = combatant.rollAttack()
                shot_location = combatant.determineHitLocation(victim)

                if attack_result >= victim.av:
                    if not victim.blocksWithShield(shot_location):
                        # Get damage result and damage for weapon type
                        combatant.broadcast(
                            f"{combatant.name} |025strikes deftly|n (|020{attack_result}|n) |025at|n {victim.name} |025and hits|n (|400{victim.av}|n), |025dealing|n (|430{combatant.getDamage()}|n) |025damage!|n"
                        )
                        victim.takeDamage(combatant, combatant.getDamage(),
                                          shot_location)
                        victim.reportAv()
                    else:
                        combatant.broadcast(
                            f"{combatant.name} |025strikes deftly|n (|020{attack_result}|n) |025at|n {victim.name} |025and hits|n (|400{victim.av}|n), |025but|n {victim.name} |025blocks with their shield.|n"
                        )
                else:
                    combatant.broadcast(
                        f"{combatant.name} |025swings wildly|n (|400{attack_result}|n)|025, missing|n {victim.name} (|020{victim.av}|n)|025.|n"
                    )
                # Clean up
                # Set self.caller's combat_turn to 0. Can no longer use combat commands.
                loop.combatTurnOff(self.caller)
                loop.cleanup()