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 }

◆ ~ActorSprite()

ActorSprite::~ActorSprite ( )

Definition at line 87 of file actorsprite.cpp.

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 }

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

Member Function Documentation

◆ addActorSpriteListener()

void ActorSprite::addActorSpriteListener ( ActorSpriteListener *const  listener)

Add an ActorSprite listener.

Definition at line 453 of file actorsprite.cpp.

454 {
455  mActorSpriteListeners.push_front(listener);
456 }

References anonymous_namespace{itemlinkhandler.cpp}::listener, and mActorSpriteListeners.

Referenced by LocalPlayer::pickUp().

◆ cleanupTargetCursors()

void ActorSprite::cleanupTargetCursors ( )
staticprotected

Remove the target cursors from memory

Definition at line 510 of file actorsprite.cpp.

511 {
513  {
514  delete2(targetCursor[type][size])
515  }
517 }

References delete2, end_foreach, for_each_cursors, EmoteDB::size(), and targetCursor.

Referenced by unload().

◆ 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.

148 {
149  if (particle != nullptr)
150  {
151  particle->setActor(mId);
153  }
154 }

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

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

◆ 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.

157 {
158  if (particle != nullptr)
159  {
160  // The effect may not die without the beings permission or we segfault
161  particle->disableAutoDelete();
163  }
164 }

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

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

◆ controlParticleDeleted()

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

Definition at line 166 of file actorsprite.cpp.

167 {
168  if (particle != nullptr)
170 }

References mChildParticleEffects, and ParticleList::removeLocally().

Referenced by Particle::~Particle().

◆ getActorX()

int ActorSprite::getActorX ( ) const
inline

Definition at line 159 of file actorsprite.h.

160  { return getPixelX() - mapTileSize / 2; }

References Actor::getPixelX(), and mapTileSize.

Referenced by FloorItem::draw().

◆ getActorY()

int ActorSprite::getActorY ( ) const
inline

Definition at line 162 of file actorsprite.h.

163  { return getPixelY() - mapTileSize; }

References Actor::getPixelY(), and mapTileSize.

Referenced by FloorItem::draw().

◆ 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.

137  { return CompoundSprite::getAlpha(); }

References Sprite::getAlpha().

◆ 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.

83  { return BlockType::NONE; }

References BlockType::NONE.

◆ getHaveCart()

bool ActorSprite::getHaveCart ( ) const
inline

Definition at line 174 of file actorsprite.h.

175  { return mHaveCart; }

References mHaveCart.

Referenced by ShopWindow::updateButtonsAndLabels().

◆ 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.

143  { return CompoundSprite::getHeight(); }

References CompoundSprite::getHeight().

◆ getId()

BeingId ActorSprite::getId ( ) const
inline

Definition at line 63 of file actorsprite.h.

64  { return mId; }

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(), ActorManager::clear(), ActorManager::cloneBeing(), EAthena::GameHandler::connect(), TmwAthena::GameHandler::connect(), ActorManager::createBeing(), ActorManager::createItem(), TmwAthena::CharServerHandler::deleteCharacter(), EAthena::CharServerHandler::deleteCharacter(), 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(), EAthena::BeingRecv::processNameResponseTitle(), Ea::PartyRecv::processPartyLeave(), EAthena::PlayerRecv::processPlayerGetExp(), EAthena::PlayerRecv::processPlayerGetExp2(), EAthena::BeingRecv::processPlayerGuilPartyInfo(), EAthena::BeingRecv::processPlayerGuilPartyInfo2(), EAthena::PlayerRecv::processPlayerHeal(), 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().

◆ getParticlesCount()

size_t ActorSprite::getParticlesCount ( ) const
inline

◆ getPoison()

bool ActorSprite::getPoison ( ) const
inline

Definition at line 168 of file actorsprite.h.

169  { return mPoison; }

References mPoison.

Referenced by SocialPlayersTab::updateAvatar().

◆ getStatusEffects()

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

Definition at line 186 of file actorsprite.h.

187  { return mStatusEffects; }

References mStatusEffects.

◆ getStatusEffectsString()

std::string ActorSprite::getStatusEffectsString ( ) const

Definition at line 519 of file actorsprite.cpp.

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 }

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

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

◆ 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.

99  { return TargetCursorSize::MEDIUM; }

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.

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.

140  { return CompoundSprite::getWidth(); }

References CompoundSprite::getWidth().

◆ 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.

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 }

References ParticleVector::delLocally(), Enable_true, StatusEffect::getParticle(), StatusEffect::getStartParticle(), IsStart_true, mStatusParticleEffects, ParticleVector::setLocally(), and anonymous_namespace{stringutils.cpp}::start.

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

◆ initTargetCursor()

void ActorSprite::initTargetCursor ( )
staticprotected

Load the target cursors into memory

Definition at line 493 of file actorsprite.cpp.

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 }

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

Referenced by load().

◆ isTrickDead()

bool ActorSprite::isTrickDead ( ) const
inline

Definition at line 183 of file actorsprite.h.

184  { return mTrickDead; }

References mTrickDead.

Referenced by InputManager::updateConditionMask().

◆ load()

void ActorSprite::load ( )
static

Definition at line 434 of file actorsprite.cpp.

435 {
436  if (loaded)
437  unload();
438 
440 
441  loaded = true;
442 }

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

Referenced by Client::loadData(), and DbManager::loadDb().

◆ logic()

void ActorSprite::logic ( )
virtual

Reimplemented in Being, and LocalPlayer.

Definition at line 109 of file actorsprite.cpp.

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 }

References BLOCK_END, BLOCK_START, 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 Being::logic().

◆ removeActorSpriteListener()

void ActorSprite::removeActorSpriteListener ( ActorSpriteListener *const  listener)

Remove an ActorSprite listener.

Definition at line 458 of file actorsprite.cpp.

460 {
462 }

References anonymous_namespace{itemlinkhandler.cpp}::listener, and mActorSpriteListeners.

◆ 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.

134  { CompoundSprite::setAlpha(alpha); }

References CompoundSprite::setAlpha().

◆ setHaveCart()

void ActorSprite::setHaveCart ( const bool  b)
inline

Definition at line 171 of file actorsprite.h.

172  { mHaveCart = b; }

References mHaveCart.

Referenced by updateStatusEffect().

◆ setId()

void ActorSprite::setId ( const BeingId  id)
inline

Definition at line 66 of file actorsprite.h.

67  { mId = id; }

References mId.

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

◆ setMap()

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

Reimplemented from Actor.

Reimplemented in Being, and LocalPlayer.

Definition at line 138 of file actorsprite.cpp.

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 }

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

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

◆ setPoison()

void ActorSprite::setPoison ( const bool  b)
inline

Definition at line 165 of file actorsprite.h.

166  { mPoison = b; }

References mPoison.

Referenced by updateStatusEffect().

◆ setRiding()

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

Reimplemented in Being.

Definition at line 177 of file actorsprite.h.

178  { mHorseId = b ? 1 : 0; }

References mHorseId.

Referenced by updateStatusEffect().

◆ setStatusEffect()

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

Definition at line 197 of file actorsprite.cpp.

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 }

References Enable_true, fromBool, mStatusEffects, anonymous_namespace{stringutils.cpp}::start, and updateStatusEffect().

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

◆ setStatusEffectOpiton0()

void ActorSprite::setStatusEffectOpiton0 ( const uint32_t  option)

Definition at line 310 of file actorsprite.cpp.

311 {
312  applyEffectByOption(this, option, "option",
314 }

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

Referenced by EAthena::BeingRecv::processPlayerStatusChange2().

◆ setStatusEffectOpitons() [1/2]

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

◆ setStatusEffectOpitons() [2/2]

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

◆ setTargetType()

void ActorSprite::setTargetType ( const TargetCursorTypeT  type)

Sets the target animation for this actor.

Definition at line 172 of file actorsprite.cpp.

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 }

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

Referenced by LocalPlayer::logic().

◆ setTrickDead()

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

Reimplemented in Being.

Definition at line 180 of file actorsprite.h.

181  { mTrickDead = b; }

References mTrickDead.

Referenced by updateStatusEffect().

◆ 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.

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 }

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 FloorItem::postInit().

◆ stopCast()

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

Reimplemented in Being.

Definition at line 191 of file actorsprite.h.

192  { }

Referenced by updateStatusEffect().

◆ unload()

void ActorSprite::unload ( )
static

Definition at line 444 of file actorsprite.cpp.

445 {
446  if (reportTrue(!loaded))
447  return;
448 
450  loaded = false;
451 }

References cleanupTargetCursors(), loaded, and reportTrue.

Referenced by load().

◆ untarget()

void ActorSprite::untarget ( )
inline

Untargets the actor.

Definition at line 115 of file actorsprite.h.

116  { mUsedTargetCursor = nullptr; }

References mUsedTargetCursor.

Referenced by LocalPlayer::setTarget(), and setTargetType().

◆ 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.

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 }

References Enable_true, StatusEffectDB::getStatusEffect(), getType(), handleStatusEffect(), localPlayer, StatusEffect::mIsCart, StatusEffect::mIsPoison, StatusEffect::mIsPostDelay, StatusEffect::mIsRiding, StatusEffect::mIsTrickDead, ActorType::Player, setHaveCart(), setPoison(), setRiding(), setTrickDead(), anonymous_namespace{stringutils.cpp}::start, and stopCast().

Referenced by logic(), and setStatusEffect().

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

Definition at line 245 of file actorsprite.h.

Referenced by Being::getMoveAction(), Being::getSitAction(), and setRiding().

◆ mId

BeingId ActorSprite::mId
protected

Definition at line 246 of file actorsprite.h.

Referenced by Being::clearGuilds(), controlAutoParticle(), getId(), setId(), and Being::talkTo().

◆ 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

Definition at line 262 of file actorsprite.h.

Referenced by isTrickDead(), Being::serverRemove(), and setTrickDead().

◆ 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(), initTargetCursor(), and setTargetType().


The documentation for this class was generated from the following files:
ActorSprite::mStatusEffects
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:241
ForceDisplay_true
const bool ForceDisplay_true
Definition: forcedisplay.h:29
BlockType::NONE
@ NONE
Definition: blocktype.h:30
reportTrue
#define reportTrue(val)
Definition: checkutils.h:251
ActorType::Unknown
@ Unknown
Definition: actortype.h:29
ActorSprite::mHaveCart
bool mHaveCart
Definition: actorsprite.h:261
ParticleVector::setLocally
void setLocally(const int index, Particle *const particle)
Definition: particlevector.cpp:37
SpriteRefs
std::vector< SpriteReference * >::const_iterator SpriteRefs
Definition: spritereference.h:51
Enable_true
const bool Enable_true
Definition: enable.h:29
CompoundSprite::update
bool update(const int time)
Definition: compoundsprite.cpp:133
ActorSprite::mChildParticleEffects
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
CAST_SIZE
#define CAST_SIZE
Definition: cast.h:33
ActorSprite::mPoison
bool mPoison
Definition: actorsprite.h:260
anonymous_namespace{stringutils.cpp}::start
unsigned int start
Definition: stringutils.cpp:227
TargetCursorSize::NUM_TC
@ NUM_TC
Definition: targetcursorsize.h:32
StatusEffect::mName
std::string mName
Definition: statuseffect.h:82
ActorSprite::handleStatusEffect
virtual void handleStatusEffect(const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
Definition: actorsprite.cpp:337
Vector::x
float x
Definition: vector.h:208
Particle
Definition: particle.h:44
Actor::mPos
Vector mPos
Definition: actor.h:139
ActorSprite::getTargetCursorSize
virtual TargetCursorSizeT getTargetCursorSize() const
Definition: actorsprite.h:98
StatusEffect::mIsTrickDead
bool mIsTrickDead
Definition: statuseffect.h:87
ParticleEngine::addEffect
Particle * addEffect(const std::string &particleEffectFile, const int pixelX, const int pixelY, const int rotation)
Definition: particleengine.cpp:129
SpriteDisplay::sprites
std::vector< SpriteReference * > sprites
Definition: spritedisplay.h:46
reportFalse
#define reportFalse(val)
Definition: checkutils.h:250
ImageSprite
Definition: imagesprite.h:31
combineDye3
std::string combineDye3(std::string file, const std::string &dye)
Definition: stringutils.cpp:562
particleEngine
ParticleEngine * particleEngine
Definition: particleengine.cpp:41
ActorSprite::loaded
static bool loaded
Definition: actorsprite.h:238
paths
Configuration paths
Definition: configuration.cpp:55
ActorSprite::mTrickDead
bool mTrickDead
Definition: actorsprite.h:262
StatusEffect::mIsPoison
bool mIsPoison
Definition: statuseffect.h:84
StatusEffectDB::getOptionMap
const OptionsMap & getOptionMap()
Definition: statuseffectdb.cpp:207
ActorSprite::setTrickDead
virtual void setTrickDead(const bool b)
Definition: actorsprite.h:180
Particle::disableAutoDelete
void disableAutoDelete()
Definition: particle.h:226
ActorSprite::mCursorPaddingX
int mCursorPaddingX
Definition: actorsprite.h:255
end_foreach
#define end_foreach
Definition: actorsprite.cpp:61
ActorSprite::updateStatusEffect
virtual void updateStatusEffect(const int32_t index, const Enable newStatus, const IsStart start)
Definition: actorsprite.cpp:316
StatusEffectDB::getStatusEffect
StatusEffect * getStatusEffect(const int index, const Enable enabling)
Definition: statuseffectdb.cpp:46
StatusEffectDB::getOpt1Map
const OptionsMap & getOpt1Map()
Definition: statuseffectdb.cpp:212
ParticleList::moveTo
void moveTo(const float x, const float y)
Definition: particlelist.cpp:86
ActorSprite::stopCast
virtual void stopCast(const bool b)
Definition: actorsprite.h:191
Image
Definition: image.h:67
AnimatedSprite::load
static AnimatedSprite * load(const std::string &filename, const int variant)
Definition: animatedsprite.cpp:71
cursorSize
static const char * cursorSize(const TargetCursorSizeT size)
Definition: actorsprite.cpp:478
fromBool
#define fromBool(val, name)
Definition: booldefines.h:48
pathJoin
std::string pathJoin(std::string str1, const std::string &str2)
Definition: stringutils.cpp:1036
TargetCursorSizeT
TargetCursorSize ::T TargetCursorSizeT
Definition: targetcursorsize.h:34
ActorSprite::ActorSpriteListenerIterator
ActorSpriteListeners::iterator ActorSpriteListenerIterator
Definition: actorsprite.h:252
StatusEffect::getParticle
Particle * getParticle() const
Definition: statuseffect.cpp:84
ActorSprite::mHorseId
int mHorseId
Definition: actorsprite.h:245
CompoundSprite::CompoundSprite
CompoundSprite()
Definition: compoundsprite.cpp:71
delete2
#define delete2(var)
Definition: delete2.h:24
ActorType::Player
@ Player
Definition: actortype.h:30
bool
ParticleList::removeLocally
void removeLocally(const Particle *const particle)
Definition: particlelist.cpp:54
Actor::Actor
Actor()
Definition: actor.cpp:28
ActorSprite::mMustResetParticles
bool mMustResetParticles
Definition: actorsprite.h:259
if
if(!vert) return
ParticleList::size
size_t size() const
Definition: particlelist.h:61
Particle::setActor
void setActor(const BeingId actor)
Definition: particle.h:243
ActorSprite::controlAutoParticle
void controlAutoParticle(Particle *const particle)
Definition: actorsprite.cpp:147
localPlayer
LocalPlayer * localPlayer
Definition: localplayer.cpp:108
SpriteDisplay::floor
std::string floor
Definition: spritedisplay.h:45
cursorType
static const char * cursorType(const TargetCursorTypeT type)
Definition: actorsprite.cpp:464
ActorSprite::mUsedTargetCursor
AnimatedSprite * mUsedTargetCursor
Definition: actorsprite.h:249
IsStart_true
const bool IsStart_true
Definition: isstart.h:29
Theme::getImageFromTheme
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:654
StatusEffect::mIsPersistent
bool mIsPersistent
Definition: statuseffect.h:83
Actor::getPixelY
virtual int getPixelY() const
Definition: actor.h:92
CompoundSprite::mSprites
std::vector< Sprite * > mSprites
Definition: compoundsprite.h:110
strprintf
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
ParticleList::addLocally
void addLocally(Particle *const particle)
Definition: particlelist.cpp:45
SpriteDisplay::image
std::string image
Definition: spritedisplay.h:44
StatusEffect::mIsRiding
bool mIsRiding
Definition: statuseffect.h:86
Loader::getImage
Image * getImage(const std::string &idPath)
Definition: imageloader.cpp:85
ActorSprite::setHaveCart
void setHaveCart(const bool b)
Definition: actorsprite.h:171
CompoundSprite::getHeight
int getHeight() const
Definition: compoundsprite.cpp:212
TargetCursorType::NONE
@ NONE
Definition: targetcursortype.h:29
CompoundSprite::addSprite
void addSprite(Sprite *const sprite)
Definition: compoundsprite.cpp:270
applyEffectByOption1
static void applyEffectByOption1(ActorSprite *const actor, uint32_t option, const char *const name, const OptionsMap &options)
Definition: actorsprite.cpp:247
ParticleEngine::enabled
static bool enabled
Definition: particleengine.h:55
ParticleContainer::clear
void clear()
Definition: particlecontainer.cpp:44
ActorSprite::cleanupTargetCursors
static void cleanupTargetCursors()
Definition: actorsprite.cpp:510
ActorSprite::mCursorPaddingY
int mCursorPaddingY
Definition: actorsprite.h:256
StatusEffect
Definition: statuseffect.h:33
DisplayType::Floor
@ Floor
Definition: displaytype.h:29
for_each_cursors
#define for_each_cursors()
Definition: actorsprite.cpp:52
Configuration::getStringValue
std::string getStringValue(const std::string &key) const
Definition: configuration.cpp:487
tick_time
volatile int tick_time
Definition: timer.cpp:52
ActorSprite::setPoison
void setPoison(const bool b)
Definition: actorsprite.h:165
ParticleVector::usedSize
size_t usedSize() const
Definition: particlevector.cpp:99
MILLISECONDS_IN_A_TICK
static const int MILLISECONDS_IN_A_TICK
Definition: timer.h:29
Actor::getPixelX
int getPixelX() const
Definition: actor.h:86
SpriteDisplay::particles
StringVect particles
Definition: spritedisplay.h:47
Sprite::getAlpha
virtual float getAlpha() const
Definition: sprite.h:102
StatusEffect::mIsCart
bool mIsCart
Definition: statuseffect.h:85
ActorSprite::setRiding
virtual void setRiding(const bool b)
Definition: actorsprite.h:177
EmoteDB::size
int size()
Definition: emotedb.cpp:305
AnimatedSprite::delayedLoad
static AnimatedSprite * delayedLoad(const std::string &filename, const int variant)
Definition: animatedsprite.cpp:88
LocalPlayer::getTarget
Being * getTarget() const
Definition: localplayer.cpp:561
Actor::setMap
virtual void setMap(Map *const map)
Definition: actor.cpp:47
CompoundSprite::getWidth
int getWidth() const
Definition: compoundsprite.cpp:200
TargetCursorTypeT
TargetCursorType ::T TargetCursorTypeT
Definition: targetcursortype.h:34
TargetCursorSize::MEDIUM
@ MEDIUM
Definition: targetcursorsize.h:30
applyEffectByOption
static void applyEffectByOption(ActorSprite *const actor, uint32_t option, const char *const name, const OptionsMap &options)
Definition: actorsprite.cpp:218
ActorSprite::mId
BeingId mId
Definition: actorsprite.h:246
StatusEffect::getStartParticle
Particle * getStartParticle() const
Definition: statuseffect.cpp:77
CompoundSprite::setAlpha
void setAlpha(float alpha)
Definition: compoundsprite.cpp:396
anonymous_namespace{itemlinkhandler.cpp}::listener
OpenUrlListener listener
Definition: itemlinkhandler.cpp:55
IsStart_false
const bool IsStart_false
Definition: isstart.h:29
Vector::y
float y
Definition: vector.h:208
BLOCK_START
#define BLOCK_START(name)
Definition: perfomance.h:78
ActorSprite::initTargetCursor
static void initTargetCursor()
Definition: actorsprite.cpp:493
BLOCK_END
#define BLOCK_END(name)
Definition: perfomance.h:79
StringVectCIter
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:30
CAST_S32
#define CAST_S32
Definition: cast.h:29
ActorSprite::mActorSpriteListeners
ActorSpriteListeners mActorSpriteListeners
Definition: actorsprite.h:253
ActorSprite::mStatusParticleEffects
ParticleVector mStatusParticleEffects
Definition: actorsprite.h:243
ParticleVector::delLocally
void delLocally(const int index)
Definition: particlevector.cpp:52
CompoundSprite::clear
void clear()
Definition: compoundsprite.cpp:297
StatusEffect::mIsPostDelay
bool mIsPostDelay
Definition: statuseffect.h:88
StatusEffectDB::getOpt3Map
const OptionsMap & getOpt3Map()
Definition: statuseffectdb.cpp:222
DisplayType::Item
@ Item
Definition: displaytype.h:28
LocalPlayer::setTarget
void setTarget(Being *const target)
Definition: localplayer.cpp:566
ActorSprite::getType
virtual ActorTypeT getType() const
Definition: actorsprite.h:72
ActorSprite::untarget
void untarget()
Definition: actorsprite.h:115
combineDye2
std::string combineDye2(std::string file, const std::string &dye)
Definition: stringutils.cpp:537
FOR_EACH
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
StatusEffectDB::getOpt2Map
const OptionsMap & getOpt2Map()
Definition: statuseffectdb.cpp:217
Image::decRef
void decRef()
Definition: image.cpp:522
mapTileSize
static const int mapTileSize
Definition: map.h:26
Theme::resolveThemePath
static std::string resolveThemePath(const std::string &path)
Definition: theme.cpp:626
ActorSprite::targetCursor
static AnimatedSprite * targetCursor[static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
Definition: actorsprite.h:236
ActorSprite::unload
static void unload()
Definition: actorsprite.cpp:444