添加新手配置读取
This commit is contained in:
parent
708de1c826
commit
c976981762
@ -36,12 +36,9 @@ void Android::Initialize()
|
|||||||
|
|
||||||
void Android::Update(int delta_time)
|
void Android::Update(int delta_time)
|
||||||
{
|
{
|
||||||
#if 0
|
if (a8::HasBitFlag(status, HS_Disable)) {
|
||||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
return;
|
||||||
SetPos(room->plane.curr_pos);
|
|
||||||
room->grid_service.MoveHuman(this);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (action_type != AT_None) {
|
if (action_type != AT_None) {
|
||||||
UpdateAction();
|
UpdateAction();
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,8 @@ enum ActionType_e
|
|||||||
enum RoomType_e
|
enum RoomType_e
|
||||||
{
|
{
|
||||||
RT_NewBrid = 0,
|
RT_NewBrid = 0,
|
||||||
RT_OldBrid = 1,
|
RT_MidBrid = 1,
|
||||||
|
RT_OldBrid = 2,
|
||||||
RT_Max
|
RT_Max
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1508,7 +1508,7 @@ void Human::RemoveObserver(Human* observer)
|
|||||||
|
|
||||||
void Human::SendUpdateMsg()
|
void Human::SendUpdateMsg()
|
||||||
{
|
{
|
||||||
if (!follow_target_) {
|
if (!follow_target_ && !a8::HasBitFlag(status, HS_Disable)) {
|
||||||
cs::MFActivePlayerData* active_player_data_pb = nullptr;
|
cs::MFActivePlayerData* active_player_data_pb = nullptr;
|
||||||
if (send_msg_times == 0 || need_sync_active_player) {
|
if (send_msg_times == 0 || need_sync_active_player) {
|
||||||
active_player_data_pb = new cs::MFActivePlayerData();
|
active_player_data_pb = new cs::MFActivePlayerData();
|
||||||
|
@ -17,6 +17,7 @@ namespace MetaData
|
|||||||
enum HumanStatus
|
enum HumanStatus
|
||||||
{
|
{
|
||||||
HS_AlreadyLordMode = 1,
|
HS_AlreadyLordMode = 1,
|
||||||
|
HS_Disable = 2,
|
||||||
HS_End
|
HS_End
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,7 +128,39 @@ public:
|
|||||||
#if 1
|
#if 1
|
||||||
{
|
{
|
||||||
MetaMgr::Instance()->gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("gas_inactive_time");
|
MetaMgr::Instance()->gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("gas_inactive_time");
|
||||||
|
|
||||||
MetaMgr::Instance()->newbie_gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("newbie_gas_inactive_time", 10);
|
MetaMgr::Instance()->newbie_gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("newbie_gas_inactive_time", 10);
|
||||||
|
MetaMgr::Instance()->newbie_born_point = MetaMgr::Instance()->GetSysParamAsInt("newbie_born_point");
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
std::string tmpstr = MetaMgr::Instance()->GetSysParamAsString("newbie_drop");
|
||||||
|
a8::Split(tmpstr, strings, ':');
|
||||||
|
for (const std::string& str : strings) {
|
||||||
|
int drop_id = a8::XValue(str);
|
||||||
|
MetaMgr::Instance()->newbie_drop.push_back(drop_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
std::string tmpstr = MetaMgr::Instance()->GetSysParamAsString("newbie_airdrop");
|
||||||
|
a8::Split(tmpstr, strings, ':');
|
||||||
|
for (const std::string& str : strings) {
|
||||||
|
int drop_id = a8::XValue(str);
|
||||||
|
MetaMgr::Instance()->newbie_airdrop.push_back(drop_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MetaMgr::Instance()->newbie_first_robot_distance =
|
||||||
|
MetaMgr::Instance()->GetSysParamAsInt("newbie_first_robot_distance", 500);
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
std::string tmpstr = MetaMgr::Instance()->GetSysParamAsString("newbie_buff_list");
|
||||||
|
a8::Split(tmpstr, strings, ':');
|
||||||
|
for (const std::string& str : strings) {
|
||||||
|
int drop_id = a8::XValue(str);
|
||||||
|
MetaMgr::Instance()->newbie_buff_list.push_back(drop_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MetaMgr::Instance()->newbie_wait_time = MetaMgr::Instance()->GetSysParamAsInt("newbie_wait_time", 10);
|
MetaMgr::Instance()->newbie_wait_time = MetaMgr::Instance()->GetSysParamAsInt("newbie_wait_time", 10);
|
||||||
MetaMgr::Instance()->jump_time = MetaMgr::Instance()->GetSysParamAsFloat("jump_time");
|
MetaMgr::Instance()->jump_time = MetaMgr::Instance()->GetSysParamAsFloat("jump_time");
|
||||||
MetaMgr::Instance()->K = MetaMgr::Instance()->GetSysParamAsFloat("K");
|
MetaMgr::Instance()->K = MetaMgr::Instance()->GetSysParamAsFloat("K");
|
||||||
@ -152,6 +184,16 @@ public:
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
MetaMgr::Instance()->human_meta = MetaMgr::Instance()->GetPlayer(40001);
|
||||||
|
if (!MetaMgr::Instance()->human_meta) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
MetaMgr::Instance()->android_meta = MetaMgr::Instance()->GetPlayer(40002);
|
||||||
|
if (!MetaMgr::Instance()->android_meta) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +64,21 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
|||||||
float max_mount_horse_distance = 100.0f;
|
float max_mount_horse_distance = 100.0f;
|
||||||
int newbie_game_times = 0;
|
int newbie_game_times = 0;
|
||||||
int niube_win_times = 0;
|
int niube_win_times = 0;
|
||||||
|
|
||||||
int newbie_fill_interval = 0;
|
int newbie_fill_interval = 0;
|
||||||
|
int newbie_born_point = 0;
|
||||||
|
std::vector<int> newbie_drop;
|
||||||
|
std::vector<int> newbie_airdrop;
|
||||||
|
int newbie_first_robot_distance = 0;
|
||||||
|
std::vector<int> newbie_buff_list;
|
||||||
|
|
||||||
int other_fill_interval = 0;
|
int other_fill_interval = 0;
|
||||||
float android_attack_range = 0;
|
float android_attack_range = 0;
|
||||||
float android_pursuit_range = 0;
|
float android_pursuit_range = 0;
|
||||||
float android_patrol_range = 0;
|
float android_patrol_range = 0;
|
||||||
int map_cell_width = 64 * 8;
|
int map_cell_width = 64 * 8;
|
||||||
|
MetaData::Player* human_meta = nullptr;
|
||||||
|
MetaData::Player* android_meta = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MetaDataLoader* loader_ = nullptr;
|
MetaDataLoader* loader_ = nullptr;
|
||||||
|
@ -189,6 +189,21 @@ void Room::AddPlayer(Player* hum)
|
|||||||
hum->FindLocation();
|
hum->FindLocation();
|
||||||
hum->RefreshView();
|
hum->RefreshView();
|
||||||
MatchTeam(hum);
|
MatchTeam(hum);
|
||||||
|
if (room_type == RT_NewBrid) {
|
||||||
|
if (force_shua_android_times_ < 1) {
|
||||||
|
CreateAndroid(20 + rand() % 10);
|
||||||
|
++force_shua_android_times_;
|
||||||
|
}
|
||||||
|
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * (1 + rand() % 3),
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(hum),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Human* hum = (Human*)param.sender.GetUserData();
|
||||||
|
hum->room->ShowAndroid(hum, 1 + rand() % 2);
|
||||||
|
},
|
||||||
|
&hum->xtimer_attacher.timer_list_);
|
||||||
|
}
|
||||||
while (human_hash_.size() > ROOM_MAX_PLAYER_NUM) {
|
while (human_hash_.size() > ROOM_MAX_PLAYER_NUM) {
|
||||||
RandRemoveAndroid();
|
RandRemoveAndroid();
|
||||||
}
|
}
|
||||||
@ -229,17 +244,36 @@ void Room::ShuaAndroid()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::ShowAndroid(Human* target, int num)
|
||||||
|
{
|
||||||
|
if (!target->born_point) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
Human* hum = pair.second;
|
||||||
|
if (a8::HasBitFlag(hum->status, HS_Disable)) {
|
||||||
|
if (hum->born_point) {
|
||||||
|
DecBornPointHumanNum(hum->born_point, hum);
|
||||||
|
}
|
||||||
|
hum->born_point = target->born_point;
|
||||||
|
IncBornPointHumanNum(hum->born_point, hum);
|
||||||
|
hum->SetPos(hum->born_point->RandPoint());
|
||||||
|
EnableHuman(hum);
|
||||||
|
++i;
|
||||||
|
if (i >= num) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Room::CreateAndroid(int robot_num)
|
void Room::CreateAndroid(int robot_num)
|
||||||
{
|
{
|
||||||
std::vector<MetaData::Robot>* robot_list = MetaMgr::Instance()->GetRobotList();
|
std::vector<MetaData::Robot>* robot_list = MetaMgr::Instance()->GetRobotList();
|
||||||
if (!robot_list || robot_list->empty()) {
|
if (!robot_list || robot_list->empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MetaData::Player* hum_meta = MetaMgr::Instance()->GetPlayer(40002);
|
|
||||||
assert(hum_meta);
|
|
||||||
if (!hum_meta) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
if (robot_num <= 0) {
|
if (robot_num <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -266,7 +300,7 @@ void Room::CreateAndroid(int robot_num)
|
|||||||
|
|
||||||
Android* hum = new Android();
|
Android* hum = new Android();
|
||||||
hum->name = robot_meta->i->name();
|
hum->name = robot_meta->i->name();
|
||||||
hum->meta = hum_meta;
|
hum->meta = MetaMgr::Instance()->android_meta;
|
||||||
hum->robot_meta = robot_meta;
|
hum->robot_meta = robot_meta;
|
||||||
hum->entity_uniid = AllocUniid();
|
hum->entity_uniid = AllocUniid();
|
||||||
hum->born_point = AllocBornPoint(hum);
|
hum->born_point = AllocBornPoint(hum);
|
||||||
@ -294,19 +328,24 @@ DEFAULT_BORN_POINT_Y + rand() % 1500)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
uniid_hash_[hum->entity_uniid] = hum;
|
uniid_hash_[hum->entity_uniid] = hum;
|
||||||
moveable_hash_[hum->entity_uniid] = hum;
|
|
||||||
human_hash_[hum->entity_uniid] = hum;
|
human_hash_[hum->entity_uniid] = hum;
|
||||||
++alive_count_;
|
++alive_count_;
|
||||||
++App::Instance()->perf.alive_count;
|
|
||||||
grid_service->AddHuman(hum);
|
|
||||||
hum->FindLocation();
|
|
||||||
hum->RefreshView();
|
|
||||||
{
|
{
|
||||||
hum->team_id = NewTeam();
|
hum->team_id = NewTeam();
|
||||||
hum->team_members = &team_hash_[hum->team_id];
|
hum->team_members = &team_hash_[hum->team_id];
|
||||||
hum->team_members->insert(hum);
|
hum->team_members->insert(hum);
|
||||||
}
|
}
|
||||||
|
++App::Instance()->perf.alive_count;
|
||||||
refreshed_robot_set_.insert(robot_meta->i->id());
|
refreshed_robot_set_.insert(robot_meta->i->id());
|
||||||
|
|
||||||
|
if (room_type == RT_NewBrid) {
|
||||||
|
a8::SetBitFlag(hum->status, HS_Disable);
|
||||||
|
} else {
|
||||||
|
moveable_hash_[hum->entity_uniid] = hum;
|
||||||
|
grid_service->AddHuman(hum);
|
||||||
|
hum->FindLocation();
|
||||||
|
hum->RefreshView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,18 +633,20 @@ bool Room::CanJoin(const std::string& accountid, RoomType_e self_room_type)
|
|||||||
if (gas_data.gas_mode != GasInactive) {
|
if (gas_data.gas_mode != GasInactive) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (accountid_hash_.find(accountid) != accountid_hash_.end()) {
|
if (GetPlayerByAccountId(accountid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (self_room_type == RT_NewBrid) {
|
if (room_type == RT_NewBrid) {
|
||||||
int remain_time_ms = GetGasInactiveTime() * 1000 -
|
if (GetPlayerNum() > 0) {
|
||||||
(frame_no - gas_data.gas_start_frameno) * FRAME_RATE_MS;
|
|
||||||
remain_time_ms = std::max(remain_time_ms, 0);
|
|
||||||
if (remain_time_ms <= MetaMgr::Instance()->newbie_wait_time * 1000) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return accountid_hash_.size() < ROOM_MAX_PLAYER_NUM;
|
if (room_type == RT_MidBrid) {
|
||||||
|
if (GetPlayerNum() > 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GetPlayerNum() < ROOM_MAX_PLAYER_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::OnPlayerOffline(Player* hum)
|
void Room::OnPlayerOffline(Player* hum)
|
||||||
@ -1557,6 +1598,15 @@ void Room::SecondRandPoint()
|
|||||||
|
|
||||||
void Room::NotifyGameStart()
|
void Room::NotifyGameStart()
|
||||||
{
|
{
|
||||||
|
if (room_type == RT_NewBrid) {
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
if (pair.second->entity_subtype == EST_Android &&
|
||||||
|
!a8::HasBitFlag(pair.second->status, HS_Disable)) {
|
||||||
|
DisableHuman(pair.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cs::SMGameStart msg;
|
cs::SMGameStart msg;
|
||||||
for (auto& pair : accountid_hash_) {
|
for (auto& pair : accountid_hash_) {
|
||||||
pair.second->SendNotifyMsg(msg);
|
pair.second->SendNotifyMsg(msg);
|
||||||
@ -1605,3 +1655,37 @@ long long Room::GetGasInactiveTime()
|
|||||||
return MetaMgr::Instance()->gas_inactive_time;
|
return MetaMgr::Instance()->gas_inactive_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::EnableHuman(Human* target)
|
||||||
|
{
|
||||||
|
if (a8::HasBitFlag(target->status, HS_Disable)) {
|
||||||
|
a8::UnSetBitFlag(target->status, HS_Disable);
|
||||||
|
moveable_hash_[target->entity_uniid] = target;
|
||||||
|
grid_service->AddHuman(target);
|
||||||
|
#if 0
|
||||||
|
target->FindLocation();
|
||||||
|
#endif
|
||||||
|
target->RefreshView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::DisableHuman(Human* target)
|
||||||
|
{
|
||||||
|
if (!a8::HasBitFlag(target->status, HS_Disable)) {
|
||||||
|
a8::SetBitFlag(target->status, HS_Disable);
|
||||||
|
moveable_hash_.erase(target->entity_uniid);
|
||||||
|
for (auto& cell : target->grid_list) {
|
||||||
|
bool has_target = false;
|
||||||
|
for (Human* hum : cell->human_list[room_idx]) {
|
||||||
|
if (hum == target) {
|
||||||
|
has_target = true;
|
||||||
|
} else {
|
||||||
|
hum->RemoveOutObjects(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (has_target) {
|
||||||
|
cell->human_list[room_idx].erase(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -118,6 +118,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
int AllocUniid();
|
int AllocUniid();
|
||||||
void ShuaAndroid();
|
void ShuaAndroid();
|
||||||
|
void ShowAndroid(Human* target, int num);
|
||||||
void CreateAndroid(int android_num);
|
void CreateAndroid(int android_num);
|
||||||
void UpdateGas();
|
void UpdateGas();
|
||||||
void UpdateGasInactive();
|
void UpdateGasInactive();
|
||||||
@ -147,10 +148,13 @@ private:
|
|||||||
void SecondRandPoint();
|
void SecondRandPoint();
|
||||||
void NotifyGameStart();
|
void NotifyGameStart();
|
||||||
void InitObstacleDatas();
|
void InitObstacleDatas();
|
||||||
|
void EnableHuman(Human* hum);
|
||||||
|
void DisableHuman(Human* hum);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int elapsed_time_ = 0;
|
int elapsed_time_ = 0;
|
||||||
int alive_count_ = 0;
|
int alive_count_ = 0;
|
||||||
|
int force_shua_android_times_ = 0;
|
||||||
MetaData::AirLine* airline_ = nullptr;
|
MetaData::AirLine* airline_ = nullptr;
|
||||||
a8::XTimerAttacher xtimer_attacher_;
|
a8::XTimerAttacher xtimer_attacher_;
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ static RoomType_e GetHumanRoomType(const cs::CMJoin& msg)
|
|||||||
#endif
|
#endif
|
||||||
if (game_times <= MetaMgr::Instance()->newbie_game_times) {
|
if (game_times <= MetaMgr::Instance()->newbie_game_times) {
|
||||||
return RT_NewBrid;
|
return RT_NewBrid;
|
||||||
|
} else if (game_times == 2) {
|
||||||
|
return RT_MidBrid;
|
||||||
}
|
}
|
||||||
return RT_OldBrid;
|
return RT_OldBrid;
|
||||||
}
|
}
|
||||||
@ -53,10 +55,6 @@ void RoomMgr::Init()
|
|||||||
if (!map_meta_) {
|
if (!map_meta_) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
hum_meta_ = MetaMgr::Instance()->GetPlayer(40001);
|
|
||||||
if (!hum_meta_) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
map_service_ = new MapService();
|
map_service_ = new MapService();
|
||||||
grid_service_ = new GridService();
|
grid_service_ = new GridService();
|
||||||
grid_service_->Init(map_meta_->i->map_width(),
|
grid_service_->Init(map_meta_->i->map_width(),
|
||||||
@ -117,7 +115,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
CreatePlayerByCMJoin(hdr.ip_saddr,
|
CreatePlayerByCMJoin(hdr.ip_saddr,
|
||||||
hdr.socket_handle,
|
hdr.socket_handle,
|
||||||
msg);
|
msg);
|
||||||
hum->meta = hum_meta_;
|
hum->meta = MetaMgr::Instance()->human_meta;
|
||||||
hum->ProcPrepareItems(msg.prepare_items());
|
hum->ProcPrepareItems(msg.prepare_items());
|
||||||
hum->ProcPrepareItems2(msg.prepare_items2());
|
hum->ProcPrepareItems2(msg.prepare_items2());
|
||||||
room->AddPlayer(hum);
|
room->AddPlayer(hum);
|
||||||
@ -157,6 +155,11 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (self_room_type == RT_MidBrid) {
|
||||||
|
if (RoomNum() < ROOM_NUM_DOWN_LIMIT - 5) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (int i = 0; i < RT_Max; ++i) {
|
for (int i = 0; i < RT_Max; ++i) {
|
||||||
if (RoomNum() > ROOM_NUM_DOWN_LIMIT - 5) {
|
if (RoomNum() > ROOM_NUM_DOWN_LIMIT - 5) {
|
||||||
for (Room* room : group_rooms[i]) {
|
for (Room* room : group_rooms[i]) {
|
||||||
|
@ -11,7 +11,6 @@ namespace MetaData
|
|||||||
{
|
{
|
||||||
struct Map;
|
struct Map;
|
||||||
struct MapTplThing;
|
struct MapTplThing;
|
||||||
struct Player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace metatable
|
namespace metatable
|
||||||
@ -81,6 +80,4 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
|||||||
std::vector<MetaData::MapTplThing*> spawn_points_;
|
std::vector<MetaData::MapTplThing*> spawn_points_;
|
||||||
std::vector<MetaData::MapTplThing*> loots_;
|
std::vector<MetaData::MapTplThing*> loots_;
|
||||||
std::vector<Building*> buildings_;
|
std::vector<Building*> buildings_;
|
||||||
|
|
||||||
MetaData::Player* hum_meta_;
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user