~ubuntu-branches/ubuntu/trusty/manaplus/trusty-proposed

« back to all changes in this revision

Viewing changes to src/being.h

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-09-17 10:35:51 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130917103551-az7p3nz9jgxwqjfn
Tags: 1.3.9.15-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  The ManaPlus Client
3
 
 *  Copyright (C) 2004-2009  The Mana World Development Team
4
 
 *  Copyright (C) 2009-2010  The Mana Developers
5
 
 *  Copyright (C) 2011-2013  The ManaPlus Developers
6
 
 *
7
 
 *  This file is part of The ManaPlus Client.
8
 
 *
9
 
 *  This program is free software; you can redistribute it and/or modify
10
 
 *  it under the terms of the GNU General Public License as published by
11
 
 *  the Free Software Foundation; either version 2 of the License, or
12
 
 *  any later version.
13
 
 *
14
 
 *  This program is distributed in the hope that it will be useful,
15
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 *  GNU General Public License for more details.
18
 
 *
19
 
 *  You should have received a copy of the GNU General Public License
20
 
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 
 */
22
 
 
23
 
#ifndef BEING_H
24
 
#define BEING_H
25
 
 
26
 
#include "equipment.h"
27
 
 
28
 
#include "resources/beinginfo.h"
29
 
 
30
 
#include <guichan/color.hpp>
31
 
 
32
 
#include <SDL_types.h>
33
 
 
34
 
#include <map>
35
 
#include <set>
36
 
 
37
 
#include "localconsts.h"
38
 
 
39
 
static const unsigned int FIRST_IGNORE_EMOTE = 14;
40
 
static const unsigned int STATUS_EFFECTS = 32;
41
 
 
42
 
static const unsigned int SPEECH_TIME = 500;
43
 
static const unsigned int SPEECH_MIN_TIME = 200;
44
 
static const unsigned int SPEECH_MAX_TIME = 800;
45
 
 
46
 
static const int DEFAULT_BEING_WIDTH = 32;
47
 
static const int DEFAULT_BEING_HEIGHT = 32;
48
 
 
49
 
class AnimatedSprite;
50
 
class BeingCacheEntry;
51
 
class Being;
52
 
class FlashText;
53
 
class Guild;
54
 
class Inventory;
55
 
class ItemInfo;
56
 
class Item;
57
 
class Particle;
58
 
class Party;
59
 
class SpeechBubble;
60
 
class Text;
61
 
 
62
 
struct Position;
63
 
 
64
 
extern volatile int cur_time;
65
 
 
66
 
enum Gender
67
 
{
68
 
    GENDER_MALE = 0,
69
 
    GENDER_FEMALE = 1,
70
 
    GENDER_UNSPECIFIED = 2,
71
 
    GENDER_OTHER = 3
72
 
};
73
 
 
74
 
 
75
 
struct NextSoundInfo
76
 
{
77
 
    NextSoundInfo() :
78
 
        sound(nullptr),
79
 
        x(0),
80
 
        y(0),
81
 
        time(0)
82
 
    {
83
 
    }
84
 
 
85
 
    const SoundInfo *sound;
86
 
    int x;
87
 
    int y;
88
 
    int time;
89
 
};
90
 
 
91
 
class Being : public ActorSprite, public ConfigListener
92
 
{
93
 
    public:
94
 
        friend class BeingEquipBackend;
95
 
        friend class LocalPlayer;
96
 
 
97
 
        enum FLAGS
98
 
        {
99
 
            FLAG_SHOP = 1,
100
 
            FLAG_AWAY = 2,
101
 
            FLAG_INACTIVE = 4,
102
 
            FLAG_GENDER_OTHER = 32,
103
 
            FLAG_GM = 64,
104
 
            FLAG_GENDER_MALE = 128,
105
 
            FLAG_SPECIAL = 128 + 64
106
 
        };
107
 
 
108
 
        /**
109
 
         * Action the being is currently performing
110
 
         * WARNING: Has to be in sync with the same enum in the Being class
111
 
         * of the server!
112
 
         */
113
 
        enum Action
114
 
        {
115
 
            STAND = 0,
116
 
            MOVE,
117
 
            ATTACK,
118
 
            SIT,
119
 
            DEAD,
120
 
            HURT,
121
 
            SPAWN
122
 
        };
123
 
 
124
 
        enum Speech
125
 
        {
126
 
            NO_SPEECH = 0,
127
 
            TEXT_OVERHEAD,
128
 
            NO_NAME_IN_BUBBLE,
129
 
            NAME_IN_BUBBLE
130
 
        };
131
 
 
132
 
        enum AttackType
133
 
        {
134
 
            HIT = 0x00,
135
 
            CRITICAL = 0x0a,
136
 
            MULTI = 0x08,
137
 
            REFLECT = 0x04,
138
 
            FLEE = 0x0b,
139
 
            SKILL = 0xff,
140
 
            MISS = 0xffff   // pseudo value for miss attacks
141
 
        };
142
 
 
143
 
        enum Reachable
144
 
        {
145
 
            REACH_UNKNOWN = 0,
146
 
            REACH_YES = 1,
147
 
            REACH_NO = 2
148
 
        };
149
 
 
150
 
        /**
151
 
         * Directions, to be used as bitmask values
152
 
         */
153
 
        enum BeingDirection
154
 
        {
155
 
            DOWN = 1,
156
 
            LEFT = 2,
157
 
            UP = 4,
158
 
            RIGHT = 8
159
 
        };
160
 
 
161
 
        /**
162
 
         * Constructor.
163
 
         *
164
 
         * @param id      a unique being id
165
 
         * @param subtype partly determines the type of the being
166
 
         * @param map     the map the being is on
167
 
         */
168
 
        Being(const int id, const Type type, const uint16_t subtype,
169
 
              Map *const map);
170
 
 
171
 
        A_DELETE_COPY(Being)
172
 
 
173
 
        virtual ~Being();
174
 
 
175
 
        Type getType() const A_WARN_UNUSED
176
 
        { return mType; }
177
 
 
178
 
        /**
179
 
         * Removes all path nodes from this being.
180
 
         */
181
 
        void clearPath();
182
 
 
183
 
        /**
184
 
         * Returns the time spent in the current action.
185
 
         */
186
 
        int getActionTime() const A_WARN_UNUSED
187
 
        { return mActionTime; }
188
 
 
189
 
        /**
190
 
         * Set the current action time.
191
 
         * @see Ea::BeingHandler that set it to tick time.
192
 
         */
193
 
        void setActionTime(const int actionTime)
194
 
        { mActionTime = actionTime; }
195
 
 
196
 
        /**
197
 
         * Makes this being take the next tile of its path.
198
 
         * TODO: Used by eAthena only?
199
 
         */
200
 
        virtual void nextTile();
201
 
 
202
 
        /**
203
 
         * Get the current X pixel offset.
204
 
         * TODO: Used by eAthena only?
205
 
         */
206
 
        int getXOffset() const A_WARN_UNUSED
207
 
        { return getOffset(LEFT, RIGHT); }
208
 
 
209
 
        /**
210
 
         * Get the current Y pixel offset.
211
 
         * TODO: Used by eAthena only?
212
 
         */
213
 
        int getYOffset() const A_WARN_UNUSED
214
 
        { return getOffset(UP, DOWN); }
215
 
 
216
 
        /**
217
 
         * Creates a path for the being from current position to ex and ey
218
 
         */
219
 
        void setDestination(const int dstX, const int dstY);
220
 
 
221
 
        /**
222
 
         * Returns the destination for this being.
223
 
         */
224
 
        const Vector &getDestination() const A_WARN_UNUSED
225
 
        { return mDest; }
226
 
 
227
 
        /**
228
 
         * Returns the tile x coord
229
 
         */
230
 
        int getTileX() const A_WARN_UNUSED
231
 
        { return mX; }
232
 
 
233
 
        /**
234
 
         * Returns the tile y coord
235
 
         */
236
 
        int getTileY() const A_WARN_UNUSED
237
 
        { return mY; }
238
 
 
239
 
        /**
240
 
         * Sets the tile x and y coord
241
 
         */
242
 
        void setTileCoords(const int x, const int y)
243
 
        { mX = x; mY = y; }
244
 
 
245
 
        /**
246
 
         * Puts a "speech balloon" above this being for the specified amount
247
 
         * of time.
248
 
         *
249
 
         * @param text The text that should appear.
250
 
         * @param time The amount of time the text should stay in milliseconds.
251
 
         */
252
 
        void setSpeech(const std::string &text,
253
 
                       const std::string &channel = "",
254
 
                       int time = 0);
255
 
 
256
 
        /**
257
 
         * Puts a damage bubble above this being.
258
 
         *
259
 
         * @param attacker the attacking being
260
 
         * @param damage the amount of damage recieved (0 means miss)
261
 
         * @param type the attack type
262
 
         * @param id skill id
263
 
         */
264
 
        void takeDamage(Being *const attacker, const int damage,
265
 
                        const AttackType type, const int attackId = 1);
266
 
 
267
 
        /**
268
 
         * Handles an attack of another being by this being.
269
 
         *
270
 
         * @param victim the victim being
271
 
         * @param damage the amount of damage dealt (0 means miss)
272
 
         * @param type the attack type
273
 
         */
274
 
        void handleAttack(Being *const victim, const int damage,
275
 
                          const int attackId = 1);
276
 
 
277
 
        virtual void handleSkill(Being *const victim, const int damage,
278
 
                                 const int skillId, const int skillLevel);
279
 
 
280
 
        const ItemInfo *getEquippedWeapon() const A_WARN_UNUSED
281
 
        { return mEquippedWeapon; }
282
 
 
283
 
        /**
284
 
         * Returns the name of the being.
285
 
         */
286
 
        const std::string &getName() const A_WARN_UNUSED
287
 
        { return mName; }
288
 
 
289
 
        /**
290
 
         * Sets the name for the being.
291
 
         *
292
 
         * @param name The name that should appear.
293
 
         */
294
 
        void setName(const std::string &name);
295
 
 
296
 
        bool getShowName() const A_WARN_UNUSED
297
 
        { return mShowName; }
298
 
 
299
 
        void setShowName(const bool doShowName);
300
 
 
301
 
        /**
302
 
         * Sets the name of the party the being is in. Shown in BeingPopup.
303
 
         */
304
 
        void setPartyName(const std::string &name)
305
 
        { mPartyName = name; }
306
 
 
307
 
        const std::string &getPartyName() const A_WARN_UNUSED
308
 
        { return mPartyName; }
309
 
 
310
 
        const std::string &getGuildName() const A_WARN_UNUSED
311
 
        { return mGuildName; }
312
 
 
313
 
        /**
314
 
         * Sets the name of the primary guild the being is in. Shown in
315
 
         * BeingPopup (eventually).
316
 
         */
317
 
        void setGuildName(const std::string &name);
318
 
 
319
 
        void setGuildPos(const std::string &pos);
320
 
 
321
 
        /**
322
 
         * Adds a guild to the being.
323
 
         */
324
 
        void addGuild(Guild *const guild);
325
 
 
326
 
        /**
327
 
         * Removers a guild from the being.
328
 
         */
329
 
        void removeGuild(const int id);
330
 
 
331
 
        /**
332
 
         * Returns a pointer to the specified guild that the being is in.
333
 
         */
334
 
        Guild *getGuild(const std::string &guildName) const A_WARN_UNUSED;
335
 
 
336
 
        /**
337
 
         * Returns a pointer to the specified guild that the being is in.
338
 
         */
339
 
        Guild *getGuild(const int id) const A_WARN_UNUSED;
340
 
 
341
 
        /**
342
 
         * Returns a pointer to the specified guild that the being is in.
343
 
         */
344
 
        Guild *getGuild() const A_WARN_UNUSED;
345
 
 
346
 
        /**
347
 
         * Returns all guilds the being is in.
348
 
         */
349
 
        const std::map<int, Guild*> &getGuilds() const A_WARN_UNUSED
350
 
        { return mGuilds; }
351
 
 
352
 
        /**
353
 
         * Removes all guilds the being is in.
354
 
         */
355
 
        void clearGuilds();
356
 
 
357
 
        /**
358
 
         * Get number of guilds the being belongs to.
359
 
         */
360
 
        int16_t getNumberOfGuilds() const A_WARN_UNUSED
361
 
        { return static_cast<int16_t>(mGuilds.size()); }
362
 
 
363
 
        bool isInParty() const A_WARN_UNUSED
364
 
        { return mParty; }
365
 
 
366
 
        void setParty(Party *const party);
367
 
 
368
 
        void setGuild(Guild *const guild);
369
 
 
370
 
        void updateGuild();
371
 
 
372
 
        Party *getParty() const A_WARN_UNUSED
373
 
        { return mParty; }
374
 
 
375
 
        int getSpritesCount() const A_WARN_UNUSED
376
 
        { return static_cast<int>(size()); }
377
 
 
378
 
        /**
379
 
         * Sets visible equipments for this being.
380
 
         */
381
 
        void setSprite(const unsigned int slot, const int id,
382
 
                       std::string color = "",
383
 
                       const unsigned char colorId = 1,
384
 
                       const bool isWeapon = false,
385
 
                       const bool isTempSprite = false);
386
 
 
387
 
        void setSpriteID(const unsigned int slot, const int id);
388
 
 
389
 
        void setSpriteColor(const unsigned int slot,
390
 
                            const std::string &color = "");
391
 
 
392
 
        /**
393
 
         * Get the number of hairstyles implemented
394
 
         */
395
 
        static int getNumOfHairstyles() A_WARN_UNUSED
396
 
        { return mNumberOfHairstyles; }
397
 
 
398
 
        /**
399
 
         * Get the number of races implemented
400
 
         */
401
 
        static int getNumOfRaces() A_WARN_UNUSED
402
 
        { return mNumberOfRaces; }
403
 
 
404
 
        /**
405
 
         * Get the number of layers used to draw the being
406
 
         */
407
 
        int getNumberOfLayers() const A_WARN_UNUSED
408
 
        { return CompoundSprite::getNumberOfLayers(); }
409
 
 
410
 
        /**
411
 
         * Performs being logic.
412
 
         */
413
 
        virtual void logic() override;
414
 
 
415
 
        /**
416
 
         * Draws the speech text above the being.
417
 
         */
418
 
        void drawSpeech(const int offsetX, const int offsetY);
419
 
 
420
 
        /**
421
 
         * Draws the emotion picture above the being.
422
 
         */
423
 
        void drawEmotion(Graphics *const graphics, const int offsetX,
424
 
                         const int offsetY);
425
 
 
426
 
        uint16_t getSubType() const
427
 
        { return mSubType; }
428
 
 
429
 
         /**
430
 
          * Set Being's subtype (mostly for view for monsters and NPCs)
431
 
          */
432
 
        void setSubtype(const uint16_t subtype, const uint8_t look);
433
 
 
434
 
        const BeingInfo *getInfo() const A_WARN_UNUSED
435
 
        { return mInfo; }
436
 
 
437
 
        TargetCursorSize getTargetCursorSize() const A_WARN_UNUSED;
438
 
 
439
 
        int getTargetOffsetX() const A_WARN_UNUSED
440
 
        {
441
 
            if (!mInfo)
442
 
                return 0;
443
 
            return mInfo->getTargetOffsetX();
444
 
        }
445
 
 
446
 
        int getTargetOffsetY() const A_WARN_UNUSED
447
 
        {
448
 
            if (!mInfo)
449
 
                return 0;
450
 
            return mInfo->getTargetOffsetY();
451
 
        }
452
 
 
453
 
        /**
454
 
         * Gets the way the object is blocked by other objects.
455
 
         */
456
 
        virtual unsigned char getWalkMask() const A_WARN_UNUSED
457
 
        {
458
 
            if (!mInfo)
459
 
                return 0;
460
 
            return mInfo->getWalkMask();
461
 
        }
462
 
 
463
 
        /**
464
 
         * Gets the way the monster blocks pathfinding for other objects
465
 
         */
466
 
        Map::BlockType getBlockType() const A_WARN_UNUSED
467
 
        {
468
 
            if (!mInfo)
469
 
                return Map::BLOCKTYPE_NONE;
470
 
            return mInfo->getBlockType();
471
 
        }
472
 
 
473
 
        /**
474
 
         * Sets the walk speed.
475
 
         * in pixels per second for eAthena,
476
 
         * in tiles per second for Manaserv.
477
 
         */
478
 
        void setWalkSpeed(const Vector &speed)
479
 
        { mWalkSpeed = speed; }
480
 
 
481
 
        /**
482
 
         * Gets the walk speed.
483
 
         * in pixels per second for eAthena,
484
 
         * in tiles per second for Manaserv (0.1 precision).
485
 
         */
486
 
        Vector getWalkSpeed() const A_WARN_UNUSED
487
 
        { return mWalkSpeed; }
488
 
 
489
 
        /**
490
 
         * Sets the attack speed.
491
 
         * @todo In what unit?
492
 
         */
493
 
        void setAttackSpeed(const int speed)
494
 
        { mAttackSpeed = speed; }
495
 
 
496
 
        /**
497
 
         * Gets the attack speed.
498
 
         * @todo In what unit?
499
 
         */
500
 
        int getAttackSpeed() const A_WARN_UNUSED
501
 
        { return mAttackSpeed; }
502
 
 
503
 
        /**
504
 
         * Sets the current action.
505
 
         */
506
 
        virtual void setAction(const Action &action, const int attackType = 0);
507
 
 
508
 
        /**
509
 
         * Get the being's action currently performed.
510
 
         */
511
 
        Action getCurrentAction() const A_WARN_UNUSED
512
 
        { return mAction; }
513
 
 
514
 
        /**
515
 
         * Returns whether this being is still alive.
516
 
         */
517
 
        bool isAlive() const A_WARN_UNUSED
518
 
        { return mAction != DEAD; }
519
 
 
520
 
        /**
521
 
         * Returns the current direction.
522
 
         */
523
 
        uint8_t getDirection() const A_WARN_UNUSED
524
 
        { return mDirection; }
525
 
 
526
 
        /**
527
 
         * Sets the current direction.
528
 
         */
529
 
        virtual void setDirection(const uint8_t direction);
530
 
 
531
 
        virtual void setDirectionDelayed(const uint8_t direction)
532
 
        { mDirectionDelayed = direction; }
533
 
 
534
 
        uint8_t getDirectionDelayed() const A_WARN_UNUSED
535
 
        { return mDirectionDelayed; }
536
 
 
537
 
        /**
538
 
         * Returns the direction the being is facing.
539
 
         */
540
 
        SpriteDirection getSpriteDirection() const A_WARN_UNUSED
541
 
        { return static_cast<SpriteDirection>(mSpriteDirection); }
542
 
 
543
 
        void setPosition(const Vector &pos);
544
 
 
545
 
        /**
546
 
         * Overloaded method provided for convenience.
547
 
         *
548
 
         * @see setPosition(const Vector &pos)
549
 
         */
550
 
        inline void setPosition(const float x, const float y,
551
 
                                const float z = 0.0f)
552
 
        { setPosition(Vector(x, y, z)); }
553
 
 
554
 
        /**
555
 
         * Returns the horizontal size of the current base sprite of the being.
556
 
         */
557
 
        virtual int getWidth() const override A_WARN_UNUSED
558
 
        { return std::max(CompoundSprite::getWidth(), DEFAULT_BEING_WIDTH); }
559
 
 
560
 
        /**
561
 
         * Returns the vertical size of the current base sprite of the being.
562
 
         */
563
 
        virtual int getHeight() const override A_WARN_UNUSED
564
 
        { return std::max(CompoundSprite::getHeight(), DEFAULT_BEING_HEIGHT); }
565
 
 
566
 
        /**
567
 
         * Returns the being's pixel radius used to detect collisions.
568
 
         */
569
 
        virtual int getCollisionRadius() const A_WARN_UNUSED
570
 
        { return 16; }
571
 
 
572
 
        /**
573
 
         * Shoots a missile particle from this being, to target being
574
 
         */
575
 
        void fireMissile(Being *const target,
576
 
                         const std::string &particle) const;
577
 
 
578
 
        /**
579
 
         * Returns the path this being is following. An empty path is returned
580
 
         * when this being isn't following any path currently.
581
 
         */
582
 
        const Path &getPath() const A_WARN_UNUSED
583
 
        { return mPath; }
584
 
 
585
 
        int getDistance() const A_WARN_UNUSED
586
 
        { return mDistance; }
587
 
 
588
 
        void setDistance(const int n)
589
 
        { mDistance = n; }
590
 
 
591
 
        /**
592
 
         * Set the Emoticon type and time displayed above
593
 
         * the being.
594
 
         */
595
 
        void setEmote(const uint8_t emotion, const int emote_time);
596
 
 
597
 
        void setState(const uint8_t state);
598
 
 
599
 
        virtual void drawSprites(Graphics *const  graphics,
600
 
                                 int posX, int posY) const override;
601
 
 
602
 
        virtual void drawSpritesSDL(Graphics *const graphics,
603
 
                                    int posX, int posY) const override;
604
 
 
605
 
        void drawHpBar(Graphics *const graphics, const int x, const int y,
606
 
                       const int maxHP, const int hp, const int damage,
607
 
                       const int color1, const int color2, const int width,
608
 
                       const int height) const;
609
 
 
610
 
        static void load();
611
 
 
612
 
        virtual void optionChanged(const std::string &value) override;
613
 
 
614
 
        void flashName(const int time);
615
 
 
616
 
        int getDamageTaken() const A_WARN_UNUSED
617
 
        { return mDamageTaken; }
618
 
 
619
 
        void setDamageTaken(const int damage)
620
 
        { mDamageTaken = damage; }
621
 
 
622
 
        void updateName();
623
 
 
624
 
        void setLevel(const int n)
625
 
        { mLevel = n; }
626
 
 
627
 
        virtual int getLevel() const A_WARN_UNUSED
628
 
        { return mLevel; }
629
 
 
630
 
        void setIsReachable(const int n)
631
 
        { mIsReachable = n; }
632
 
 
633
 
        int isReachable() const A_WARN_UNUSED
634
 
        { return mIsReachable; }
635
 
 
636
 
        static void reReadConfig();
637
 
 
638
 
        static BeingCacheEntry* getCacheEntry(const int id) A_WARN_UNUSED;
639
 
 
640
 
        void addToCache() const;
641
 
 
642
 
        bool updateFromCache();
643
 
 
644
 
        /**
645
 
         * Sets the gender of this being.
646
 
         */
647
 
        virtual void setGender(const Gender gender);
648
 
 
649
 
        Gender getGender() const A_WARN_UNUSED
650
 
        { return mGender; }
651
 
 
652
 
        /**
653
 
         * Return sprite sit action for current environment.
654
 
         */
655
 
        std::string getSitAction() const A_WARN_UNUSED;
656
 
 
657
 
        std::string getMoveAction() const A_WARN_UNUSED;
658
 
 
659
 
        std::string getDeadAction() const A_WARN_UNUSED;
660
 
 
661
 
        std::string getStandAction() const A_WARN_UNUSED;
662
 
 
663
 
        std::string getSpawnAction() const A_WARN_UNUSED;
664
 
 
665
 
        std::string getWeaponAttackAction(const ItemInfo *const weapon) const;
666
 
 
667
 
        std::string getAttackAction(const Attack *const attack) const;
668
 
 
669
 
        /**
670
 
         * Whether or not this player is a GM.
671
 
         */
672
 
        bool isGM() const A_WARN_UNUSED
673
 
        { return mIsGM; }
674
 
 
675
 
        /**
676
 
         * Triggers whether or not to show the name as a GM name.
677
 
         */
678
 
        void setGM(const bool gm);
679
 
 
680
 
        bool canTalk() const A_WARN_UNUSED
681
 
        { return mType == NPC; }
682
 
 
683
 
        void talkTo() const;
684
 
 
685
 
        bool draw(Graphics *const graphics,
686
 
                  const int offsetX, const int offsetY) const override;
687
 
 
688
 
        bool drawSpriteAt(Graphics *const graphics,
689
 
                          const int x, const int y) const;
690
 
 
691
 
        void setMoveTime()
692
 
        { mMoveTime = cur_time; }
693
 
 
694
 
        void setAttackTime()
695
 
        { mAttackTime = cur_time; }
696
 
 
697
 
        void setTalkTime()
698
 
        { mTalkTime = cur_time; }
699
 
 
700
 
        void setTestTime()
701
 
        { mTestTime = cur_time; }
702
 
 
703
 
        void setOtherTime()
704
 
        { mOtherTime = cur_time; }
705
 
 
706
 
        unsigned int getMoveTime() const
707
 
        { return mMoveTime; }
708
 
 
709
 
        unsigned int getAttackTime() const
710
 
        { return mAttackTime; }
711
 
 
712
 
        unsigned int getTalkTime() const
713
 
        { return mTalkTime; }
714
 
 
715
 
        unsigned int getTestTime() const
716
 
        { return mTestTime; }
717
 
 
718
 
        unsigned int getOtherTime() const
719
 
        { return mOtherTime; }
720
 
 
721
 
        void resetCounters();
722
 
 
723
 
        virtual void updateColors();
724
 
 
725
 
        void setEnemy(const bool n)
726
 
        { mEnemy = n; }
727
 
 
728
 
        const std::string &getIp() const A_WARN_UNUSED
729
 
        { return mIp; }
730
 
 
731
 
        void setIp(std::string ip)
732
 
        { mIp = ip; }
733
 
 
734
 
        unsigned int getPvpRank() const A_WARN_UNUSED
735
 
        { return mPvpRank; }
736
 
 
737
 
        void setPvpRank(const unsigned int rank)
738
 
        { mPvpRank = rank; }
739
 
 
740
 
        void setHP(const int n);
741
 
 
742
 
        void setMaxHP(const int hp);
743
 
 
744
 
        int getHP() const A_WARN_UNUSED
745
 
        { return mHP; }
746
 
 
747
 
        uint8_t calcDirection(const int dstX,
748
 
                              const int dstY) const A_WARN_UNUSED;
749
 
 
750
 
        uint8_t calcDirection() const A_WARN_UNUSED;
751
 
 
752
 
        void setAttackDelay(const int n)
753
 
        { mAttackDelay = n; }
754
 
 
755
 
        int getAttackDelay() const A_WARN_UNUSED
756
 
        { return mAttackDelay; }
757
 
 
758
 
        int getMinHit() const A_WARN_UNUSED
759
 
        { return mMinHit; }
760
 
 
761
 
        void setMinHit(const int n)
762
 
        { mMinHit = n; }
763
 
 
764
 
        int getMaxHit() const A_WARN_UNUSED
765
 
        { return mMaxHit; }
766
 
 
767
 
        void setMaxHit(const int n)
768
 
        { mMaxHit = n; }
769
 
 
770
 
        int getCriticalHit() const A_WARN_UNUSED
771
 
        { return mCriticalHit; }
772
 
 
773
 
        void setCriticalHit(const int n)
774
 
        { mCriticalHit = n; }
775
 
 
776
 
        void updateHit(const int amount);
777
 
 
778
 
        Equipment *getEquipment() A_WARN_UNUSED;
779
 
 
780
 
        void undressItemById(const int id);
781
 
 
782
 
        int getGoodStatus() const A_WARN_UNUSED
783
 
        { return mGoodStatus; }
784
 
 
785
 
        void setGoodStatus(const int n)
786
 
        { mGoodStatus = n; }
787
 
 
788
 
        std::string getGenderSign() const A_WARN_UNUSED;
789
 
 
790
 
        std::string getGenderSignWithSpace() const A_WARN_UNUSED;
791
 
 
792
 
        void updateComment();
793
 
 
794
 
        const std::string getComment() const A_WARN_UNUSED
795
 
        { return mComment; }
796
 
 
797
 
        void setComment(std::string n)
798
 
        { mComment = n; }
799
 
 
800
 
        static void clearCache();
801
 
 
802
 
        static std::string loadComment(const std::string &name,
803
 
                                       const int type) A_WARN_UNUSED;
804
 
 
805
 
        static void saveComment(const std::string &name,
806
 
                                const std::string &comment, const int type);
807
 
 
808
 
        bool isAdvanced() const A_WARN_UNUSED
809
 
        { return mAdvanced; }
810
 
 
811
 
        void setAdvanced(const bool n)
812
 
        { mAdvanced = n; addToCache(); }
813
 
 
814
 
        bool isShopEnabled() const A_WARN_UNUSED
815
 
        { return mShop; }
816
 
 
817
 
        void enableShop(const bool b)
818
 
        { mShop = b; }
819
 
 
820
 
        /**
821
 
         * Sets the attack range.
822
 
         */
823
 
        void setAttackRange(const int range)
824
 
        { mAttackRange = range; }
825
 
 
826
 
        void attack(Being *target = nullptr, bool keep = false,
827
 
                    bool dontChangeEquipment = false);
828
 
 
829
 
        void attack2(Being *target = nullptr, bool keep = false,
830
 
                     bool dontChangeEquipment = false);
831
 
 
832
 
        void updatePercentHP();
833
 
 
834
 
        void setRaceName(std::string name)
835
 
        { mRaceName = name; }
836
 
 
837
 
        std::string getRaceName() const A_WARN_UNUSED
838
 
        { return mRaceName; }
839
 
 
840
 
        int getSpriteID(const int slot) const A_WARN_UNUSED;
841
 
 
842
 
        void setHairStyle(const unsigned int slot, const int id);
843
 
 
844
 
        void setHairColor(const unsigned int slot,
845
 
                          const unsigned char color);
846
 
 
847
 
        void setHairColor(const unsigned char color)
848
 
        { mHairColor = color; }
849
 
 
850
 
        unsigned char getHairColor() const A_WARN_UNUSED
851
 
        { return mHairColor; }
852
 
 
853
 
        void recalcSpritesOrder();
854
 
 
855
 
        int getHitEffect(const Being *const attacker,
856
 
                         const AttackType type,
857
 
                         const int attackId) const A_WARN_UNUSED;
858
 
 
859
 
        Cursor::Cursor getHoverCursor() const A_WARN_UNUSED
860
 
        { return mInfo ? mInfo->getHoverCursor() : Cursor::CURSOR_POINTER; }
861
 
 
862
 
        void addAfkEffect();
863
 
 
864
 
        void removeAfkEffect();
865
 
 
866
 
        void updateAwayEffect();
867
 
 
868
 
        void addSpecialEffect(const int effect);
869
 
 
870
 
        void removeSpecialEffect();
871
 
 
872
 
        void addEffect(const std::string &name);
873
 
 
874
 
        void addPet(const int id);
875
 
 
876
 
        void removePet();
877
 
 
878
 
        void updatePets();
879
 
 
880
 
        Being *getPet()
881
 
        { return mPet; }
882
 
 
883
 
        void setPet(Being *const pet)
884
 
        { mPet = pet; }
885
 
 
886
 
        void setOwner(Being *const owner)
887
 
        { mOwner = owner; }
888
 
 
889
 
        void playSfx(const SoundInfo &sound, Being *const being,
890
 
                     const bool main, const int x, const int y);
891
 
 
892
 
        int getLook()
893
 
        { return mLook; }
894
 
 
895
 
        void setLook(const int look);
896
 
 
897
 
        static uint8_t genderToInt(const Gender sex) A_WARN_UNUSED;
898
 
 
899
 
        static Gender intToGender(uint8_t sex) A_WARN_UNUSED;
900
 
 
901
 
        NextSoundInfo mNextSound;
902
 
 
903
 
    protected:
904
 
        /**
905
 
         * Sets the new path for this being.
906
 
         */
907
 
        void setPath(const Path &path);
908
 
 
909
 
        /**
910
 
         * Updates name's location.
911
 
         */
912
 
        virtual void updateCoords();
913
 
 
914
 
        void showName();
915
 
 
916
 
        static int getDefaultEffectId(const int type);
917
 
 
918
 
        BeingInfo *mInfo;
919
 
        AnimatedSprite *mEmotionSprite;
920
 
        AnimatedSprite* mAnimationEffect;
921
 
 
922
 
        std::string mSpriteAction;
923
 
        std::string mName;              /**< Name of character */
924
 
        std::string mRaceName;
925
 
        std::string mPartyName;
926
 
        std::string mGuildName;
927
 
        std::string mSpeech;
928
 
 
929
 
        /**
930
 
         * Holds a text object when the being displays it's name, 0 otherwise
931
 
         */
932
 
        FlashText *mDispName;
933
 
        const gcn::Color *mNameColor;
934
 
 
935
 
        /** Engine-related infos about weapon. */
936
 
        const ItemInfo *mEquippedWeapon;
937
 
 
938
 
        static int mNumberOfHairstyles; /** Number of hair styles in use */
939
 
        static int mNumberOfRaces; /** Number of races in use */
940
 
 
941
 
        Path mPath;
942
 
        Text *mText;
943
 
        const gcn::Color *mTextColor;
944
 
 
945
 
        Vector mDest;  /**< destination coordinates. */
946
 
 
947
 
        StringVect mSpriteColors;
948
 
        std::vector<int> mSpriteIDs;
949
 
        std::vector<int> mSpriteColorsIds;
950
 
 
951
 
        // Character guild information
952
 
        std::map<int, Guild*> mGuilds;
953
 
        Party *mParty;
954
 
 
955
 
        int mActionTime;      /**< Time spent in current action */
956
 
        int mEmotionTime;     /**< Time until emotion disappears */
957
 
 
958
 
        /** Time until the last speech sentence disappears */
959
 
        int mSpeechTime;
960
 
        int mAttackSpeed;     /**< Attack speed */
961
 
 
962
 
        int mLevel;
963
 
        int mAttackRange;
964
 
        Gender mGender;
965
 
        Action mAction;       /**< Action the being is performing */
966
 
        uint16_t mSubType;      /**< Subtype (graphical view, basically) */
967
 
        uint8_t mDirection;               /**< Facing direction */
968
 
        uint8_t mDirectionDelayed;        /**< Facing direction */
969
 
        uint8_t mSpriteDirection;         /**< Facing direction */
970
 
        bool mShowName;
971
 
        bool mIsGM;
972
 
 
973
 
    private:
974
 
        /**
975
 
         * Calculates the offset in the given directions.
976
 
         * If walking in direction 'neg' the value is negated.
977
 
         * TODO: Used by eAthena only?
978
 
         */
979
 
        int getOffset(const signed char pos,
980
 
                      const signed char neg) const A_WARN_UNUSED;
981
 
 
982
 
        int searchSlotValue(const std::vector<int> &slotRemap,
983
 
                            const int val) const A_WARN_UNUSED;
984
 
 
985
 
        void searchSlotValueItr(std::vector<int>::iterator &it, int &idx,
986
 
                                std::vector<int> &slotRemap,
987
 
                                const int val) const;
988
 
 
989
 
        void dumpSprites() const;
990
 
 
991
 
        const Type mType;
992
 
 
993
 
        /** Speech Bubble components */
994
 
        SpeechBubble *mSpeechBubble;
995
 
 
996
 
        /**
997
 
         * Walk speed for x and y movement values.
998
 
         * In pixels per second for eAthena,
999
 
         * In pixels per ticks for Manaserv.
1000
 
         * @see MILLISECONDS_IN_A_TICK
1001
 
         */
1002
 
        Vector mWalkSpeed;
1003
 
        std::string mIp;
1004
 
        int *mSpriteRemap;
1005
 
        int *mSpriteHide;
1006
 
        std::string mComment;
1007
 
        Being *mPet;
1008
 
        Being *mOwner;
1009
 
        Particle *mSpecialParticle;
1010
 
 
1011
 
        int mX, mY;   /**< Position in tile */
1012
 
 
1013
 
        int mDamageTaken;
1014
 
        int mHP;
1015
 
        int mMaxHP;
1016
 
        int mDistance;
1017
 
        int mIsReachable; /**< 0 - unknown, 1 - reachable, 2 - not reachable*/
1018
 
        int mGoodStatus;
1019
 
 
1020
 
        static int mUpdateConfigTime;
1021
 
        static unsigned int mConfLineLim;
1022
 
        static int mSpeechType;
1023
 
        static bool mHighlightMapPortals;
1024
 
        static bool mHighlightMonsterAttackRange;
1025
 
        static bool mLowTraffic;
1026
 
        static bool mDrawHotKeys;
1027
 
        static bool mShowBattleEvents;
1028
 
        static bool mShowMobHP;
1029
 
        static bool mShowOwnHP;
1030
 
        static bool mShowGender;
1031
 
        static bool mShowLevel;
1032
 
        static bool mShowPlayersStatus;
1033
 
        static bool mEnableReorderSprites;
1034
 
        static bool mHideErased;
1035
 
        static bool mMoveNames;
1036
 
        static int mAwayEffect;
1037
 
 
1038
 
        unsigned int mMoveTime;
1039
 
        unsigned int mAttackTime;
1040
 
        unsigned int mTalkTime;
1041
 
        unsigned int mOtherTime;
1042
 
        unsigned int mTestTime;
1043
 
        int mAttackDelay;
1044
 
        int mMinHit;
1045
 
        int mMaxHit;
1046
 
        int mCriticalHit;
1047
 
        unsigned int mPvpRank;
1048
 
        unsigned int mNumber;
1049
 
        int mPetId;
1050
 
        int mLook;
1051
 
        unsigned char mHairColor;
1052
 
        bool mErased;
1053
 
        bool mEnemy;
1054
 
        bool mGotComment;
1055
 
        bool mAdvanced;
1056
 
        bool mShop;
1057
 
        bool mAway;
1058
 
        bool mInactive;
1059
 
};
1060
 
 
1061
 
extern std::list<BeingCacheEntry*> beingInfoCache;
1062
 
 
1063
 
#endif  // BEING_H