void Being::event(Event::Channel channel, const Event &event) { if (channel == Event::ChatChannel && (event.getType() == Event::Being || event.getType() == Event::Player) && event.getInt("permissions") & PlayerRelation::SPEECH_FLOAT) { try { if (mId == event.getInt("beingId")) { setSpeech(event.getString("text")); } } catch (BadEvent badEvent) {} } else if (channel == Event::ConfigChannel && event.getType() == Event::ConfigOptionChanged) { if (getType() == PLAYER && event.getString("option") == "visiblenames") { setShowName(config.getBoolValue("visiblenames")); } } }
NPC::NPC(int id, int job, Map *map): Player(id, job, map, true) { NPCInfo info = NPCDB::get(job); // Setup NPC sprites for (std::list<NPCsprite*>::const_iterator i = info.sprites.begin(); i != info.sprites.end(); i++) { std::string file = "graphics/sprites/" + (*i)->sprite; int variant = (*i)->variant; mSprites.push_back(AnimatedSprite::load(file, variant)); mSpriteIDs.push_back(0); mSpriteColors.push_back(""); } if (mParticleEffects) { //setup particle effects for (std::list<std::string>::const_iterator i = info.particles.begin(); i != info.particles.end(); i++) { Particle *p = particleEngine->addEffect(*i, 0, 0); this->controlParticle(p); } } setShowName(true); }
void Player::optionChanged(const std::string &value) { if (value == "visiblenames") { setShowName(config.getValue("visiblenames", 1)); } }
void LocalPlayer::optionChanged(const std::string &value) { if (value == "showownname") { setShowName(config.getValue("showownname", 1)); } }
NPC::NPC(int id, int subtype, Map *map): Being(id, subtype, map) { setSubtype(subtype); setShowName(true); }
LocalPlayer::LocalPlayer(int id, int job, Map *map): Player(id, job, map), #ifdef EATHENA_SUPPORT mAttackRange(0), #endif mEquipment(new Equipment), mInStorage(false), #ifdef EATHENA_SUPPORT mTargetTime(-1), #endif mLastTarget(-1), mCharacterPoints(0), mCorrectionPoints(0), mLevel(1), mExp(0), mExpNeeded(0), mMp(0), mMaxMp(0), mMoney(0), mTotalWeight(1), mMaxWeight(1), mHp(1), mMaxHp(1), mSkillPoints(0), mTarget(NULL), mPickUpTarget(NULL), mTrading(false), mGoingToTarget(false), mKeepAttacking(false), mLastAction(-1), mWalkingDir(0), mDestX(0), mDestY(0), mInventory(new Inventory(INVENTORY_SIZE)), #ifdef TMWSERV_SUPPORT mLocalWalkTime(-1), #endif mStorage(new Inventory(STORAGE_SIZE)), mMessageTime(0) { // Variable to keep the local player from doing certain actions before a map // is initialized. e.g. drawing a player's name using the TextManager, since // it appears to be dependant upon map coordinates for updating drawing. mMapInitialized = false; mUpdateName = true; mTextColor = &guiPalette->getColor(Palette::PLAYER); mNameColor = &guiPalette->getColor(Palette::SELF); initTargetCursor(); config.addListener("showownname", this); setShowName(config.getValue("showownname", 1)); }
Being::Being(int id, Type type, int subtype, Map *map): ActorSprite(id), mInfo(BeingInfo::Unknown), mActionTime(0), mSpeechTime(0), mAttackSpeed(350), mAction(STAND), mSubType(0xFFFF), mDirection(DOWN), mSpriteDirection(DIRECTION_DOWN), mDispName(0), mShowName(false), mEquippedWeapon(NULL), mText(0), mGender(GENDER_UNSPECIFIED), mParty(NULL), mIsGM(false), mType(type), mSpeedPixelsPerTick(Vector(0.0f, 0.0f, 0.0f)), mDamageTaken(0), mIp(0) { setMap(map); setSubtype(subtype); mSpeechBubble = new SpeechBubble; mMoveSpeed = Net::getPlayerHandler()->getDefaultMoveSpeed(); if (getType() == PLAYER) mShowName = config.getBoolValue("visiblenames"); if (getType() == PLAYER || getType() == NPC) setShowName(true); updateColors(); listen(Event::ConfigChannel); listen(Event::ChatChannel); }