完成子弹伤害公式
This commit is contained in:
parent
c64c00f76b
commit
411041a792
@ -667,3 +667,47 @@ void Bullet::OnKillTarget(Entity* target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bullet::CalcDmg(Entity* entity,
|
||||
float& finaly_dmg,
|
||||
float& hero_atk_rate,
|
||||
float& target_def_rate)
|
||||
{
|
||||
finaly_dmg = 0;
|
||||
hero_atk_rate = 0;
|
||||
target_def_rate = 0;
|
||||
|
||||
if (sender.Get()->IsAndroid()) {
|
||||
Android* android = (Android*)sender.Get();
|
||||
hero_atk_rate -= android->ai->GetAttackRate();
|
||||
}
|
||||
hero_atk_rate += ability_->GetAttrRate(kHAT_Atk);
|
||||
if (IsCurrWeapon()) {
|
||||
hero_atk_rate += ability_->GetAttrRate(kHAT_WeaponDmg);
|
||||
}
|
||||
|
||||
{
|
||||
float atk = gun_meta->i->atk();
|
||||
if (sender.Get()->GetBattleContext()) {
|
||||
float gun_atk_add = sender.Get()->GetBattleContext()->GetWeaponAttrAbs(weapon_uniid, kHAT_Atk);
|
||||
float hero_atk_add = sender.Get()->GetBattleContext()->GetHeroAttrAbs(sender.Get()->hero_uniid, kHAT_Atk);
|
||||
float base_atk = sender.Get()->GetBaseAtk() + gun_meta->i->atk();
|
||||
if ((gun_atk_add + hero_atk_add) > 0.0001f &&
|
||||
base_atk > 0.0001f) {
|
||||
hero_atk_rate += (gun_atk_add + hero_atk_add) / base_atk;
|
||||
}
|
||||
atk += gun_atk_add;
|
||||
}
|
||||
if (entity->IsCreature(room)) {
|
||||
Creature* target = (Creature*)entity;
|
||||
if (target->GetBattleContext()) {
|
||||
float def_abs = target->GetBattleContext()->GetHeroAttrAbs(target->hero_uniid, kHAT_Def);
|
||||
if (def_abs > 0.0001f &&
|
||||
target->GetBaseDef() > 0.0001f) {
|
||||
target_def_rate += def_abs / target->GetBaseDef();
|
||||
}
|
||||
}
|
||||
}
|
||||
finaly_dmg = atk * (1 + hero_atk_rate) * (1 - target_def_rate);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class Ability;
|
||||
class Bullet : public MoveableEntity
|
||||
{
|
||||
public:
|
||||
std::string weapon_uniid;
|
||||
long long weapon_uniid = 0;
|
||||
int gun_lv = 0;
|
||||
MetaData::Equip* gun_meta = nullptr;
|
||||
MetaData::EquipUpgrade* gun_upgrade_meta = nullptr;
|
||||
@ -43,8 +43,10 @@ class Bullet : public MoveableEntity
|
||||
float GetExplosionRange();
|
||||
bool IsCurrWeapon();
|
||||
bool IsPreBattleBullet();
|
||||
/*void CalcDmg(Entity* entity, float& finaly_dmg,
|
||||
);*/
|
||||
void CalcDmg(Entity* entity,
|
||||
float& finaly_dmg,
|
||||
float& hero_atk_rate,
|
||||
float& target_def_rate);
|
||||
|
||||
protected:
|
||||
Bullet();
|
||||
|
@ -69,6 +69,7 @@ class Creature : public MoveableEntity
|
||||
{
|
||||
public:
|
||||
|
||||
long long hero_uniid = 0;
|
||||
std::vector<Weapon> weapons;
|
||||
long long last_shot_frameno_ = 0;
|
||||
int status = 0;
|
||||
|
@ -3287,14 +3287,7 @@ void Human::OnBulletHit(Bullet* bullet)
|
||||
#ifdef NEWGS
|
||||
float def = 0;
|
||||
float finaly_dmg = 0;
|
||||
{
|
||||
float base_atk = bullet->gun_meta->i->atk();
|
||||
float total_atk = bullet->GetAtk() + GetAttrAbs(kHAT_Atk);
|
||||
float atk_rate = (total_atk - base_atk) / base_atk;
|
||||
float base_def = 0;
|
||||
float def_rate = (0)/base_def;
|
||||
finaly_dmg = total_atk * (1 + atk_rate) * (1 - def_rate);
|
||||
}
|
||||
//bullet->CalcDmg(this, finaly_dmg, def);
|
||||
#else
|
||||
float dmg = bullet->GetAtk();
|
||||
float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) +
|
||||
|
@ -136,7 +136,6 @@ class Human : public Creature
|
||||
int today_enter_times = 0;
|
||||
int account_registertime = 0;
|
||||
int channel = 0;
|
||||
long long hero_uniid = 0;
|
||||
long long battle_uuid = 0;
|
||||
int is_valid_battle = 0;
|
||||
std::string payload;
|
||||
|
Loading…
x
Reference in New Issue
Block a user