1
This commit is contained in:
parent
f66d2ab72c
commit
9a085fc04f
@ -50,11 +50,7 @@ void Bullet::Initialize()
|
|||||||
|
|
||||||
void Bullet::Update(int delta_time)
|
void Bullet::Update(int delta_time)
|
||||||
{
|
{
|
||||||
if (trace_target_id) {
|
if (!trace_target_id) {
|
||||||
ClearBuffList();
|
|
||||||
room->RemoveObjectLater(this);
|
|
||||||
later_removed_ = true;
|
|
||||||
} else {
|
|
||||||
MapServiceUpdate();
|
MapServiceUpdate();
|
||||||
++updated_times_;
|
++updated_times_;
|
||||||
}
|
}
|
||||||
@ -831,3 +827,10 @@ void Bullet::ProcFlyHook(Entity* target)
|
|||||||
&sender.Get()->xtimer_attacher.timer_list_
|
&sender.Get()->xtimer_attacher.timer_list_
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bullet::ForceRemove()
|
||||||
|
{
|
||||||
|
ClearBuffList();
|
||||||
|
room->RemoveObjectLater(this);
|
||||||
|
later_removed_ = true;
|
||||||
|
}
|
||||||
|
@ -43,13 +43,14 @@ class Bullet : public MoveableEntity
|
|||||||
float GetExplosionRange();
|
float GetExplosionRange();
|
||||||
bool IsCurrWeapon();
|
bool IsCurrWeapon();
|
||||||
bool IsPreBattleBullet();
|
bool IsPreBattleBullet();
|
||||||
|
void ForceRemove();
|
||||||
|
void OnHit(std::set<Entity*>& objects);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Bullet();
|
Bullet();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void OnHit(std::set<Entity*>& objects);
|
|
||||||
void ProcBomb();
|
void ProcBomb();
|
||||||
void ProcSmokeBomb();
|
void ProcSmokeBomb();
|
||||||
void ProcFragBomb(int delay_time);
|
void ProcFragBomb(int delay_time);
|
||||||
|
@ -113,12 +113,10 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
|||||||
Entity* target = c->room->GetEntityByUniId(bullet_info.trace_target_uniid);
|
Entity* target = c->room->GetEntityByUniId(bullet_info.trace_target_uniid);
|
||||||
if (target->IsCreature(c->room)) {
|
if (target->IsCreature(c->room)) {
|
||||||
bullet->trace_target_id = bullet_info.trace_target_uniid;
|
bullet->trace_target_id = bullet_info.trace_target_uniid;
|
||||||
float finaly_dmg = ((Creature*)target)->GetBattleContext()->CalcDmg((Creature*)target, bullet);
|
|
||||||
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()
|
||||||
finaly_dmg
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3574,9 +3572,9 @@ void Creature::AutoNavigation(a8::Vec2 target_pos, float speed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Creature::AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id, float dmg)
|
void Creature::AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id)
|
||||||
{
|
{
|
||||||
trace_bullet_hash_[bullet_uniid] = std::make_tuple(target_uniid, gun_id, dmg);
|
trace_bullet_hash_[bullet_uniid] = std::make_tuple(target_uniid, gun_id);
|
||||||
room->xtimer.AddDeadLineTimerAndAttach
|
room->xtimer.AddDeadLineTimerAndAttach
|
||||||
(
|
(
|
||||||
SERVER_FRAME_RATE * 10,
|
SERVER_FRAME_RATE * 10,
|
||||||
@ -3587,6 +3585,11 @@ void Creature::AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id, fl
|
|||||||
{
|
{
|
||||||
Creature* c = (Creature*)param.sender.GetUserData();
|
Creature* c = (Creature*)param.sender.GetUserData();
|
||||||
c->trace_bullet_hash_.erase(param.param1);
|
c->trace_bullet_hash_.erase(param.param1);
|
||||||
|
Entity* entity = c->room->GetEntityByUniId(param.param1);
|
||||||
|
if (entity && entity->GetEntityType() == ET_Bullet) {
|
||||||
|
Bullet* bullet = (Bullet*)bullet;
|
||||||
|
bullet->ForceRemove();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
&xtimer_attacher.timer_list_);
|
&xtimer_attacher.timer_list_);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ class Creature : public MoveableEntity
|
|||||||
float GetAttrRate(int attr_id);
|
float GetAttrRate(int attr_id);
|
||||||
void RecalcDtoAttr();
|
void RecalcDtoAttr();
|
||||||
void AutoNavigation(a8::Vec2 target_pos, float speed);
|
void AutoNavigation(a8::Vec2 target_pos, float speed);
|
||||||
void AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id, float dmg);
|
void AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnBuffRemove(Buff& buff);
|
virtual void OnBuffRemove(Buff& buff);
|
||||||
@ -322,8 +322,8 @@ protected:
|
|||||||
long long last_follow_move_frameno_ = 0;
|
long long last_follow_move_frameno_ = 0;
|
||||||
int follow_target_last_chg_move_dir_times_ = -1;
|
int follow_target_last_chg_move_dir_times_ = -1;
|
||||||
xtimer_list* follow_target_timer_ = nullptr;
|
xtimer_list* follow_target_timer_ = nullptr;
|
||||||
//target_uniid, gun_id, dmg
|
//target_uniid, gun_id
|
||||||
std::map<int, std::tuple<int, int, float>> trace_bullet_hash_;
|
std::map<int, std::tuple<int, int>> trace_bullet_hash_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CreatureWeakPtr weak_ptr_;
|
CreatureWeakPtr weak_ptr_;
|
||||||
|
@ -1116,10 +1116,13 @@ void Player::_CMRequestBulletDmg(f8::MsgHdr& hdr, const cs::CMRequestBulletDmg&
|
|||||||
}
|
}
|
||||||
auto& tuple = itr->second;
|
auto& tuple = itr->second;
|
||||||
|
|
||||||
Entity* entity = room->GetEntityByUniId(std::get<0>(tuple));
|
Entity* bullet_entity = room->GetEntityByUniId(msg.bullet_uniid());
|
||||||
if (entity && entity->IsCreature(room) && entity != this) {
|
if (bullet_entity && bullet_entity->GetEntityType() == ET_Bullet) {
|
||||||
|
Bullet* bullet = (Bullet*)bullet_entity;
|
||||||
|
Entity* entity = room->GetEntityByUniId(msg.target_uniid());
|
||||||
|
if (entity && entity->IsCreature(room) && entity != this && !entity->IsDead(room)) {
|
||||||
Creature* c = (Creature*)entity;
|
Creature* c = (Creature*)entity;
|
||||||
float dmg = std::get<2>(tuple);
|
float dmg = c->GetBattleContext()->CalcDmg(c, bullet);
|
||||||
if (msg.strengthen_wall_uniid()) {
|
if (msg.strengthen_wall_uniid()) {
|
||||||
dmg *= 2;
|
dmg *= 2;
|
||||||
}
|
}
|
||||||
@ -1147,6 +1150,7 @@ void Player::_CMRequestBulletDmg(f8::MsgHdr& hdr, const cs::CMRequestBulletDmg&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
trace_bullet_hash_.erase(itr);
|
trace_bullet_hash_.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1308,7 +1312,7 @@ void Player::AsyncRequestWatchWar(bool send_rsp_msg)
|
|||||||
target->StartRefreshViewTimer();
|
target->StartRefreshViewTimer();
|
||||||
} else {
|
} else {
|
||||||
respmsg.set_error_code(1);
|
respmsg.set_error_code(1);
|
||||||
respmsg.set_error_msg("无法观战");
|
respmsg.set_error_msg("no watch war");
|
||||||
hum->SendNotifyMsg(respmsg);
|
hum->SendNotifyMsg(respmsg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user