/
player.h
1323 lines (1145 loc) · 38.8 KB
/
player.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2023 The Forgotten Server Authors. All rights reserved.
// Use of this source code is governed by the GPL-2.0 License that can be found in the LICENSE file.
#ifndef FS_PLAYER_H
#define FS_PLAYER_H
#include "creature.h"
#include "cylinder.h"
#include "depotlocker.h"
#include "enums.h"
#include "groups.h"
#include "guild.h"
#include "protocolgame.h"
#include "town.h"
#include "vocation.h"
class DepotChest;
class House;
class NetworkMessage;
class Npc;
class Party;
class SchedulerTask;
enum skillsid_t
{
SKILLVALUE_LEVEL = 0,
SKILLVALUE_TRIES = 1,
SKILLVALUE_PERCENT = 2,
};
enum fightMode_t : uint8_t
{
FIGHTMODE_ATTACK = 1,
FIGHTMODE_BALANCED = 2,
FIGHTMODE_DEFENSE = 3,
};
enum pvpMode_t : uint8_t
{
PVP_MODE_DOVE = 0,
PVP_MODE_WHITE_HAND = 1,
PVP_MODE_YELLOW_HAND = 2,
PVP_MODE_RED_FIST = 3,
};
enum tradestate_t : uint8_t
{
TRADE_NONE,
TRADE_INITIATED,
TRADE_ACCEPT,
TRADE_ACKNOWLEDGE,
TRADE_TRANSFER,
};
struct VIPEntry
{
VIPEntry(uint32_t guid, std::string_view name, std::string_view description, uint32_t icon, bool notify) :
guid{guid}, name{name}, description{description}, icon{icon}, notify{notify}
{}
uint32_t guid;
std::string name;
std::string description;
uint32_t icon;
bool notify;
};
struct OpenContainer
{
Container* container;
uint16_t index;
};
static constexpr int16_t MINIMUM_SKILL_LEVEL = 10;
struct Skill
{
uint64_t tries = 0;
uint16_t level = MINIMUM_SKILL_LEVEL;
uint16_t percent = 0;
};
using MuteCountMap = std::map<uint32_t, uint32_t>;
static constexpr int32_t PLAYER_MAX_SPEED = 1500;
static constexpr int32_t PLAYER_MIN_SPEED = 10;
static constexpr int32_t NOTIFY_DEPOT_BOX_RANGE = 1;
class Player final : public Creature, public Cylinder
{
public:
explicit Player(ProtocolGame_ptr p);
~Player();
using Creature::onWalk;
// non-copyable
Player(const Player&) = delete;
Player& operator=(const Player&) = delete;
Player* getPlayer() override { return this; }
const Player* getPlayer() const override { return this; }
void setID() final;
static MuteCountMap muteCountMap;
const std::string& getName() const override { return name; }
void setName(std::string_view name) { this->name = name; }
const std::string& getNameDescription() const override { return name; }
std::string getDescription(int32_t lookDistance) const override;
CreatureType_t getType() const override { return CREATURETYPE_PLAYER; }
uint16_t getRandomMount() const;
uint16_t getCurrentMount() const;
void setCurrentMount(uint16_t mountId);
bool isMounted() const { return defaultOutfit.lookMount != 0; }
bool toggleMount(bool mount);
bool tameMount(uint16_t mountId);
bool untameMount(uint16_t mountId);
bool hasMount(const Mount* mount) const;
bool hasMounts() const;
void dismount();
void sendFYIBox(const std::string& message)
{
if (client) {
client->sendFYIBox(message);
}
}
void setGUID(uint32_t guid) { this->guid = guid; }
uint32_t getGUID() const { return guid; }
bool canSeeInvisibility() const override { return hasFlag(PlayerFlag_CanSenseInvisibility) || group->access; }
void removeList() override;
void addList() override;
void kickPlayer(bool displayEffect);
static uint64_t getExpForLevel(const uint64_t lv)
{
return (((lv - 6ULL) * lv + 17ULL) * lv - 12ULL) / 6ULL * 100ULL;
}
uint16_t getStaminaMinutes() const { return staminaMinutes; }
bool addOfflineTrainingTries(skills_t skill, uint64_t tries);
void addOfflineTrainingTime(int32_t addTime)
{
offlineTrainingTime = std::min<int32_t>(12 * 3600 * 1000, offlineTrainingTime + addTime);
}
void removeOfflineTrainingTime(int32_t removeTime)
{
offlineTrainingTime = std::max<int32_t>(0, offlineTrainingTime - removeTime);
}
int32_t getOfflineTrainingTime() const { return offlineTrainingTime; }
int32_t getOfflineTrainingSkill() const { return offlineTrainingSkill; }
void setOfflineTrainingSkill(int32_t skill) { offlineTrainingSkill = skill; }
uint64_t getBankBalance() const { return bankBalance; }
void setBankBalance(uint64_t balance) { bankBalance = balance; }
Guild* getGuild() const { return guild; }
void setGuild(Guild* guild);
GuildRank_ptr getGuildRank() const { return guildRank; }
void setGuildRank(GuildRank_ptr newGuildRank) { guildRank = newGuildRank; }
bool isGuildMate(const Player* player) const;
const std::string& getGuildNick() const { return guildNick; }
void setGuildNick(std::string nick) { guildNick = nick; }
bool isInWar(const Player* player) const;
bool isInWarList(uint32_t guildId) const;
void setLastWalkthroughAttempt(int64_t walkthroughAttempt) { lastWalkthroughAttempt = walkthroughAttempt; }
void setLastWalkthroughPosition(Position walkthroughPosition) { lastWalkthroughPosition = walkthroughPosition; }
Inbox* getInbox() const { return inbox; }
StoreInbox* getStoreInbox() const { return storeInbox; }
uint32_t getClientIcons() const;
const GuildWarVector& getGuildWarVector() const { return guildWarVector; }
Vocation* getVocation() const { return vocation; }
OperatingSystem_t getOperatingSystem() const { return operatingSystem; }
void setOperatingSystem(OperatingSystem_t clientos) { operatingSystem = clientos; }
uint16_t getProtocolVersion() const
{
if (!client) {
return 0;
}
return client->getVersion();
}
bool hasSecureMode() const { return secureMode; }
void setParty(Party* party) { this->party = party; }
Party* getParty() const { return party; }
PartyShields_t getPartyShield(const Player* player) const;
bool isInviting(const Player* player) const;
bool isPartner(const Player* player) const;
void sendPlayerPartyIcons(Player* player);
bool addPartyInvitation(Party* party);
void removePartyInvitation(Party* party);
void clearPartyInvitations();
GuildEmblems_t getGuildEmblem(const Player* player) const;
uint64_t getSpentMana() const { return manaSpent; }
bool hasFlag(PlayerFlags value) const { return (group->flags & value) != 0; }
BedItem* getBedItem() { return bedItem; }
void setBedItem(BedItem* b) { bedItem = b; }
void addBlessing(uint8_t blessing) { blessings.set(blessing); }
void removeBlessing(uint8_t blessing) { blessings.reset(blessing); }
bool hasBlessing(uint8_t blessing) const { return blessings.test(blessing); }
bool isOffline() const { return (getID() == 0); }
void disconnect()
{
if (client) {
client->disconnect();
}
}
Connection::Address getIP() const;
void addContainer(uint8_t cid, Container* container);
void closeContainer(uint8_t cid);
void setContainerIndex(uint8_t cid, uint16_t index);
Container* getContainerByID(uint8_t cid);
int8_t getContainerID(const Container* container) const;
uint16_t getContainerIndex(uint8_t cid) const;
bool canOpenCorpse(uint32_t ownerId) const;
void setStorageValue(uint32_t key, std::optional<int32_t> value, bool isSpawn = false) override;
void setGroup(Group* newGroup) { group = newGroup; }
Group* getGroup() const { return group; }
void setInMarket(bool value) { inMarket = value; }
bool isInMarket() const { return inMarket; }
int32_t getIdleTime() const { return idleTime; }
void resetIdleTime() { idleTime = 0; }
bool isInGhostMode() const override { return ghostMode; }
bool canSeeGhostMode(const Creature* creature) const override;
void switchGhostMode() { ghostMode = !ghostMode; }
uint32_t getAccount() const { return accountNumber; }
AccountType_t getAccountType() const { return accountType; }
uint32_t getLevel() const { return level; }
uint8_t getLevelPercent() const { return levelPercent; }
uint32_t getMagicLevel() const { return std::max<int32_t>(0, magLevel + varStats[STAT_MAGICPOINTS]); }
uint32_t getSpecialMagicLevel(CombatType_t type) const
{
return std::max<int32_t>(0, specialMagicLevelSkill[combatTypeToIndex(type)]);
}
uint32_t getBaseMagicLevel() const { return magLevel; }
uint16_t getMagicLevelPercent() const { return magLevelPercent; }
uint8_t getSoul() const { return soul; }
bool isAccessPlayer() const { return group->access; }
bool isPremium() const;
void setPremiumTime(time_t premiumEndsAt);
bool setVocation(uint16_t vocId);
uint16_t getVocationId() const { return vocation->getId(); }
PlayerSex_t getSex() const { return sex; }
void setSex(PlayerSex_t);
uint64_t getExperience() const { return experience; }
time_t getLastLoginSaved() const { return lastLoginSaved; }
time_t getLastLogout() const { return lastLogout; }
const Position& getLoginPosition() const { return loginPosition; }
const Position& getTemplePosition() const { return town->getTemplePosition(); }
Town* getTown() const { return town; }
void setTown(Town* town) { this->town = town; }
void clearModalWindows();
bool hasModalWindowOpen(uint32_t modalWindowId) const;
void onModalWindowHandled(uint32_t modalWindowId);
bool isPushable() const override;
uint32_t isMuted() const;
void addMessageBuffer();
void removeMessageBuffer();
bool removeItemOfType(uint16_t itemId, uint32_t amount, int32_t subType, bool ignoreEquipped = false) const;
uint32_t getCapacity() const
{
if (hasFlag(PlayerFlag_CannotPickupItem)) {
return 0;
} else if (hasFlag(PlayerFlag_HasInfiniteCapacity)) {
return std::numeric_limits<uint32_t>::max();
}
return capacity;
}
uint32_t getFreeCapacity() const
{
if (hasFlag(PlayerFlag_CannotPickupItem)) {
return 0;
} else if (hasFlag(PlayerFlag_HasInfiniteCapacity)) {
return std::numeric_limits<uint32_t>::max();
}
return std::max<int32_t>(0, capacity - inventoryWeight);
}
int32_t getMaxHealth() const override { return std::max<int32_t>(1, healthMax + varStats[STAT_MAXHITPOINTS]); }
uint32_t getMana() const { return mana; }
uint32_t getMaxMana() const { return std::max<int32_t>(0, manaMax + varStats[STAT_MAXMANAPOINTS]); }
uint16_t getManaShieldBar() const { return manaShieldBar; }
void setManaShieldBar(uint16_t value) { manaShieldBar = value; }
uint16_t getMaxManaShieldBar() const { return maxManaShieldBar; }
void setMaxManaShieldBar(uint16_t value) { maxManaShieldBar = value; }
Item* getInventoryItem(slots_t slot) const;
bool isItemAbilityEnabled(slots_t slot) const { return inventoryAbilities[slot]; }
void setItemAbility(slots_t slot, bool enabled) { inventoryAbilities[slot] = enabled; }
void setVarSkill(skills_t skill, int32_t modifier) { varSkills[skill] += modifier; }
void setVarSpecialSkill(SpecialSkills_t skill, int32_t modifier) { varSpecialSkills[skill] += modifier; }
void setSpecialMagicLevelSkill(CombatType_t type, int16_t modifier)
{
specialMagicLevelSkill[combatTypeToIndex(type)] += modifier;
}
void setVarStats(stats_t stat, int32_t modifier);
int32_t getDefaultStats(stats_t stat) const;
void addConditionSuppressions(uint32_t conditions);
void removeConditionSuppressions(uint32_t conditions);
DepotChest* getDepotChest(uint32_t depotId, bool autoCreate);
DepotLocker& getDepotLocker();
void onReceiveMail() const;
bool isNearDepotBox() const;
bool canSee(const Position& pos) const override;
bool canSeeCreature(const Creature* creature) const override;
bool canWalkthrough(const Creature* creature) const;
bool canWalkthroughEx(const Creature* creature) const;
RaceType_t getRace() const override { return RACE_BLOOD; }
uint64_t getMoney() const;
// safe-trade functions
void setTradeState(tradestate_t state) { tradeState = state; }
tradestate_t getTradeState() const { return tradeState; }
Item* getTradeItem() { return tradeItem; }
// shop functions
void setShopOwner(Npc* owner, int32_t onBuy, int32_t onSell)
{
shopOwner = owner;
purchaseCallback = onBuy;
saleCallback = onSell;
}
Npc* getShopOwner(int32_t& onBuy, int32_t& onSell)
{
onBuy = purchaseCallback;
onSell = saleCallback;
return shopOwner;
}
const Npc* getShopOwner(int32_t& onBuy, int32_t& onSell) const
{
onBuy = purchaseCallback;
onSell = saleCallback;
return shopOwner;
}
// V.I.P. functions
void notifyStatusChange(Player* loginPlayer, VipStatus_t status);
bool removeVIP(uint32_t vipGuid);
bool addVIP(uint32_t vipGuid, const std::string& vipName, VipStatus_t status);
bool addVIPInternal(uint32_t vipGuid);
bool editVIP(uint32_t vipGuid, const std::string& description, uint32_t icon, bool notify);
// follow functions
bool setFollowCreature(Creature* creature) override;
void goToFollowCreature() override;
// follow events
void onFollowCreature(const Creature* creature) override;
// walk events
void onWalk(Direction& dir) override;
void onWalkAborted() override;
void onWalkComplete() override;
void stopWalk();
void openShopWindow(Npc* npc, const std::list<ShopInfo>& shop);
bool closeShopWindow(bool sendCloseShopWindow = true);
bool updateSaleShopList(const Item* item);
bool hasShopItemForSale(uint32_t itemId, uint8_t subType) const;
void setChaseMode(bool mode);
void setFightMode(fightMode_t mode) { fightMode = mode; }
void setSecureMode(bool mode) { secureMode = mode; }
// combat functions
bool setAttackedCreature(Creature* creature) override;
bool isImmune(CombatType_t type) const override;
bool isImmune(ConditionType_t type) const override;
bool hasShield() const;
bool isAttackable() const override;
static bool lastHitIsPlayer(Creature* lastHitCreature);
void changeHealth(int32_t healthChange, bool sendHealthChange = true) override;
void changeMana(int32_t manaChange);
void changeSoul(int32_t soulChange);
bool isPzLocked() const { return pzLocked; }
BlockType_t blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage, bool checkDefense = false,
bool checkArmor = false, bool field = false, bool ignoreResistances = false) override;
void doAttacking(uint32_t interval) override;
bool hasExtraSwing() override { return lastAttack > 0 && ((OTSYS_TIME() - lastAttack) >= getAttackSpeed()); }
uint16_t getSpecialSkill(uint8_t skill) const { return std::max<uint16_t>(0, varSpecialSkills[skill]); }
uint16_t getSkillLevel(uint8_t skill) const
{
return std::max<uint16_t>(0, skills[skill].level + varSkills[skill]);
}
uint16_t getSpecialMagicLevelSkill(CombatType_t type) const
{
return std::max<int32_t>(0, specialMagicLevelSkill[combatTypeToIndex(type)]);
}
uint16_t getBaseSkill(uint8_t skill) const { return skills[skill].level; }
uint16_t getSkillPercent(uint8_t skill) const { return skills[skill].percent; }
bool getAddAttackSkill() const { return addAttackSkillPoint; }
BlockType_t getLastAttackBlockType() const { return lastAttackBlockType; }
Item* getWeapon(slots_t slot, bool ignoreAmmo) const;
Item* getWeapon(bool ignoreAmmo = false) const;
WeaponType_t getWeaponType() const;
int32_t getWeaponSkill(const Item* item) const;
void getShieldAndWeapon(const Item*& shield, const Item*& weapon) const;
void drainHealth(Creature* attacker, int32_t damage) override;
void drainMana(Creature* attacker, int32_t manaLoss);
void addManaSpent(uint64_t amount);
void removeManaSpent(uint64_t amount, bool notify = false);
void addSkillAdvance(skills_t skill, uint64_t count);
void removeSkillTries(skills_t skill, uint64_t count, bool notify = false);
int32_t getArmor() const override;
int32_t getDefense() const override;
float getAttackFactor() const override;
float getDefenseFactor() const override;
void addInFightTicks(bool pzlock = false);
uint64_t getGainedExperience(Creature* attacker) const override;
// combat event functions
void onAddCondition(ConditionType_t type) override;
void onAddCombatCondition(ConditionType_t type) override;
void onEndCondition(ConditionType_t type) override;
void onCombatRemoveCondition(Condition* condition) override;
void onAttackedCreature(Creature* target, bool addFightTicks = true) override;
void onAttacked() override;
void onAttackedCreatureDrainHealth(Creature* target, int32_t points) override;
void onTargetCreatureGainHealth(Creature* target, int32_t points) override;
bool onKilledCreature(Creature* target, bool lastHit = true) override;
void onGainExperience(uint64_t gainExp, Creature* target) override;
void onGainSharedExperience(uint64_t gainExp, Creature* source);
void onAttackedCreatureBlockHit(BlockType_t blockType) override;
void onBlockHit() override;
void onChangeZone(ZoneType_t zone) override;
void onAttackedCreatureChangeZone(ZoneType_t zone) override;
void onIdleStatus() override;
void onPlacedCreature() override;
LightInfo getCreatureLight() const override;
Skulls_t getSkull() const override;
Skulls_t getSkullClient(const Creature* creature) const override;
int64_t getSkullTicks() const { return skullTicks; }
void setSkullTicks(int64_t ticks) { skullTicks = ticks; }
bool hasAttacked(const Player* attacked) const;
void addAttacked(const Player* attacked);
void removeAttacked(const Player* attacked);
void clearAttacked();
void addUnjustifiedDead(const Player* attacked);
void sendCreatureSkull(const Creature* creature) const
{
if (client) {
client->sendCreatureSkull(creature);
}
}
void checkSkullTicks(int64_t ticks);
bool canWear(uint32_t lookType, uint8_t addons) const;
bool hasOutfit(uint32_t lookType, uint8_t addons);
void addOutfit(uint16_t lookType, uint8_t addons);
bool removeOutfit(uint16_t lookType);
bool removeOutfitAddon(uint16_t lookType, uint8_t addons);
bool getOutfitAddons(const Outfit& outfit, uint8_t& addons) const;
size_t getMaxVIPEntries() const;
size_t getMaxDepotItems() const;
// tile
// send methods
void sendAddTileItem(const Tile* tile, const Position& pos, const Item* item)
{
if (client) {
int32_t stackpos = tile->getStackposOfItem(this, item);
if (stackpos != -1) {
client->sendAddTileItem(pos, stackpos, item);
}
}
}
void sendUpdateTileItem(const Tile* tile, const Position& pos, const Item* item)
{
if (client) {
int32_t stackpos = tile->getStackposOfItem(this, item);
if (stackpos != -1) {
client->sendUpdateTileItem(pos, stackpos, item);
}
}
}
void sendRemoveTileThing(const Position& pos, int32_t stackpos)
{
if (stackpos != -1 && client) {
client->sendRemoveTileThing(pos, stackpos);
}
}
void sendUpdateTileCreature(const Creature* creature)
{
if (client) {
client->sendUpdateTileCreature(creature->getPosition(),
creature->getTile()->getClientIndexOfCreature(this, creature), creature);
}
}
void sendRemoveTileCreature(const Creature* creature, const Position& pos, int32_t stackpos)
{
if (client) {
client->sendRemoveTileCreature(creature, pos, stackpos);
}
}
void sendUpdateTile(const Tile* tile, const Position& pos)
{
if (client) {
client->sendUpdateTile(tile, pos);
}
}
void sendUpdateCreatureIcons(const Creature* creature)
{
if (client) {
client->sendUpdateCreatureIcons(creature);
}
}
void sendChannelMessage(const std::string& author, const std::string& text, SpeakClasses type, uint16_t channel)
{
if (client) {
client->sendChannelMessage(author, text, type, channel);
}
}
void sendChannelEvent(uint16_t channelId, const std::string& playerName, ChannelEvent_t channelEvent)
{
if (client) {
client->sendChannelEvent(channelId, playerName, channelEvent);
}
}
void sendCreatureAppear(const Creature* creature, const Position& pos,
MagicEffectClasses magicEffect = CONST_ME_NONE)
{
if (client) {
client->sendAddCreature(creature, pos, creature->getTile()->getClientIndexOfCreature(this, creature),
magicEffect);
}
}
void sendCreatureMove(const Creature* creature, const Position& newPos, int32_t newStackPos, const Position& oldPos,
int32_t oldStackPos, bool teleport)
{
if (client) {
client->sendMoveCreature(creature, newPos, newStackPos, oldPos, oldStackPos, teleport);
}
}
void sendCreatureTurn(const Creature* creature)
{
if (client && canSeeCreature(creature)) {
int32_t stackpos = creature->getTile()->getClientIndexOfCreature(this, creature);
if (stackpos != -1) {
client->sendCreatureTurn(creature, stackpos);
}
}
}
void sendCreatureSay(const Creature* creature, SpeakClasses type, const std::string& text,
const Position* pos = nullptr)
{
if (client) {
client->sendCreatureSay(creature, type, text, pos);
}
}
void sendPrivateMessage(const Player* speaker, SpeakClasses type, const std::string& text)
{
if (client) {
client->sendPrivateMessage(speaker, type, text);
}
}
void sendCreatureSquare(const Creature* creature, SquareColor_t color)
{
if (client) {
client->sendCreatureSquare(creature, color);
}
}
void sendCreatureChangeOutfit(const Creature* creature, const Outfit_t& outfit)
{
if (client) {
client->sendCreatureOutfit(creature, outfit);
}
}
void sendCreatureChangeVisible(const Creature* creature, bool visible)
{
if (!client) {
return;
}
if (creature->getPlayer()) {
if (visible) {
client->sendCreatureOutfit(creature, creature->getCurrentOutfit());
} else {
static Outfit_t outfit;
client->sendCreatureOutfit(creature, outfit);
}
} else if (canSeeInvisibility()) {
client->sendCreatureOutfit(creature, creature->getCurrentOutfit());
} else {
int32_t stackpos = creature->getTile()->getClientIndexOfCreature(this, creature);
if (stackpos == -1) {
return;
}
if (visible) {
client->sendAddCreature(creature, creature->getPosition(), stackpos);
} else {
client->sendRemoveTileCreature(creature, creature->getPosition(), stackpos);
}
}
}
void sendCreatureLight(const Creature* creature)
{
if (client) {
client->sendCreatureLight(creature);
}
}
void sendCreatureWalkthrough(const Creature* creature, bool walkthrough)
{
if (client) {
client->sendCreatureWalkthrough(creature, walkthrough);
}
}
void sendCreatureShield(const Creature* creature)
{
if (client) {
client->sendCreatureShield(creature);
}
}
void sendSpellCooldown(uint8_t spellId, uint32_t time)
{
if (client) {
client->sendSpellCooldown(spellId, time);
}
}
void sendSpellGroupCooldown(SpellGroup_t groupId, uint32_t time)
{
if (client) {
client->sendSpellGroupCooldown(groupId, time);
}
}
void sendUseItemCooldown(uint32_t time)
{
if (client) {
client->sendUseItemCooldown(time);
}
}
void sendSupplyUsed(const uint16_t clientId) const
{
if (client) {
client->sendSupplyUsed(clientId);
}
}
void sendModalWindow(const ModalWindow& modalWindow);
// container
void sendAddContainerItem(const Container* container, const Item* item);
void sendUpdateContainerItem(const Container* container, uint16_t slot, const Item* newItem);
void sendRemoveContainerItem(const Container* container, uint16_t slot);
void sendContainer(uint8_t cid, const Container* container, bool hasParent, uint16_t firstIndex)
{
if (client) {
client->sendContainer(cid, container, hasParent, firstIndex);
}
}
// inventory
void sendInventoryItem(slots_t slot, const Item* item)
{
if (client) {
client->sendInventoryItem(slot, item);
}
}
void sendItems()
{
if (client) {
client->sendItems();
}
}
void openSavedContainers();
void sendQuiverUpdate(bool sendAll = false)
{
if (!sendAll) {
// update one slot
Thing* slotThing = getThing(CONST_SLOT_RIGHT);
if (slotThing) {
Item* slotItem = slotThing->getItem();
if (slotItem && slotItem->getWeaponType() == WEAPON_QUIVER) {
sendInventoryItem(CONST_SLOT_RIGHT, slotItem);
}
}
} else {
// update all slots
std::vector<slots_t> slots = {CONST_SLOT_RIGHT, CONST_SLOT_LEFT, CONST_SLOT_AMMO};
for (auto const& slot : slots) {
Thing* slotThing = getThing(slot);
if (slotThing) {
Item* slotItem = slotThing->getItem();
if (slotItem && slotItem->getWeaponType() == WEAPON_QUIVER) {
sendInventoryItem(slot, slotItem);
}
}
}
}
}
// event methods
void onUpdateTileItem(const Tile* tile, const Position& pos, const Item* oldItem, const ItemType& oldType,
const Item* newItem, const ItemType& newType) override;
void onRemoveTileItem(const Tile* tile, const Position& pos, const ItemType& iType, const Item* item) override;
void onCreatureAppear(Creature* creature, bool isLogin) override;
void onRemoveCreature(Creature* creature, bool isLogout) override;
void onCreatureMove(Creature* creature, const Tile* newTile, const Position& newPos, const Tile* oldTile,
const Position& oldPos, bool teleport) override;
void onEquipInventory();
void onDeEquipInventory();
void onAttackedCreatureDisappear(bool isLogout) override;
void onFollowCreatureDisappear(bool isLogout) override;
// container
void onAddContainerItem(const Item* item);
void onUpdateContainerItem(const Container* container, const Item* oldItem, const Item* newItem);
void onRemoveContainerItem(const Container* container, const Item* item);
void onCloseContainer(const Container* container);
void onSendContainer(const Container* container);
void autoCloseContainers(const Container* container);
// inventory
void onUpdateInventoryItem(Item* oldItem, Item* newItem);
void onRemoveInventoryItem(Item* item);
void sendCancelMessage(const std::string& msg) const
{
if (client) {
client->sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, msg));
}
}
void sendCancelMessage(ReturnValue message) const;
void sendCancelTarget() const
{
if (client) {
client->sendCancelTarget();
}
}
void sendCancelWalk() const
{
if (client) {
client->sendCancelWalk();
}
}
void sendChangeSpeed(const Creature* creature, uint32_t newSpeed) const
{
if (client) {
client->sendChangeSpeed(creature, newSpeed);
}
}
void sendCreatureHealth(const Creature* creature) const
{
if (client) {
client->sendCreatureHealth(creature);
}
}
void sendDistanceShoot(const Position& from, const Position& to, unsigned char type) const
{
if (client) {
client->sendDistanceShoot(from, to, type);
}
}
void sendHouseWindow(House* house, uint32_t listId) const;
void sendCreatePrivateChannel(uint16_t channelId, const std::string& channelName)
{
if (client) {
client->sendCreatePrivateChannel(channelId, channelName);
}
}
void sendClosePrivate(uint16_t channelId);
void sendIcons() const
{
if (client) {
client->sendIcons(getClientIcons());
}
}
void sendMagicEffect(const Position& pos, uint8_t type) const
{
if (client) {
client->sendMagicEffect(pos, type);
}
}
void sendPing();
void sendPingBack() const
{
if (client) {
client->sendPingBack();
}
}
void sendStats();
void sendExperienceTracker(int64_t rawExp, int64_t finalExp) const
{
if (client) {
client->sendExperienceTracker(rawExp, finalExp);
}
}
void sendBasicData() const
{
if (client) {
client->sendBasicData();
}
}
void sendSkills() const
{
if (client) {
client->sendSkills();
}
}
void sendTextMessage(MessageClasses mclass, const std::string& message) const
{
if (client) {
client->sendTextMessage(TextMessage(mclass, message));
}
}
void sendTextMessage(const TextMessage& message) const
{
if (client) {
client->sendTextMessage(message);
}
}
void sendReLoginWindow(uint8_t unfairFightReduction) const
{
if (client) {
client->sendReLoginWindow(unfairFightReduction);
}
}
void sendTextWindow(Item* item, uint16_t maxlen, bool canWrite) const
{
if (client) {
client->sendTextWindow(windowTextId, item, maxlen, canWrite);
}
}
void sendTextWindow(uint32_t itemId, const std::string& text) const
{
if (client) {
client->sendTextWindow(windowTextId, itemId, text);
}
}
void sendToChannel(const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId) const
{
if (client) {
client->sendToChannel(creature, type, text, channelId);
}
}
void sendShop(Npc* npc) const
{
if (client) {
client->sendShop(npc, shopItemList);
}
}
void sendSaleItemList() const
{
if (client) {
client->sendSaleItemList(shopItemList);
}
}
void sendCloseShop() const
{
if (client) {
client->sendCloseShop();
}
}
void sendMarketEnter() const
{
if (client) {
client->sendMarketEnter();
}
}
void sendMarketLeave()
{
inMarket = false;
if (client) {
client->sendMarketLeave();
}
}
void sendMarketBrowseItem(uint16_t itemId, const MarketOfferList& buyOffers,
const MarketOfferList& sellOffers) const
{
if (client) {
client->sendMarketBrowseItem(itemId, buyOffers, sellOffers);
}
}
void sendMarketBrowseOwnOffers(const MarketOfferList& buyOffers, const MarketOfferList& sellOffers) const
{
if (client) {
client->sendMarketBrowseOwnOffers(buyOffers, sellOffers);
}
}
void sendMarketBrowseOwnHistory(const HistoryMarketOfferList& buyOffers,
const HistoryMarketOfferList& sellOffers) const
{
if (client) {
client->sendMarketBrowseOwnHistory(buyOffers, sellOffers);
}
}
void sendMarketAcceptOffer(const MarketOfferEx& offer) const
{
if (client) {
client->sendMarketAcceptOffer(offer);
}
}
void sendMarketCancelOffer(const MarketOfferEx& offer) const
{
if (client) {
client->sendMarketCancelOffer(offer);
}
}
void sendTradeItemRequest(const std::string& traderName, const Item* item, bool ack) const
{
if (client) {
client->sendTradeItemRequest(traderName, item, ack);
}
}
void sendTradeClose() const
{
if (client) {
client->sendCloseTrade();
}
}
void sendChannelsDialog()
{
if (client) {
client->sendChannelsDialog();
}
}
void sendOpenPrivateChannel(const std::string& receiver)