This commit is contained in:
aozhiwei 2022-10-09 14:55:54 +08:00
parent b92d5ccd8c
commit 1dd0b0e25e
3 changed files with 63 additions and 27 deletions

View File

@ -16,6 +16,7 @@
#include "entityfactory.h"
#include "player.h"
#include "incubator.h"
#include "skillhelper.h"
RoomObstacle::RoomObstacle():Obstacle()
{
@ -856,36 +857,54 @@ void RoomObstacle::ActiveMedicalStation()
room->grid_service->GetAllCellsByXy(room, GetPos().x, GetPos().y, *grid_list_);
}
if (meta->i->width() > 0 && meta->int_param2 > 0) {
room->xtimer.AddRepeatTimerAndAttach
(
meta->int_param1 / FRAME_RATE_MS,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
Room* room = obstacle->room;
std::set<Creature*> target_list;
room->grid_service->TraverseCreatures
(room->GetRoomIdx(),
*obstacle->grid_list_,
[obstacle, &target_list, room] (Creature* hum, bool& stop)
{
if (obstacle->master.Get()->team_id == hum->team_id &&
!hum->dead &&
obstacle->TestCollision(room, hum)) {
if (!skill_meta || !skill_meta->number_meta) {
return;
}
if (skill_meta->GetMagicId() != MAGIC_YLZ) {
return;
}
room->xtimer.AddRepeatTimerAndAttach
(
meta->int_param1 / FRAME_RATE_MS,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
if (!obstacle->master.Get()) {
return;
}
Room* room = obstacle->room;
std::set<Creature*> target_list;
room->grid_service->TraverseCreatures
(room->GetRoomIdx(),
*obstacle->grid_list_,
[obstacle, &target_list, room] (Creature* hum, bool& stop)
{
if (obstacle->master.Get()->team_id == hum->team_id &&
!hum->dead
) {
if (IntersectCircleCircle(
obstacle->GetPos(),
SkillHelper::GetYlzRange(obstacle->skill_meta),
hum->GetPos(),
hum->GetRadius()
)) {
target_list.insert(hum);
}
}
);
for (auto& c : target_list) {
c->AddHp(obstacle->meta->int_param2);
}
},
&xtimer_attacher.timer_list_
);
}
}
);
for (auto& c : target_list) {
c->AddHp(SkillHelper::GetYlzRecoverHp(obstacle->master.Get(),
c,
obstacle->skill_meta));
}
},
&xtimer_attacher.timer_list_
);
}
void RoomObstacle::ActivePortal()

View File

@ -306,3 +306,17 @@ void SkillHelper::ProcSummonObstacle(const MetaData::Skill* skill_meta, RoomObst
}
}
int SkillHelper::GetYlzRange(const MetaData::Skill* skill_meta)
{
return skill_meta->number_meta->float_range2;
}
int SkillHelper::GetYlzRecoverHp(Creature* sender, Creature* target, const MetaData::Skill* skill_meta)
{
float hp =
(skill_meta->number_meta->float_ratio +
skill_meta->number_meta->float_ratio * sender->GetBattleContext()->GetHeroTotalAtk()) *
(1 + target->GetBattleContext()->GetExtRecoverHp());
return hp;
}

View File

@ -34,6 +34,9 @@ class SkillHelper
static int GetYmczBuffTime(const MetaData::Skill* skill_meta);
static int GetYmczReserveDistance(const MetaData::Skill* skill_meta);
static float GetYmczDmg(Creature* sender, Creature* target, const MetaData::Skill* skill_meta);
//医疗站
static int GetYlzRange(const MetaData::Skill* skill_meta);
static int GetYlzRecoverHp(Creature* sender, Creature* target, const MetaData::Skill* skill_meta);
static void ProcBulletHitBuff(Bullet* bullet, Creature* c, int buff_uniid);
static bool ProcBulletDmg(Bullet* bullet, Creature* target, float& finaly_dmg);