From 11a6f342e579c26320334b9ae9735701386e3b25 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Tue, 13 Apr 2010 22:48:28 -0600 Subject: Add race support for eAthena The job/class field is used to select the race. If the given race isn't defined, it falls back on the first race (so servers can use jobs/classes without races). Also rename job to subtype for Being and subclasses, and begin support for changing monster and NPC subtypes on the fly (particle effects still need to be reset when they change). Reviewed-by: Bertram --- src/player.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/player.cpp') diff --git a/src/player.cpp b/src/player.cpp index ad8c1db4..9113b4ab 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -43,8 +43,8 @@ #include "utils/stringutils.h" -Player::Player(int id, int job, Map *map, bool isNPC): - Being(id, job, map), +Player::Player(int id, int subtype, Map *map, bool isNPC): + Being(id, subtype, map), mGender(GENDER_UNSPECIFIED), mParty(NULL), mIsGM(false) @@ -58,11 +58,7 @@ Player::Player(int id, int job, Map *map, bool isNPC): mSpriteColors.push_back(""); } - /* Human base sprite. When implementing different races remove this - * line and set the base sprite when setting the race of the player - * character. - */ - setSprite(Net::getCharHandler()->baseSprite(), -100); + setSubtype(subtype); } mShowName = config.getValue("visiblenames", 1); config.addListener("visiblenames", this); @@ -137,6 +133,17 @@ void Player::logic() Being::logic(); } +void Player::setSubtype(Uint16 subtype) +{ + Being::setSubtype(subtype); + + int id = -100 - subtype; + if (ItemDB::exists(id)) // Prevent showing errors when sprite doesn't exist + setSprite(Net::getCharHandler()->baseSprite(), id); + else + setSprite(Net::getCharHandler()->baseSprite(), -100); +} + void Player::setGender(Gender gender) { if (gender != mGender) -- cgit v1.2.3-70-g09d2