添加数值

This commit is contained in:
aozhiwei 2019-07-19 14:58:10 +08:00
parent eb337405de
commit b7d9cf732d
8 changed files with 44 additions and 52 deletions

View File

@ -29,7 +29,10 @@ void Buff::ProcLastBurn(const a8::XParams& param)
Human* hum = (Human*)param.sender.GetUserData(); Human* hum = (Human*)param.sender.GetUserData();
Buff* buff = (Buff*)param.param1.GetUserData(); Buff* buff = (Buff*)param.param1.GetUserData();
if (!hum->dead && !hum->HasBuffEffect(BET_Invincible)) { if (!hum->dead && !hum->HasBuffEffect(BET_Invincible)) {
hum->DecHP(buff->meta->param1, float power = buff->meta->param1;
float def = hum->ability.def;
float finally_dmg = power * (1 - def/MetaMgr::Instance()->K);
hum->DecHP(finally_dmg,
hum->last_attacker_id, hum->last_attacker_id,
hum->last_attacker_name, hum->last_attacker_name,
hum->last_attacker_weapon_id); hum->last_attacker_weapon_id);
@ -70,8 +73,11 @@ void Buff::ProcReleaseFireBomb(const a8::XParams& param)
for (Human* hum : cell->human_list) { for (Human* hum : cell->human_list) {
if (hum != sender && !hum->dead && !hum->HasBuffEffect(BET_Invincible)) { if (hum != sender && !hum->dead && !hum->HasBuffEffect(BET_Invincible)) {
if (hum->TestCollision(&collider)) { if (hum->TestCollision(&collider)) {
float power = buff->meta->param4 + sender->ability.atk;
float def = hum->ability.def;
float finally_dmg = power * (1 - def/MetaMgr::Instance()->K);
hum->DecHP( hum->DecHP(
buff->meta->param4, finally_dmg,
sender->entity_uniid, sender->entity_uniid,
sender->name, sender->name,
0 0

View File

@ -58,15 +58,15 @@ void Bullet::OnHit(std::set<Entity*>& objects)
if (!hum->dead) { if (!hum->dead) {
#else #else
if (hum != player && !hum->dead && if (hum != player && !hum->dead &&
(hum->team_id == 0 || player->team_id != hum->team_id)) { (hum->team_id == 0 || master->team_id != hum->team_id)) {
#endif #endif
float dmg = meta->i->atk() * (1 + player->ability.damage_add); float power = meta->i->atk() + master->ability.atk;
float def = hum->ability.def + hum->ability.def_add; float def = hum->ability.def;
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K); float finaly_dmg = power * (1 - def/MetaMgr::Instance()->K);
player->stats.damage_amount_out += finaly_dmg; master->stats.damage_amount_out += finaly_dmg;
hum->OnHit(); hum->OnHit();
if (!hum->HasBuffEffect(BET_Invincible)) { if (!hum->HasBuffEffect(BET_Invincible)) {
hum->DecHP(finaly_dmg, player->entity_uniid, player->name, meta->i->id()); hum->DecHP(finaly_dmg, master->entity_uniid, master->name, meta->i->id());
} }
} }
} }
@ -75,11 +75,11 @@ void Bullet::OnHit(std::set<Entity*>& objects)
{ {
Obstacle* obstacle = (Obstacle*)target; Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->dead && obstacle->meta->i->attack_type() == 1) { if (!obstacle->dead && obstacle->meta->i->attack_type() == 1) {
float dmg = meta->i->atk() * (1 + player->ability.damage_add); float dmg = meta->i->atk() + master->ability.atk;
float def = 0; float def = 0;
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K); float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
#if 0 #if 0
player->stats.damage_amount_out += finaly_dmg; master->stats.damage_amount_out += finaly_dmg;
#endif #endif
obstacle->health = std::max(0.0f, obstacle->health - finaly_dmg); obstacle->health = std::max(0.0f, obstacle->health - finaly_dmg);
@ -154,8 +154,8 @@ void Bullet::MapServiceUpdate()
std::set<Entity*> objects; std::set<Entity*> objects;
for (auto& grid : grid_list) { for (auto& grid : grid_list) {
for (Human* hum: grid->human_list) { for (Human* hum: grid->human_list) {
if (hum != player && !hum->dead && if (hum != master && !hum->dead &&
(hum->team_id == 0 || player->team_id != hum->team_id)) { (hum->team_id == 0 || master->team_id != hum->team_id)) {
if (TestCollision(hum)) { if (TestCollision(hum)) {
objects.insert(hum); objects.insert(hum);
} }
@ -207,7 +207,10 @@ void Bullet::PostAttack()
if (hum->pos.Distance(obstacle->pos) < obstacle->meta->i->damage_dia()) { if (hum->pos.Distance(obstacle->pos) < obstacle->meta->i->damage_dia()) {
hum->OnHit(); hum->OnHit();
if (!hum->HasBuffEffect(BET_Invincible)) { if (!hum->HasBuffEffect(BET_Invincible)) {
hum->DecHP(obstacle->meta->i->damage(), sender->entity_uniid, sender->name, 0); float power = obstacle->meta->i->damage() + sender->ability.atk;
float def = hum->ability.def;
float finally_dmg = power * (1 - def/MetaMgr::Instance()->K);
hum->DecHP(finally_dmg, sender->entity_uniid, sender->name, 0);
} }
} }
} }
@ -221,7 +224,7 @@ void Bullet::PostAttack()
room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE, room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE,
a8::XParams() a8::XParams()
.SetSender(obstacle) .SetSender(obstacle)
.SetParam1(player), .SetParam1(master),
fire_func, fire_func,
&obstacle->xtimer_attacher.timer_list_); &obstacle->xtimer_attacher.timer_list_);
room->xtimer.AddDeadLineTimerAndAttach(meta->i->time() * SERVER_FRAME_RATE, room->xtimer.AddDeadLineTimerAndAttach(meta->i->time() * SERVER_FRAME_RATE,
@ -250,7 +253,10 @@ void Bullet::ProcMissible(const a8::XParams& param)
if (src_pos.Distance(target->pos) < bullet_meta->i->range()) { if (src_pos.Distance(target->pos) < bullet_meta->i->range()) {
target->OnHit(); target->OnHit();
if (!target->HasBuffEffect(BET_Invincible)) { if (!target->HasBuffEffect(BET_Invincible)) {
target->DecHP(bullet_meta->i->atk(), float power = bullet_meta->i->atk() + sender->ability.atk;
float def = target->ability.def;
float finally_dmg = power * (1 - def/MetaMgr::Instance()->K);
target->DecHP(finally_dmg,
sender->entity_uniid, sender->entity_uniid,
sender->name, sender->name,
bullet_meta->i->id() bullet_meta->i->id()
@ -260,7 +266,10 @@ void Bullet::ProcMissible(const a8::XParams& param)
} else { } else {
target->OnHit(); target->OnHit();
if (!target->HasBuffEffect(BET_Invincible)) { if (!target->HasBuffEffect(BET_Invincible)) {
target->DecHP(bullet_meta->i->atk(), float power = bullet_meta->i->atk() + sender->ability.atk;
float def = target->ability.def;
float finally_dmg = power * (1 - def/MetaMgr::Instance()->K);
target->DecHP(finally_dmg,
sender->entity_uniid, sender->entity_uniid,
sender->name, sender->name,
bullet_meta->i->id() bullet_meta->i->id()

View File

@ -16,7 +16,7 @@ class Bullet : public Entity
{ {
public: public:
MetaData::Equip* meta = nullptr; MetaData::Equip* meta = nullptr;
Human* player = nullptr; Human* master = nullptr;
a8::Vec2 dir; a8::Vec2 dir;
a8::Vec2 born_pos; a8::Vec2 born_pos;
a8::Vec2 born_dir; a8::Vec2 born_dir;

View File

@ -123,16 +123,16 @@ void FrameEvent::AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos)
{ {
{ {
auto& tuple = a8::FastAppend(smokes_); auto& tuple = a8::FastAppend(smokes_);
std::get<0>(tuple) = bullet->player; std::get<0>(tuple) = bullet->master;
auto& p = std::get<1>(tuple); auto& p = std::get<1>(tuple);
p.set_item_id(item_id); p.set_item_id(item_id);
TypeConvert::ToPb(pos, p.mutable_pos()); TypeConvert::ToPb(pos, p.mutable_pos());
p.set_player_id(bullet->player->entity_uniid); p.set_player_id(bullet->master->entity_uniid);
} }
{ {
int idx = smokes_.size() - 1; int idx = smokes_.size() - 1;
for (auto& cell : bullet->player->grid_list) { for (auto& cell : bullet->master->grid_list) {
for (auto& hum : cell->human_list) { for (auto& hum : cell->human_list) {
hum->smokes_.push_back(idx); hum->smokes_.push_back(idx);
} }

View File

@ -1635,7 +1635,10 @@ void Human::_UpdateAssaultMove()
for (Human* hum : cell->human_list) { for (Human* hum : cell->human_list) {
if (hum->team_id != team_id && hum->pos.Distance(skill_target_pos) < hum->GetRadius()) { if (hum->team_id != team_id && hum->pos.Distance(skill_target_pos) < hum->GetRadius()) {
if (!hum->HasBuffEffect(BET_Invincible)) { if (!hum->HasBuffEffect(BET_Invincible)) {
hum->DecHP(phase->param1.GetDouble(), entity_uniid, name, 0); float power = phase->param1.GetDouble() + ability.atk;
float def = hum->ability.def;
float finally_dmg = power * (1 - def/MetaMgr::Instance()->K);
hum->DecHP(finally_dmg, entity_uniid, name, 0);
target_list.insert(hum); target_list.insert(hum);
} }
a8::Vec2 pull_dir = skill_dir; a8::Vec2 pull_dir = skill_dir;
@ -1908,32 +1911,6 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
switch (phase->func_id) { switch (phase->func_id) {
case Skill_Jump: case Skill_Jump:
{ {
#if 0
a8::Vec2 old_pos = pos;
pos = skill_target_pos;
if (IsCollisionInMapService()) {
pos = old_pos;
} else {
for (auto& cell : grid_list) {
for (Human* hum : cell->human_list) {
if (hum->team_id != team_id && hum->pos.Distance(skill_target_pos) < hum->GetRadius()) {
if (!hum->HasBuffEffect(BET_Invincible)) {
hum->DecHP(phase->param1.GetDouble(), entity_uniid, name, 0);
}
a8::Vec2 pull_dir = pos - old_pos;
if (std::abs(pull_dir.x) > FLT_EPSILON ||
std::abs(pull_dir.y) > FLT_EPSILON) {
pull_dir.Normalize();
hum->PullHuman(pull_dir, phase->param2.GetDouble());
}
}
}
}
room->frame_event.AddExplosion(0, pos, 2);
room->grid_service.MoveHuman(this);
CheckGrass();
}
#endif
} }
break; break;
case Skill_Shot: case Skill_Shot:

View File

@ -205,7 +205,10 @@ void Obstacle::Explosion()
Human* hum = (Human*)target; Human* hum = (Human*)target;
if (!hum->dead && hum != master) { if (!hum->dead && hum != master) {
float dmg = meta->i->damage(); float dmg = meta->i->damage();
float def = hum->ability.def + hum->ability.def_add; if (master) {
dmg += master->ability.atk;
}
float def = hum->ability.def;
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K); float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
hum->OnHit(); hum->OnHit();
if (!hum->HasBuffEffect(BET_Invincible)) { if (!hum->HasBuffEffect(BET_Invincible)) {

View File

@ -556,7 +556,7 @@ void Room::CreateBullet(Human* hum, MetaData::Equip* bullet_meta,
a8::Vec2 pos, a8::Vec2 dir, float fly_distance) a8::Vec2 pos, a8::Vec2 dir, float fly_distance)
{ {
Bullet* bullet = new Bullet(); Bullet* bullet = new Bullet();
bullet->player = hum; bullet->master = hum;
bullet->room = this; bullet->room = this;
bullet->meta = bullet_meta; bullet->meta = bullet_meta;
bullet->pos = pos; bullet->pos = pos;

View File

@ -103,9 +103,6 @@ struct HumanAbility
float atk = 0.0f; float atk = 0.0f;
float def = 0.0f; float def = 0.0f;
float speed = 0.0f; float speed = 0.0f;
float damage_add = 0.0f;
float def_add = 0.0f;
float reflect_damage = 0.0f;
float shot_range = 0.0f; float shot_range = 0.0f;
float shot_speed = 0.0f; float shot_speed = 0.0f;