explosion_damage_delay
This commit is contained in:
parent
1b7e3ebe6d
commit
df3696ba61
@ -14,6 +14,7 @@
|
|||||||
#include "explosion.h"
|
#include "explosion.h"
|
||||||
#include "obstacle.h"
|
#include "obstacle.h"
|
||||||
#include "ability.h"
|
#include "ability.h"
|
||||||
|
#include "entityfactory.h"
|
||||||
|
|
||||||
Car::Car():Creature()
|
Car::Car():Creature()
|
||||||
{
|
{
|
||||||
@ -406,8 +407,8 @@ void Car::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
|||||||
passenger->RemoveBuffByEffectId(kBET_Passenger);
|
passenger->RemoveBuffByEffectId(kBET_Passenger);
|
||||||
room->frame_event.AddCarChg(passenger->GetWeakPtrRef());
|
room->frame_event.AddCarChg(passenger->GetWeakPtrRef());
|
||||||
}
|
}
|
||||||
Explosion explosion;
|
std::shared_ptr<Explosion> explosion = EntityFactory::Instance()->MakeExplosion();
|
||||||
explosion.IndifferenceAttack(
|
explosion->IndifferenceAttack(
|
||||||
room,
|
room,
|
||||||
GetPos(),
|
GetPos(),
|
||||||
meta->i->explosion_range(),
|
meta->i->explosion_range(),
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "hero.h"
|
#include "hero.h"
|
||||||
#include "dummyentity.h"
|
#include "dummyentity.h"
|
||||||
#include "mapblock.h"
|
#include "mapblock.h"
|
||||||
|
#include "explosion.h"
|
||||||
|
|
||||||
void EntityFactory::Init()
|
void EntityFactory::Init()
|
||||||
{
|
{
|
||||||
@ -114,3 +115,9 @@ MapBlock* EntityFactory::MakeBlock(int entity_uniid)
|
|||||||
p->entity_type_ = ET_MapBlock;
|
p->entity_type_ = ET_MapBlock;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Explosion> EntityFactory::MakeExplosion()
|
||||||
|
{
|
||||||
|
std::shared_ptr<Explosion> e(new Explosion);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
@ -11,6 +11,7 @@ class Car;
|
|||||||
class Hero;
|
class Hero;
|
||||||
class DummyEntity;
|
class DummyEntity;
|
||||||
class MapBlock;
|
class MapBlock;
|
||||||
|
class Explosion;
|
||||||
class EntityFactory : public a8::Singleton<EntityFactory>
|
class EntityFactory : public a8::Singleton<EntityFactory>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -32,6 +33,7 @@ class EntityFactory : public a8::Singleton<EntityFactory>
|
|||||||
Hero* MakeHero(int entity_uniid);
|
Hero* MakeHero(int entity_uniid);
|
||||||
DummyEntity* MakeDummy(int entity_uniid);
|
DummyEntity* MakeDummy(int entity_uniid);
|
||||||
MapBlock* MakeBlock(int entity_uniid);
|
MapBlock* MakeBlock(int entity_uniid);
|
||||||
|
std::shared_ptr<Explosion> MakeExplosion();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
@ -50,16 +50,8 @@ void Explosion::EnemyAndObstacleAttack(CreatureWeakPtr& sender,
|
|||||||
InternalAttack();
|
InternalAttack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Explosion::InternalAttack()
|
void Explosion::ProcDamage()
|
||||||
{
|
{
|
||||||
if (explosion_range_ <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
room_->frame_event.AddExplosionEx
|
|
||||||
(sender_,
|
|
||||||
0,
|
|
||||||
center_,
|
|
||||||
explosion_effect_);
|
|
||||||
std::set<GridCell*> grid_list;
|
std::set<GridCell*> grid_list;
|
||||||
room_->grid_service->GetAllCellsByXy
|
room_->grid_service->GetAllCellsByXy
|
||||||
(
|
(
|
||||||
@ -85,7 +77,7 @@ void Explosion::InternalAttack()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type_ == kExplosionEnemyAndObstacle) {
|
if (type_ == kExplosionEnemyAndObstacle) {
|
||||||
if (sender_.Get()->IsProperTarget(c)) {
|
if (sender_.Get() && sender_.Get()->IsProperTarget(c)) {
|
||||||
if (center_.Distance(c->GetPos()) < explosion_range_) {
|
if (center_.Distance(c->GetPos()) < explosion_range_) {
|
||||||
objects.insert(c);
|
objects.insert(c);
|
||||||
}
|
}
|
||||||
@ -128,6 +120,39 @@ void Explosion::InternalAttack()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Explosion::InternalAttack()
|
||||||
|
{
|
||||||
|
if (explosion_range_ <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
room_->frame_event.AddExplosionEx
|
||||||
|
(sender_,
|
||||||
|
0,
|
||||||
|
center_,
|
||||||
|
explosion_effect_);
|
||||||
|
|
||||||
|
if (explosion_damage_delay_ <= 0) {
|
||||||
|
ProcDamage();
|
||||||
|
} else {
|
||||||
|
std::shared_ptr<Explosion>* self = new std::shared_ptr<Explosion>(this);
|
||||||
|
room_->xtimer.AddDeadLineTimerAndAttach
|
||||||
|
(explosion_damage_delay_ / FRAME_RATE_MS,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(self),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
std::shared_ptr<Explosion>* self = (std::shared_ptr<Explosion>*)param.sender.GetUserData();
|
||||||
|
(*self)->ProcDamage();
|
||||||
|
},
|
||||||
|
&room_->xtimer_attacher_.timer_list_,
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
std::shared_ptr<Explosion>* self = (std::shared_ptr<Explosion>*)param.sender.GetUserData();
|
||||||
|
delete self;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Explosion::IsPreBattleExplosion()
|
bool Explosion::IsPreBattleExplosion()
|
||||||
{
|
{
|
||||||
return create_frameno_ <= room_->GetBattleStartFrameNo() || room_->GetBattleStartFrameNo() == 0;
|
return create_frameno_ <= room_->GetBattleStartFrameNo() || room_->GetBattleStartFrameNo() == 0;
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
#include "weakptr.h"
|
#include "weakptr.h"
|
||||||
|
|
||||||
class Room;
|
class Room;
|
||||||
class Explosion
|
class EntityFactory;
|
||||||
|
class Explosion : public std::enable_shared_from_this<Explosion>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int exclude_uniid = 0;
|
int exclude_uniid = 0;
|
||||||
@ -14,6 +15,7 @@ class Explosion
|
|||||||
long long GetSpecialDamageType() { return special_damage_type_; };
|
long long GetSpecialDamageType() { return special_damage_type_; };
|
||||||
bool IsPreBattleExplosion();
|
bool IsPreBattleExplosion();
|
||||||
int GetExplosionEffect() { return explosion_effect_; };
|
int GetExplosionEffect() { return explosion_effect_; };
|
||||||
|
void SetDmageDelay(int delay) { explosion_damage_delay_ = delay; };
|
||||||
|
|
||||||
void IndifferenceAttack(Room* room,
|
void IndifferenceAttack(Room* room,
|
||||||
const a8::Vec2& center,
|
const a8::Vec2& center,
|
||||||
@ -29,8 +31,10 @@ class Explosion
|
|||||||
long long special_damage_type = 0);
|
long long special_damage_type = 0);
|
||||||
void AddForceTarget(CreatureWeakPtr force_target);
|
void AddForceTarget(CreatureWeakPtr force_target);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
Explosion() {};
|
||||||
void InternalAttack();
|
void InternalAttack();
|
||||||
|
void ProcDamage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int type_ = 0;
|
int type_ = 0;
|
||||||
@ -39,8 +43,11 @@ class Explosion
|
|||||||
CreatureWeakPtr force_target_;
|
CreatureWeakPtr force_target_;
|
||||||
float explosion_range_ = 0;
|
float explosion_range_ = 0;
|
||||||
int explosion_effect_ = 0;
|
int explosion_effect_ = 0;
|
||||||
|
int explosion_damage_delay_ = 0;
|
||||||
float dmg_ = 0;
|
float dmg_ = 0;
|
||||||
a8::Vec2 center_;
|
a8::Vec2 center_;
|
||||||
long long special_damage_type_ = 0;
|
long long special_damage_type_ = 0;
|
||||||
long long create_frameno_ = 0;
|
long long create_frameno_ = 0;
|
||||||
|
|
||||||
|
friend class EntityFactory;
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "creature.h"
|
#include "creature.h"
|
||||||
#include "obstacle.h"
|
#include "obstacle.h"
|
||||||
#include "explosion.h"
|
#include "explosion.h"
|
||||||
|
#include "entityfactory.h"
|
||||||
|
|
||||||
void FragMiTask::Done()
|
void FragMiTask::Done()
|
||||||
{
|
{
|
||||||
@ -18,13 +19,13 @@ void FragMiTask::Done()
|
|||||||
center = bomb_pos;
|
center = bomb_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
Explosion explosion;
|
std::shared_ptr<Explosion> explosion = EntityFactory::Instance()->MakeExplosion();
|
||||||
if (force_target.Get()) {
|
if (force_target.Get()) {
|
||||||
explosion.AddForceTarget(force_target);
|
explosion->AddForceTarget(force_target);
|
||||||
}
|
}
|
||||||
explosion.EnemyAndObstacleAttack(sender,
|
explosion->EnemyAndObstacleAttack(sender,
|
||||||
center,
|
center,
|
||||||
explosion_range,
|
explosion_range,
|
||||||
gun_meta->i->explosion_effect(),
|
gun_meta->i->explosion_effect(),
|
||||||
GetAtk());
|
GetAtk());
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "roomobstacle.h"
|
#include "roomobstacle.h"
|
||||||
#include "loot.h"
|
#include "loot.h"
|
||||||
#include "explosion.h"
|
#include "explosion.h"
|
||||||
|
#include "entityfactory.h"
|
||||||
|
|
||||||
enum ObstacleDataFlags_e
|
enum ObstacleDataFlags_e
|
||||||
{
|
{
|
||||||
@ -915,13 +916,13 @@ bool Obstacle::ProcSpecEvent(Creature* c, ColliderComponent* collider)
|
|||||||
void Obstacle::ProcDieExplosion(Room* room)
|
void Obstacle::ProcDieExplosion(Room* room)
|
||||||
{
|
{
|
||||||
if (meta->i->damage_dia() > 0.01f) {
|
if (meta->i->damage_dia() > 0.01f) {
|
||||||
Explosion explosion;
|
std::shared_ptr<Explosion> explosion = EntityFactory::Instance()->MakeExplosion();
|
||||||
explosion.IndifferenceAttack(
|
explosion->IndifferenceAttack(
|
||||||
room,
|
room,
|
||||||
GetPos(),
|
GetPos(),
|
||||||
meta->i->damage_dia(),
|
meta->i->damage_dia(),
|
||||||
meta->i->explosion_effect(),
|
meta->i->explosion_effect(),
|
||||||
meta->i->damage()
|
meta->i->damage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -864,6 +864,14 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg)
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
App::Instance()->debug_params[1] = a8::XValue(cmds[1]);
|
App::Instance()->debug_params[1] = a8::XValue(cmds[1]);
|
||||||
#endif
|
#endif
|
||||||
|
} else if (cmd == "wudi") {
|
||||||
|
int buff_uniid = TryAddBuff(this, 1005);
|
||||||
|
if (buff_uniid != 0) {
|
||||||
|
Buff* buff = GetBuffByUniId(buff_uniid);
|
||||||
|
if (buff->remover_timer) {
|
||||||
|
room->xtimer.ModifyTimer(buff->remover_timer, SERVER_FRAME_RATE * 10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (cmd == "reset_skill" && cmds.size() >= 2) {
|
} else if (cmd == "reset_skill" && cmds.size() >= 2) {
|
||||||
int skill_id = a8::XValue(cmds[1]);
|
int skill_id = a8::XValue(cmds[1]);
|
||||||
Skill* skill = GetSkill(skill_id);
|
Skill* skill = GetSkill(skill_id);
|
||||||
|
@ -79,6 +79,7 @@ public:
|
|||||||
a8::XTimer xtimer;
|
a8::XTimer xtimer;
|
||||||
Plane plane;
|
Plane plane;
|
||||||
a8::TimerAttacher timer_attacher;
|
a8::TimerAttacher timer_attacher;
|
||||||
|
a8::XTimerAttacher xtimer_attacher_;
|
||||||
GridService* grid_service = nullptr;
|
GridService* grid_service = nullptr;
|
||||||
MapService* map_service = nullptr;
|
MapService* map_service = nullptr;
|
||||||
MapInstance* map_instance = nullptr;
|
MapInstance* map_instance = nullptr;
|
||||||
@ -337,7 +338,6 @@ private:
|
|||||||
long long alive_count_chged_frameno_ = 0;
|
long long alive_count_chged_frameno_ = 0;
|
||||||
int human_alive_count_ = 0;
|
int human_alive_count_ = 0;
|
||||||
MetaData::AirLine* airline_ = nullptr;
|
MetaData::AirLine* airline_ = nullptr;
|
||||||
a8::XTimerAttacher xtimer_attacher_;
|
|
||||||
size_t airdrop_times_ = 0;
|
size_t airdrop_times_ = 0;
|
||||||
size_t airraid_times_ = 0;
|
size_t airraid_times_ = 0;
|
||||||
int level0room_born_point_uniid_ = 0;
|
int level0room_born_point_uniid_ = 0;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "mapservice.h"
|
#include "mapservice.h"
|
||||||
#include "roomobstacle.h"
|
#include "roomobstacle.h"
|
||||||
#include "explosion.h"
|
#include "explosion.h"
|
||||||
|
#include "entityfactory.h"
|
||||||
|
|
||||||
RoomObstacle::RoomObstacle():Obstacle()
|
RoomObstacle::RoomObstacle():Obstacle()
|
||||||
{
|
{
|
||||||
@ -194,15 +195,15 @@ void RoomObstacle::SpecExplosion()
|
|||||||
bomb_born_offset = bomb_born_offset * a8::RandEx(1, std::max(2, meta->i->explosion_float()));
|
bomb_born_offset = bomb_born_offset * a8::RandEx(1, std::max(2, meta->i->explosion_float()));
|
||||||
a8::Vec2 bomb_pos = GetPos() + bomb_born_offset;
|
a8::Vec2 bomb_pos = GetPos() + bomb_born_offset;
|
||||||
if (room->grid_service->CanAdd(bomb_pos.x, bomb_pos.y)) {
|
if (room->grid_service->CanAdd(bomb_pos.x, bomb_pos.y)) {
|
||||||
Explosion explosion;
|
std::shared_ptr<Explosion> explosion = EntityFactory::Instance()->MakeExplosion();
|
||||||
explosion.exclude_uniid = GetUniId();
|
explosion->exclude_uniid = GetUniId();
|
||||||
explosion.IndifferenceAttack(
|
explosion->IndifferenceAttack(
|
||||||
room,
|
room,
|
||||||
bomb_pos,
|
bomb_pos,
|
||||||
meta->i->damage_dia(),
|
meta->i->damage_dia(),
|
||||||
meta->i->explosion_effect(),
|
meta->i->explosion_effect(),
|
||||||
meta->i->damage()
|
meta->i->damage()
|
||||||
);
|
);
|
||||||
if (master.Get()) {
|
if (master.Get()) {
|
||||||
std::set<Creature*> target_list;
|
std::set<Creature*> target_list;
|
||||||
room->grid_service->TraverseCreatures
|
room->grid_service->TraverseCreatures
|
||||||
|
@ -171,6 +171,7 @@ message Equip
|
|||||||
optional int32 cast_time = 64;
|
optional int32 cast_time = 64;
|
||||||
optional int32 auto_switch_weapon_time = 65;
|
optional int32 auto_switch_weapon_time = 65;
|
||||||
optional int32 quality = 66;
|
optional int32 quality = 66;
|
||||||
|
optional int32 explosion_damage_delay = 67;
|
||||||
|
|
||||||
optional string inventory_slot = 31; //库存槽位
|
optional string inventory_slot = 31; //库存槽位
|
||||||
optional int32 _inventory_slot = 32; //库存槽位
|
optional int32 _inventory_slot = 32; //库存槽位
|
||||||
|
Loading…
x
Reference in New Issue
Block a user