This commit is contained in:
aozhiwei 2021-04-02 19:21:22 +08:00
parent 871e44508f
commit e1ba7d045c
5 changed files with 102 additions and 20 deletions

View File

@ -173,7 +173,7 @@ void Bullet::ProcBomb()
block = true;
}
}
float delay_time = 0;
int delay_time = 0;
if (!block) {
delay_time = gun_meta->i->missiles_time();
}
@ -343,13 +343,9 @@ void Bullet::Check(float distance)
}
}
void Bullet::ProcFragBomb(float delay_time)
void Bullet::ProcFragBomb(int delay_time)
{
if (sender.Get()) {
RoomObstacle* dummy_obstacle = nullptr;
if (delay_time > 0.0001) {
dummy_obstacle = room->CreateObstacle(0, 0, 0);
}
FragMiTask* task = new FragMiTask();
task->room = room;
task->sender.Attach(sender.Get());
@ -357,9 +353,8 @@ void Bullet::ProcFragBomb(float delay_time)
task->gun_meta = gun_meta;
task->meta = meta;
task->atk = GetAtk();
task->dummy_obstacle_uniid = dummy_obstacle ? dummy_obstacle->GetEntityUniId() : 0;
room->xtimer.AddDeadLineTimerAndAttach
(std::max(1, (int)(SERVER_FRAME_RATE * delay_time)),
(std::max(1, (int)(delay_time / FRAME_RATE_MS)),
a8::XParams()
.SetSender(task),
[] (const a8::XParams& param)
@ -377,12 +372,12 @@ void Bullet::ProcFragBomb(float delay_time)
}
}
void Bullet::ProcPosionGasBomb(float delay_time)
void Bullet::ProcPosionGasBomb(int delay_time)
{
}
void Bullet::ProcMolotorCocktailBomb(float delay_time)
void Bullet::ProcMolotorCocktailBomb(int delay_time)
{
}

View File

@ -43,9 +43,9 @@ protected:
void OnHit(std::set<Entity*>& objects);
void ProcBomb();
void ProcSmokeBomb();
void ProcFragBomb(float delay_time);
void ProcPosionGasBomb(float delay_time);
void ProcMolotorCocktailBomb(float delay_time);
void ProcFragBomb(int delay_time);
void ProcPosionGasBomb(int delay_time);
void ProcMolotorCocktailBomb(int delay_time);
bool IsBomb();
inline void MapServiceUpdate();
float GetAtk();

View File

@ -5,13 +5,101 @@
#include "player.h"
#include "metadata.h"
#include "metamgr.h"
#include "gridservice.h"
#include "creature.h"
#include "obstacle.h"
void FragMiTask::Done()
{
if (sender.Get()) {
room->frame_event.AddExplosionEx(sender,
meta->i->id(),
bomb_pos,
gun_meta->i->explosion_effect());
if (!sender.Get()) {
return;
}
room->frame_event.AddExplosionEx(sender,
meta->i->id(),
bomb_pos,
gun_meta->i->explosion_effect());
std::set<GridCell*> grid_list;
sender.Get()->room->grid_service->GetAllCellsByXy
(
sender.Get()->room,
bomb_pos.x,
bomb_pos.y,
grid_list
);
std::set<Creature*> objects;
sender.Get()->room->grid_service->TouchCreatures
(
sender.Get()->room->GetRoomIdx(),
grid_list,
[this, &objects] (Creature* c, bool& stop)
{
if (sender.Get()->IsProperTarget(c)) {
if (bomb_pos.Distance(c->GetPos()) < meta->i->explosion_range()) {
objects.insert(c);
}
}
}
);
std::set<Entity*> entitys;
sender.Get()->room->grid_service->TouchAllLayerEntityList
(
sender.Get()->room->GetRoomIdx(),
grid_list,
[this, &entitys] (Entity* entity, bool& stop)
{
}
);
for (auto& target : objects) {
if (target->HasBuffEffect(kBET_Invincible) ||
target->HasBuffEffect(kBET_AdPlaying)) {
continue;
}
if (sender.Get()->room->GetRoomMode() == kZombieMode &&
sender.Get()->GetRace() == target->GetRace()) {
continue;
}
if (!target->dead) {
float dmg = GetAtk() * (1 + sender.Get()->GetAttrRate(kHAT_Atk)) +
sender.Get()->GetAttrAbs(kHAT_Atk);
float def = target->ability.def * (1 + target->GetAttrRate(kHAT_Def)) +
target->GetAttrAbs(kHAT_Def);
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
finaly_dmg = std::max(finaly_dmg, 0.0f);
target->DecHP(finaly_dmg,
sender.Get()->GetEntityUniId(),
sender.Get()->GetName(),
gun_meta->i->id());
}
}
for (auto& target : entitys) {
if (target->GetEntityType() != ET_Obstacle) {
continue;
}
Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->IsDead(room) &&
obstacle->Attackable() &&
!obstacle->IsTerminatorAirDropBox(room)) {
float dmg = GetAtk() * (1 + sender.Get()->GetAttrRate(kHAT_Atk)) +
sender.Get()->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));
if (obstacle->GetHealth(room) <= 0.01f) {
obstacle->Die(room);
}
if (obstacle->IsDead(room)) {
if (obstacle->meta->i->damage_dia() > 0.01f &&
obstacle->meta->i->damage() > 0.01f) {
#if 0
obstacle->Explosion(this);
#endif
}
sender.Get()->DropItems(obstacle);
}
obstacle->BroadcastFullState(room);
}
}
}

View File

@ -19,7 +19,6 @@ class FragMiTask : public MicroTask
MetaData::Equip* gun_meta = nullptr;
MetaData::Equip* meta = nullptr;
float atk = 0;
int dummy_obstacle_uniid = 0;
void Done();
float GetAtk() { return atk; }

View File

@ -106,7 +106,7 @@ message Equip
optional string param2 = 44;
optional int32 reloadtype = 46;
optional float Recoil_force = 47;
optional float missiles_time = 48;
optional int32 missiles_time = 48;
optional int32 heroid = 49;
optional string inventory_slot = 31; //