CharacterComponent::CharacterComponent(Entity &entity, MessageIn &msg): 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), mBaseEntity(&entity) { auto *beingComponent = entity.getComponent<BeingComponent>(); const AttributeManager::AttributeScope &attributes = attributeManager->getAttributeScope(CharacterScope); LOG_DEBUG("Character creation: initialisation of " << attributes.size() << " attributes."); for (auto attributeScope : attributes) beingComponent->createAttribute(attributeScope.first, *attributeScope.second); auto *actorComponent = entity.getComponent<ActorComponent>(); actorComponent->setWalkMask(Map::BLOCKMASK_WALL); actorComponent->setBlockType(BLOCKTYPE_CHARACTER); actorComponent->setSize(16); CombatComponent *combatcomponent = new CombatComponent(entity); entity.addComponent(combatcomponent); combatcomponent->getAttacks().attack_added.connect( sigc::mem_fun(this, &CharacterComponent::attackAdded)); combatcomponent->getAttacks().attack_removed.connect( sigc::mem_fun(this, &CharacterComponent::attackRemoved)); // Default knuckle attack int damageBase = beingComponent->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); combatcomponent->addAttack(mKnuckleAttackInfo); // Get character data. mDatabaseID = msg.readInt32(); beingComponent->setName(msg.readString()); CharacterData characterData(&entity, this); deserializeCharacterData(characterData, msg); Inventory(&entity, mPossessions).initialize(); modifiedAllAttributes(entity);; beingComponent->signal_attribute_changed.connect(sigc::mem_fun( this, &CharacterComponent::attributeChanged)); }
void CharacterComponent::markAllInfoAsChanged(Entity &entity) { modifiedAllAbilities(entity); modifiedAllAttributes(entity); markAllQuestsAsModified(); }