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 55 of file actorsprite.h.

Member Typedef Documentation

◆ ActorSpriteListenerIterator

typedef ActorSpriteListeners::iterator ActorSprite::ActorSpriteListenerIterator
protected

Definition at line 253 of file actorsprite.h.

◆ ActorSpriteListeners

Definition at line 252 of file actorsprite.h.

Constructor & Destructor Documentation

◆ ActorSprite()

ActorSprite::ActorSprite ( const BeingId  id)
explicit

Definition at line 69 of file actorsprite.cpp.

69  :
71  Actor(),
73  mStatusParticleEffects(nullptr, true),
75  mHorseId(0),
76  mId(id),
77  mUsedTargetCursor(nullptr),
79  mCursorPaddingX(0),
80  mCursorPaddingY(0),
81  mMustResetParticles(false),
82  mPoison(false),
83  mHaveCart(false),
84  mTrickDead(false)
85 {
86 }
AnimatedSprite * mUsedTargetCursor
Definition: actorsprite.h:250
bool mTrickDead
Definition: actorsprite.h:263
int mCursorPaddingY
Definition: actorsprite.h:257
ParticleList mChildParticleEffects
Definition: actorsprite.h:245
bool mHaveCart
Definition: actorsprite.h:262
ActorSpriteListeners mActorSpriteListeners
Definition: actorsprite.h:254
BeingId mId
Definition: actorsprite.h:247
ParticleVector mStatusParticleEffects
Definition: actorsprite.h:244
bool mMustResetParticles
Definition: actorsprite.h:260
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:242
int mCursorPaddingX
Definition: actorsprite.h:256
Actor()
Definition: actor.cpp:29

◆ ~ActorSprite()

ActorSprite::~ActorSprite ( )

Definition at line 88 of file actorsprite.cpp.

89 {
91  mMustResetParticles = true;
92 
93  mUsedTargetCursor = nullptr;
94 
95  if (localPlayer != nullptr &&
96  localPlayer != this &&
97  localPlayer->getTarget() == this)
98  {
99  localPlayer->setTarget(nullptr);
100  }
101 
102  // Notify listeners of the destruction.
104  {
105  if (reportFalse(*iter))
106  (*iter)->actorSpriteDestroyed(*this);
107  }
108 }
#define reportFalse(val)
Definition: checkutils.h:251
ActorSpriteListeners::iterator ActorSpriteListenerIterator
Definition: actorsprite.h:253
void setTarget(Being *const target)
Being * getTarget() const
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
LocalPlayer * localPlayer

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 454 of file actorsprite.cpp.

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

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 511 of file actorsprite.cpp.

512 {
514  {
515  delete2(targetCursor[type][size])
516  }
518 }
#define end_foreach
Definition: actorsprite.cpp:62
#define for_each_cursors()
Definition: actorsprite.cpp:53
static AnimatedSprite * targetCursor[static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
Definition: actorsprite.h:237
#define delete2(var)
Definition: delete2.h:25
int size()
Definition: emotedb.cpp:306

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 148 of file actorsprite.cpp.

149 {
150  if (particle != nullptr)
151  {
152  particle->setActor(mId);
154  }
155 }
void addLocally(Particle *const particle)
void setActor(const BeingId actor)
Definition: particle.h:244

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 157 of file actorsprite.cpp.

158 {
159  if (particle != nullptr)
160  {
161  // The effect may not die without the beings permission or we segfault
162  particle->disableAutoDelete();
164  }
165 }
void disableAutoDelete()
Definition: particle.h:227

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 167 of file actorsprite.cpp.

168 {
169  if (particle != nullptr)
171 }
void removeLocally(const Particle *const particle)

References mChildParticleEffects, and ParticleList::removeLocally().

Referenced by Particle::~Particle().

◆ getActorX()

int ActorSprite::getActorX ( ) const
inline

Definition at line 160 of file actorsprite.h.

161  { return getPixelX() - mapTileSize / 2; }
int getPixelX() const
Definition: actor.h:87
static const int mapTileSize
Definition: map.h:27

References Actor::getPixelX(), and mapTileSize.

Referenced by FloorItem::draw().

◆ getActorY()

int ActorSprite::getActorY ( ) const
inline

Definition at line 163 of file actorsprite.h.

164  { return getPixelY() - mapTileSize; }
virtual int getPixelY() const
Definition: actor.h:93

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 137 of file actorsprite.h.

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

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 83 of file actorsprite.h.

84  { return BlockType::NONE; }

References BlockType::NONE.

◆ getHaveCart()

bool ActorSprite::getHaveCart ( ) const
inline

Definition at line 175 of file actorsprite.h.

176  { 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 143 of file actorsprite.h.

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

References CompoundSprite::getHeight().

◆ getId()

BeingId ActorSprite::getId ( ) const
inline

Definition at line 64 of file actorsprite.h.

65  { return mId; }

References mId.

Referenced by CharSelectDialog::action(), Being::addToCache(), EAthena::FamilyHandler::askForChild(), LocalPlayer::attack(), Being::botLogic(), EAthena::NpcHandler::buy(), TmwAthena::NpcHandler::buy(), EAthena::VendingHandler::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(), EAthena::CharServerHandler::deleteCharacter(), TmwAthena::CharServerHandler::deleteCharacter(), ActorManager::erase(), ActorManager::findActor(), ActorManager::findBeing(), ActorManager::findItem(), PopupMenu::handleLink(), EAthena::GuildHandler::invite(), EAthena::PartyHandler::invite(), TmwAthena::PartyHandler::invite(), TmwAthena::PartyHandler::inviteResponse(), EAthena::PartyHandler::kick(), TmwAthena::PartyHandler::kick(), EAthena::GuildHandler::leave(), ActorManager::logic(), TargetDebugTab::logic(), EAthena::AdminHandler::mute(), EAthena::BuyingStoreHandler::open(), EAthena::VendingHandler::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(), EAthena::TradeHandler::request(), TmwAthena::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

Definition at line 195 of file actorsprite.h.

196  {
199  }
size_t size() const
Definition: particlelist.h:62
size_t usedSize() const

References mChildParticleEffects, mStatusParticleEffects, ParticleList::size(), and ParticleVector::usedSize().

Referenced by BeingPopup::show().

◆ getPoison()

bool ActorSprite::getPoison ( ) const
inline

Definition at line 169 of file actorsprite.h.

170  { return mPoison; }

References mPoison.

Referenced by SocialPlayersTab::updateAvatar().

◆ getStatusEffects()

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

Definition at line 187 of file actorsprite.h.

188  { return mStatusEffects; }

References mStatusEffects.

◆ getStatusEffectsString()

std::string ActorSprite::getStatusEffectsString ( ) const

Definition at line 520 of file actorsprite.cpp.

521 {
522  std::string effectsStr;
523  if (!mStatusEffects.empty())
524  {
525  FOR_EACH (std::set<int32_t>::const_iterator, it, mStatusEffects)
526  {
527  const StatusEffect *const effect =
529  *it,
530  Enable_true);
531  if (effect == nullptr)
532  continue;
533  if (!effectsStr.empty())
534  effectsStr.append(", ");
535  effectsStr.append(effect->mName);
536  }
537  }
538  return effectsStr;
539 }
std::string mName
Definition: statuseffect.h:83
const bool Enable_true
Definition: enable.h:30
StatusEffect * getStatusEffect(const int index, const Enable enabling)

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 99 of file actorsprite.h.

References TargetCursorSize::MEDIUM.

Referenced by setTargetType().

◆ getTargetOffsetX()

virtual int ActorSprite::getTargetOffsetX ( ) const
inlinevirtual

Reimplemented in Being.

Definition at line 102 of file actorsprite.h.

103  { return 0; }

◆ getTargetOffsetY()

virtual int ActorSprite::getTargetOffsetY ( ) const
inlinevirtual

Reimplemented in Being.

Definition at line 105 of file actorsprite.h.

106  { 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 140 of file actorsprite.h.

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

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 338 of file actorsprite.cpp.

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

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 494 of file actorsprite.cpp.

495 {
496  static const std::string targetCursorFile("target-cursor-%s-%s.xml");
497 
498  // Load target cursors
500  {
503  targetCursorFile.c_str(),
504  cursorType(static_cast<TargetCursorTypeT>(type)),
505  cursorSize(static_cast<TargetCursorSizeT>(size)))),
506  0);
507  }
509 }
static const char * cursorType(const TargetCursorTypeT type)
static const char * cursorSize(const TargetCursorSizeT size)
static AnimatedSprite * load(const std::string &filename, const int variant)
static std::string resolveThemePath(const std::string &path)
Definition: theme.cpp:627
std::string strprintf(const char *const format,...)
TargetCursorSize ::T TargetCursorSizeT
TargetCursorType ::T TargetCursorTypeT

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 184 of file actorsprite.h.

185  { return mTrickDead; }

References mTrickDead.

Referenced by InputManager::updateConditionMask().

◆ load()

void ActorSprite::load ( )
static

Definition at line 435 of file actorsprite.cpp.

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

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

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

◆ logic()

void ActorSprite::logic ( )
virtual

Reimplemented in LocalPlayer, and Being.

Definition at line 110 of file actorsprite.cpp.

111 {
112  BLOCK_START("ActorSprite::logic")
113  // Update sprite animations
115 
116  // Restart status/particle effects, if needed
118  {
119  mMustResetParticles = false;
120  FOR_EACH (std::set<int32_t>::const_iterator, it, mStatusEffects)
121  {
122  const StatusEffect *const effect
124  if (effect != nullptr &&
125  effect->mIsPersistent)
126  {
127  updateStatusEffect(*it,
128  Enable_true,
129  IsStart_false);
130  }
131  }
132  }
133 
134  // Update particle effects
136  BLOCK_END("ActorSprite::logic")
137 }
virtual void updateStatusEffect(const int32_t index, const Enable newStatus, const IsStart start)
Vector mPos
Definition: actor.h:140
bool update(const int time)
void moveTo(const float x, const float y)
bool mIsPersistent
Definition: statuseffect.h:84
float y
Definition: vector.h:209
float x
Definition: vector.h:209
static const int MILLISECONDS_IN_A_TICK
Definition: timer.h:30
if(!vert) return
const bool IsStart_false
Definition: isstart.h:30
volatile int tick_time
Definition: timer.cpp:53
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

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 459 of file actorsprite.cpp.

461 {
463 }

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 134 of file actorsprite.h.

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

References CompoundSprite::setAlpha().

◆ setHaveCart()

void ActorSprite::setHaveCart ( const bool  b)
inline

Definition at line 172 of file actorsprite.h.

173  { mHaveCart = b; }

References mHaveCart.

Referenced by updateStatusEffect().

◆ setId()

void ActorSprite::setId ( const BeingId  id)
inline

Definition at line 67 of file actorsprite.h.

68  { 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 LocalPlayer, and Being.

Definition at line 139 of file actorsprite.cpp.

140 {
141  Actor::setMap(map);
142 
143  // Clear particle effect list because child particles became invalid
145  mMustResetParticles = true; // Reset status particles on next redraw
146 }
virtual void setMap(Map *const map)
Definition: actor.cpp:48

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 166 of file actorsprite.h.

167  { mPoison = b; }

References mPoison.

Referenced by updateStatusEffect().

◆ setRiding()

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

Reimplemented in Being.

Definition at line 178 of file actorsprite.h.

179  { 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 198 of file actorsprite.cpp.

201 {
202  const Enable wasActive = fromBool(
203  mStatusEffects.find(index) != mStatusEffects.end(), Enable);
204 
205  if (active != wasActive)
206  {
207  updateStatusEffect(index, active, start);
208  if (active == Enable_true)
209  {
210  mStatusEffects.insert(index);
211  }
212  else
213  {
214  mStatusEffects.erase(index);
215  }
216  }
217 }
#define fromBool(val, name)
Definition: booldefines.h:49
bool Enable
Definition: enable.h:30

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

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

◆ setStatusEffectOpiton0()

void ActorSprite::setStatusEffectOpiton0 ( const uint32_t  option)

Definition at line 311 of file actorsprite.cpp.

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

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 
)

Definition at line 299 of file actorsprite.cpp.

302 {
303  applyEffectByOption(this, option, "option",
305  applyEffectByOption1(this, opt1, "opt1",
307  applyEffectByOption(this, opt2, "opt2",
309 }
static void applyEffectByOption1(ActorSprite *const actor, uint32_t option, const char *const name, const OptionsMap &options)
const OptionsMap & getOpt2Map()
const OptionsMap & getOpt1Map()

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

◆ 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 173 of file actorsprite.cpp.

174 {
175  if (type == TargetCursorType::NONE)
176  {
177  untarget();
178  }
179  else
180  {
181  const size_t sz = CAST_SIZE(getTargetCursorSize());
183  if (mUsedTargetCursor != nullptr)
184  {
185  static const int targetWidths[CAST_SIZE(
187  = {0, 0, 0};
188  static const int targetHeights[CAST_SIZE(
190  = {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize};
191 
192  mCursorPaddingX = CAST_S32(targetWidths[sz]);
193  mCursorPaddingY = CAST_S32(targetHeights[sz]);
194  }
195  }
196 }
#define CAST_S32
Definition: cast.h:30
#define CAST_SIZE
Definition: cast.h:34
virtual TargetCursorSizeT getTargetCursorSize() const
Definition: actorsprite.h:99
void untarget()
Definition: actorsprite.h:116

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 181 of file actorsprite.h.

182  { 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 365 of file actorsprite.cpp.

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

References ParticleEngine::addEffect(), CompoundSprite::addSprite(), CompoundSprite::clear(), ParticleContainer::clear(), combineDye2(), combineDye3(), controlAutoParticle(), 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 192 of file actorsprite.h.

193  { }

Referenced by updateStatusEffect().

◆ unload()

void ActorSprite::unload ( )
static

Definition at line 445 of file actorsprite.cpp.

446 {
447  if (reportTrue(!loaded))
448  return;
449 
451  loaded = false;
452 }
#define reportTrue(val)
Definition: checkutils.h:252
static void cleanupTargetCursors()

References cleanupTargetCursors(), loaded, and reportTrue.

Referenced by load().

◆ untarget()

void ActorSprite::untarget ( )
inline

Untargets the actor.

Definition at line 116 of file actorsprite.h.

117  { 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 317 of file actorsprite.cpp.

320 {
322  index, newStatus);
323  if (effect == nullptr)
324  return;
325  if (effect->mIsPoison && getType() == ActorType::Player)
326  setPoison(newStatus == Enable_true);
327  else if (effect->mIsCart && localPlayer == this)
328  setHaveCart(newStatus == Enable_true);
329  else if (effect->mIsRiding)
330  setRiding(newStatus == Enable_true);
331  else if (effect->mIsTrickDead)
332  setTrickDead(newStatus == Enable_true);
333  else if (effect->mIsPostDelay)
334  stopCast(newStatus == Enable_true);
335  handleStatusEffect(effect, index, newStatus, start);
336 }
void setPoison(const bool b)
Definition: actorsprite.h:166
virtual void setRiding(const bool b)
Definition: actorsprite.h:178
virtual ActorTypeT getType() const
Definition: actorsprite.h:73
virtual void stopCast(const bool b)
Definition: actorsprite.h:192
virtual void setTrickDead(const bool b)
Definition: actorsprite.h:181
virtual void handleStatusEffect(const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
void setHaveCart(const bool b)
Definition: actorsprite.h:172
bool mIsPostDelay
Definition: statuseffect.h:89
bool mIsTrickDead
Definition: statuseffect.h:88

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 239 of file actorsprite.h.

Referenced by load(), and unload().

◆ mActorSpriteListeners

ActorSpriteListeners ActorSprite::mActorSpriteListeners
protected

Definition at line 254 of file actorsprite.h.

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

◆ mChildParticleEffects

ParticleList ActorSprite::mChildParticleEffects
protected

◆ mCursorPaddingX

int ActorSprite::mCursorPaddingX
protected

Definition at line 256 of file actorsprite.h.

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

◆ mCursorPaddingY

int ActorSprite::mCursorPaddingY
protected

Definition at line 257 of file actorsprite.h.

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

◆ mHaveCart

bool ActorSprite::mHaveCart
protected

Definition at line 262 of file actorsprite.h.

Referenced by getHaveCart(), and setHaveCart().

◆ mHorseId

int ActorSprite::mHorseId
protected

Definition at line 246 of file actorsprite.h.

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

◆ mId

BeingId ActorSprite::mId
protected

Definition at line 247 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 260 of file actorsprite.h.

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

◆ mPoison

bool ActorSprite::mPoison
protected

Definition at line 261 of file actorsprite.h.

Referenced by getPoison(), and setPoison().

◆ mStatusEffects

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

Definition at line 242 of file actorsprite.h.

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

◆ mStatusParticleEffects

ParticleVector ActorSprite::mStatusParticleEffects
protected

Definition at line 244 of file actorsprite.h.

Referenced by getParticlesCount(), and handleStatusEffect().

◆ mTrickDead

bool ActorSprite::mTrickDead
protected

Definition at line 263 of file actorsprite.h.

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

◆ mUsedTargetCursor

AnimatedSprite* ActorSprite::mUsedTargetCursor
protected

Target cursor being used

Definition at line 250 of file actorsprite.h.

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

◆ targetCursor

AnimatedSprite * ActorSprite::targetCursor
staticprotected

Animated target cursors.

Definition at line 235 of file actorsprite.h.

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


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