添加机甲属性加成

This commit is contained in:
aozhiwei 2020-07-31 11:23:57 +08:00
parent 417813f2d5
commit a593062cb3
3 changed files with 44 additions and 6 deletions

View File

@ -66,10 +66,10 @@ void Bullet::OnHit(std::set<Entity*>& objects)
continue;
}
if (!hum->dead && (IsBomb() || player->team_id != hum->team_id)) {
float dmg = GetAtk() * (1 + player->GetBuffAttrRate(kHAT_Atk)) +
player->GetBuffAttrAbs(kHAT_Atk);
float def = hum->ability.def * (1 + hum->GetBuffAttrRate(kHAT_Def)) +
hum->GetBuffAttrAbs(kHAT_Def);
float dmg = GetAtk() * (1 + player->GetAttrRate(kHAT_Atk)) +
player->GetAttrAbs(kHAT_Atk);
float def = hum->ability.def * (1 + hum->GetAttrRate(kHAT_Def)) +
hum->GetAttrAbs(kHAT_Def);
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
finaly_dmg = std::max(finaly_dmg, 0.0f);
player->stats.damage_amount_out += finaly_dmg;
@ -86,8 +86,8 @@ void Bullet::OnHit(std::set<Entity*>& objects)
if (!obstacle->IsDead(room) &&
obstacle->Attackable() &&
!obstacle->IsTerminatorAirDropBox(room)) {
float dmg = GetAtk() * (1 + player->GetBuffAttrRate(kHAT_Atk)) +
player->GetBuffAttrAbs(kHAT_Atk);
float dmg = GetAtk() * (1 + player->GetAttrRate(kHAT_Atk)) +
player->GetAttrAbs(kHAT_Atk);
float def = 0;
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
obstacle->SetHealth(room, std::max(0.0f, obstacle->GetHealth(room) - finaly_dmg));

View File

@ -3157,6 +3157,42 @@ float Human::GetBuffAttrRate(int attr_type)
return 0;
}
float Human::GetAttrAbs(int attr_id)
{
float attr_abs_val = GetBuffAttrAbs(attr_id);
if (attr_id == kHAT_Atk || attr_id == kHAT_Def) {
Buff* buff = GetBuffByEffectId(kBET_Car);
if (buff) {
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(buff->meta->param4);
if (equip_meta) {
switch (attr_id) {
case kHAT_Atk:
{
attr_abs_val += equip_meta->i->atk();
}
break;
case kHAT_Def:
{
attr_abs_val += equip_meta->i->def();
}
break;
default:
{
}
break;
}
}
}
}
return attr_abs_val;
}
float Human::GetAttrRate(int attr_id)
{
float attr_rate_val = GetBuffAttrRate(attr_id);
return attr_rate_val;
}
bool Human::IsPlayer() const
{
return IsEntitySubType(EST_Player);

View File

@ -269,6 +269,8 @@ class Human : public MoveableEntity
void DecItem(int item_id, int item_num);
float GetBuffAttrAbs(int attr_id);
float GetBuffAttrRate(int attr_id);
float GetAttrAbs(int attr_id);
float GetAttrRate(int attr_id);
bool IsPlayer() const;
bool IsAndroid() const;
void DropItems(Obstacle* obstacle);