完成灼烧buff

This commit is contained in:
aozhiwei 2019-07-10 15:11:54 +08:00
parent 1f04049994
commit 912bd0593a
7 changed files with 103 additions and 5 deletions

View File

@ -189,11 +189,13 @@ enum BuffEffectType_e
BET_Begin = 0,
BET_ChgAttr = 1, //改变属性
BET_Vertigo = 2, //眩晕
BET_LastDmg = 3, //持续伤害
BET_Unuse = 3, //
BET_LastBurn = 4, //持续灼烧
BET_Invincible = 5, //无敌
BET_Hide = 6, //隐身
BET_Dcgr = 7, //电磁干扰
BET_ReleaseDcgr = 8, //释放电磁干扰
BET_ReleaseFireBomb = 9, //释放燃烧弹
BET_End
};
@ -206,6 +208,20 @@ enum SkillFunc_e
Skill_FuncEnd
};
enum HumanAttrType_e
{
HAT_Begin = 0,
HAT_Hp = 1,
HAT_HPRecover = 2,
HAT_Atk = 3,
HAT_Def = 4,
HAT_Speed = 5,
HAT_ShotRange = 6,
HAT_ShotSpeed = 7,
HAT_ReloadSpeed = 8,
HAT_End
};
const char* const PROJ_NAME_FMT = "game%d_gameserver";
const char* const PROJ_ROOT_FMT = "/data/logs/%s";

View File

@ -53,3 +53,8 @@ bool IsValidBuffEffect(int buff_effect)
{
return buff_effect > BET_Begin && buff_effect < BET_End;
}
bool IsValidHumanAttr(int attr_type)
{
return attr_type > HAT_Begin && attr_type < HAT_End;
}

View File

@ -24,3 +24,4 @@ class Global : public a8::Singleton<Global>
bool IsValidSlotId(int slot_id);
SkillFunc_e Str2SkillFunc(const std::string& func_str);
bool IsValidBuffEffect(int buff_effect);
bool IsValidHumanAttr(int attr_type);

View File

@ -66,19 +66,22 @@ void Human::Initialize()
float Human::GetSpeed()
{
float speed = 0.0f;
if (downed) {
return meta->i->move_speed3() + ability.speed;
speed = meta->i->move_speed3() + ability.speed;
} else {
speed = meta->i->move_speed() + ability.speed;
if (shot_hold) {
if (curr_weapon->weapon_idx == GUN_SLOT1 ||
curr_weapon->weapon_idx == GUN_SLOT2) {
if (action_type != AT_Reload) {
return meta->i->shot_speed();
speed = meta->i->shot_speed();
}
}
}
return meta->i->move_speed() + ability.speed;
}
speed = (speed + buff_attr_abs_[HAT_Speed]) * (1 + buff_attr_rate_[HAT_Speed]);
return std::min(speed, 1.0f);
}
float Human::GetSpeed4()
@ -581,6 +584,9 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i
}
}
}
last_attacker_id = killer_id;
last_attacker_name = killer_name;
last_attacker_weapon_id = weapon_id;
SyncAroundPlayers();
}
@ -1368,6 +1374,7 @@ void Human::AddBuff(MetaData::Buff* buff_meta)
&buff->xtimer_attacher.timer_list_
);
}
ProcBuffEffect(buff);
}
void Human::RemoveBuff(int buff_id)
@ -1389,6 +1396,60 @@ bool Human::HasBuffEffect(int buff_effect_id)
return GetBuffByEffectId(buff_effect_id) != nullptr;
}
void Human::RecalcBuffAttr()
{
buff_attr_abs_ = {};
buff_attr_rate_ = {};
for (auto& buff : buff_list_) {
if (buff.meta->i->buff_effect() == BET_ChgAttr) {
int attr_type = (int)buff.meta->param1;
int calc_type = (int)buff.meta->param2;
if (IsValidHumanAttr(attr_type)) {
if (calc_type == 1) {
buff_attr_abs_[attr_type] += buff.meta->param3;
} else if (calc_type == 2) {
buff_attr_rate_[attr_type] += buff.meta->param3;
}
}
}
}
}
void Human::ProcBuffEffect(Buff* buff)
{
switch (buff->meta->i->buff_effect()) {
case BET_ChgAttr:
{
RecalcBuffAttr();
}
break;
case BET_LastBurn:
{
room->xtimer.AddRepeatTimerAndAttach(
SERVER_FRAME_RATE,
a8::XParams()
.SetSender(this)
.SetParam1(buff),
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
Buff* buff = (Buff*)param.param1.GetUserData();
if (!hum->dead) {
hum->DecHP(buff->meta->param1,
hum->last_attacker_id,
hum->last_attacker_name,
hum->last_attacker_weapon_id);
}
},
&buff->xtimer_attacher.timer_list_
);
}
break;
default:
break;
}
}
void Human::_UpdateMove(int speed)
{
for (int i = 0; i < speed; ++i) {

View File

@ -50,6 +50,9 @@ class Human : public Entity
MetaData::Tank* skin_jlf_meta = nullptr;
HumanAbility ability;
int born_point = 0;
int last_attacker_id = 0;
std::string last_attacker_name;
int last_attacker_weapon_id = 0;
a8::Vec2 move_dir;
a8::Vec2 attack_dir;
@ -202,6 +205,9 @@ class Human : public Entity
void AddBuff(MetaData::Buff* buff_meta);
void RemoveBuff(int buff_id);
bool HasBuffEffect(int buff_effect_id);
Buff* GetBuffByEffectId(int effect_id);
void RecalcBuffAttr();
void ProcBuffEffect(Buff* buff);
protected:
void _UpdateMove(int speed);
@ -212,7 +218,6 @@ private:
void Revive();
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
Buff* GetBuffById(int buff_id);
Buff* GetBuffByEffectId(int effect_id);
protected:
long long last_shot_frameno_ = 0;
@ -253,6 +258,9 @@ private:
std::list<Buff> buff_list_;
std::array<Buff*, BET_End> buff_effect_ = {};
std::array<float, HAT_End> buff_attr_abs_ = {};
std::array<float, HAT_End> buff_attr_rate_ = {};
bool already_report_battle_ = false;
bool sent_game_end_ = false;

View File

@ -414,6 +414,9 @@ namespace MetaData
void Buff::Init()
{
param1 = a8::XValue(i->buff_param1()).GetDouble();
param2 = a8::XValue(i->buff_param2()).GetDouble();
param3 = a8::XValue(i->buff_param3()).GetDouble();
}
bool Buff::EffectCanStack()

View File

@ -132,6 +132,10 @@ namespace MetaData
void Init();
bool EffectCanStack();
float param1 = 0.0f;
float param2 = 0.0f;
float param3 = 0.0f;
};
struct SkillPhase