forked from SYJourney/JourneyClient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.h
174 lines (148 loc) · 6.24 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
//////////////////////////////////////////////////////////////////////////////////
// This file is part of the continued Journey MMORPG client //
// Copyright (C) 2015-2019 Daniel Allendorf, Ryan Payton //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as published by //
// the Free Software Foundation, either version 3 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 Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "ActiveBuffs.h"
#include "MonsterBook.h"
#include "PassiveBuffs.h"
#include "QuestLog.h"
#include "SkillBook.h"
#include "TeleportRock.h"
#include "Inventory/Inventory.h"
#include "../Gameplay/Playable.h"
#include "../Gameplay/Combat/Skill.h"
#include "../Gameplay/MapleMap/Layer.h"
#include "../Gameplay/MapleMap/MapInfo.h"
namespace ms
{
class Player : public Playable, public Char
{
public:
// Construct a player object from the given character entry
Player(const CharEntry& entry);
Player();
// Draw the player
void draw(Layer::Id layer, double viewx, double viewy, float alpha) const;
// Update the player's animation, physics and states.
int8_t update(const Physics& physics) override;
// Set flipped ignore if attacking
void set_direction(bool flipped) override;
// Set state ignore if attacking
void set_state(State stance) override;
// Respawn the player at the given position
void respawn(Point<int16_t> position, bool underwater);
// Sends a Keyaction to the player's state, to apply forces, change the state and other behavior.
void send_action(KeyAction::Id action, bool pressed);
// Recalculates the total stats from base stats, inventories and skills.
void recalc_stats(bool equipchanged);
// Change the equipment at the specified slot and recalculate stats
void change_equip(int16_t slot);
// Use the item from the player's inventory with the given id
void use_item(int32_t itemid);
// Return if the player is attacking
bool is_attacking() const;
// Return whether the player can attack or not
bool can_attack() const;
// Return whether the player can use a skill or not
SpecialMove::ForbidReason can_use(const SpecialMove& move) const;
// Create an attack struct using the player's stats
Attack prepare_attack(bool skill) const;
// Execute a rush movement
void rush(double targetx);
// Check whether the player is invincible
bool is_invincible() const override;
// Handle an attack to the player
MobAttackResult damage(const MobAttack& attack);
// Apply a buff to the player
void give_buff(Buff buff);
// Cancel a buff
void cancel_buff(Buffstat::Id stat);
// Return whether the buff is active
bool has_buff(Buffstat::Id stat) const;
// Change a skill
void change_skill(int32_t skill_id, int32_t level, int32_t masterlevel, int64_t expiration);
// Put a skill on cooldown
void add_cooldown(int32_t skill_id, int32_t time);
// Check if a skill is on cooldown
bool has_cooldown(int32_t skill_id) const;
// Change the player's level, display the "level up" effect.
void change_level(uint16_t level);
// Change the player's job, display the job change effect.
void change_job(uint16_t jobid);
// Return the character's level
uint16_t get_level() const override;
// Return the character's level of a skill
int32_t get_skilllevel(int32_t skillid) const override;
// Return the character's attacking speed
int8_t get_integer_attackspeed() const override;
// Returns the current walking force, calculated from the total ES_SPEED stat.
float get_walkforce() const;
// Returns the current jumping force, calculated from the total ES_JUMP stat.
float get_jumpforce() const;
// Returns the climbing force, calculated from the total ES_SPEED stat.
float get_climbforce() const;
// Returns the flying force
float get_flyforce() const;
// Return whether the player is underwater
bool is_underwater() const;
// Returns if a Keyaction is currently active
bool is_key_down(KeyAction::Id action) const;
// Return a pointer to the ladder the player is on
Optional<const Ladder> get_ladder() const;
// Change players position to the seat's position and stance to Char::State::SIT
void set_seat(Optional<const Seat> seat);
// Change players x-position to the ladder x and change stance to Char::State::LADDER or Char::State::ROPE
void set_ladder(Optional<const Ladder> ladder);
// Sets a quick cooldown on climbing so when jumping off a ladder or rope, it doesn't start climb again.
void set_climb_cooldown();
// Checks if the player can climb
bool can_climb();
// Obtain a reference to the player's stats
CharStats& get_stats();
// Obtain a reference to the player's stats
const CharStats& get_stats() const;
// Obtain a reference to the player's inventory
Inventory& get_inventory();
// Obtain a reference to the player's inventory
const Inventory& get_inventory() const;
// Obtain a reference to the player's skills
SkillBook& get_skills();
// Obtain a reference to the player's QuestLog
QuestLog& get_quests();
// Obtain a reference to the player's TeleportRock locations
TeleportRock& get_teleportrock();
// Obtain a reference to the player's MonsterBook
MonsterBook& get_monsterbook();
private:
CharStats stats;
Inventory inventory;
SkillBook skillbook;
QuestLog questlog;
TeleportRock teleportrock;
MonsterBook monsterbook;
EnumMap<Buffstat::Id, Buff> buffs;
ActiveBuffs active_buffs;
PassiveBuffs passive_buffs;
std::unordered_map<int32_t, int32_t> cooldowns;
std::map<KeyAction::Id, bool> keysdown;
Movement lastmove;
Randomizer randomizer;
Optional<const Ladder> ladder;
TimedBool climb_cooldown;
bool underwater;
};
}