添加潜水功能

This commit is contained in:
aozhiwei 2021-10-21 12:10:04 +08:00
parent da8626a1e4
commit 2d78f7599b
13 changed files with 133 additions and 1 deletions

View File

@ -743,3 +743,52 @@ void Buff::CalcPassengerShotOffset()
} }
} }
} }
void Buff::ProcDive()
{
if (owner->IsHuman()) {
owner->AsHuman()->SetOxygen(MetaMgr::Instance()->dive_oxygen_total);
owner->AsHuman()->room->frame_event.AddPropChg
(owner->AsHuman()->GetWeakPtrRef(),
kPropDive,
MetaMgr::Instance()->dive_oxygen_total,
owner->AsHuman()->GetOxygen(),
true);
}
owner->room->xtimer.AddRepeatTimerAndAttach
(
SERVER_FRAME_RATE,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Buff* buff = (Buff*)param.sender.GetUserData();
if (buff->owner->dead || !buff->owner->IsHuman()) {
buff->owner->RemoveBuffByUniId(buff->buff_uniid);
return;
}
Human* hum = buff->owner->AsHuman();
if (hum->GetOxygen() > 0) {
hum->DecOxygen(MetaMgr::Instance()->dive_oxygen_consume);
hum->room->frame_event.AddPropChg(hum->GetWeakPtrRef(),
kPropDive,
MetaMgr::Instance()->dive_oxygen_total,
hum->GetOxygen(),
true);
return;
}
hum->DecHP(MetaMgr::Instance()->dive_hp_consume,
VP_Water,
"",
0);
},
&xtimer_attacher.timer_list_
);
}
void Buff::ProcRemoveDive()
{
if (owner->IsHuman()) {
owner->AsHuman()->SetOxygen(0);
}
}

View File

@ -73,6 +73,8 @@ class Buff
void ProcAutoShot(); void ProcAutoShot();
void ProcBeatBack(); void ProcBeatBack();
void ProcDisperse(); void ProcDisperse();
void ProcDive();
void ProcRemoveDive();
void CalcPassengerShotOffset(); void CalcPassengerShotOffset();

View File

@ -219,6 +219,7 @@ enum VirtualPlayer_e
VP_Gas = 9000000, VP_Gas = 9000000,
VP_Buff = 9000001, VP_Buff = 9000001,
VP_Explosion = 9000002, VP_Explosion = 9000002,
VP_Water = 9000003,
}; };
enum EquipType_e enum EquipType_e
@ -264,6 +265,7 @@ enum PropertyType_e
kPropSkillMaxTimes = 26, kPropSkillMaxTimes = 26,
kPropCarOil = 27, kPropCarOil = 27,
kPropFollowTarget = 30, kPropFollowTarget = 30,
kPropDive = 31,
}; };
enum MapObjectType_e enum MapObjectType_e

View File

@ -18,6 +18,7 @@ const int kRescueBuffId = 7017;
const int kVertigoBuffId = 7018; const int kVertigoBuffId = 7018;
const int kPeaceModeBuffId = 7019; const int kPeaceModeBuffId = 7019;
const int kPullToWalkableBuffId = 8003; const int kPullToWalkableBuffId = 8003;
const int kDiveBuffId = 8054;
enum BuffEffectType_e enum BuffEffectType_e
{ {
@ -94,6 +95,7 @@ enum BuffEffectType_e
kBET_PeaceMode = 69, //和平模式 kBET_PeaceMode = 69, //和平模式
kBET_ClientUse1 = 70, // kBET_ClientUse1 = 70, //
kBET_ClientUse2 = 71, // kBET_ClientUse2 = 71, //
kBET_Dive = 72, //下潜模式
kBET_End kBET_End
}; };

View File

@ -1386,6 +1386,11 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
{ {
} }
break; break;
case kBET_Dive:
{
buff->ProcDive();
}
break;
default: default:
{ {
} }

View File

@ -1187,6 +1187,10 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
player_data->set_max_health(GetMaxHP()); player_data->set_max_health(GetMaxHP());
player_data->set_cur_weapon_idx(GetCurrWeapon()->weapon_idx); player_data->set_cur_weapon_idx(GetCurrWeapon()->weapon_idx);
player_data->set_cur_scope(curr_scope_idx); player_data->set_cur_scope(curr_scope_idx);
if (HasBuffEffect(kBET_Dive)) {
player_data->set_dive_oxygen_max(MetaMgr::Instance()->dive_oxygen_total);
player_data->set_dive_oxygen_curr(oxygen_);
}
for (auto& weapon : weapons) { for (auto& weapon : weapons) {
auto p = player_data->add_weapons(); auto p = player_data->add_weapons();
weapon.ToPB(p); weapon.ToPB(p);
@ -2878,6 +2882,11 @@ void Human::OnBuffRemove(Buff& buff)
buff.ProcRemovePassenger(); buff.ProcRemovePassenger();
} }
break; break;
case kBET_Dive:
{
buff.ProcRemoveDive();
}
break;
case kBET_AddInventory: case kBET_AddInventory:
{ {
for (int slot : buff.meta->param2_int_list) { for (int slot : buff.meta->param2_int_list) {
@ -3804,6 +3813,20 @@ void Human::DoFollow(int target_id)
IncFollowTimes(); IncFollowTimes();
} }
void Human::DoDive()
{
if (!HasBuffEffect(kBET_InWater)) {
return;
}
if (HasBuffEffect(kBET_Dive)) {
return;
}
if (HasBuffEffect(kBET_Camouflage) ) {
RemoveBuffByEffectId(kBET_Camouflage);
}
MustBeAddBuff(this, kDiveBuffId);
}
void Human::OnWatcherDie(Human* watcher) void Human::OnWatcherDie(Human* watcher)
{ {
if (follow_target_ == watcher) { if (follow_target_ == watcher) {
@ -3827,3 +3850,9 @@ void Human::TraverseObservers(std::function<void (Human*, bool&)> func)
} }
} }
} }
void Human::DecOxygen(int val)
{
oxygen_ -= val;
oxygen_ = std::max(0, oxygen_);
}

View File

@ -264,8 +264,12 @@ class Human : public Creature
void ProcUseItem(int item_id); void ProcUseItem(int item_id);
void StartRefreshViewTimer(); void StartRefreshViewTimer();
void DoFollow(int target_id); void DoFollow(int target_id);
void DoDive();
void OnWatcherDie(Human* watcher); void OnWatcherDie(Human* watcher);
FrameData& GetFrameData() { return framedata_; }; FrameData& GetFrameData() { return framedata_; };
int GetOxygen() { return oxygen_; };
void SetOxygen(int oxygen) { oxygen_ = oxygen; };
void DecOxygen(int val);
protected: protected:
void _InternalUpdateMove(float speed); void _InternalUpdateMove(float speed);
@ -325,6 +329,7 @@ protected:
long long last_sync_teamdata_frameno_ = 0; long long last_sync_teamdata_frameno_ = 0;
bool leave_ = false; bool leave_ = false;
long long leave_frameno_ = 0; long long leave_frameno_ = 0;
int oxygen_ = 0;
std::array<int, IS_END> volume_ = {}; std::array<int, IS_END> volume_ = {};
Human* follow_target_ = nullptr; Human* follow_target_ = nullptr;

View File

@ -112,7 +112,14 @@ void KillMgr::FillHintInfo(Human* dead_hum, KillInfo* info, RollMsgHintInfo& hin
} }
} }
break; break;
default: case VP_Water:
{
hint_info.killer_name = "";
hint_info.hint_template = MetaMgr::Instance()->GetTextElements
("battle_server_dead_text_drown");
}
break;
default:
{ {
Entity* killer = dead_hum->room->GetEntityByUniId(info->killer_id); Entity* killer = dead_hum->room->GetEntityByUniId(info->killer_id);
if (killer) { if (killer) {

View File

@ -514,6 +514,10 @@ public:
METAMGR_READ(level1room_robot_autodie_distance, 500); METAMGR_READ(level1room_robot_autodie_distance, 500);
METAMGR_READ_STR(level1room_born_point, ""); METAMGR_READ_STR(level1room_born_point, "");
METAMGR_READ(dive_oxygen_total, 200);
METAMGR_READ(dive_oxygen_consume, 20);
METAMGR_READ(dive_hp_consume, 20);
METAMGR_READ(dive_explosion_dmg_switch, 0);
} }
if (MetaMgr::Instance()->K < 0.01f) { if (MetaMgr::Instance()->K < 0.01f) {
abort(); abort();

View File

@ -183,6 +183,11 @@ class MetaMgr : public a8::Singleton<MetaMgr>
int match_choose_time = 0; int match_choose_time = 0;
int match_lock_time = 0; int match_lock_time = 0;
int dive_oxygen_total = 0;
int dive_oxygen_consume = 0;
int dive_hp_consume = 0;
int dive_explosion_dmg_switch = 0;
private: private:
MetaDataLoader* loader_ = nullptr; MetaDataLoader* loader_ = nullptr;

View File

@ -122,6 +122,9 @@ void Player::InternalUpdate(int delta_time)
if (follow != -1) { if (follow != -1) {
UpdateFollow(); UpdateFollow();
} }
if (dive) {
UpdateDive();
}
if (shot_start || shot_hold) { if (shot_start || shot_hold) {
UpdateShot(); UpdateShot();
} }
@ -797,6 +800,9 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
if (msg.has_follow()) { if (msg.has_follow()) {
follow = msg.follow(); follow = msg.follow();
} }
if (msg.has_dive()) {
dive = msg.dive();
}
if (msg.has_use_skill()) { if (msg.has_use_skill()) {
use_skill = msg.use_skill(); use_skill = msg.use_skill();
use_skill_id = msg.skill_id(); use_skill_id = msg.skill_id();
@ -1321,6 +1327,12 @@ void Player::UpdateFollow()
follow = -1; follow = -1;
} }
void Player::UpdateDive()
{
DoDive();
dive = 0;
}
void Player::CheckShotHoldState(Weapon* weapon) void Player::CheckShotHoldState(Weapon* weapon)
{ {
if (weapon->meta->buff_meta && weapon->meta->buff_meta->i->trigger_type() == kBTT_SeriesShot) { if (weapon->meta->buff_meta && weapon->meta->buff_meta->i->trigger_type() == kBTT_SeriesShot) {

View File

@ -69,6 +69,7 @@ class Player : public Human
int switch_seat = 0; int switch_seat = 0;
int follow = -1; int follow = -1;
int dive = 0;
::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids;
@ -93,6 +94,7 @@ class Player : public Human
void UpdateUseSkill(); void UpdateUseSkill();
void UpdateAiming(); void UpdateAiming();
void UpdateFollow(); void UpdateFollow();
void UpdateDive();
void Shot(); void Shot();
void ProcInteraction(); void ProcInteraction();
void ObstacleInteraction(Obstacle* entity); void ObstacleInteraction(Obstacle* entity);

View File

@ -143,6 +143,9 @@ message MFVec2
valule: valule:
property_type: 30 id property_type: 30 id
valule: id valule: id
property_type: 31
property_subtype:
valule:
*/ */
message MFPropertyChg message MFPropertyChg
{ {
@ -595,6 +598,9 @@ message MFActivePlayerData
optional float shoot_offset_x = 50 [default = 0]; //-x optional float shoot_offset_x = 50 [default = 0]; //-x
optional float shoot_offset_y = 51 [default = 0]; //-y optional float shoot_offset_y = 51 [default = 0]; //-y
optional int32 dive_oxygen_max = 63; //
optional int32 dive_oxygen_curr = 64; //
} }
// //
@ -1016,6 +1022,8 @@ message CMMove
optional int32 switch_seat = 37; // optional int32 switch_seat = 37; //
optional int32 follow = 38; //0: uniid optional int32 follow = 38; //0: uniid
optional int32 dive = 39; //
} }
//GM指令 //GM指令