ManaPlus
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
ActorSprite Class Reference

#include <actorsprite.h>

Inheritance diagram for ActorSprite:
CompoundSprite Actor Sprite Being FloorItem LocalPlayer

Public Member Functions

 ActorSprite (const BeingId id)
 
 ~ActorSprite ()
 
BeingId getId () const
 
void setId (const BeingId id)
 
virtual ActorTypeT getType () const
 
virtual void logic ()
 
void setMap (Map *const map)
 
virtual BlockTypeT getBlockType () const
 
void controlAutoParticle (Particle *const particle)
 
void controlCustomParticle (Particle *const particle)
 
virtual TargetCursorSizeT getTargetCursorSize () const
 
virtual int getTargetOffsetX () const
 
virtual int getTargetOffsetY () const
 
void setTargetType (const TargetCursorTypeT type)
 
void untarget ()
 
void setStatusEffect (const int32_t index, const Enable active, const IsStart start)
 
void setStatusEffectOpitons (const uint32_t option, const uint32_t opt1, const uint32_t opt2, const uint32_t opt3)
 
void setStatusEffectOpitons (const uint32_t option, const uint32_t opt1, const uint32_t opt2)
 
void setStatusEffectOpiton0 (const uint32_t option)
 
void setAlpha (const float alpha)
 
float getAlpha () const
 
int getWidth () const
 
int getHeight () const
 
void addActorSpriteListener (ActorSpriteListener *const listener)
 
void removeActorSpriteListener (ActorSpriteListener *const listener)
 
int getActorX () const
 
int getActorY () const
 
void setPoison (const bool b)
 
bool getPoison () const
 
void setHaveCart (const bool b)
 
bool getHaveCart () const
 
virtual void setRiding (const bool b)
 
virtual void setTrickDead (const bool b)
 
bool isTrickDead () const
 
const std::set< int32_t > & getStatusEffects () const
 
std::string getStatusEffectsString () const
 
virtual void stopCast (const bool b)
 
size_t getParticlesCount () const
 
void controlParticleDeleted (const Particle *const particle)
 
- Public Member Functions inherited from CompoundSprite
 CompoundSprite ()
 
 ~CompoundSprite ()
 
bool reset ()
 
bool play (const std::string &action)
 
bool update (const int time)
 
void drawSimple (Graphics *const graphics, const int posX, const int posY) const
 
int getWidth () const
 
int getHeight () const
 
const ImagegetImage () const
 
bool setSpriteDirection (const SpriteDirection::Type direction)
 
int getNumberOfLayers () const
 
unsigned int getCurrentFrame () const
 
unsigned int getFrameCount () const
 
void addSprite (Sprite *const sprite)
 
void setSprite (const size_t layer, Sprite *const sprite)
 
void removeSprite (const int layer)
 
void clear ()
 
void ensureSize (const size_t layerCount)
 
void drawSprites (Graphics *const graphics, const int posX, const int posY) const
 
virtual void drawSpritesSDL (Graphics *const graphics, const int posX, const int posY) const
 
void setAlpha (float alpha)
 
bool updateNumber (const unsigned num)
 
int getLastTime () const
 
int getStartTime () const
 
- Public Member Functions inherited from Sprite
virtual ~Sprite ()
 
virtual void draw (Graphics *const graphics, const int posX, const int posY) const =0
 
virtual const void * getHash () const
 
virtual const void * getHash2 () const
 
- Public Member Functions inherited from Actor
virtual ~Actor ()
 
virtual void draw (Graphics *const graphics, const int offsetX, const int offsetY) const =0
 
const VectorgetPixelPositionF () const
 
virtual void setPixelPositionF (const Vector &pos)
 
int getPixelX () const
 
virtual int getPixelY () const
 
virtual int getSortPixelY () const
 
virtual int getTileX () const
 
virtual int getTileY () const
 
virtual int getNumberOfLayers () const
 
const MapgetMap () const
 

Static Public Member Functions

static void load ()
 
static void unload ()
 
- Static Public Member Functions inherited from CompoundSprite
static void setEnableDelay (bool b)
 

Protected Types

typedef std::list< ActorSpriteListener * > ActorSpriteListeners
 
typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator
 
- Protected Types inherited from CompoundSprite
typedef std::list< CompoundItem * > ImagesCache
 

Protected Member Functions

virtual void updateStatusEffect (const int32_t index, const Enable newStatus, const IsStart start)
 
virtual void handleStatusEffect (const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
 
void setupSpriteDisplay (const SpriteDisplay &display, const ForceDisplay forceDisplay, const DisplayTypeT displayType, const std::string &color)
 
- Protected Member Functions inherited from CompoundSprite
void redraw () const
 
void updateImages () const
 
bool updateFromCache () const
 
void initCurrentCacheItem () const
 
- Protected Member Functions inherited from Sprite
 Sprite ()
 
- Protected Member Functions inherited from Actor
 Actor ()
 

Static Protected Member Functions

static void initTargetCursor ()
 
static void cleanupTargetCursors ()
 

Protected Attributes

std::set< int32_t > mStatusEffects
 
ParticleVector mStatusParticleEffects
 
ParticleList mChildParticleEffects
 
int mHorseId
 
BeingId mId
 
AnimatedSpritemUsedTargetCursor
 
ActorSpriteListeners mActorSpriteListeners
 
int mCursorPaddingX
 
int mCursorPaddingY
 
bool mMustResetParticles
 
bool mPoison
 
bool mHaveCart
 
bool mTrickDead
 
- Protected Attributes inherited from CompoundSprite
ImagesCache imagesCache
 
CompoundItemmCacheItem
 
ImagemImage
 
ImagemAlphaImage
 
int mOffsetX
 
int mOffsetY
 
int mStartTime
 
int mLastTime
 
int mNextRedrawTime
 
bool mNeedsRedraw
 
bool mEnableAlphaFix
 
bool mDisableAdvBeingCaching
 
bool mDisableBeingCaching
 
- Protected Attributes inherited from Sprite
float mAlpha
 
- Protected Attributes inherited from Actor
MapmMap
 
Vector mPos
 
int mYDiff
 

Static Protected Attributes

static AnimatedSpritetargetCursor [static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
 
static bool loaded = false
 
- Static Protected Attributes inherited from CompoundSprite
static bool mEnableDelay = true
 

Additional Inherited Members

- Public Types inherited from CompoundSprite
typedef std::vector< Sprite * >::iterator SpriteIterator
 
typedef std::vector< Sprite * >::const_iterator SpriteConstIterator
 
- Data Fields inherited from CompoundSprite
std::vector< Sprite * > mSprites
 
- Data Fields inherited from Actor
int mPixelX
 
int mPixelY
 

Detailed Description

Definition at line 54 of file actorsprite.h.

Member Typedef Documentation

◆ ActorSpriteListenerIterator

typedef ActorSpriteListeners::iterator ActorSprite::ActorSpriteListenerIterator
protected

Definition at line 252 of file actorsprite.h.

◆ ActorSpriteListeners

Definition at line 251 of file actorsprite.h.

Constructor & Destructor Documentation

◆ ActorSprite()

ActorSprite::ActorSprite ( const BeingId  id)
explicit

Definition at line 68 of file actorsprite.cpp.

68  :
70  Actor(),
72  mStatusParticleEffects(nullptr, true),
74  mHorseId(0),
75  mId(id),
76  mUsedTargetCursor(nullptr),
78  mCursorPaddingX(0),
79  mCursorPaddingY(0),
80  mMustResetParticles(false),
81  mPoison(false),
82  mHaveCart(false),
83  mTrickDead(false)
84 {
85 }
ParticleVector mStatusParticleEffects
Definition: actorsprite.h:243
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:241
int mCursorPaddingX
Definition: actorsprite.h:255
bool mMustResetParticles
Definition: actorsprite.h:259
bool mTrickDead
Definition: actorsprite.h:262
Actor()
Definition: actor.cpp:28
AnimatedSprite * mUsedTargetCursor
Definition: actorsprite.h:249
int mCursorPaddingY
Definition: actorsprite.h:256
ActorSpriteListeners mActorSpriteListeners
Definition: actorsprite.h:253
bool mHaveCart
Definition: actorsprite.h:261
BeingId mId
Definition: actorsprite.h:246

◆ ~ActorSprite()

ActorSprite::~ActorSprite ( )

Definition at line 87 of file actorsprite.cpp.

References ParticleContainer::clear(), FOR_EACH, LocalPlayer::getTarget(), localPlayer, mActorSpriteListeners, mChildParticleEffects, mMustResetParticles, mUsedTargetCursor, reportFalse, and LocalPlayer::setTarget().

88 {
90  mMustResetParticles = true;
91 
92  mUsedTargetCursor = nullptr;
93 
94  if (localPlayer != nullptr &&
95  localPlayer != this &&
96  localPlayer->getTarget() == this)
97  {
98  localPlayer->setTarget(nullptr);
99  }
100 
101  // Notify listeners of the destruction.
103  {
104  if (reportFalse(*iter))
105  (*iter)->actorSpriteDestroyed(*this);
106  }
107 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
ActorSpriteListeners::iterator ActorSpriteListenerIterator
Definition: actorsprite.h:252
#define reportFalse(val)
Definition: checkutils.h:250
bool mMustResetParticles
Definition: actorsprite.h:259
AnimatedSprite * mUsedTargetCursor
Definition: actorsprite.h:249
LocalPlayer * localPlayer
ActorSpriteListeners mActorSpriteListeners
Definition: actorsprite.h:253
void setTarget(Being *const target)
Being * getTarget() const

Member Function Documentation

◆ addActorSpriteListener()

void ActorSprite::addActorSpriteListener ( ActorSpriteListener *const  listener)

Add an ActorSprite listener.

Definition at line 453 of file actorsprite.cpp.

References mActorSpriteListeners.

Referenced by getHeight().

454 {
455  mActorSpriteListeners.push_front(listener);
456 }
ActorSpriteListeners mActorSpriteListeners
Definition: actorsprite.h:253

◆ cleanupTargetCursors()

void ActorSprite::cleanupTargetCursors ( )
staticprotected

Remove the target cursors from memory

Definition at line 510 of file actorsprite.cpp.

References delete2, end_foreach, for_each_cursors, ServerCommandType::size, and targetCursor.

Referenced by getParticlesCount(), and unload().

511 {
513  {
514  delete2(targetCursor[type][size])
515  }
517 }
static AnimatedSprite * targetCursor[static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
Definition: actorsprite.h:236
#define delete2(var)
Definition: delete2.h:24
#define end_foreach
Definition: actorsprite.cpp:61
#define for_each_cursors()
Definition: actorsprite.cpp:52

◆ controlAutoParticle()

void ActorSprite::controlAutoParticle ( Particle *const  particle)

Take control of a particle. Particle can be auto deleted.

Definition at line 147 of file actorsprite.cpp.

References ParticleList::addLocally(), mChildParticleEffects, mId, and Particle::setActor().

Referenced by getBlockType(), setupSpriteDisplay(), and EffectManager::trigger().

148 {
149  if (particle != nullptr)
150  {
151  particle->setActor(mId);
153  }
154 }
void addLocally(Particle *const particle)
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
void setActor(const BeingId actor)
Definition: particle.h:243
BeingId mId
Definition: actorsprite.h:246

◆ controlCustomParticle()

void ActorSprite::controlCustomParticle ( Particle *const  particle)

Take control of a particle. Owner must remove particle by self.

Definition at line 156 of file actorsprite.cpp.

References ParticleList::addLocally(), Particle::disableAutoDelete(), and mChildParticleEffects.

Referenced by Being::addItemParticles(), Being::addItemParticlesCards(), getBlockType(), Being::recreateItemParticles(), LocalPlayer::setTestParticle(), and EffectManager::triggerReturn().

157 {
158  if (particle != nullptr)
159  {
160  // The effect may not die without the beings permission or we segfault
161  particle->disableAutoDelete();
163  }
164 }
void addLocally(Particle *const particle)
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
void disableAutoDelete()
Definition: particle.h:226

◆ controlParticleDeleted()

void ActorSprite::controlParticleDeleted ( const Particle *const  particle)

Definition at line 166 of file actorsprite.cpp.

References mChildParticleEffects, and ParticleList::removeLocally().

Referenced by getParticlesCount(), and Particle::~Particle().

167 {
168  if (particle != nullptr)
170 }
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
void removeLocally(const Particle *const particle)

◆ getActorX()

int ActorSprite::getActorX ( ) const
inline

Definition at line 159 of file actorsprite.h.

References Actor::getPixelX(), and mapTileSize.

Referenced by FloorItem::draw().

160  { return getPixelX() - mapTileSize / 2; }
int getPixelX() const
Definition: actor.h:86
static const int mapTileSize
Definition: map.h:26

◆ getActorY()

int ActorSprite::getActorY ( ) const
inline

Definition at line 162 of file actorsprite.h.

References Actor::getPixelY(), and mapTileSize.

Referenced by FloorItem::draw().

163  { return getPixelY() - mapTileSize; }
virtual int getPixelY() const
Definition: actor.h:92
static const int mapTileSize
Definition: map.h:26

◆ getAlpha()

float ActorSprite::getAlpha ( ) const
inlinevirtual

Returns the current alpha value used to draw the actor.

Implements Actor.

Definition at line 136 of file actorsprite.h.

References Sprite::getAlpha().

137  { return CompoundSprite::getAlpha(); }
virtual float getAlpha() const
Definition: sprite.h:102

◆ getBlockType()

virtual BlockTypeT ActorSprite::getBlockType ( ) const
inlinevirtual

Gets the way the object blocks pathfinding for other objects

Reimplemented in Being.

Definition at line 82 of file actorsprite.h.

References controlAutoParticle(), controlCustomParticle(), and BlockType::NONE.

83  { return BlockType::NONE; }

◆ getHaveCart()

bool ActorSprite::getHaveCart ( ) const
inline

Definition at line 174 of file actorsprite.h.

References mHaveCart.

Referenced by Actions::showHideWindow(), and ShopWindow::updateButtonsAndLabels().

175  { return mHaveCart; }
bool mHaveCart
Definition: actorsprite.h:261

◆ getHeight()

int ActorSprite::getHeight ( ) const
inlinevirtual

Returns the vertical size of the actors graphical representation in pixels or 0 when it is undefined.

Reimplemented from Actor.

Reimplemented in Being.

Definition at line 142 of file actorsprite.h.

References addActorSpriteListener(), CompoundSprite::getHeight(), anonymous_namespace{itemlinkhandler.cpp}::listener, load(), removeActorSpriteListener(), and unload().

143  { return CompoundSprite::getHeight(); }
int getHeight() const

◆ getId()

BeingId ActorSprite::getId ( ) const
inline

Definition at line 63 of file actorsprite.h.

References mId.

Referenced by CharSelectDialog::action(), Being::addToCache(), EAthena::FamilyHandler::askForChild(), LocalPlayer::attack(), Being::botLogic(), EAthena::VendingHandler::buy(), EAthena::NpcHandler::buy(), TmwAthena::NpcHandler::buy(), EAthena::VendingHandler::buy2(), EAthena::VendingHandler::buyItems(), EAthena::PetHandler::catchPet(), EAthena::PartyHandler::changeLeader(), Actions::changeRelation(), ActorManager::clear(), ActorManager::cloneBeing(), EAthena::GameHandler::connect(), TmwAthena::GameHandler::connect(), ActorManager::createBeing(), ActorManager::createItem(), TmwAthena::CharServerHandler::deleteCharacter(), EAthena::CharServerHandler::deleteCharacter(), Actions::doSit(), ActorManager::erase(), ActorManager::findActor(), ActorManager::findBeing(), ActorManager::findItem(), PopupMenu::handleLink(), EAthena::PartyHandler::invite(), TmwAthena::PartyHandler::invite(), EAthena::GuildHandler::invite(), TmwAthena::PartyHandler::inviteResponse(), EAthena::PartyHandler::kick(), TmwAthena::PartyHandler::kick(), EAthena::GuildHandler::leave(), TargetDebugTab::logic(), ActorManager::logic(), EAthena::AdminHandler::mute(), EAthena::VendingHandler::open(), EAthena::BuyingStoreHandler::open(), FindBeingEqualFunctor::operator()(), SpellManager::parseCommand(), EAthena::PlayerHandler::pickUp(), TmwAthena::PlayerHandler::pickUp(), LocalPlayer::pingRequest(), ActorManager::printBeingsToChat(), EAthena::BeingRecv::processBeingChangeLookCards(), TmwAthena::BeingRecv::processBeingMove(), TmwAthena::BeingRecv::processBeingVisible(), EAthena::BuyingStoreRecv::processBuyingStoreItemsList(), EAthena::ChatRecv::processChatRoomCreateAck(), EAthena::MercenaryRecv::processMercenaryInfo(), Ea::BeingRecv::processNameResponse(), EAthena::BeingRecv::processNameResponse2(), Ea::PartyRecv::processPartyLeave(), EAthena::PlayerRecv::processPlayerGetExp(), EAthena::PlayerRecv::processPlayerGetExp2(), EAthena::BeingRecv::processPlayerGuilPartyInfo(), EAthena::BeingRecv::processPlayerGuilPartyInfo2(), EAthena::PlayerRecv::processPlayerHeal(), Ea::BeingRecv::processPlayerStop(), TmwAthena::TradeHandler::request(), EAthena::TradeHandler::request(), EAthena::GuildHandler::requestAlliance(), EAthena::AdminHandler::requestLogin(), EAthena::GuildHandler::requestOpposition(), EAthena::BuyingStoreHandler::sell(), CharSelectDialog::setName(), PlayerInfo::setPetBeing(), ActorManager::setPlayer(), EAthena::PlayerHandler::setStat(), TmwAthena::PlayerHandler::setStat(), BeingPopup::show(), PopupMenu::showChatPopup(), PopupMenu::showPopup(), PopupMenu::showUndressPopup(), EAthena::NpcHandler::talk(), TmwAthena::NpcHandler::talk(), EAthena::AdminHandler::unequipAll(), Being::updateFromCache(), SkillDialog::useSkillDefault(), SkillDialog::useSkillPosition(), SkillDialog::useSkillTarget(), and EAthena::BeingHandler::viewPlayerEquipment().

64  { return mId; }
BeingId mId
Definition: actorsprite.h:246

◆ getParticlesCount()

size_t ActorSprite::getParticlesCount ( ) const
inline

◆ getPoison()

bool ActorSprite::getPoison ( ) const
inline

Definition at line 168 of file actorsprite.h.

References mPoison.

Referenced by SocialPlayersTab::updateAvatar().

169  { return mPoison; }

◆ getStatusEffects()

const std::set<int32_t>& ActorSprite::getStatusEffects ( ) const
inline

Definition at line 186 of file actorsprite.h.

References getStatusEffectsString(), and mStatusEffects.

187  { return mStatusEffects; }
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:241

◆ getStatusEffectsString()

std::string ActorSprite::getStatusEffectsString ( ) const

Definition at line 519 of file actorsprite.cpp.

References ServerCommandType::effect, Enable_true, FOR_EACH, StatusEffectDB::getStatusEffect(), StatusEffect::mName, and mStatusEffects.

Referenced by getStatusEffects(), TargetDebugTab::logic(), and BeingPopup::show().

520 {
521  std::string effectsStr;
522  if (!mStatusEffects.empty())
523  {
524  FOR_EACH (std::set<int32_t>::const_iterator, it, mStatusEffects)
525  {
526  const StatusEffect *const effect =
528  *it,
529  Enable_true);
530  if (effect == nullptr)
531  continue;
532  if (!effectsStr.empty())
533  effectsStr.append(", ");
534  effectsStr.append(effect->mName);
535  }
536  }
537  return effectsStr;
538 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:241
std::string mName
Definition: statuseffect.h:82
const bool Enable_true
Definition: enable.h:29
StatusEffect * getStatusEffect(const int index, const Enable enabling)

◆ getTargetCursorSize()

virtual TargetCursorSizeT ActorSprite::getTargetCursorSize ( ) const
inlinevirtual

Returns the required size of a target cursor for this being.

Reimplemented in Being.

Definition at line 98 of file actorsprite.h.

References TargetCursorSize::MEDIUM.

Referenced by setTargetType().

◆ getTargetOffsetX()

virtual int ActorSprite::getTargetOffsetX ( ) const
inlinevirtual

Reimplemented in Being.

Definition at line 101 of file actorsprite.h.

102  { return 0; }

◆ getTargetOffsetY()

virtual int ActorSprite::getTargetOffsetY ( ) const
inlinevirtual

Reimplemented in Being.

Definition at line 104 of file actorsprite.h.

References setTargetType().

105  { return 0; }

◆ getType()

virtual ActorTypeT ActorSprite::getType ( ) const
inlinevirtual

◆ getWidth()

int ActorSprite::getWidth ( ) const
inlinevirtual

Returns the horizontal size of the actors graphical representation in pixels or 0 when it is undefined.

Reimplemented from Actor.

Reimplemented in Being.

Definition at line 139 of file actorsprite.h.

References CompoundSprite::getWidth().

140  { return CompoundSprite::getWidth(); }
int getWidth() const

◆ handleStatusEffect()

void ActorSprite::handleStatusEffect ( const StatusEffect *const  effect,
const int32_t  effectId,
const Enable  newStatus,
const IsStart  start 
)
protectedvirtual

Handle an update to a status or stun effect

Parameters
TheStatusEffect to effect
effectId-1 for stun, otherwise the effect index

Reimplemented in LocalPlayer.

Definition at line 337 of file actorsprite.cpp.

References ParticleVector::delLocally(), Enable_true, StatusEffect::getParticle(), StatusEffect::getStartParticle(), IsStart_true, mStatusParticleEffects, and ParticleVector::setLocally().

Referenced by getParticlesCount(), LocalPlayer::handleStatusEffect(), and updateStatusEffect().

341 {
342  if (effect == nullptr)
343  return;
344 
345  if (newStatus == Enable_true)
346  {
347  if (effectId >= 0)
348  {
349  Particle *particle = nullptr;
350  if (start == IsStart_true)
351  particle = effect->getStartParticle();
352  if (particle == nullptr)
353  particle = effect->getParticle();
354  if (particle != nullptr)
355  mStatusParticleEffects.setLocally(effectId, particle);
356  }
357  }
358  else
359  {
361  }
362 }
ParticleVector mStatusParticleEffects
Definition: actorsprite.h:243
const bool Enable_true
Definition: enable.h:29
void setLocally(const int index, Particle *const particle)
const bool IsStart_true
Definition: isstart.h:29
Particle * getParticle() const
Particle * getStartParticle() const
void delLocally(const int index)

◆ initTargetCursor()

void ActorSprite::initTargetCursor ( )
staticprotected

Load the target cursors into memory

Definition at line 493 of file actorsprite.cpp.

References cursorSize(), cursorType(), end_foreach, for_each_cursors, AnimatedSprite::load(), Theme::resolveThemePath(), ServerCommandType::size, strprintf(), and targetCursor.

Referenced by getParticlesCount(), and load().

494 {
495  static const std::string targetCursorFile("target-cursor-%s-%s.xml");
496 
497  // Load target cursors
499  {
502  targetCursorFile.c_str(),
503  cursorType(static_cast<TargetCursorTypeT>(type)),
504  cursorSize(static_cast<TargetCursorSizeT>(size)))),
505  0);
506  }
508 }
static AnimatedSprite * targetCursor[static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
Definition: actorsprite.h:236
static const char * cursorSize(const TargetCursorSizeT size)
static AnimatedSprite * load(const std::string &filename, const int variant)
#define end_foreach
Definition: actorsprite.cpp:61
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
static const char * cursorType(const TargetCursorTypeT type)
#define for_each_cursors()
Definition: actorsprite.cpp:52
static std::string resolveThemePath(const std::string &path)
Definition: theme.cpp:626

◆ isTrickDead()

bool ActorSprite::isTrickDead ( ) const
inline

Definition at line 183 of file actorsprite.h.

References mTrickDead.

Referenced by InputManager::updateConditionMask().

184  { return mTrickDead; }
bool mTrickDead
Definition: actorsprite.h:262

◆ load()

void ActorSprite::load ( )
static

Definition at line 434 of file actorsprite.cpp.

References initTargetCursor(), loaded, and unload().

Referenced by anonymous_namespace{client.cpp}::LoginListener::action(), getHeight(), Client::loadData(), and DbManager::loadDb().

435 {
436  if (loaded)
437  unload();
438 
440 
441  loaded = true;
442 }
static bool loaded
Definition: actorsprite.h:238
static void unload()
static void initTargetCursor()

◆ logic()

void ActorSprite::logic ( )
virtual

Reimplemented in Being, and LocalPlayer.

Definition at line 109 of file actorsprite.cpp.

References BLOCK_END, BLOCK_START, ServerCommandType::effect, Enable_true, FOR_EACH, StatusEffectDB::getStatusEffect(), IsStart_false, mChildParticleEffects, MILLISECONDS_IN_A_TICK, StatusEffect::mIsPersistent, mMustResetParticles, ParticleList::moveTo(), Actor::mPos, mStatusEffects, tick_time, CompoundSprite::update(), updateStatusEffect(), Vector::x, and Vector::y.

Referenced by getType(), and Being::logic().

110 {
111  BLOCK_START("ActorSprite::logic")
112  // Update sprite animations
114 
115  // Restart status/particle effects, if needed
117  {
118  mMustResetParticles = false;
119  FOR_EACH (std::set<int32_t>::const_iterator, it, mStatusEffects)
120  {
121  const StatusEffect *const effect
123  if (effect != nullptr &&
124  effect->mIsPersistent)
125  {
126  updateStatusEffect(*it,
127  Enable_true,
128  IsStart_false);
129  }
130  }
131  }
132 
133  // Update particle effects
135  BLOCK_END("ActorSprite::logic")
136 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
bool update(const int time)
volatile int tick_time
Definition: timer.cpp:52
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:241
#define BLOCK_START(name)
Definition: perfomance.h:78
Vector mPos
Definition: actor.h:139
virtual void updateStatusEffect(const int32_t index, const Enable newStatus, const IsStart start)
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
const bool Enable_true
Definition: enable.h:29
bool mMustResetParticles
Definition: actorsprite.h:259
static const int MILLISECONDS_IN_A_TICK
Definition: timer.h:29
const bool IsStart_false
Definition: isstart.h:29
bool mIsPersistent
Definition: statuseffect.h:83
float x
Definition: vector.h:208
void moveTo(const float x, const float y)
float y
Definition: vector.h:208
StatusEffect * getStatusEffect(const int index, const Enable enabling)

◆ removeActorSpriteListener()

void ActorSprite::removeActorSpriteListener ( ActorSpriteListener *const  listener)

Remove an ActorSprite listener.

Definition at line 458 of file actorsprite.cpp.

References mActorSpriteListeners.

Referenced by getHeight().

460 {
461  mActorSpriteListeners.remove(listener);
462 }
ActorSpriteListeners mActorSpriteListeners
Definition: actorsprite.h:253

◆ setAlpha()

void ActorSprite::setAlpha ( const float  alpha)
inlinevirtual

Sets the alpha value used to draw the actor.

Implements Actor.

Definition at line 133 of file actorsprite.h.

References CompoundSprite::setAlpha().

134  { CompoundSprite::setAlpha(alpha); }
void setAlpha(float alpha)

◆ setHaveCart()

void ActorSprite::setHaveCart ( const bool  b)
inline

Definition at line 171 of file actorsprite.h.

References mHaveCart.

Referenced by updateStatusEffect().

172  { mHaveCart = b; }
bool mHaveCart
Definition: actorsprite.h:261

◆ setId()

void ActorSprite::setId ( const BeingId  id)
inline

Definition at line 66 of file actorsprite.h.

References mId.

Referenced by EAthena::GameHandler::connect(), and TmwAthena::GameHandler::connect().

67  { mId = id; }
BeingId mId
Definition: actorsprite.h:246

◆ setMap()

void ActorSprite::setMap ( Map *const  map)
virtual

Reimplemented from Actor.

Reimplemented in Being, and LocalPlayer.

Definition at line 138 of file actorsprite.cpp.

References ParticleContainer::clear(), mChildParticleEffects, mMustResetParticles, and Actor::setMap().

Referenced by getType(), FloorItem::postInit(), and Being::setMap().

139 {
140  Actor::setMap(map);
141 
142  // Clear particle effect list because child particles became invalid
144  mMustResetParticles = true; // Reset status particles on next redraw
145 }
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
bool mMustResetParticles
Definition: actorsprite.h:259
virtual void setMap(Map *const map)
Definition: actor.cpp:47

◆ setPoison()

void ActorSprite::setPoison ( const bool  b)
inline

Definition at line 165 of file actorsprite.h.

References mPoison.

Referenced by updateStatusEffect().

166  { mPoison = b; }

◆ setRiding()

virtual void ActorSprite::setRiding ( const bool  b)
inlinevirtual

Reimplemented in Being.

Definition at line 177 of file actorsprite.h.

References mHorseId.

Referenced by updateStatusEffect().

178  { mHorseId = b ? 1 : 0; }

◆ setStatusEffect()

void ActorSprite::setStatusEffect ( const int32_t  index,
const Enable  active,
const IsStart  start 
)

Definition at line 197 of file actorsprite.cpp.

References Enable_true, fromBool, mStatusEffects, and updateStatusEffect().

Referenced by applyEffectByOption(), applyEffectByOption1(), TmwAthena::BeingRecv::processBeingStatusChange(), EAthena::BeingRecv::processBeingStatusChange(), and untarget().

200 {
201  const Enable wasActive = fromBool(
202  mStatusEffects.find(index) != mStatusEffects.end(), Enable);
203 
204  if (active != wasActive)
205  {
206  updateStatusEffect(index, active, start);
207  if (active == Enable_true)
208  {
209  mStatusEffects.insert(index);
210  }
211  else
212  {
213  mStatusEffects.erase(index);
214  }
215  }
216 }
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:241
virtual void updateStatusEffect(const int32_t index, const Enable newStatus, const IsStart start)
const bool Enable_true
Definition: enable.h:29
#define fromBool(val, name)
Definition: booldefines.h:48
bool Enable
Definition: enable.h:29

◆ setStatusEffectOpiton0()

void ActorSprite::setStatusEffectOpiton0 ( const uint32_t  option)

Definition at line 310 of file actorsprite.cpp.

References applyEffectByOption(), and StatusEffectDB::getOptionMap().

Referenced by EAthena::BeingRecv::processPlayerStatusChange2(), and untarget().

311 {
312  applyEffectByOption(this, option, "option",
314 }
const OptionsMap & getOptionMap()
static void applyEffectByOption(ActorSprite *const actor, uint32_t option, const char *const name, const OptionsMap &options)

◆ setStatusEffectOpitons() [1/2]

void ActorSprite::setStatusEffectOpitons ( const uint32_t  option,
const uint32_t  opt1,
const uint32_t  opt2,
const uint32_t  opt3 
)

Definition at line 283 of file actorsprite.cpp.

References applyEffectByOption(), applyEffectByOption1(), StatusEffectDB::getOpt1Map(), StatusEffectDB::getOpt2Map(), StatusEffectDB::getOpt3Map(), and StatusEffectDB::getOptionMap().

Referenced by TmwAthena::BeingRecv::processBeingMove(), EAthena::BeingRecv::processBeingMove(), EAthena::BeingRecv::processBeingSpawn(), TmwAthena::BeingRecv::processBeingVisible(), EAthena::BeingRecv::processBeingVisible(), TmwAthena::BeingRecv::processPlayerMove(), TmwAthena::BeingRecv::processPlayerStatusChange(), EAthena::BeingRecv::processPlayerStatusChange(), TmwAthena::BeingRecv::processPlayerUpdate1(), TmwAthena::BeingRecv::processPlayerUpdate2(), and untarget().

287 {
288  applyEffectByOption(this, option, "option",
290  applyEffectByOption1(this, opt1, "opt1",
292  applyEffectByOption(this, opt2, "opt2",
294  applyEffectByOption(this, opt3, "opt3",
296 }
const OptionsMap & getOpt2Map()
const OptionsMap & getOpt1Map()
const OptionsMap & getOptionMap()
static void applyEffectByOption1(ActorSprite *const actor, uint32_t option, const char *const name, const OptionsMap &options)
const OptionsMap & getOpt3Map()
static void applyEffectByOption(ActorSprite *const actor, uint32_t option, const char *const name, const OptionsMap &options)

◆ setStatusEffectOpitons() [2/2]

void ActorSprite::setStatusEffectOpitons ( const uint32_t  option,
const uint32_t  opt1,
const uint32_t  opt2 
)

Definition at line 298 of file actorsprite.cpp.

References applyEffectByOption(), applyEffectByOption1(), StatusEffectDB::getOpt1Map(), StatusEffectDB::getOpt2Map(), and StatusEffectDB::getOptionMap().

301 {
302  applyEffectByOption(this, option, "option",
304  applyEffectByOption1(this, opt1, "opt1",
306  applyEffectByOption(this, opt2, "opt2",
308 }
const OptionsMap & getOpt2Map()
const OptionsMap & getOpt1Map()
const OptionsMap & getOptionMap()
static void applyEffectByOption1(ActorSprite *const actor, uint32_t option, const char *const name, const OptionsMap &options)
static void applyEffectByOption(ActorSprite *const actor, uint32_t option, const char *const name, const OptionsMap &options)

◆ setTargetType()

void ActorSprite::setTargetType ( const TargetCursorTypeT  type)

Sets the target animation for this actor.

Definition at line 172 of file actorsprite.cpp.

References CAST_S32, CAST_SIZE, getTargetCursorSize(), mapTileSize, mCursorPaddingX, mCursorPaddingY, mUsedTargetCursor, TargetCursorType::NONE, TargetCursorSize::NUM_TC, targetCursor, and untarget().

Referenced by getTargetOffsetY(), and LocalPlayer::logic().

173 {
174  if (type == TargetCursorType::NONE)
175  {
176  untarget();
177  }
178  else
179  {
180  const size_t sz = CAST_SIZE(getTargetCursorSize());
182  if (mUsedTargetCursor != nullptr)
183  {
184  static const int targetWidths[CAST_SIZE(
186  = {0, 0, 0};
187  static const int targetHeights[CAST_SIZE(
189  = {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize};
190 
191  mCursorPaddingX = CAST_S32(targetWidths[sz]);
192  mCursorPaddingY = CAST_S32(targetHeights[sz]);
193  }
194  }
195 }
static AnimatedSprite * targetCursor[static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
Definition: actorsprite.h:236
int mCursorPaddingX
Definition: actorsprite.h:255
virtual TargetCursorSizeT getTargetCursorSize() const
Definition: actorsprite.h:98
#define CAST_S32
Definition: cast.h:29
AnimatedSprite * mUsedTargetCursor
Definition: actorsprite.h:249
int mCursorPaddingY
Definition: actorsprite.h:256
static const int mapTileSize
Definition: map.h:26
#define CAST_SIZE
Definition: cast.h:33
void untarget()
Definition: actorsprite.h:115

◆ setTrickDead()

virtual void ActorSprite::setTrickDead ( const bool  b)
inlinevirtual

Reimplemented in Being.

Definition at line 180 of file actorsprite.h.

References mTrickDead.

Referenced by updateStatusEffect().

181  { mTrickDead = b; }
bool mTrickDead
Definition: actorsprite.h:262

◆ setupSpriteDisplay()

void ActorSprite::setupSpriteDisplay ( const SpriteDisplay display,
const ForceDisplay  forceDisplay,
const DisplayTypeT  displayType,
const std::string &  color 
)
protected

Definition at line 364 of file actorsprite.cpp.

References ParticleEngine::addEffect(), CompoundSprite::addSprite(), ParticleContainer::clear(), CompoundSprite::clear(), combineDye2(), combineDye3(), controlAutoParticle(), Image::decRef(), AnimatedSprite::delayedLoad(), ParticleEngine::enabled, DisplayType::Floor, SpriteDisplay::floor, FOR_EACH, ForceDisplay_true, Loader::getImage(), Theme::getImageFromTheme(), Configuration::getStringValue(), SpriteDisplay::image, DisplayType::Item, mChildParticleEffects, mMustResetParticles, CompoundSprite::mSprites, particleEngine, SpriteDisplay::particles, pathJoin(), paths, and SpriteDisplay::sprites.

Referenced by getParticlesCount(), FloorItem::postInit(), and Being::setSubtype().

368 {
369  clear();
370 
371  FOR_EACH (SpriteRefs, it, display.sprites)
372  {
373  if (*it == nullptr)
374  continue;
375  const std::string file = pathJoin(paths.getStringValue("sprites"),
376  combineDye3((*it)->sprite, color));
377 
378  const int variant = (*it)->variant;
379  addSprite(AnimatedSprite::delayedLoad(file, variant));
380  }
381 
382  // Ensure that something is shown, if desired
383  if (mSprites.empty() && forceDisplay == ForceDisplay_true)
384  {
385  if (display.image.empty())
386  {
388  paths.getStringValue("sprites"),
389  paths.getStringValue("spriteErrorFile")),
390  0));
391  }
392  else
393  {
394  std::string imagePath;
395  switch (displayType)
396  {
397  case DisplayType::Item:
398  default:
399  imagePath = pathJoin(paths.getStringValue("itemIcons"),
400  display.image);
401  break;
402  case DisplayType::Floor:
403  imagePath = pathJoin(paths.getStringValue("itemIcons"),
404  display.floor);
405  break;
406  }
407  imagePath = combineDye2(imagePath, color);
408  Image *img = Loader::getImage(imagePath);
409 
410  if (img == nullptr)
411  img = Theme::getImageFromTheme("unknown-item.png");
412 
413  addSprite(new ImageSprite(img));
414  if (img != nullptr)
415  img->decRef();
416  }
417  }
418 
420 
421  // setup particle effects
422  if (ParticleEngine::enabled && (particleEngine != nullptr))
423  {
424  FOR_EACH (StringVectCIter, itr, display.particles)
425  {
426  Particle *const p = particleEngine->addEffect(*itr, 0, 0, 0);
428  }
429  }
430 
431  mMustResetParticles = true;
432 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
static bool enabled
std::string getStringValue(const std::string &key) const
std::vector< SpriteReference * > sprites
Definition: spritedisplay.h:46
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:30
Particle * addEffect(const std::string &particleEffectFile, const int pixelX, const int pixelY, const int rotation)
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
std::string combineDye3(std::string file, const std::string &dye)
std::string pathJoin(std::string str1, const std::string &str2)
void addSprite(Sprite *const sprite)
ParticleEngine * particleEngine
void controlAutoParticle(Particle *const particle)
bool mMustResetParticles
Definition: actorsprite.h:259
const bool ForceDisplay_true
Definition: forcedisplay.h:29
Image * getImage(const std::string &idPath)
Definition: imageloader.cpp:85
static AnimatedSprite * delayedLoad(const std::string &filename, const int variant)
StringVect particles
Definition: spritedisplay.h:47
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:654
std::vector< Sprite * > mSprites
std::string floor
Definition: spritedisplay.h:45
Configuration paths
Definition: image.h:61
std::string combineDye2(std::string file, const std::string &dye)
void decRef()
Definition: image.cpp:522
std::string image
Definition: spritedisplay.h:44
std::vector< SpriteReference * >::const_iterator SpriteRefs

◆ stopCast()

virtual void ActorSprite::stopCast ( const bool  b)
inlinevirtual

Reimplemented in Being.

Definition at line 191 of file actorsprite.h.

Referenced by updateStatusEffect().

192  { }

◆ unload()

void ActorSprite::unload ( )
static

Definition at line 444 of file actorsprite.cpp.

References cleanupTargetCursors(), loaded, and reportTrue.

Referenced by getHeight(), Client::initConfigListeners(), and load().

445 {
446  if (reportTrue(!loaded))
447  return;
448 
450  loaded = false;
451 }
static bool loaded
Definition: actorsprite.h:238
static void cleanupTargetCursors()
#define reportTrue(val)
Definition: checkutils.h:251

◆ untarget()

void ActorSprite::untarget ( )
inline

◆ updateStatusEffect()

void ActorSprite::updateStatusEffect ( const int32_t  index,
const Enable  newStatus,
const IsStart  start 
)
protectedvirtual

Notify self that a status effect has flipped. The new flag is passed.

Definition at line 316 of file actorsprite.cpp.

References ServerCommandType::effect, Enable_true, StatusEffectDB::getStatusEffect(), getType(), handleStatusEffect(), localPlayer, StatusEffect::mIsCart, StatusEffect::mIsPoison, StatusEffect::mIsPostDelay, StatusEffect::mIsRiding, StatusEffect::mIsTrickDead, ActorType::Player, setHaveCart(), setPoison(), setRiding(), setTrickDead(), and stopCast().

Referenced by getParticlesCount(), logic(), and setStatusEffect().

319 {
321  index, newStatus);
322  if (effect == nullptr)
323  return;
324  if (effect->mIsPoison && getType() == ActorType::Player)
325  setPoison(newStatus == Enable_true);
326  else if (effect->mIsCart && localPlayer == this)
327  setHaveCart(newStatus == Enable_true);
328  else if (effect->mIsRiding)
329  setRiding(newStatus == Enable_true);
330  else if (effect->mIsTrickDead)
331  setTrickDead(newStatus == Enable_true);
332  else if (effect->mIsPostDelay)
333  stopCast(newStatus == Enable_true);
334  handleStatusEffect(effect, index, newStatus, start);
335 }
const bool Enable_true
Definition: enable.h:29
virtual void setTrickDead(const bool b)
Definition: actorsprite.h:180
virtual void stopCast(const bool b)
Definition: actorsprite.h:191
LocalPlayer * localPlayer
void setHaveCart(const bool b)
Definition: actorsprite.h:171
void setPoison(const bool b)
Definition: actorsprite.h:165
bool mIsTrickDead
Definition: statuseffect.h:87
virtual void setRiding(const bool b)
Definition: actorsprite.h:177
bool mIsPostDelay
Definition: statuseffect.h:88
StatusEffect * getStatusEffect(const int index, const Enable enabling)
virtual void handleStatusEffect(const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
virtual ActorTypeT getType() const
Definition: actorsprite.h:72

Field Documentation

◆ loaded

bool ActorSprite::loaded = false
staticprotected

set of active status effects

Definition at line 238 of file actorsprite.h.

Referenced by load(), and unload().

◆ mActorSpriteListeners

ActorSpriteListeners ActorSprite::mActorSpriteListeners
protected

Definition at line 253 of file actorsprite.h.

Referenced by addActorSpriteListener(), removeActorSpriteListener(), and ~ActorSprite().

◆ mChildParticleEffects

ParticleList ActorSprite::mChildParticleEffects
protected

◆ mCursorPaddingX

int ActorSprite::mCursorPaddingX
protected

Definition at line 255 of file actorsprite.h.

Referenced by Being::drawBeingCursor(), and setTargetType().

◆ mCursorPaddingY

int ActorSprite::mCursorPaddingY
protected

Definition at line 256 of file actorsprite.h.

Referenced by Being::drawBeingCursor(), and setTargetType().

◆ mHaveCart

bool ActorSprite::mHaveCart
protected

Definition at line 261 of file actorsprite.h.

Referenced by getHaveCart(), and setHaveCart().

◆ mHorseId

int ActorSprite::mHorseId
protected

◆ mId

BeingId ActorSprite::mId
protected

◆ mMustResetParticles

bool ActorSprite::mMustResetParticles
protected

Reset particle status effects on next redraw?

Definition at line 259 of file actorsprite.h.

Referenced by logic(), setMap(), setupSpriteDisplay(), and ~ActorSprite().

◆ mPoison

bool ActorSprite::mPoison
protected

Definition at line 260 of file actorsprite.h.

Referenced by getPoison(), and setPoison().

◆ mStatusEffects

std::set<int32_t> ActorSprite::mStatusEffects
protected

Definition at line 241 of file actorsprite.h.

Referenced by getStatusEffects(), getStatusEffectsString(), logic(), and setStatusEffect().

◆ mStatusParticleEffects

ParticleVector ActorSprite::mStatusParticleEffects
protected

Definition at line 243 of file actorsprite.h.

Referenced by getParticlesCount(), and handleStatusEffect().

◆ mTrickDead

bool ActorSprite::mTrickDead
protected

◆ mUsedTargetCursor

AnimatedSprite* ActorSprite::mUsedTargetCursor
protected

Target cursor being used

Definition at line 249 of file actorsprite.h.

Referenced by Being::drawBeingCursor(), setTargetType(), untarget(), and ~ActorSprite().

◆ targetCursor

AnimatedSprite * ActorSprite::targetCursor
staticprotected

Animated target cursors.

Definition at line 236 of file actorsprite.h.

Referenced by cleanupTargetCursors(), getParticlesCount(), initTargetCursor(), and setTargetType().


The documentation for this class was generated from the following files: