#include <character.h>
Public Member Functions | |
Character () | |
Character (std::vector< int > _stats, int _x, int _y, Tile _sprite, MiscType _corpse, int _chunk_x, int _chunk_y, int _depth, int _morality, int _speed) | |
Character (int _x, int _y, int _chunk_x, int _chunk_y, int _depth) | |
void | act (long ms) |
bool | is_alive () const |
void | take_damage (int damage) |
void | attack (Character *_chara) |
int | did_hit (Character *_chara) |
int | damage_dealt (Character *_chara) |
std::vector< Item * > * | get_inventory () |
std::vector< Item * > * | get_equipment () |
void | add_item (Item *new_item) |
void | drop_item (Item *item) |
void | drop_item (int item) |
void | destroy_item (Item *item) |
void | equip_item (Item *item) |
void | remove_item (int item) |
void | remove_all () |
int | get_x () |
int | get_y () |
IntPoint | get_coords () |
IntPoint | get_chunk () |
int | get_chunk_x () |
int | get_chunk_y () |
Tile | get_char () |
Item * | get_corpse () |
int | get_depth () |
Character * | get_target () |
int | get_max_hp () |
int | get_cur_hp () |
int | get_moral () |
int | get_armor_hit (int body_part, int type) |
float | get_armor_dam (int body_part, int type) |
void | set_x (int _x) |
void | set_y (int _y) |
void | set_chunk (IntPoint _chunk) |
void | set_chunk_x (int _chunk_x) |
void | set_chunk_y (int _chunk_y) |
void | set_depth (int) |
void | set_target (Character *_target) |
void | consume_item (Item *item) |
int | get_stat (int) |
void | set_stat (int stat, int amount) |
int | get_current_stat (int) |
void | set_current_stat (int stat, int amount) |
void | regain_consciousness () |
void | pass_out () |
bool | is_conscious () |
void | reduce_endurance (int factor) |
void | gain_endurance (int factor) |
bool | can_act () |
Protected Attributes | |
int | moral |
std::vector< int > | stats |
std::vector< int > | current_stats |
int | x |
int | y |
std::vector< Item * > | inventory |
std::vector< Item * > | equipment |
int | inventory_size |
Tile | sprite |
Item * | corpse |
int | depth |
IntPoint | chunk |
Character * | target |
bool | conscious |
long | timer |
int | speed |
A class which is used to construct all characters in game. This is the class that acts as the base for all enemies, NPCs, the main character, and anything else that may be considered an enemy in the game.
Character::Character | ( | ) |
The default constructor.
Character::Character | ( | std::vector< int > | _stats, |
int | _x, | ||
int | _y, | ||
Tile | _sprite, | ||
MiscType | _corpse, | ||
int | _chunk_x, | ||
int | _chunk_y, | ||
int | _depth, | ||
int | _morality, | ||
int | _speed | ||
) |
The constructor for the character class. This is the constructor which is used to construct the enemy and main character derived classes.
_stats | The stats to give the character. |
_sprite | The sprite of the character. |
_corpse | The corpse to be crated from the MiscType. |
_morality | The morality to give the character. |
_x | The x value to give the character. |
_y | The y value to give to the character. |
_chunk_x | The x coordinate of the chunk to place the character. |
_chunk_y | The y coordinate of the chunk to place the character. |
_depth | The depth in the chunk to place the charcter. |
Character::Character | ( | int | _x, |
int | _y, | ||
int | _chunk_x, | ||
int | _chunk_y, | ||
int | _depth | ||
) |
The constructor for the character class. This is the constructor which is used to construct the enemy and main character derived classes.
_x | The x value to give the character. |
_y | The y value to give to the character. |
_chunk_x | The x coordinate of the chunk to place the character. |
_chunk_y | The y coordinate of the chunk to place the character. |
_depth | The depth in the chunk to place the charcter. |
void Character::act | ( | long | ms | ) |
Run the actions that happen to the character every frame.
void Character::add_item | ( | Item * | new_item | ) |
Add an item to the character's inventory.
new_item | The item to place in the character's inventory. |
void Character::attack | ( | Character * | _chara | ) |
Reduces a given character's health by a certain amount. Damages another character by calling take_damage() on that character.
bool Character::can_act | ( | ) |
Checks to see if the character is good to act!
void Character::consume_item | ( | Item * | item | ) |
Consume an item based on the stats of that item. Checks to see if the item is consumable. If so, alter the appropriate stats based on the item's attributes.
item | The item to consume. |
int Character::damage_dealt | ( | Character * | _chara | ) |
Determines the amount of damage done by the attack. _chara The character being attacked.
void Character::destroy_item | ( | Item * | item | ) |
Remove an item from the inventory and destroy the reference to it. This function IS memory safe, and will remove the pointer to the item. This means that there should no longer be ANY references to this object upon calling this function. If the item is not found in the inventory, nothing will happen.
item | The item to destroy. |
int Character::did_hit | ( | Character * | _chara | ) |
Determines whether or not the attack hit the character. _chara The character being attacked.
void Character::drop_item | ( | Item * | item | ) |
Remove an item from the character's inventory. This function is NOT memory safe, and only remove's the pointer to the item, it does not delete the item. The item should always be asisgned somewhere else (in the case of this function, it should be in the chunk). If the item passed in is not in the inventory, nothing will happen.
item | The item to remove from the inventory. |
void Character::drop_item | ( | int | item | ) |
Remove an item from the character's inventory by index. Behaves the same as add_item(Item* new_item)
void Character::equip_item | ( | Item * | item | ) |
Moves an item from the inventory to the equipment. Checks if it is possible to equip or wield the item. If so, it checks the equipment slot that item should go into and places it in that slot. If an item is already equipped, it will remove it from the equipment. The armor or attack is updated based on the item's stats.
item | THe item which will be equipped. |
void Character::gain_endurance | ( | int | factor | ) |
Gains endurance based on the factor.
float Character::get_armor_dam | ( | int | body_part, |
int | type | ||
) |
Public accessor for the armor. Gets the damage reduction of the armor.
int Character::get_armor_hit | ( | int | body_part, |
int | type | ||
) |
Public accessor for the armor. Gets the hit resistance value of the armor.
Tile Character::get_char | ( | ) |
IntPoint Character::get_chunk | ( | ) |
int Character::get_chunk_x | ( | ) |
int Character::get_chunk_y | ( | ) |
IntPoint Character::get_coords | ( | ) |
Public accessor or the coordinates.
Item * Character::get_corpse | ( | ) |
int Character::get_cur_hp | ( | ) |
Public accessor for the current health. Current health corresponds to current_stats[HEALTH].
int Character::get_current_stat | ( | int | stat | ) |
Public getter for accessing a stat value.
stat | The index value of the stat to access. |
int Character::get_depth | ( | ) |
vector< Item * > * Character::get_equipment | ( | ) |
Public access function for the character's equipment.
vector< Item * > * Character::get_inventory | ( | ) |
Public access function for the character's inventory.
int Character::get_max_hp | ( | ) |
Public accessor for the max health. Max health corresponds to stats[HEALTH].
int Character::get_moral | ( | ) |
int Character::get_stat | ( | int | stat | ) |
Public getter for accessing a current stat value.
stat | The index value of the stat to access. |
Character * Character::get_target | ( | ) |
int Character::get_x | ( | ) |
int Character::get_y | ( | ) |
bool Character::is_alive | ( | ) | const |
A check to see whether or not the character is alive.
bool Character::is_conscious | ( | ) |
Returns whether or not the character is conscious.
void Character::pass_out | ( | ) |
Sets conscious to false.
void Character::reduce_endurance | ( | int | factor | ) |
Reduces the current endurance of the character by a factor. The amount passed in indicates what factor the endurance should be reduced by (e.g. walking reduces the endurance by 1, which will be multiplied by something to reduce endurance).
void Character::regain_consciousness | ( | ) |
Sets conscious to true.
void Character::remove_all | ( | ) |
Removes all equipment.
void Character::remove_item | ( | int | item | ) |
Removes an item from the equipment by index. If there is an item equipped, it will remove it.
item | The index of the item to be removed. |
void Character::set_chunk | ( | IntPoint | _chunk | ) |
void Character::set_chunk_x | ( | int | _chunk_x | ) |
Public setter for the x component of chunk.
_chunk_x | New x component of the chunk. |
void Character::set_chunk_y | ( | int | _chunk_y | ) |
Public setter for the y component of chunk.
_chunk_y | New y component of the chunk. |
void Character::set_current_stat | ( | int | stat, |
int | amount | ||
) |
Public setter for setting a stat value.
stat | The index value of the stat to set. |
amount | The value the stat should be set to. |
void Character::set_depth | ( | int | d | ) |
void Character::set_stat | ( | int | stat, |
int | amount | ||
) |
Public setter for setting a current stat value.
stat | The index value of the stat to set. |
amount | The value the stat should be set to. |
void Character::set_target | ( | Character * | _target | ) |
void Character::set_x | ( | int | _x | ) |
void Character::set_y | ( | int | _y | ) |
void Character::take_damage | ( | int | damage | ) |
Reduces the character's current health by a given amount.
damage | The amount to reduce the character's health by. |
|
protected |
An IntPoint object of the character's coordinates in the chunk_map.
|
protected |
Whether or not the character is conscious.
|
protected |
An item representing the body of the character. An item that is completely separate from the inventory that is droppped onto the map upon the death of the character. Because it will always be moved to the chunk object before destructing the character, it does not need to be deleted by the character.
|
protected |
A vector representing the current stats of a character. Whenever one of the player's stats temporarily changes, as in a lowering or raising of health, or lowering or raising of another stat, it will be held in this vector.
|
protected |
The depth the character is in the chunk.
|
protected |
A vector representing the character's equipment. This will be "statically" sized, and certain indices represent certain item slots, e.g. head
|
protected |
A vector representing the character's current inventory.
|
protected |
An integer representing the maximum size of a characters inventory.
|
protected |
A protected spectrum ranging from 0-5. Morality acts as the basis for whether or not characters will attack each other, i.e. characters with 0 will attack characters with 5.
|
protected |
How quickly the character moves. Represents the threshold for how many milliseconds must pass before the character can act.
|
protected |
How the character will appear in the game.
|
protected |
A vector representation of the stats of a character. All of the stats of a character (health, armor, strength, etc. will be held in this vector.
|
protected |
What the character is currently focused on. For the main character, this will primarily be to display information about the enemy or NPC that they are focused on. For non-players characters (both enemies and NPCs, this will act as a continuous representation of their focus.
|
protected |
The current timer of the character.
|
protected |
The character's coordinate in the x direction.
|
protected |
The character's coordinates in the y direction.