添加护盾/立刻复活

This commit is contained in:
aozhiwei 2019-07-25 14:48:17 +08:00
parent a23787edcd
commit 48cf9c6c2a
9 changed files with 85 additions and 8 deletions

View File

@ -88,3 +88,8 @@ void Buff::ProcReleaseFireBomb(const a8::XParams& param)
}
}
}
void Buff::ProcLastRecover(const a8::XParams& param)
{
}

View File

@ -33,4 +33,5 @@ class Buff
static void ProcLastBurn(const a8::XParams& param);
static void ProcReleaseDcgr(const a8::XParams& param);
static void ProcReleaseFireBomb(const a8::XParams& param);
static void ProcLastRecover(const a8::XParams& param);
};

View File

@ -161,7 +161,7 @@ enum BuffEffectType_e
kBET_OnceChgAttr = 11, //一次性buff
kBET_LastRecover = 12, //持续回血
kBET_Shield = 13, //护盾
kBET_ImmediatelyRevive = 14, //离开复活
kBET_ImmediatelyRevive = 14, //立刻复活
kBET_End
};

View File

@ -141,13 +141,13 @@ void FrameEvent::AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos)
}
}
void FrameEvent::AddDead(Human* hum)
void FrameEvent::AddDead(Human* hum, int revive_time)
{
{
dead_objs_.push_back(
std::make_tuple(
hum->entity_uniid,
MetaMgr::Instance()->revive_time * 1000
revive_time
)
);
}

View File

@ -19,7 +19,7 @@ public:
float fly_distance, int hit_time, int target_id = 0, int skill_id = 0);
void AddExplosion(int item_id, a8::Vec2 bomb_pos, int effect);
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos);
void AddDead(Human* hum);
void AddDead(Human* hum, int revive_time);
void AddRevive(Human* hum);
void AddBuff(Human* hum, Buff* buff);
void RemoveBuff(Human* hum, int buff_id);

View File

@ -459,6 +459,24 @@ void Human::ResetAction()
void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
{
if (!dead && !room->game_over) {
if (immediately_revive_times_ > 0) {
--immediately_revive_times_;
status = 0;
ClearBuffList();
room->frame_event.AddDead(this, 0);
room->xtimer.AddDeadLineTimerAndAttach(1,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->ImmediatelyRevive();
},
&xtimer_attacher.timer_list_
);
return;
}
lethal_weapon = weapon_id;
{
Entity* entity = room->GetEntityByUniId(killer_id);
@ -486,7 +504,8 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
);
status = 0;
ClearBuffList();
room->frame_event.AddDead(this);
room->frame_event.AddDead(this,
MetaMgr::Instance()->revive_time * 1000);
room->OnHumanDie(this);
{
OnLeaveGrass();
@ -1165,6 +1184,10 @@ void Human::TriggerBuff(std::set<Entity*>& target_list, BuffTriggerType_e trigge
void Human::AddBuff(MetaData::Buff* buff_meta)
{
if (buff_meta->i->buff_effect() == kBET_ImmediatelyRevive) {
++immediately_revive_times_;
return;
}
if (GetBuffById(buff_meta->i->buff_id())) {
return;
}
@ -1242,6 +1265,16 @@ void Human::ClearBuffList()
if (buff_effect_[itr->meta->i->buff_effect()] == &(*itr)) {
buff_effect_[itr->meta->i->buff_effect()] = nullptr;
}
switch (itr->meta->i->buff_effect()) {
case kBET_Shield:
{
energy_shield = 0.0f;
max_energy_shield = 0.0f;
}
break;
default:
break;
}
room->frame_event.RemoveBuff(this, itr->meta->i->buff_id());
}
buff_list_.clear();
@ -1339,12 +1372,20 @@ void Human::ProcBuffEffect(Buff* buff)
break;
case kBET_LastRecover:
{
room->xtimer.AddRepeatTimerAndAttach(
kSERVER_FRAME_RATE,
a8::XParams()
.SetSender(this)
.SetParam1(buff),
Buff::ProcLastRecover,
&buff->xtimer_attacher.timer_list_
);
}
break;
case kBET_Shield:
{
energy_shield = buff->meta->param1;
max_energy_shield = buff->meta->param1;
}
break;
default:
@ -1806,6 +1847,28 @@ void Human::Revive()
playing_skill = false;
}
void Human::ImmediatelyRevive()
{
dead = false;
ability.hp = GetMaxHP();
status = 0;
ClearBuffList();
{
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(1003);
if (buff_meta) {
AddBuff(buff_meta);
}
}
room->frame_event.AddRevive(this);
CheckSpecObject();
use_skill = false;
curr_skill_phase = 0;
skill_dir = a8::Vec2();
skill_param1 = 0.0f;
playing_skill = false;
}
void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list)
{
switch (skill_meta_->i->skill_target()) {

View File

@ -212,6 +212,7 @@ private:
void ClearFrameData();
void DeadDrop();
void Revive();
void ImmediatelyRevive();
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
Buff* GetBuffById(int buff_id);
void ProcSkillPhase(MetaData::SkillPhase* phase);
@ -267,6 +268,7 @@ private:
Tank tank_;
long long send_gameover_trycount_ = 0;
bool sending_gameover_ = false;
int immediately_revive_times_ = 0;
xtimer_list* grass_hide_timer_list_ = nullptr;
xtimer_list* leave_grass_timer_list_ = nullptr;

View File

@ -68,7 +68,12 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
hum->SetMeta(hum_meta);
room->AddPlayer(hum);
hum->ProcPrepareItems(msg.prepare_items());
for (int buff_id : msg.buff_list()) {
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(buff_id);
if (buff_meta) {
hum->AddBuff(buff_meta);
}
}
{
cs::SMJoinedNotify notifymsg;
notifymsg.set_error_code(0);

View File

@ -622,6 +622,7 @@ message CMJoin
optional string from_appid = 21; //from_appid
optional MFDriver driver = 22; //
optional MFSkin tankskin = 23; //
repeated int32 buff_list = 24; //
repeated MFRoomMember room_member = 100; //()
}