2020-08-24 21:04:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CNShardServer.hpp"
|
2020-09-10 13:01:35 +00:00
|
|
|
#include "Player.hpp"
|
2020-08-24 21:04:56 +00:00
|
|
|
|
2020-09-09 19:09:01 +00:00
|
|
|
#include "contrib/JSON.hpp"
|
|
|
|
|
|
|
|
struct Reward {
|
|
|
|
int32_t id;
|
|
|
|
int32_t itemTypes[4];
|
|
|
|
int32_t itemIds[4];
|
|
|
|
int32_t money;
|
|
|
|
int32_t fusionmatter;
|
|
|
|
|
|
|
|
Reward(int32_t id, nlohmann::json types, nlohmann::json ids, int32_t m, int32_t fm) :
|
|
|
|
id(id), money(m), fusionmatter(fm) {
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
itemTypes[i] = types[i];
|
|
|
|
itemIds[i] = ids[i];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-09-10 16:40:38 +00:00
|
|
|
struct TaskData {
|
|
|
|
/*
|
|
|
|
* TODO: We'll probably want to keep only the data the server actually needs,
|
|
|
|
* but for now RE/development is much easier if we have everything at
|
|
|
|
* our fingertips.
|
|
|
|
*/
|
|
|
|
nlohmann::json task;
|
|
|
|
|
|
|
|
TaskData(nlohmann::json t) : task(t) {}
|
|
|
|
|
|
|
|
// convenience
|
|
|
|
auto operator[](std::string s) { return task[s]; }
|
2020-09-10 13:01:35 +00:00
|
|
|
};
|
|
|
|
|
2020-08-24 21:04:56 +00:00
|
|
|
namespace MissionManager {
|
2020-09-09 19:09:01 +00:00
|
|
|
extern std::map<int32_t, Reward*> Rewards;
|
2020-09-10 16:40:38 +00:00
|
|
|
extern std::map<int32_t, TaskData*> Tasks;
|
2020-09-26 01:48:45 +00:00
|
|
|
extern nlohmann::json AvatarGrowth[37];
|
2020-08-24 21:04:56 +00:00
|
|
|
void init();
|
|
|
|
|
2020-12-22 21:18:46 +00:00
|
|
|
bool startTask(Player* plr, int TaskID);
|
2020-09-10 16:40:38 +00:00
|
|
|
void taskStart(CNSocket* sock, CNPacketData* data);
|
|
|
|
void taskEnd(CNSocket* sock, CNPacketData* data);
|
2020-08-24 21:04:56 +00:00
|
|
|
void setMission(CNSocket* sock, CNPacketData* data);
|
|
|
|
void quitMission(CNSocket* sock, CNPacketData* data);
|
2020-09-10 13:01:35 +00:00
|
|
|
|
2020-09-10 16:40:38 +00:00
|
|
|
int findQSlot(Player *plr, int id);
|
2020-09-10 13:01:35 +00:00
|
|
|
void dropQuestItem(CNSocket *sock, int task, int count, int id, int mobid);
|
2020-10-19 17:26:14 +00:00
|
|
|
// checks if player doesn't have n/n quest items
|
2020-09-21 19:43:53 +00:00
|
|
|
bool isQuestItemFull(CNSocket* sock, int itemId, int itemCount);
|
2020-12-13 00:32:19 +00:00
|
|
|
int giveMissionReward(CNSocket *sock, int task, int choice=0);
|
2020-09-23 21:04:58 +00:00
|
|
|
void updateFusionMatter(CNSocket* sock, int fusion);
|
2020-09-10 16:40:38 +00:00
|
|
|
|
|
|
|
void mobKilled(CNSocket *sock, int mobid);
|
2020-09-13 18:45:51 +00:00
|
|
|
|
2020-12-13 00:32:19 +00:00
|
|
|
bool endTask(CNSocket *sock, int32_t taskNum, int choice=0);
|
2020-09-13 18:45:51 +00:00
|
|
|
void saveMission(Player* player, int missionId);
|
2020-10-14 18:36:38 +00:00
|
|
|
void quitTask(CNSocket* sock, int32_t taskNum, bool manual);
|
2020-10-14 04:26:30 +00:00
|
|
|
|
|
|
|
void failInstancedMissions(CNSocket* sock);
|
2020-09-09 19:09:01 +00:00
|
|
|
}
|