Monster::Monster(MonsterClass *specy): Being(OBJECT_MONSTER), mSpecy(specy), mTargetListener(&monsterTargetEventDispatch), mOwner(NULL), mCurrentAttack(NULL) { LOG_DEBUG("Monster spawned! (id: " << mSpecy->getId() << ")."); setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER); /* * Initialise the attribute structures. */ const AttributeManager::AttributeScope &mobAttr = attributeManager->getAttributeScope(MonsterScope); for (AttributeManager::AttributeScope::const_iterator it = mobAttr.begin(), it_end = mobAttr.end(); it != it_end; ++it) { mAttributes.insert(std::pair< unsigned int, Attribute > (it->first, Attribute(*it->second))); } /* * Set the attributes to the values defined by the associated monster * class with or without mutations as needed. */ int mutation = specy->getMutation(); for (AttributeMap::iterator it2 = mAttributes.begin(), it2_end = mAttributes.end(); it2 != it2_end; ++it2) { double attr = 0.0f; if (specy->hasAttribute(it2->first)) { attr = specy->getAttribute(it2->first); setAttribute(it2->first, mutation ? attr * (100 + (rand()%(mutation << 1)) - mutation) / 100.0 : attr); } } setSize(specy->getSize()); setGender(specy->getGender()); // Set positions relative to target from which the monster can attack int dist = specy->getAttackDistance(); mAttackPositions.push_back(AttackPosition(dist, 0, LEFT)); mAttackPositions.push_back(AttackPosition(-dist, 0, RIGHT)); mAttackPositions.push_back(AttackPosition(0, -dist, DOWN)); mAttackPositions.push_back(AttackPosition(0, dist, UP)); // Load default script loadScript(specy->getScript()); }
Character::Character(MessageIn &msg): Being(OBJECT_CHARACTER), mClient(NULL), mConnected(true), mTransactionHandler(NULL), mSpecialUpdateNeeded(false), mDatabaseID(-1), mHairStyle(0), mHairColor(0), mLevel(1), mLevelProgress(0), mUpdateLevelProgress(false), mRecalculateLevel(true), mParty(0), mTransaction(TRANS_NONE), mTalkNpcId(0), mNpcThread(0), mKnuckleAttackInfo(0) { const AttributeManager::AttributeScope &attr = attributeManager->getAttributeScope(CharacterScope); LOG_DEBUG("Character creation: initialisation of " << attr.size() << " attributes."); for (AttributeManager::AttributeScope::const_iterator it1 = attr.begin(), it1_end = attr.end(); it1 != it1_end; ++it1) mAttributes.insert(std::make_pair(it1->first, Attribute(*it1->second))); setWalkMask(Map::BLOCKMASK_WALL); setBlockType(BLOCKTYPE_CHARACTER); // Get character data. mDatabaseID = msg.readInt32(); setName(msg.readString()); deserializeCharacterData(*this, msg); mOld = getPosition(); Inventory(this).initialize(); modifiedAllAttribute(); setSize(16); // Default knuckle attack int damageBase = this->getModifiedAttribute(ATTR_STR); int damageDelta = damageBase / 2; Damage knuckleDamage; knuckleDamage.skill = skillManager->getDefaultSkillId(); knuckleDamage.base = damageBase; knuckleDamage.delta = damageDelta; knuckleDamage.cth = 2; knuckleDamage.element = ELEMENT_NEUTRAL; knuckleDamage.type = DAMAGE_PHYSICAL; knuckleDamage.range = DEFAULT_TILE_LENGTH; mKnuckleAttackInfo = new AttackInfo(0, knuckleDamage, 7, 3, 0); addAttack(mKnuckleAttackInfo); }
Character::Character(MessageIn &msg): Being(OBJECT_CHARACTER), mClient(NULL), mConnected(true), mTransactionHandler(NULL), mSpecialUpdateNeeded(false), mDatabaseID(-1), mHairStyle(0), mHairColor(0), mLevel(1), mLevelProgress(0), mUpdateLevelProgress(false), mRecalculateLevel(true), mParty(0), mTransaction(TRANS_NONE), mTalkNpcId(0), mNpcThread(0) { const AttributeManager::AttributeScope &attr = attributeManager->getAttributeScope(CharacterScope); LOG_DEBUG("Character creation: initialisation of " << attr.size() << " attributes."); for (AttributeManager::AttributeScope::const_iterator it1 = attr.begin(), it1_end = attr.end(); it1 != it1_end; ++it1) mAttributes.insert(std::make_pair(it1->first, Attribute(*it1->second))); setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_MONSTER); // Get character data. mDatabaseID = msg.readInt32(); setName(msg.readString()); deserializeCharacterData(*this, msg); mOld = getPosition(); Inventory(this).initialize(); modifiedAllAttribute(); setSize(16); }