1
This commit is contained in:
parent
f66d2ab72c
commit
9a085fc04f
@ -50,11 +50,7 @@ void Bullet::Initialize()
|
||||
|
||||
void Bullet::Update(int delta_time)
|
||||
{
|
||||
if (trace_target_id) {
|
||||
ClearBuffList();
|
||||
room->RemoveObjectLater(this);
|
||||
later_removed_ = true;
|
||||
} else {
|
||||
if (!trace_target_id) {
|
||||
MapServiceUpdate();
|
||||
++updated_times_;
|
||||
}
|
||||
@ -831,3 +827,10 @@ void Bullet::ProcFlyHook(Entity* target)
|
||||
&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();
|
||||
bool IsCurrWeapon();
|
||||
bool IsPreBattleBullet();
|
||||
void ForceRemove();
|
||||
void OnHit(std::set<Entity*>& objects);
|
||||
|
||||
protected:
|
||||
Bullet();
|
||||
|
||||
private:
|
||||
|
||||
void OnHit(std::set<Entity*>& objects);
|
||||
void ProcBomb();
|
||||
void ProcSmokeBomb();
|
||||
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);
|
||||
if (target->IsCreature(c->room)) {
|
||||
bullet->trace_target_id = bullet_info.trace_target_uniid;
|
||||
float finaly_dmg = ((Creature*)target)->GetBattleContext()->CalcDmg((Creature*)target, bullet);
|
||||
c->AddTraceBullet(
|
||||
bullet_uniid,
|
||||
bullet_info.trace_target_uniid,
|
||||
bullet_info.weapon_meta->i->id(),
|
||||
finaly_dmg
|
||||
bullet_info.weapon_meta->i->id()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
(
|
||||
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();
|
||||
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_);
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ class Creature : public MoveableEntity
|
||||
float GetAttrRate(int attr_id);
|
||||
void RecalcDtoAttr();
|
||||
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:
|
||||
virtual void OnBuffRemove(Buff& buff);
|
||||
@ -322,8 +322,8 @@ protected:
|
||||
long long last_follow_move_frameno_ = 0;
|
||||
int follow_target_last_chg_move_dir_times_ = -1;
|
||||
xtimer_list* follow_target_timer_ = nullptr;
|
||||
//target_uniid, gun_id, dmg
|
||||
std::map<int, std::tuple<int, int, float>> trace_bullet_hash_;
|
||||
//target_uniid, gun_id
|
||||
std::map<int, std::tuple<int, int>> trace_bullet_hash_;
|
||||
|
||||
private:
|
||||
CreatureWeakPtr weak_ptr_;
|
||||
|
@ -1116,34 +1116,38 @@ void Player::_CMRequestBulletDmg(f8::MsgHdr& hdr, const cs::CMRequestBulletDmg&
|
||||
}
|
||||
auto& tuple = itr->second;
|
||||
|
||||
Entity* entity = room->GetEntityByUniId(std::get<0>(tuple));
|
||||
if (entity && entity->IsCreature(room) && entity != this) {
|
||||
Creature* c = (Creature*)entity;
|
||||
float dmg = std::get<2>(tuple);
|
||||
if (msg.strengthen_wall_uniid()) {
|
||||
dmg *= 2;
|
||||
}
|
||||
bool shield = false;
|
||||
if (dmg > 0.00001f) {
|
||||
if (msg.shield_hit()) {
|
||||
Buff* hold_shield_buff = c->GetBuffByEffectId(kBET_HoldShield);
|
||||
if (hold_shield_buff) {
|
||||
c->shield_hp_ = std::max(0.0f, c->shield_hp_ - dmg);
|
||||
room->frame_event.AddPropChg(c->GetWeakPtrRef(),
|
||||
kPropShieldHp,
|
||||
c->shield_max_hp_,
|
||||
c->shield_hp_);
|
||||
if (c->shield_hp_ <= 0) {
|
||||
c->RemoveBuffByUniId(hold_shield_buff->buff_uniid);
|
||||
}
|
||||
shield = true;
|
||||
}
|
||||
Entity* bullet_entity = room->GetEntityByUniId(msg.bullet_uniid());
|
||||
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;
|
||||
float dmg = c->GetBattleContext()->CalcDmg(c, bullet);
|
||||
if (msg.strengthen_wall_uniid()) {
|
||||
dmg *= 2;
|
||||
}
|
||||
if (!shield) {
|
||||
DecHP(dmg,
|
||||
GetUniId(),
|
||||
GetName(),
|
||||
std::get<1>(tuple));
|
||||
bool shield = false;
|
||||
if (dmg > 0.00001f) {
|
||||
if (msg.shield_hit()) {
|
||||
Buff* hold_shield_buff = c->GetBuffByEffectId(kBET_HoldShield);
|
||||
if (hold_shield_buff) {
|
||||
c->shield_hp_ = std::max(0.0f, c->shield_hp_ - dmg);
|
||||
room->frame_event.AddPropChg(c->GetWeakPtrRef(),
|
||||
kPropShieldHp,
|
||||
c->shield_max_hp_,
|
||||
c->shield_hp_);
|
||||
if (c->shield_hp_ <= 0) {
|
||||
c->RemoveBuffByUniId(hold_shield_buff->buff_uniid);
|
||||
}
|
||||
shield = true;
|
||||
}
|
||||
}
|
||||
if (!shield) {
|
||||
DecHP(dmg,
|
||||
GetUniId(),
|
||||
GetName(),
|
||||
std::get<1>(tuple));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1308,7 +1312,7 @@ void Player::AsyncRequestWatchWar(bool send_rsp_msg)
|
||||
target->StartRefreshViewTimer();
|
||||
} else {
|
||||
respmsg.set_error_code(1);
|
||||
respmsg.set_error_msg("无法观战");
|
||||
respmsg.set_error_msg("no watch war");
|
||||
hum->SendNotifyMsg(respmsg);
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user