This commit is contained in:
aozhiwei 2022-05-24 08:50:58 +08:00
parent 71e08d66ae
commit d18195c5a5
4 changed files with 34 additions and 3 deletions

View File

@ -18,9 +18,8 @@ else()
message(LIB_DIR: ${LIB_DIR} )
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DNDEBUG")
#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DNDEBUG -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DDEBUG -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DNDEBUG -DNEWGS")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DDEBUG -fsanitize=address -fno-omit-frame-pointer -DNEWGS")
include_directories(
AFTER

View File

@ -3025,3 +3025,27 @@ void Creature::WinSkillExp(int win_exp)
return;
}
}
float Creature::GetAttrAbs(int attr_id)
{
float val = 0;
if (GetAbility()){
val += GetAbility()->GetAttrAbs(attr_id);
}
if (GetBattleContext()) {
val += GetBattleContext()->GetAttrAbs(attr_id);
}
return val;
}
float Creature::GetAttrRate(int attr_id)
{
float val = 0;
if (GetAbility()){
val += GetAbility()->GetAttrRate(attr_id);
}
if (GetBattleContext()) {
val += GetBattleContext()->GetAttrRate(attr_id);
}
return val;
}

View File

@ -238,6 +238,7 @@ class Creature : public MoveableEntity
bool CheckCollision();
Trigger* GetTrigger() { return trigger_; };
std::shared_ptr<Ability>& GetAbility() { return ability_; };
std::shared_ptr<BattleDataContext>& GetBattleContext() { return battle_context_; };
void RefreshHP();
void TraverseBuff(std::function<void (Buff*, bool&)> func);
long long GetCollisionTimes() { return collision_times_; };
@ -252,6 +253,8 @@ class Creature : public MoveableEntity
void SetDisableMoveDirTimes(int times) { disable_move_dir_times_ = times; };
void DoRecoilForce(int distance);
void WinSkillExp(int win_exp);
float GetAttrAbs(int attr_id);
float GetAttrRate(int attr_id);
protected:
virtual void OnBuffRemove(Buff& buff);

View File

@ -3283,11 +3283,16 @@ void Human::OnBulletHit(Bullet* bullet)
if (!dead && (bullet->IsBomb() || bullet->sender.Get()->team_id != team_id)) {
float old_hp = GetHP();
float old_max_hp = GetMaxHP();
#ifdef NEWGS
float def = 0;
float finaly_dmg = 0;
#else
float dmg = bullet->GetAtk();
float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) +
GetAbility()->GetAttrAbs(kHAT_Def);
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
finaly_dmg = std::max(finaly_dmg, 0.0f);
#endif
if (bullet->sender.Get()->IsHuman()) {
bullet->sender.Get()->AsHuman()->stats.damage_amount_out += finaly_dmg;
}