Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
580a9e1519 | ||
![]() |
3c3c897625 |
@ -90,6 +90,9 @@ void AndroidAI::ChangeToState(AndroidState_e to_state)
|
||||
void AndroidAI::DoMove()
|
||||
{
|
||||
Human* hum = (Human*)owner;
|
||||
if (hum->room->IsWaitingStart()) {
|
||||
return;
|
||||
}
|
||||
if (a8::HasBitFlag(hum->status, HS_Fly)) {
|
||||
return;
|
||||
}
|
||||
@ -118,6 +121,9 @@ void AndroidAI::DoAttack()
|
||||
a8::HasBitFlag(hum->status, HS_Jump)) {
|
||||
return;
|
||||
}
|
||||
if (hum->room->IsWaitingStart()) {
|
||||
return;
|
||||
}
|
||||
if (hum->room->gas_data.gas_mode == GasInactive) {
|
||||
return;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class Human : public Entity
|
||||
std::set<Human*> kill_humans;
|
||||
Human* last_tank_attacker = nullptr;
|
||||
long long last_tank_attack_idx = 0;
|
||||
const BornPoint* born_point = nullptr;
|
||||
BornPoint* born_point = nullptr;
|
||||
|
||||
bool shot_start = false;
|
||||
bool shot_hold = false;
|
||||
|
@ -107,7 +107,9 @@ void Player::UpdateMove()
|
||||
if (action_type == AT_Relive) {
|
||||
CancelAction();
|
||||
}
|
||||
if (dead || a8::HasBitFlag(status, HS_Fly)) {
|
||||
if (dead ||
|
||||
room->IsWaitingStart() ||
|
||||
a8::HasBitFlag(status, HS_Fly)) {
|
||||
moving = false;
|
||||
moved_frames = 0;
|
||||
last_collision_door = nullptr;
|
||||
@ -137,6 +139,8 @@ void Player::UpdateMove()
|
||||
void Player::UpdateShot()
|
||||
{
|
||||
if (dead ||
|
||||
downed ||
|
||||
room->IsWaitingStart() ||
|
||||
a8::HasBitFlag(status, HS_Fly) ||
|
||||
a8::HasBitFlag(status, HS_Jump) ) {
|
||||
shot_start = false;
|
||||
|
@ -952,45 +952,72 @@ void Room::UpdateGasInactive()
|
||||
{
|
||||
if (frame_no - gas_data.gas_start_frameno >=
|
||||
MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) {
|
||||
#if 1
|
||||
gas_data.gas_mode = GasWaiting;
|
||||
gas_data.old_area_meta = MetaMgr::Instance()->GetSafeArea(30001);
|
||||
gas_data.new_area_meta = MetaMgr::Instance()->GetSafeArea(30002);
|
||||
gas_data.gas_progress = gas_data.old_area_meta->i->rad();
|
||||
gas_data.gas_start_frameno = frame_no;
|
||||
gas_data.pos_old = a8::Vec2(map_meta->i->map_width() / 2.0f,
|
||||
map_meta->i->map_height() / 2.0f);
|
||||
gas_data.pos_old_bk = gas_data.pos_old;
|
||||
{
|
||||
bool gen_ok = GenSmallCircle(gas_data.pos_old,
|
||||
gas_data.old_area_meta->i->rad(),
|
||||
gas_data.new_area_meta->i->rad(),
|
||||
gas_data.pos_new);
|
||||
assert(gen_ok);
|
||||
}
|
||||
gas_data.rad_old = gas_data.old_area_meta->i->rad();
|
||||
gas_data.rad_new = gas_data.new_area_meta->i->rad();
|
||||
battle_start_frameno_ = frame_no;
|
||||
#else
|
||||
gas_data.gas_mode = GasJump;
|
||||
gas_data.gas_start_frameno = frame_no;
|
||||
#endif
|
||||
if (human_hash_.size() < ROOM_MAX_PLAYER_NUM) {
|
||||
CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size());
|
||||
NotifyUiUpdate();
|
||||
}
|
||||
NotifyUiUpdate();
|
||||
CombineTeam();
|
||||
ShuaPlane();
|
||||
NotifyGameStart();
|
||||
NotifyWxVoip();
|
||||
InitAirDrop();
|
||||
RoomMgr::Instance()->ActiveRoom(room_uuid);
|
||||
#if 0
|
||||
ShuaPlane();
|
||||
int auto_jump_interval = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_interval");
|
||||
auto_jump_timer_ = xtimer.AddRepeatTimerAndAttach(SERVER_FRAME_RATE * auto_jump_interval,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Room* room = (Room*)param.sender.GetUserData();
|
||||
int auto_jump_min_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_min_num");
|
||||
int auto_jump_max_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_max_num");
|
||||
int jump_num = a8::RandEx(auto_jump_min_num, auto_jump_max_num);
|
||||
if (room->last_player_jump_pos.Distance(room->plane.curr_pos) < 64 * 8) {
|
||||
jump_num = 1 + rand() % 2;
|
||||
}
|
||||
for (int i = 0; i < jump_num; ++i) {
|
||||
room->TouchHumanList(
|
||||
a8::XParams()
|
||||
.SetSender(room),
|
||||
[] (Human* hum, a8::XParams& param) -> bool
|
||||
{
|
||||
if (a8::HasBitFlag(hum->status, HS_Fly) && hum->entity_subtype != EST_Player) {
|
||||
hum->DoJump();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
},
|
||||
&xtimer_attacher.timer_list_);
|
||||
auto_jump_timer_ = xtimer.AddRepeatTimerAndAttach
|
||||
(SERVER_FRAME_RATE * auto_jump_interval,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Room* room = (Room*)param.sender.GetUserData();
|
||||
int auto_jump_min_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_min_num");
|
||||
int auto_jump_max_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_max_num");
|
||||
int jump_num = a8::RandEx(auto_jump_min_num, auto_jump_max_num);
|
||||
if (room->last_player_jump_pos.Distance(room->plane.curr_pos) < 64 * 8) {
|
||||
jump_num = 1 + rand() % 2;
|
||||
}
|
||||
for (int i = 0; i < jump_num; ++i) {
|
||||
room->TouchHumanList
|
||||
(
|
||||
a8::XParams()
|
||||
.SetSender(room),
|
||||
[] (Human* hum, a8::XParams& param) -> bool
|
||||
{
|
||||
if (a8::HasBitFlag(hum->status, HS_Fly) &&
|
||||
hum->entity_subtype != EST_Player) {
|
||||
hum->DoJump();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
},
|
||||
&xtimer_attacher.timer_list_);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1544,3 +1571,114 @@ void Room::CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl)
|
||||
born_point.thing_tpl = &thing_tpl;
|
||||
born_point_hash_[AllocUniid()] = born_point;
|
||||
}
|
||||
|
||||
void Room::SecondRandPoint()
|
||||
{
|
||||
for (auto& pair : accountid_hash_) {
|
||||
Human* hum = pair.second;
|
||||
hum->born_point = AllocBornPoint(hum);
|
||||
}
|
||||
CombineTeamBornPoint();
|
||||
}
|
||||
|
||||
void Room::NotifyGameStart()
|
||||
{
|
||||
cs::SMGameStart msg;
|
||||
for (auto& pair : accountid_hash_) {
|
||||
pair.second->SendNotifyMsg(msg);
|
||||
}
|
||||
|
||||
waiting_start_ = true;
|
||||
xtimer.AddDeadLineTimerAndAttach
|
||||
(SERVER_FRAME_RATE * 2,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Room* room = (Room*)param.sender.GetUserData();
|
||||
room->waiting_start_ = false;
|
||||
},
|
||||
&xtimer_attacher.timer_list_);
|
||||
xtimer.AddDeadLineTimerAndAttach
|
||||
(SERVER_FRAME_RATE * 1,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Room* room = (Room*)param.sender.GetUserData();
|
||||
room->SecondRandPoint();
|
||||
},
|
||||
&xtimer_attacher.timer_list_);
|
||||
}
|
||||
|
||||
void Room::CombineTeamBornPoint()
|
||||
{
|
||||
for (auto& pair : team_hash_) {
|
||||
Human* target = nullptr;
|
||||
for (Human* hum : pair.second) {
|
||||
if (!target) {
|
||||
target = hum;
|
||||
} else {
|
||||
if (target->born_point) {
|
||||
if (hum->born_point) {
|
||||
DecBornPointHumanNum(hum->born_point, hum);
|
||||
}
|
||||
hum->born_point = target->born_point;
|
||||
if (hum->born_point) {
|
||||
IncBornPointHumanNum(hum->born_point, hum);
|
||||
}
|
||||
}
|
||||
} //end if
|
||||
if (!hum->born_point) {
|
||||
hum->pos = a8::Vec2(DEFAULT_BORN_POINT_X + rand() % 100,
|
||||
DEFAULT_BORN_POINT_Y + rand() % 200);
|
||||
} else {
|
||||
hum->pos = hum->born_point->RandPoint();
|
||||
}
|
||||
hum->FindLocation();
|
||||
hum->RefreshView();
|
||||
grid_service.MoveHuman(hum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
||||
{
|
||||
switch (hum->entity_subtype) {
|
||||
case EST_Player:
|
||||
{
|
||||
++point->player_num;
|
||||
}
|
||||
break;
|
||||
case EST_Android:
|
||||
{
|
||||
++point->android_num;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Room::DecBornPointHumanNum(BornPoint* point, Human* hum)
|
||||
{
|
||||
switch (hum->entity_subtype) {
|
||||
case EST_Player:
|
||||
{
|
||||
--point->player_num;
|
||||
}
|
||||
break;
|
||||
case EST_Android:
|
||||
{
|
||||
--point->android_num;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
Player* GetPlayerByAccountId(const std::string& accountid);
|
||||
Player* GetPlayerByUniId(int uniid);
|
||||
Entity* GetEntityByUniId(int uniid);
|
||||
bool IsWaitingStart() { return waiting_start_; }
|
||||
|
||||
void AddPlayer(Player* hum);
|
||||
Human* FindEnemy(Human* hum);
|
||||
@ -130,6 +131,11 @@ private:
|
||||
BornPoint* AllocBornPoint(Human* hum);
|
||||
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
|
||||
void CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl);
|
||||
void SecondRandPoint();
|
||||
void NotifyGameStart();
|
||||
void CombineTeamBornPoint();
|
||||
void IncBornPointHumanNum(BornPoint* point, Human* hum);
|
||||
void DecBornPointHumanNum(BornPoint* point, Human* hum);
|
||||
|
||||
private:
|
||||
int elapsed_time_ = 0;
|
||||
@ -137,6 +143,7 @@ private:
|
||||
MetaData::AirLine* airline_ = nullptr;
|
||||
a8::XTimerAttacher xtimer_attacher;
|
||||
xtimer_list* auto_jump_timer_ = nullptr;
|
||||
bool waiting_start_ = false;
|
||||
|
||||
int current_teamid = 0;
|
||||
int current_uniid = 0;
|
||||
|
@ -36,4 +36,5 @@ enum SMMessageId_e
|
||||
_SMDebugMsg = 1010;
|
||||
_SMWxVoip = 1011;
|
||||
_SMUiUpdate = 1012;
|
||||
_SMGameStart = 1013;
|
||||
}
|
||||
|
@ -413,6 +413,9 @@ message MFObjectFull
|
||||
optional MFProjectileFull union_obj_8 = 9;
|
||||
optional MFSmokeFull union_obj_9 = 10;
|
||||
optional MFHeroFull union_obj_10 = 11;
|
||||
|
||||
optional int32 obj_uniid = 14; //唯一id
|
||||
optional int32 object_flags = 15; //对象标志位 1<<0: 存缓存 1<<1:读缓存
|
||||
}
|
||||
|
||||
//活跃玩家数据(当前)
|
||||
@ -868,4 +871,10 @@ message SMUiUpdate
|
||||
optional int32 alive_count = 1; //存活数量
|
||||
optional int32 kill_count = 2; //击杀数
|
||||
repeated MFCar car_list = 3; //载具列表
|
||||
}
|
||||
}
|
||||
|
||||
//游戏开始
|
||||
message SMGameStart
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user