1
This commit is contained in:
parent
cacdd34267
commit
340a786f02
@ -793,6 +793,7 @@ void Bullet::ClearBuffList()
|
|||||||
sender.Get()->RemoveBuffByUniId(buff_uniid);
|
sender.Get()->RemoveBuffByUniId(buff_uniid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
buff_list_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bullet::ProcFlyHook(Entity* target)
|
void Bullet::ProcFlyHook(Entity* target)
|
||||||
@ -830,7 +831,9 @@ void Bullet::ProcFlyHook(Entity* target)
|
|||||||
|
|
||||||
void Bullet::ForceRemove()
|
void Bullet::ForceRemove()
|
||||||
{
|
{
|
||||||
|
if (!later_removed_) {
|
||||||
ClearBuffList();
|
ClearBuffList();
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
later_removed_ = true;
|
later_removed_ = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -89,7 +89,8 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
|||||||
bullet_info.bullet_born_pos,
|
bullet_info.bullet_born_pos,
|
||||||
bullet_info.bullet_dir,
|
bullet_info.bullet_dir,
|
||||||
bullet_info.fly_distance,
|
bullet_info.fly_distance,
|
||||||
bullet_info.weapon_uniid);
|
bullet_info.weapon_uniid,
|
||||||
|
bullet_info.trace_target_uniid);
|
||||||
#ifdef DEBUG1
|
#ifdef DEBUG1
|
||||||
if (bullet_info.c.Get()->IsPlayer()) {
|
if (bullet_info.c.Get()->IsPlayer()) {
|
||||||
bullet_info.c.Get()->SendDebugMsg(a8::Format("CreateBullet id:%d",
|
bullet_info.c.Get()->SendDebugMsg(a8::Format("CreateBullet id:%d",
|
||||||
@ -105,22 +106,15 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
|||||||
bullet_info.weapon_lv,
|
bullet_info.weapon_lv,
|
||||||
bullet_info.bullet_born_pos,
|
bullet_info.bullet_born_pos,
|
||||||
bullet_info.bullet_dir,
|
bullet_info.bullet_dir,
|
||||||
bullet_info.fly_distance);
|
bullet_info.fly_distance,
|
||||||
|
bullet_info.trace_target_uniid);
|
||||||
if (bullet_uniid && bullet_info.trace_target_uniid) {
|
if (bullet_uniid && bullet_info.trace_target_uniid) {
|
||||||
Entity* entity = c->room->GetEntityByUniId(bullet_uniid);
|
|
||||||
if (entity->GetEntityType() == ET_Bullet) {
|
|
||||||
Bullet* bullet = (Bullet*)bullet;
|
|
||||||
Entity* target = c->room->GetEntityByUniId(bullet_info.trace_target_uniid);
|
|
||||||
if (target->IsCreature(c->room)) {
|
|
||||||
bullet->trace_target_id = bullet_info.trace_target_uniid;
|
|
||||||
c->AddTraceBullet(
|
c->AddTraceBullet(
|
||||||
bullet_uniid,
|
bullet_uniid,
|
||||||
bullet_info.trace_target_uniid,
|
bullet_info.trace_target_uniid,
|
||||||
bullet_info.weapon_meta->i->id()
|
bullet_info.weapon_meta->i->id()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
BulletInfo* info_copy = new BulletInfo();
|
BulletInfo* info_copy = new BulletInfo();
|
||||||
*info_copy = bullet_info;
|
*info_copy = bullet_info;
|
||||||
@ -332,8 +326,10 @@ void InternalShot(Creature* c,
|
|||||||
bullet_born_pos = c->GetPos() + bullet_born_offset;
|
bullet_born_pos = c->GetPos() + bullet_born_offset;
|
||||||
if (c->IsPlayer() || c->IsCar()) {
|
if (c->IsPlayer() || c->IsCar()) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
a8::XPrintf("offset:%f,%f angle:%f old_angle:%f angle_xy:%f,%f %f %f gun_muzzle_position:%f,%f,%f pos:%f,%f gun_id:%d\n",
|
a8::XPrintf("idx:%d offset:%f,%f angle:%f old_angle:%f angle_xy:%f,%f %f %f gun_muzzle_position:%f,%f,%f pos:%f,%f gun_id:%d\n",
|
||||||
{bullet_born_offset.x,
|
{
|
||||||
|
i,
|
||||||
|
bullet_born_offset.x,
|
||||||
bullet_born_offset.y,
|
bullet_born_offset.y,
|
||||||
bullet_born_angle,
|
bullet_born_angle,
|
||||||
old_bullet_born_angle,
|
old_bullet_born_angle,
|
||||||
@ -3587,7 +3583,7 @@ void Creature::AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id)
|
|||||||
c->trace_bullet_hash_.erase(param.param1);
|
c->trace_bullet_hash_.erase(param.param1);
|
||||||
Entity* entity = c->room->GetEntityByUniId(param.param1);
|
Entity* entity = c->room->GetEntityByUniId(param.param1);
|
||||||
if (entity && entity->GetEntityType() == ET_Bullet) {
|
if (entity && entity->GetEntityType() == ET_Bullet) {
|
||||||
Bullet* bullet = (Bullet*)bullet;
|
Bullet* bullet = (Bullet*)entity;
|
||||||
bullet->ForceRemove();
|
bullet->ForceRemove();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -81,7 +81,8 @@ void FrameEvent::AddBullet(int bullet_uniid,
|
|||||||
int weapon_lv,
|
int weapon_lv,
|
||||||
a8::Vec2 born_pos,
|
a8::Vec2 born_pos,
|
||||||
a8::Vec2 dir,
|
a8::Vec2 dir,
|
||||||
float fly_distance)
|
float fly_distance,
|
||||||
|
int trace_target_id)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (sender.Get()->IsPlayer()) {
|
if (sender.Get()->IsPlayer()) {
|
||||||
@ -104,6 +105,9 @@ void FrameEvent::AddBullet(int bullet_uniid,
|
|||||||
p.set_gun_id(weapon_meta->i->id());
|
p.set_gun_id(weapon_meta->i->id());
|
||||||
p.set_gun_lv(weapon_lv);
|
p.set_gun_lv(weapon_lv);
|
||||||
p.set_fly_distance(fly_distance);
|
p.set_fly_distance(fly_distance);
|
||||||
|
if (trace_target_id) {
|
||||||
|
p.set_trace_target_uniid(trace_target_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int bullet_idx = bullets_.size() - 1;
|
int bullet_idx = bullets_.size() - 1;
|
||||||
|
@ -28,7 +28,8 @@ public:
|
|||||||
int weapon_lv,
|
int weapon_lv,
|
||||||
a8::Vec2 born_pos,
|
a8::Vec2 born_pos,
|
||||||
a8::Vec2 dir,
|
a8::Vec2 dir,
|
||||||
float fly_distance);
|
float fly_distance,
|
||||||
|
int trace_target_id);
|
||||||
void RemoveBullet(a8::Vec2 pos, int bullet_uniid);
|
void RemoveBullet(a8::Vec2 pos, int bullet_uniid);
|
||||||
void AddExplosion(Bullet* bullet, int item_id, a8::Vec2 bomb_pos);
|
void AddExplosion(Bullet* bullet, int item_id, a8::Vec2 bomb_pos);
|
||||||
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos, float time_addition);
|
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos, float time_addition);
|
||||||
|
@ -595,7 +595,8 @@ int Room::CreateBullet(Creature* sender,
|
|||||||
a8::Vec2 pos,
|
a8::Vec2 pos,
|
||||||
a8::Vec2 dir,
|
a8::Vec2 dir,
|
||||||
float fly_distance,
|
float fly_distance,
|
||||||
long long weapon_uniid)
|
long long weapon_uniid,
|
||||||
|
int trace_target_id)
|
||||||
{
|
{
|
||||||
int bullet_uniid = 0;
|
int bullet_uniid = 0;
|
||||||
if (grid_service->CanAdd(pos.x, pos.y)) {
|
if (grid_service->CanAdd(pos.x, pos.y)) {
|
||||||
@ -614,6 +615,7 @@ int Room::CreateBullet(Creature* sender,
|
|||||||
bullet->born_pos = pos;
|
bullet->born_pos = pos;
|
||||||
bullet->born_dir = dir;
|
bullet->born_dir = dir;
|
||||||
bullet->fly_distance = fly_distance;
|
bullet->fly_distance = fly_distance;
|
||||||
|
bullet->trace_target_id = trace_target_id;
|
||||||
bullet->Initialize();
|
bullet->Initialize();
|
||||||
AddObjectLater(bullet);
|
AddObjectLater(bullet);
|
||||||
bullet_uniid = bullet->GetUniId();
|
bullet_uniid = bullet->GetUniId();
|
||||||
|
@ -170,7 +170,8 @@ public:
|
|||||||
a8::Vec2 pos,
|
a8::Vec2 pos,
|
||||||
a8::Vec2 dir,
|
a8::Vec2 dir,
|
||||||
float fly_distance,
|
float fly_distance,
|
||||||
long long weapon_uniid);
|
long long weapon_uniid,
|
||||||
|
int trace_target_id);
|
||||||
Car* CreateCar(Human* driver,
|
Car* CreateCar(Human* driver,
|
||||||
int car_uniid,
|
int car_uniid,
|
||||||
MetaData::Equip* meta,
|
MetaData::Equip* meta,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user