void Character::flagAttribute(int attr) { // Inform the client of this attribute modification. accountHandler->updateAttributes(getDatabaseID(), attr, getAttribute(attr), getModifiedAttribute(attr)); mModifiedAttributes.insert(attr); }
void CharacterComponent::attributeChanged(Entity *entity, AttributeInfo *attribute) { auto *beingComponent = entity->getComponent<BeingComponent>(); // Inform the client of this attribute modification. accountHandler->updateAttributes(getDatabaseID(), attribute->id, beingComponent->getAttributeBase(attribute), beingComponent->getModifiedAttribute(attribute)); mModifiedAttributes.insert(attribute); }
void ActiveSyncSource::open() { // extract account ID and throw error if missing std::string username = m_context->getSyncUsername(); SE_LOG_DEBUG(NULL, NULL, "using eas sync account %s from config %s", username.c_str(), m_context->getConfigName().c_str()); m_account = username; m_folder = getDatabaseID(); // create handler m_handler.set(eas_sync_handler_new(m_account.c_str()), "EAS handler"); }
void CharacterComponent::attributeChanged(Entity *entity, unsigned attr) { auto *beingComponent = entity->getComponent<BeingComponent>(); // Inform the client of this attribute modification. accountHandler->updateAttributes(getDatabaseID(), attr, beingComponent->getAttributeBase(attr), beingComponent->getModifiedAttribute(attr)); mModifiedAttributes.insert(attr); // Update the knuckle Attack if required if (attr == ATTR_STR && mKnuckleAttackInfo) { // TODO: dehardcode this Damage &knuckleDamage = mKnuckleAttackInfo->getDamage(); knuckleDamage.base = beingComponent->getModifiedAttribute(ATTR_STR); knuckleDamage.delta = knuckleDamage.base / 2; } }
void CharacterComponent::receiveExperience(int skill, int experience, int optimalLevel) { // reduce experience when skill is over optimal level int levelOverOptimum = levelForExp(getExperience(skill)) - optimalLevel; if (optimalLevel && levelOverOptimum > 0) { experience *= EXP_LEVEL_FLEXIBILITY / (levelOverOptimum + EXP_LEVEL_FLEXIBILITY); } // Add exp int oldExp = mExperience[skill]; long int newExp = mExperience[skill] + experience; if (newExp < 0) newExp = 0; // Avoid integer underflow/negative exp. // Check the skill cap long int maxSkillCap = Configuration::getValue("game_maxSkillCap", INT_MAX); assert(maxSkillCap <= INT_MAX); // Avoid integer overflow. if (newExp > maxSkillCap) { newExp = maxSkillCap; if (oldExp != maxSkillCap) { LOG_INFO("Player hit the skill cap"); // TODO: Send a message to player letting them know they hit the cap // or not? } } mExperience[skill] = newExp; mModifiedExperience.insert(skill); // Inform account server if (newExp != oldExp) accountHandler->updateExperience(getDatabaseID(), skill, newExp); mRecalculateLevel = true; }