2. Enemy

2. The Enemy Class

2.1 Enemy Initialization

The Enemy class functions as hostile opponents for the player to battle and interact with. Enemies can be used as regular hostiles or as bosses (special abilities not available yet). Enemies can be used to deliver loot/key items or just to level up the player. Setting up an enemy goes as follows:

You must supply 5parameters when creating an instance of the enemy class:

  • name

    • Name of the enemy

  • hp

    • The hp amount the enemy will spawn with

  • minatk

    • Enemy's minimum attack damage

  • maxatk

    • Enemy's maximum attack damage

  • drops

    • A list of the possible loot an enemy could drop after death (enter empty list if you don't want drops)

The items in drops list should be class instances of items, armor, weapons, potions, etc.

Create an enemy like this:

zombie = TARBSengine.Enemy("Dave the Zombie", 20, 5, 15, [super_shield, potion])
# An enemy with the name "Dave the Zombie". Has 20 HP
# Has a minimum of 5 attack damage and a maximum of 15
# Has the possibility to drop a super shield or a potion

2.2 Enemy.atk

Enemy.atk(opponent)

Preform a basic attack on the opponent. Attack automatically factors in the extra damage from the current weapon the player is holding. If debugging is enabled, the function outputs the total damage done and how much HP the opponent has left. This function is the same as the Player.atk function, just transferred over to the Enemy class.

Usage:

zombie.atk(player)
## Damage done: 12
## Enemy HP: 8

2.3 Enemy.say

Enemy.say(text)

Outputs text to the screen to be used as dialogue. The output contains the name of the enemy speaking as well as the text that is set in the parameters.

Usage:

zombie.say("I'm going to eat your brains")
## Dave the Zombie: I'm going to eat your brains

Last updated