移除跳伞逻辑

This commit is contained in:
aozhiwei 2019-06-29 13:59:56 +08:00
parent 872aa189d0
commit b0897f7327
13 changed files with 18 additions and 356 deletions

View File

@ -86,9 +86,6 @@ void AndroidAI::ChangeToState(AndroidState_e to_state)
void AndroidAI::DoMove()
{
Human* hum = (Human*)owner;
if (a8::HasBitFlag(hum->status, HS_Fly)) {
return;
}
if (owner->updated_times % 2 == 0) {
Human* hum = (Human*)owner;
int speed = std::max(1, (int)hum->GetSpeed());
@ -110,10 +107,6 @@ void AndroidAI::DoMove()
void AndroidAI::DoAttack()
{
Human* hum = (Human*)owner;
if (a8::HasBitFlag(hum->status, HS_Fly) ||
a8::HasBitFlag(hum->status, HS_Jump)) {
return;
}
if (hum->room->gas_data.gas_mode == GasInactive) {
return;
}

View File

@ -32,10 +32,6 @@ void Android::Initialize()
void Android::Update(int delta_time)
{
if (a8::HasBitFlag(status, HS_Fly)) {
pos = room->plane.curr_pos;
room->grid_service.MoveHuman(this);
}
if (action_type != AT_None) {
UpdateAction();
}

View File

@ -65,9 +65,7 @@ void Human::Initialize()
float Human::GetSpeed()
{
if (a8::HasBitFlag(status, HS_Jump)) {
return meta->i->jump_speed() + buff.speed;
} if (downed) {
if (downed) {
return meta->i->move_speed3() + buff.speed;
} else {
if (shot_hold) {
@ -296,10 +294,6 @@ bool Human::IsCollision()
return true;
}
if (a8::HasBitFlag(status, HS_Jump)) {
return false;
}
std::vector<Entity*> objects;
for (auto& grid : grid_list) {
for (Entity* entity : grid->entity_list) {
@ -338,10 +332,6 @@ bool Human::IsCollisionInMapService()
return true;
}
if (a8::HasBitFlag(status, HS_Jump)) {
return false;
}
std::set<ColliderComponent*> colliders;
room->map_service.GetColliders(pos.x, pos.y, colliders);
@ -845,44 +835,6 @@ bool Human::HasNoDownedTeammate()
return false;
}
void Human::Land()
{
a8::UnSetBitFlag(status, HS_Jump);
if (App::Instance()->HasFlag(8)) {
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(a8::RandEx(12103, 12122));
if (weapon_meta) {
weapons[GUN_SLOT1].weapon_idx = GUN_SLOT1;
weapons[GUN_SLOT1].weapon_id = weapon_meta->i->id();
weapons[GUN_SLOT1].weapon_lv = 1;
weapons[GUN_SLOT1].ammo = 0;
weapons[GUN_SLOT1].meta = weapon_meta;
weapons[GUN_SLOT1].Recalc();
curr_weapon = &weapons[GUN_SLOT1];
}
}
FindLocation();
SyncAroundPlayers();
}
void Human::DoJump()
{
if (a8::HasBitFlag(status, HS_Fly)) {
a8::UnSetBitFlag(status, HS_Fly);
a8::SetBitFlag(status, HS_Jump);
jump_frameno = room->frame_no;
SyncAroundPlayers();
room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->jump_time * SERVER_FRAME_RATE,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->Land();
},
&xtimer_attacher.timer_list_);
}
}
void Human::DoSkill()
{
if (skill_meta && skill_meta->i->condition() == SC_Active) {
@ -1353,17 +1305,6 @@ void Human::FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState
state->set_left_time(left_time);
state->set_lasting_time(anodyne_max_time * 1000);
}
if (a8::HasBitFlag(status, HS_Fly)) {
cs::MFBodyState* state = states->Add();
state->set_state_type(2);
}
if (a8::HasBitFlag(status, HS_Jump)) {
int passed_time = (room->frame_no - jump_frameno) * FRAME_RATE_MS;
cs::MFBodyState* state = states->Add();
state->set_state_type(3);
state->set_left_time(std::max(0, MetaMgr::Instance()->jump_time * 1000 - passed_time));
state->set_lasting_time(MetaMgr::Instance()->jump_time * 1000);
}
if (a8::HasBitFlag(status, HS_Hide) && skill_meta) {
int passed_time = (room->frame_no - hide_frameno_) * FRAME_RATE_MS;
cs::MFBodyState* state = states->Add();

View File

@ -15,8 +15,6 @@ namespace MetaData
enum HumanStatus
{
HS_PainKiller = 1,
HS_Fly = 2,
HS_Jump = 3,
HS_Hide = 4,
HS_Accelerate = 5,
HS_DamageAdd = 6,
@ -152,8 +150,6 @@ class Human : public Entity
void RemoveOutObjects(Entity* entity);
bool HasLiveTeammate();
bool HasNoDownedTeammate();
void Land();
void DoJump();
void DoSkill();
void FindLocation();
void RefreshView();

View File

@ -342,22 +342,6 @@ namespace MetaData
return 0;
}
void AirLine::Init()
{
{
std::vector<std::string> strings;
a8::Split(i->start_point(), strings, ':');
start_point_x = a8::XValue(strings[0]).GetDouble();
start_point_y = a8::XValue(strings[1]).GetDouble();
}
{
std::vector<std::string> strings;
a8::Split(i->end_point(), strings, ':');
end_point_x = a8::XValue(strings[0]).GetDouble();
end_point_y = a8::XValue(strings[1]).GetDouble();
}
}
void Skill::Init()
{
value1 = a8::XValue(i->value1()).GetDouble();

View File

@ -120,24 +120,6 @@ namespace MetaData
int rand_space = 0;
};
struct AirDrop
{
const metatable::AirDrop* i = nullptr;
};
struct AirLine
{
const metatable::AirLine* i = nullptr;
float start_point_x = 0.0f;
float start_point_y = 0.0f;
float end_point_x = 0.0f;
float end_point_y = 0.0f;
void Init();
};
struct Skill
{
const metatable::Skill* i = nullptr;

View File

@ -29,10 +29,6 @@ public:
std::list<MetaData::Building> building_list;
std::list<metatable::Drop> drop_meta_list;
std::list<MetaData::Drop> drop_list;
std::list<metatable::AirDrop> airdrop_meta_list;
std::list<MetaData::AirDrop> airdrop_list;
std::list<metatable::AirLine> airline_meta_list;
std::vector<MetaData::AirLine> airline_list;
std::list<metatable::Dress> dress_meta_list;
std::list<MetaData::Dress> dress_list;
std::list<metatable::Skill> skill_meta_list;
@ -91,8 +87,6 @@ public:
f8::ReadCsvMetaFile(res_path + "player@player.csv", player_meta_list);
f8::ReadCsvMetaFile(res_path + "mapThing@mapThing.csv", mapthing_meta_list);
f8::ReadCsvMetaFile(res_path + "drop@drop.csv", drop_meta_list);
f8::ReadCsvMetaFile(res_path + "airdrop@airdrop.csv", airdrop_meta_list);
f8::ReadCsvMetaFile(res_path + "airline@airline.csv", airline_meta_list);
f8::ReadJsonMetaFile(res_path + "maps.json", building_meta_list);
f8::ReadCsvMetaFile(res_path + "dress@dress.csv", dress_meta_list);
f8::ReadCsvMetaFile(res_path + "skill@skill.csv", skill_meta_list);
@ -104,7 +98,6 @@ public:
#if 1
{
MetaMgr::Instance()->gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("gas_inactive_time");
MetaMgr::Instance()->jump_time = MetaMgr::Instance()->GetSysParamAsFloat("jump_time");
MetaMgr::Instance()->K = MetaMgr::Instance()->GetSysParamAsFloat("K");
MetaMgr::Instance()->kill_param = MetaMgr::Instance()->GetSysParamAsFloat("kill_parameter");
MetaMgr::Instance()->rank_param = MetaMgr::Instance()->GetSysParamAsFloat("rank_parameter");
@ -209,17 +202,6 @@ private:
drop_hash[item.i->drop_id()] = &item;
}
for (auto& meta : airdrop_meta_list) {
MetaData::AirDrop& item = a8::FastAppend(airdrop_list);
item.i = &meta;
}
for (auto& meta : airline_meta_list) {
MetaData::AirLine& item = a8::FastAppend(airline_list);
item.i = &meta;
item.Init();
}
{
for (auto& meta : building_meta_list) {
MetaData::Building& item = a8::FastAppend(building_list);
@ -372,19 +354,6 @@ std::vector<MetaData::MapTplThing>* MetaMgr::GetMapTplThing(std::string& map_nam
return itr != loader_->maptpl_hash.end() ? &itr->second : nullptr;
}
std::list<MetaData::AirDrop>& MetaMgr::GetAirDrops()
{
return loader_->airdrop_list;
}
MetaData::AirLine* MetaMgr::RandAirLine()
{
if (loader_->airline_list.empty()) {
abort();
}
return &loader_->airline_list[rand() % loader_->airline_list.size()];
}
MetaData::Skill* MetaMgr::GetSkill(int skill_id)
{
auto itr = loader_->skill_hash.find(skill_id);

View File

@ -29,8 +29,6 @@ class MetaMgr : public a8::Singleton<MetaMgr>
MetaData::Drop* GetDrop(int drop_id);
MetaData::SafeArea* GetSafeArea(int area_id);
std::vector<MetaData::MapTplThing>* GetMapTplThing(std::string& map_name);
std::list<MetaData::AirDrop>& GetAirDrops();
MetaData::AirLine* RandAirLine();
MetaData::Skill* GetSkill(int skill_id);
MetaData::Dress* GetDress(int dress_id);
float GetRankRewardParam(int rank);
@ -39,7 +37,6 @@ class MetaMgr : public a8::Singleton<MetaMgr>
MetaData::Robot* GetRobot(int robot_id);
int gas_inactive_time = 10;
int jump_time = 10;
float K = 100.0f;
float kill_param = 0.0f;
float rank_param = 0.0f;

View File

@ -46,10 +46,6 @@ void Player::Update(int delta_time)
if (poisoning) {
poisoning_time += delta_time;
}
if (a8::HasBitFlag(status, HS_Fly)) {
pos = room->plane.curr_pos;
room->grid_service.MoveHuman(this);
}
if (moving) {
UpdateMove();
}
@ -90,9 +86,6 @@ void Player::Update(int delta_time)
if (emote) {
UpdateEmote();
}
if (jump) {
UpdateJump();
}
if (use_skill) {
UpdateUseSkill();
}
@ -104,7 +97,7 @@ void Player::UpdateMove()
if (action_type == AT_Relive) {
CancelAction();
}
if (dead || a8::HasBitFlag(status, HS_Fly)) {
if (dead) {
moving = false;
moved_frames = 0;
last_collision_door = nullptr;
@ -124,9 +117,7 @@ void Player::UpdateMove()
void Player::UpdateShot()
{
if (dead ||
a8::HasBitFlag(status, HS_Fly) ||
a8::HasBitFlag(status, HS_Jump) ) {
if (dead) {
shot_start = false;
shot_hold = false;
series_shot_frames = 0;
@ -155,11 +146,6 @@ void Player::UpdateShot()
void Player::UpdateSelectWeapon()
{
if (a8::HasBitFlag(status, HS_Fly)) {
select_weapon = false;
selected_weapon_idx = 0;
return;
}
if (selected_weapon_idx >= 0 && selected_weapon_idx < weapons.size()) {
Weapon* old_weapon = curr_weapon;
Weapon* weapon = &weapons[selected_weapon_idx];
@ -232,8 +218,7 @@ void Player::UpdateUseItemIdx()
void Player::UpdateSpectate()
{
if (room->gas_data.gas_mode == GasInactive ||
a8::HasBitFlag(status, HS_Fly)) {
if (room->gas_data.gas_mode == GasInactive) {
spectate = false;
return;
}
@ -243,45 +228,11 @@ void Player::UpdateSpectate()
void Player::UpdateEmote()
{
if (a8::HasBitFlag(status, HS_Fly)) {
emote = false;
emote_id = 0;
return;
}
room->frame_event.AddEmote(this, emote_id);
emote = false;
emote_id = 0;
}
void Player::UpdateJump()
{
if (a8::HasBitFlag(status, HS_Fly)) {
DoJump();
for (size_t i = 0; i < 4; ++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 (a8::HasBitFlag(hum->status, HS_Fly) && hum->entity_subtype != EST_Player) {
hum->DoJump();
return false;
}
return true;
});
},
&xtimer_attacher.timer_list_);
}
}
jump = false;
}
void Player::UpdateUseSkill()
{
DoSkill();
@ -304,14 +255,7 @@ void Player::Shot()
CancelAction();
}
#if 1
if (true) {
#else
if (room->gas_data.gas_mode != GasInactive &&
!a8::HasBitFlag(status, HS_Fly) &&
!a8::HasBitFlag(status, HS_Jump)
) {
#endif
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
@ -407,10 +351,6 @@ void Player::Shot()
void Player::ProcInteraction()
{
if (a8::HasBitFlag(status, HS_Fly)) {
interaction_objids.Clear();
return;
}
for (auto obj_id : interaction_objids) {
Entity* entity = room->GetEntityByUniId(obj_id);
if (entity) {
@ -825,22 +765,20 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
}
}
assert(!isnan(move_dir.x) && !isnan(move_dir.y));
if (!a8::HasBitFlag(status, HS_Fly)) {
if (msg.has_attack_dir()) {
if (std::isfinite(msg.attack_dir().x()) &&
std::isfinite(msg.attack_dir().y()) &&
(
std::abs(msg.attack_dir().x()) > 0.00001f ||
std::abs(msg.attack_dir().y()) > 0.00001f
)
){
TypeConvert::FromPb(attack_dir, &msg.attack_dir());
attack_dir.Normalize();
}
} else {
if (moving) {
attack_dir = move_dir;
}
if (msg.has_attack_dir()) {
if (std::isfinite(msg.attack_dir().x()) &&
std::isfinite(msg.attack_dir().y()) &&
(
std::abs(msg.attack_dir().x()) > 0.00001f ||
std::abs(msg.attack_dir().y()) > 0.00001f
)
){
TypeConvert::FromPb(attack_dir, &msg.attack_dir());
attack_dir.Normalize();
}
} else {
if (moving) {
attack_dir = move_dir;
}
}
if (moving) {

View File

@ -72,7 +72,6 @@ class Player : public Human
void UpdateUseItemIdx();
void UpdateSpectate();
void UpdateEmote();
void UpdateJump();
void UpdateUseSkill();
void Shot();
void ProcInteraction();

View File

@ -55,7 +55,6 @@ void Room::Init()
},
&xtimer_attacher.timer_list_);
}
InitAirDrop();
ShuaAndroid();
}
@ -312,17 +311,6 @@ void Room::FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg)
msg.set_player_id(self_hum->entity_uniid);
msg.set_started(false);
msg.set_room_uuid(a8::XValue(room_uuid).GetString());
#if 0
for (auto& pair : uniid_hash_) {
if (pair.second->entity_type == ET_Player) {
Human* hum = (Human*)pair.second;
cs::MFPlayerInfo* info = msg.add_player_infos();
info->set_player_id(hum->entity_uniid);
info->set_team_id(hum->team_id);
info->set_name(hum->name);
}
}
#endif
}
void Room::ScatterDrop(a8::Vec2 center, int drop_id)
@ -789,34 +777,8 @@ void Room::UpdateGas()
CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size());
NotifyUiUpdate();
}
ShuaPlane();
NotifyWxVoip();
RoomMgr::Instance()->ActiveRoom(room_uuid);
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);
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_);
}
}
break;
@ -893,86 +855,6 @@ void Room::MatchTeam(Human* hum)
}
}
void Room::InitAirDrop()
{
std::list<MetaData::AirDrop>& air_drops = MetaMgr::Instance()->GetAirDrops();
for (auto& air_drop : air_drops) {
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * air_drop.i->time(),
a8::XParams()
.SetSender(this)
.SetParam1(air_drop.i->appear_time())
.SetParam2(air_drop.i->drop_id())
.SetParam3(air_drop.i->id()),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
if (!room->game_over) {
room->AirDrop(param.param1, param.param2);
}
},
&xtimer_attacher.timer_list_);
}
}
void Room::AirDrop(int appear_time, int box_id)
{
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(box_id);
if (thing_meta) {
a8::Vec2 dir = a8::Vec2::UP;
dir.Rotate(a8::RandAngle());
a8::Vec2 box_pos = gas_data.pos_new + dir * (500 + rand() % 300);
#if 1
if (box_pos.x < 1.0f) {
box_pos.x = 1.0f;
}
if (box_pos.x >= MAP_WIDTH) {
box_pos.x = MAP_WIDTH - 1;
}
if (box_pos.y < 1.0f) {
box_pos.y = 1.0f;
}
if (box_pos.y >= MAP_HEIGHT) {
box_pos.y = MAP_HEIGHT - 1;
}
#endif
frame_event.AddAirDrop(appear_time, box_id, box_pos);
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * appear_time / 1000.f,
a8::XParams()
.SetSender(this)
.SetParam1(box_id)
.SetParam2(box_pos.x)
.SetParam3(box_pos.y),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
if (!room->game_over) {
room->CreateObstacle(param.param1.GetInt(),
param.param2.GetDouble(),
param.param3.GetDouble());
}
},
&xtimer_attacher.timer_list_);
}
}
void Room::ShuaPlane()
{
airline_ = MetaMgr::Instance()->RandAirLine();
plane.start_point = a8::Vec2(airline_->start_point_x, airline_->start_point_y);
plane.end_point = a8::Vec2(airline_->end_point_x, airline_->end_point_y);
plane.dir = plane.end_point - plane.start_point;
plane.dir.Normalize();
plane.curr_pos = plane.start_point;
for (auto& pair : human_hash_) {
a8::SetBitFlag(pair.second->status, HS_Fly);
pair.second->pos = plane.curr_pos;
pair.second->attack_dir = plane.dir;
pair.second->move_dir = plane.dir;
grid_service.MoveHuman(pair.second);
}
}
Obstacle* Room::InternalCreateObstacle(int id, float x, float y,
std::function<void (Obstacle*)> on_precreate)
{

View File

@ -13,7 +13,6 @@ namespace MetaData
struct Map;
struct SafeArea;
struct Building;
struct AirLine;
}
struct timer_list;
@ -40,7 +39,6 @@ public:
long long game_over_tick = 0;
timer_list* game_over_timer = nullptr;
a8::XTimer xtimer;
Plane plane;
GridService grid_service;
MapService map_service;
long long battle_start_frameno_ = 0;
@ -97,9 +95,6 @@ private:
a8::Vec2& out_pos);
void AutoMatchTeam();
void MatchTeam(Human* hum);
void InitAirDrop();
void AirDrop(int appear_time, int box_id);
void ShuaPlane();
int NewTeam();
Obstacle* CreateObstacle(int id, float x, float y);
void CreateThings();
@ -115,9 +110,7 @@ private:
private:
int elapsed_time_ = 0;
int alive_count_ = 0;
MetaData::AirLine* airline_ = nullptr;
a8::XTimerAttacher xtimer_attacher;
xtimer_list* auto_jump_timer_ = nullptr;
int current_teamid = 0;
int current_uniid = 0;

View File

@ -90,14 +90,6 @@ struct PlayerStats
int rank = 0;
};
struct Plane
{
a8::Vec2 start_point;
a8::Vec2 end_point;
a8::Vec2 dir;
a8::Vec2 curr_pos;
};
struct HumanAbility
{
float speed = 0.0f;