This commit is contained in:
aozhiwei 2021-03-15 16:16:46 +08:00
commit 90eddc10b2
13 changed files with 172 additions and 42 deletions

View File

@ -24,6 +24,7 @@ void AIComponent::SetAiMode(int ai_mode)
int AIComponent::GetAiLevel() int AIComponent::GetAiLevel()
{ {
return 1;
return ai_level_; return ai_level_;
} }

View File

@ -475,15 +475,11 @@ void AndroidNewAI::UpdateThinking()
hum->room->IsWaitingStart() || hum->room->IsWaitingStart() ||
hum->HasBuffEffect(kBET_Jump) || hum->HasBuffEffect(kBET_Jump) ||
a8::HasBitFlag(hum->status, HS_DisableAttack)) { a8::HasBitFlag(hum->status, HS_DisableAttack)) {
#if 1
if (hum->room->IsWaitingStart()) { if (hum->room->IsWaitingStart()) {
ChangeToStateNewAI(ASE_Idle); ChangeToStateNewAI(ASE_Idle);
} else { } else {
ChangeToStateNewAI(ASE_RandomWalk); ChangeToStateNewAI(ASE_RandomWalk);
} }
#else
ChangeToStateNewAI(ASE_RandomWalk);
#endif
} else { } else {
Human* target = GetTarget(); Human* target = GetTarget();
if (target) { if (target) {

View File

@ -60,6 +60,11 @@ void Android::InternalUpdate(int delta_time)
if (action_type != AT_None) { if (action_type != AT_None) {
UpdateAction(); UpdateAction();
} }
if (HasBuffEffect(kBET_Fly)) {
SetPos(room->plane.curr_pos);
room->grid_service->MoveHuman(this);
return;
}
ai->Update(delta_time); ai->Update(delta_time);
} }

View File

@ -141,13 +141,15 @@ enum BuffEffectType_e
kBET_CliEffect3 = 21, //僵尸被动光环地震(客户端表现用) kBET_CliEffect3 = 21, //僵尸被动光环地震(客户端表现用)
kBET_CliEffect4 = 22, //被拖拽(客户端表现用) kBET_CliEffect4 = 22, //被拖拽(客户端表现用)
kBET_HunLuan = 23, //混乱,在烟雾弹中不自动瞄准 kBET_HunLuan = 23, //混乱,在烟雾弹中不自动瞄准
kBET_Jump = 24, //跳伞中 kBET_Fly = 24, //飞行中
kBET_ThroughWall = 25, //穿墙 kBET_Jump = 25, //跳伞中
kBET_InGrass = 26, //在草丛 kBET_InGrass = 27, //在草丛
kBET_InWater = 27, //在水里 kBET_InWater = 28, //在水里
kBET_InIce = 27, //在冰里 kBET_InIce = 29, //在冰里
kBET_Driver = 28, //驾驶中 kBET_Driver = 30, //驾驶中
kBET_Passenger = 29, //乘座 kBET_Passenger = 31, //乘座
kBET_ThroughWall = 50, //穿墙
kBET_End kBET_End
}; };
@ -400,5 +402,8 @@ const int TURN_OVER_SKILL_ID = 41001;
const int HUNLUAN_BUFFID = 6001; const int HUNLUAN_BUFFID = 6001;
const int DRIVER_BUFFID = 6003; const int kThroughWall_BUFFID = 6003;
const int PASSENGER_BUFFID = 6004; const int FLY_BUFFID = 7001;
const int JUMP_BUFFID = 7002;
const int DRIVER_BUFFID = 7003;
const int PASSENGER_BUFFID = 7004;

View File

@ -36,7 +36,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
if (room->GetGasData().gas_mode == GasJump && if (room->GetGasData().gas_mode == GasJump &&
entity != hum && entity != hum &&
entity->GetEntityType() == ET_Player && entity->GetEntityType() == ET_Player &&
a8::HasBitFlag(((Human*)entity)->status, HS_Fly)) { ((Human*)entity)->HasBuffEffect(kBET_Fly)) {
continue; continue;
} }
} }

View File

@ -82,7 +82,8 @@ void InternalShot(Human* hum,
bullet_dir, bullet_dir,
fly_distance); fly_distance);
if (hum->room->BattleStarted() || if (hum->room->BattleStarted() ||
(hum->room->GetGasData().gas_mode == GasJump && !a8::HasBitFlag(hum->status, HS_Jump))) { (hum->room->GetGasData().gas_mode == GasJump &&
!hum->HasBuffEffect(kBET_Jump))) {
hum->room->CreateBullet(hum, hum->room->CreateBullet(hum,
weapon_meta, weapon_meta,
weapon_upgrade_meta, weapon_upgrade_meta,
@ -1318,21 +1319,25 @@ bool Human::CanUseSkill()
void Human::DoJump() void Human::DoJump()
{ {
if (a8::HasBitFlag(status, HS_Fly)) { if (HasBuffEffect(kBET_Fly)) {
a8::UnSetBitFlag(status, HS_Fly); RemoveBuffByEffectId(kBET_Fly);
a8::SetBitFlag(status, HS_Jump); MustBeAddBuff(this, kThroughWall_BUFFID);
MustBeAddBuff(this, JUMP_BUFFID);
jump_frameno_ = room->GetFrameNo(); jump_frameno_ = room->GetFrameNo();
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
room->xtimer.AddDeadLineTimerAndAttach MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(JUMP_BUFFID);
(MetaMgr::Instance()->jump_time * SERVER_FRAME_RATE, if (buff_meta) {
a8::XParams() room->xtimer.AddDeadLineTimerAndAttach
.SetSender(this), (buff_meta->i->duration_time() * SERVER_FRAME_RATE,
[] (const a8::XParams& param) a8::XParams()
{ .SetSender(this),
Human* hum = (Human*)param.sender.GetUserData(); [] (const a8::XParams& param)
hum->OnLand(); {
}, Human* hum = (Human*)param.sender.GetUserData();
&xtimer_attacher.timer_list_); hum->OnLand();
},
&xtimer_attacher.timer_list_);
}
} }
} }
@ -1700,18 +1705,36 @@ void Human::RemoveObserver(Human* observer)
void Human::SendUpdateMsg() void Human::SendUpdateMsg()
{ {
if (!follow_target_ && !a8::HasBitFlag(status, HS_Disable) && IsPlayer()) { if (!follow_target_ && !a8::HasBitFlag(status, HS_Disable) && IsPlayer()) {
#ifdef DEBUG
long long begin_tick = a8::XGetTickCount();
long long end_tick = a8::XGetTickCount();
#endif
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();
FillMFActivePlayerData(active_player_data_pb); FillMFActivePlayerData(active_player_data_pb);
need_sync_active_player = false; need_sync_active_player = false;
} }
#ifdef DEBUG
end_tick = a8::XGetTickCount();
if (a8::XGetTickCount() - begin_tick > 1000) {
abort();
}
begin_tick = a8::XGetTickCount();
#endif
cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this); cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this);
if (send_msg_times == 0 || last_sync_gas_frameno < room->GetGasData().gas_start_frameno) { if (send_msg_times == 0 || last_sync_gas_frameno < room->GetGasData().gas_start_frameno) {
last_sync_gas_frameno = room->GetGasData().gas_start_frameno; last_sync_gas_frameno = room->GetGasData().gas_start_frameno;
FillMFGasData(msg->mutable_gas_data()); FillMFGasData(msg->mutable_gas_data());
} }
#ifdef DEBUG
end_tick = a8::XGetTickCount();
if (a8::XGetTickCount() - begin_tick > 1000) {
abort();
}
begin_tick = a8::XGetTickCount();
#endif
NotifyObservers(msg, active_player_data_pb); NotifyObservers(msg, active_player_data_pb);
delete msg; delete msg;
@ -2201,7 +2224,7 @@ void Human::ClearFrameData()
Human* hum = (Human*)entity; Human* hum = (Human*)entity;
hum->RemovePartObjects(this); hum->RemovePartObjects(this);
} }
#ifdef DEBUG #ifdef DEBUG1
room->CheckPartObjects(); room->CheckPartObjects();
#endif #endif
} }
@ -2220,7 +2243,7 @@ void Human::ClearFrameData()
hum->RemovePartObjects(this); hum->RemovePartObjects(this);
} }
} }
#ifdef DEBUG #ifdef DEBUG1
room->CheckPartObjects(); room->CheckPartObjects();
#endif #endif
} }
@ -3044,6 +3067,15 @@ void Human::AddBuff(Human* caster,
#endif #endif
} }
void Human::MustBeAddBuff(Human* caster, int buff_id)
{
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(buff_id);
if (!buff_meta) {
abort();
}
AddBuff(caster, buff_meta, 1);
}
bool Human::IsImmuneBuffEffect(int buff_effect) bool Human::IsImmuneBuffEffect(int buff_effect)
{ {
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) { for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
@ -4211,6 +4243,7 @@ void Human::OnBuffRemove(const Buff& buff)
void Human::OnLand() void Human::OnLand()
{ {
//着陆 //着陆
RemoveBuffByEffectId(kBET_Jump);
RemoveBuffByEffectId(kBET_ThroughWall); RemoveBuffByEffectId(kBET_ThroughWall);
if (IsCollisionInMapService()) { if (IsCollisionInMapService()) {
a8::Vec2 old_pos = GetPos(); a8::Vec2 old_pos = GetPos();

View File

@ -23,8 +23,6 @@ enum HumanStatus
HS_AlreadyProcNewBieLogic = 6, HS_AlreadyProcNewBieLogic = 6,
HS_LastAndroid = 7, HS_LastAndroid = 7,
HS_DisableAttack = 8, HS_DisableAttack = 8,
HS_Fly = 9,
HS_Jump = 10,
HS_End HS_End
}; };
@ -266,6 +264,7 @@ class Human : public MoveableEntity
MetaData::Buff* buff_meta, MetaData::Buff* buff_meta,
int skill_lv, int skill_lv,
MetaData::Skill* buff_skill_meta = nullptr); MetaData::Skill* buff_skill_meta = nullptr);
void MustBeAddBuff(Human* caster, int buff_id);
bool IsImmuneBuffEffect(int buff_effect); bool IsImmuneBuffEffect(int buff_effect);
void RemoveBuffById(int buff_id); void RemoveBuffById(int buff_id);
void RemoveBuffByEffectId(int buff_effect_id); void RemoveBuffByEffectId(int buff_effect_id);

View File

@ -180,7 +180,6 @@ public:
} }
} }
MetaMgr::Instance()->jump_time = MetaMgr::Instance()->GetSysParamAsFloat("jump_time");
MetaMgr::Instance()->K = MetaMgr::Instance()->GetSysParamAsFloat("K"); MetaMgr::Instance()->K = MetaMgr::Instance()->GetSysParamAsFloat("K");
MetaMgr::Instance()->kill_param = MetaMgr::Instance()->GetSysParamAsFloat("kill_parameter"); MetaMgr::Instance()->kill_param = MetaMgr::Instance()->GetSysParamAsFloat("kill_parameter");
MetaMgr::Instance()->rank_param = MetaMgr::Instance()->GetSysParamAsFloat("rank_parameter"); MetaMgr::Instance()->rank_param = MetaMgr::Instance()->GetSysParamAsFloat("rank_parameter");

View File

@ -61,7 +61,6 @@ class MetaMgr : public a8::Singleton<MetaMgr>
int zbmode_game_duration = 60 * 2; int zbmode_game_duration = 60 * 2;
int zbmode_player_num = 15; int zbmode_player_num = 15;
int zbmode_init_zombie_num = 2; int zbmode_init_zombie_num = 2;
int jump_time = 10;
float K = 100.0f; float K = 100.0f;
float kill_param = 0.0f; float kill_param = 0.0f;
float rank_param = 0.0f; float rank_param = 0.0f;

View File

@ -56,6 +56,10 @@ void Player::InternalUpdate(int delta_time)
if (poisoning) { if (poisoning) {
poisoning_time += delta_time; poisoning_time += delta_time;
} }
if (HasBuffEffect(kBET_Fly)) {
SetPos(room->plane.curr_pos);
room->grid_service->MoveHuman(this);
}
if (HasSpecMove()) { if (HasSpecMove()) {
_UpdateSpecMove(); _UpdateSpecMove();
} else { } else {
@ -97,6 +101,9 @@ void Player::InternalUpdate(int delta_time)
if (emote) { if (emote) {
UpdateEmote(); UpdateEmote();
} }
if (jump) {
UpdateJump();
}
if (get_down) { if (get_down) {
UpdateGetDown(); UpdateGetDown();
} }
@ -311,7 +318,7 @@ void Player::UpdateSpectate()
{ {
if (room->GetGasData().gas_mode == GasInactive || if (room->GetGasData().gas_mode == GasInactive ||
room->GetGasData().gas_mode == GasJump || room->GetGasData().gas_mode == GasJump ||
a8::HasBitFlag(status, HS_Fly)) { HasBuffEffect(kBET_Fly)) {
spectate = false; spectate = false;
return; return;
} }
@ -326,6 +333,41 @@ void Player::UpdateEmote()
emote_id = 0; emote_id = 0;
} }
void Player::UpdateJump()
{
if (HasBuffEffect(kBET_Fly)) {
DoJump();
if (GetPos().Distance(room->last_player_jump_pos) > 64 * 4) {
size_t num = 2 + rand() % 2;
for (size_t i = 0; i < num; ++i){
room->xtimer.AddDeadLineTimerAndAttach
(SERVER_FRAME_RATE / 10,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->room->TouchHumanList
(
a8::XParams()
.SetSender(hum),
[] (Human* hum, a8::XParams& param) -> bool
{
if (hum->HasBuffEffect(kBET_Fly) && hum->IsAndroid()) {
hum->DoJump();
return false;
}
return true;
});
},
&xtimer_attacher.timer_list_);
}
}
room->last_player_jump_pos = GetPos();
}
jump = false;
}
void Player::UpdateGetDown() void Player::UpdateGetDown()
{ {
DoGetDown(); DoGetDown();

View File

@ -55,6 +55,8 @@ class Player : public Human
bool emote = false; bool emote = false;
int emote_id = 0; int emote_id = 0;
bool jump = false;
bool use_skill = false; bool use_skill = false;
bool get_down = false; bool get_down = false;
@ -75,6 +77,7 @@ class Player : public Human
void UpdateUseItemId(); void UpdateUseItemId();
void UpdateSpectate(); void UpdateSpectate();
void UpdateEmote(); void UpdateEmote();
void UpdateJump();
void UpdateGetDown(); void UpdateGetDown();
void UpdateUseSkill(); void UpdateUseSkill();
void Shot(); void Shot();

View File

@ -127,15 +127,39 @@ void Room::Update(int delta_time)
elapsed_time_ += delta_time; elapsed_time_ += delta_time;
while (elapsed_time_ >= 50) { while (elapsed_time_ >= 50) {
#ifdef DEBUG
long long begin_tick = a8::XGetTickCount();
long long end_tick = a8::XGetTickCount();
#endif
if (GetFrameNo() % 2 == 0) { if (GetFrameNo() % 2 == 0) {
UpdateGas(); UpdateGas();
} }
#ifdef DEBUG
end_tick = a8::XGetTickCount();
if (a8::XGetTickCount() - begin_tick > 1000) {
abort();
}
begin_tick = a8::XGetTickCount();
#endif
for (auto& pair : moveable_hash_) { for (auto& pair : moveable_hash_) {
pair.second->Update(50); pair.second->Update(50);
} }
#ifdef DEBUG
end_tick = a8::XGetTickCount();
if (a8::XGetTickCount() - begin_tick > 1000) {
abort();
}
begin_tick = a8::XGetTickCount();
#endif
if (GetFrameNo() % 2 == 0) { if (GetFrameNo() % 2 == 0) {
SyncFrameData(); SyncFrameData();
} }
#ifdef DEBUG
end_tick = a8::XGetTickCount();
if (a8::XGetTickCount() - begin_tick > 1000) {
abort();
}
#endif
++frameno_; ++frameno_;
elapsed_time_ -= 50; elapsed_time_ -= 50;
} }
@ -1072,6 +1096,7 @@ void Room::UpdateGas()
void Room::UpdateGasInactive() void Room::UpdateGasInactive()
{ {
if (GetFrameNo() - gas_data_.gas_start_frameno >= GetGasInactiveTime() * SERVER_FRAME_RATE) { if (GetFrameNo() - gas_data_.gas_start_frameno >= GetGasInactiveTime() * SERVER_FRAME_RATE) {
long long begin_tick = a8::XGetTickCount();
gas_data_.gas_mode = GasJump; gas_data_.gas_mode = GasJump;
gas_data_.gas_start_frameno = GetFrameNo(); gas_data_.gas_start_frameno = GetFrameNo();
if (human_hash_.size() < GetRoomMaxPlayerNum()) { if (human_hash_.size() < GetRoomMaxPlayerNum()) {
@ -1094,7 +1119,7 @@ void Room::UpdateGasInactive()
int auto_jump_min_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_min_num"); 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 auto_jump_max_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_max_num");
int jump_num = a8::RandEx(auto_jump_min_num, 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) { if (room->last_player_jump_pos.Distance(room->plane.curr_pos) < 64 * 8) {
jump_num = 1 + rand() % 2; jump_num = 1 + rand() % 2;
} }
for (int i = 0; i < jump_num; ++i) { for (int i = 0; i < jump_num; ++i) {
@ -1104,7 +1129,7 @@ void Room::UpdateGasInactive()
.SetSender(room), .SetSender(room),
[] (Human* hum, a8::XParams& param) -> bool [] (Human* hum, a8::XParams& param) -> bool
{ {
if (a8::HasBitFlag(hum->status, HS_Fly) && if (hum->HasBuffEffect(kBET_Fly) &&
hum->GetEntitySubType() != EST_Player) { hum->GetEntitySubType() != EST_Player) {
hum->DoJump(); hum->DoJump();
return false; return false;
@ -1114,6 +1139,10 @@ void Room::UpdateGasInactive()
} }
}, },
&xtimer_attacher_.timer_list_); &xtimer_attacher_.timer_list_);
#if 1
a8::XPrintf("max_run_delay:%d %d\n", {PerfMonitor::Instance()->max_run_delay_time,
a8::XGetTickCount() - begin_tick});
#endif
} }
} }
@ -1200,7 +1229,7 @@ void Room::UpdateGasJump()
a8::XParams(), a8::XParams(),
[] (Human* hum, a8::XParams& param) -> bool [] (Human* hum, a8::XParams& param) -> bool
{ {
if (a8::HasBitFlag(hum->status, HS_Fly)) { if (hum->HasBuffEffect(kBET_Fly)) {
hum->DoJump(); hum->DoJump();
} }
if (hum->GetEntitySubType() == EST_Player) { if (hum->GetEntitySubType() == EST_Player) {
@ -1624,10 +1653,10 @@ void Room::ShuaPlane()
plane.dir = plane.end_point - plane.start_point; plane.dir = plane.end_point - plane.start_point;
plane.dir.Normalize(); plane.dir.Normalize();
plane.curr_pos = plane.start_point; plane.curr_pos = plane.start_point;
last_player_jump_pos_ = plane.curr_pos; last_player_jump_pos = plane.curr_pos;
for (auto& pair : human_hash_) { for (auto& pair : human_hash_) {
a8::SetBitFlag(pair.second->status, HS_Fly); pair.second->MustBeAddBuff(pair.second, FLY_BUFFID);
pair.second->SetPos(plane.curr_pos); pair.second->SetPos(plane.curr_pos);
pair.second->attack_dir = plane.dir; pair.second->attack_dir = plane.dir;
pair.second->move_dir = plane.dir; pair.second->move_dir = plane.dir;
@ -2135,6 +2164,7 @@ void Room::NotifyGameStart()
} }
}, },
&xtimer_attacher_.timer_list_); &xtimer_attacher_.timer_list_);
#if 0
xtimer.AddDeadLineTimerAndAttach xtimer.AddDeadLineTimerAndAttach
(SERVER_FRAME_RATE * 1, (SERVER_FRAME_RATE * 1,
a8::XParams() a8::XParams()
@ -2146,7 +2176,7 @@ void Room::NotifyGameStart()
room->SecondRandPoint(); room->SecondRandPoint();
}, },
&xtimer_attacher_.timer_list_); &xtimer_attacher_.timer_list_);
#endif
if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) { if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) {
NewBieRoomStart(); NewBieRoomStart();
} }
@ -3235,9 +3265,27 @@ bool Room::CanAddToScene(Human* hum)
void Room::SyncFrameData() void Room::SyncFrameData()
{ {
#ifdef DEBUG
long long begin_tick = a8::XGetTickCount();
long long end_tick = a8::XGetTickCount();
#endif
for (auto& pair : human_hash_) { for (auto& pair : human_hash_) {
pair.second->SendUpdateMsg(); pair.second->SendUpdateMsg();
#ifdef DEBUG
end_tick = a8::XGetTickCount();
if (a8::XGetTickCount() - begin_tick > 100) {
abort();
}
begin_tick = a8::XGetTickCount();
#endif
} }
#ifdef DEBUG
end_tick = a8::XGetTickCount();
if (a8::XGetTickCount() - begin_tick > 1000) {
abort();
}
begin_tick = a8::XGetTickCount();
#endif
frame_event.Clear(); frame_event.Clear();
} }

View File

@ -46,6 +46,7 @@ public:
MapService* map_service = nullptr; MapService* map_service = nullptr;
bool debug_trace = false; bool debug_trace = false;
bool added_to_over_room = false; bool added_to_over_room = false;
a8::Vec2 last_player_jump_pos;
~Room(); ~Room();
void InitData(RoomInitInfo& init_info); void InitData(RoomInitInfo& init_info);
@ -306,5 +307,4 @@ private:
std::vector<ObstacleData> obstacle_datas_; std::vector<ObstacleData> obstacle_datas_;
xtimer_list* auto_jump_timer_ = nullptr; xtimer_list* auto_jump_timer_ = nullptr;
a8::Vec2 last_player_jump_pos_;
}; };