forked from nekiro/TFS-1.5-Downgrades
-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.h
1232 lines (1066 loc) · 34.4 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
/**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2019 Mark Samman <mark.samman@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef FS_PLAYER_H_4083D3D3A05B4EDE891B31BB720CD06F
#define FS_PLAYER_H_4083D3D3A05B4EDE891B31BB720CD06F
#include "creature.h"
#include "container.h"
#include "cylinder.h"
#include "outfit.h"
#include "enums.h"
#include "vocation.h"
#include "protocolgame.h"
#include "party.h"
#include "depotchest.h"
#include "depotlocker.h"
#include "guild.h"
#include "groups.h"
#include "town.h"
#include <bitset>
class House;
class NetworkMessage;
class Weapon;
class ProtocolGame;
class Npc;
class Party;
class SchedulerTask;
class Bed;
class Guild;
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 tradestate_t : uint8_t {
TRADE_NONE,
TRADE_INITIATED,
TRADE_ACCEPT,
TRADE_ACKNOWLEDGE,
TRADE_TRANSFER,
};
struct VIPEntry {
VIPEntry(uint32_t guid, std::string name) :
guid(guid), name(std::move(name)) {}
uint32_t guid;
std::string name;
};
struct OpenContainer {
Container* container;
uint16_t index;
};
struct OutfitEntry {
constexpr OutfitEntry(uint16_t lookType, uint8_t addons) : lookType(lookType), addons(addons) {}
uint16_t lookType;
uint8_t addons;
};
static constexpr int16_t MINIMUM_SKILL_LEVEL = 10;
struct Skill {
uint64_t tries = 0;
uint16_t level = MINIMUM_SKILL_LEVEL;
uint8_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 PLAYER_SEARCHDIST = 9;
class Player final : public Creature, public Cylinder
{
public:
explicit Player(ProtocolGame_ptr p);
~Player();
// 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() override {
if (id == 0) {
id = playerAutoID++;
}
}
static MuteCountMap muteCountMap;
const std::string& getName() const override {
return name;
}
void setName(const std::string& 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;
}
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;
}
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;
}
uint16_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();
}
}
uint32_t 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 addStorageValue(const uint32_t key, const int32_t value, const bool isLogin = false);
bool getStorageValue(const uint32_t key, int32_t& value) const;
void genReservedStorageRange();
void setGroup(Group* newGroup) {
group = newGroup;
}
Group* getGroup() const {
return group;
}
void setLastDepotId(int16_t newId) {
lastDepotId = newId;
}
int16_t getLastDepotId() const {
return lastDepotId;
}
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 getBaseMagicLevel() const {
return magLevel;
}
uint8_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);
uint16_t getHelpers() const;
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;
}
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]);
}
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 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(uint32_t depotId);
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);
//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(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<int32_t>(0, varSpecialSkills[skill]);
}
uint16_t getSkillLevel(uint8_t skill) const {
return std::max<int32_t>(0, skills[skill].level + varSkills[skill]);
}
uint16_t getBaseSkill(uint8_t skill) const {
return skills[skill].level;
}
uint8_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 addCombatExhaust(uint32_t ticks);
void addHealExhaust(uint32_t ticks);
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 sendUpdateTile(const Tile* tile, const Position& pos) {
if (client) {
client->sendUpdateTile(tile, pos);
}
}
void sendChannelMessage(const std::string& author, const std::string& text, SpeakClasses type, uint16_t channel) {
if (client) {
client->sendChannelMessage(author, text, type, channel);
}
}
void sendCreatureAppear(const Creature* creature, const Position& pos, bool isLogin) {
if (client) {
client->sendAddCreature(creature, pos, creature->getTile()->getClientIndexOfCreature(this, creature), isLogin);
}
}
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, false);
} else {
client->sendRemoveTileThing(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 sendAnimatedText(const std::string& message, const Position& pos, TextColor_t color) {
if (client) {
client->sendAnimatedText(message, pos, color);
}
}
//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);
}
}
//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 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 sendStats();
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() const {
if (client) {
client->sendReLoginWindow();
}
}
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() const {
if (client) {
client->sendShop(shopItemList);
}
}
void sendSaleItemList() const {
if (client) {
client->sendSaleItemList(shopItemList);
}
}
void sendCloseShop() const {
if (client) {
client->sendCloseShop();
}
}
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 sendWorldLight(LightInfo lightInfo) {
if (client) {
client->sendWorldLight(lightInfo);
}
}
void sendChannelsDialog() {
if (client) {
client->sendChannelsDialog();
}
}
void sendOpenPrivateChannel(const std::string& receiver) {
if (client) {
client->sendOpenPrivateChannel(receiver);
}
}
void sendOutfitWindow() {
if (client) {
client->sendOutfitWindow();
}
}
void sendCloseContainer(uint8_t cid) {
if (client) {
client->sendCloseContainer(cid);
}
}
void sendChannel(uint16_t channelId, const std::string& channelName) {
if (client) {
client->sendChannel(channelId, channelName);
}
}
void sendTutorial(uint8_t tutorialId) {
if (client) {
client->sendTutorial(tutorialId);
}
}
void sendAddMarker(const Position& pos, uint8_t markType, const std::string& desc) {
if (client) {
client->sendAddMarker(pos, markType, desc);
}
}
void sendQuestLog() {
if (client) {
client->sendQuestLog();
}
}
void sendQuestLine(const Quest* quest) {
if (client) {
client->sendQuestLine(quest);
}
}
void sendFightModes() {
if (client) {
client->sendFightModes();
}
}
void sendNetworkMessage(const NetworkMessage& message) {
if (client) {
client->writeToOutputBuffer(message);
}
}
void receivePing() {
lastPong = OTSYS_TIME();
}
void onThink(uint32_t interval) override;
void postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t link = LINK_OWNER) override;
void postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, cylinderlink_t link = LINK_OWNER) override;