1
This commit is contained in:
parent
bf281fee0f
commit
162216cc27
@ -1072,3 +1072,55 @@ void Bullet::Raycast()
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void Bullet::ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos)
|
||||
{
|
||||
#if 1
|
||||
#else
|
||||
Entity* entity = room->GetEntityByUniId(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;
|
||||
}
|
||||
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->GetTrigger()->ShieldDestory();
|
||||
if (hold_shield_buff->meta->_buff_param1_int_list.size() > 0) {
|
||||
TryAddBuff(this, hold_shield_buff->meta->_buff_param1_int_list[0]);
|
||||
}
|
||||
c->RemoveBuffByUniId(hold_shield_buff->buff_uniid);
|
||||
}
|
||||
shield = true;
|
||||
}
|
||||
}
|
||||
if (!shield) {
|
||||
bullet->strengthen_wall = msg.strengthen_wall_uniid() ? 1 : 0;
|
||||
std::set<Entity*> objects;
|
||||
objects.insert(c);
|
||||
bullet->OnHit(objects);
|
||||
#if 0
|
||||
c->OnBulletHit(bullet);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("dmg:%f shield:%d\n",
|
||||
{
|
||||
dmg,
|
||||
shield ? 1 : 0
|
||||
});
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ class Bullet : public MoveableEntity, public IBullet
|
||||
virtual Room* GetRoom() { return room; };
|
||||
virtual float GetHitRadius() override;
|
||||
virtual const Position& GetPos() override;
|
||||
virtual void ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos) override;
|
||||
|
||||
protected:
|
||||
Bullet();
|
||||
|
@ -1198,13 +1198,16 @@ void Player::_CMRequestBulletDmg(f8::MsgHdr& hdr, const cs::CMRequestBulletDmg&
|
||||
{
|
||||
auto itr = room->report_bullet_hash.find(msg.bullet_uniid());
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("CMRequestBulletDmg bullet_uniid:%d shield_hit:%d strengthen_wall_uniid:%d target_uniid:%d found:%d\n",
|
||||
a8::XPrintf("CMRequestBulletDmg bullet_uniid:%d shield_hit:%d strengthen_wall_uniid:%d target_uniid:%d found:%d pos:%f,%f,%f\n",
|
||||
{
|
||||
msg.bullet_uniid(),
|
||||
msg.shield_hit(),
|
||||
msg.strengthen_wall_uniid(),
|
||||
msg.target_uniid(),
|
||||
itr == room->report_bullet_hash.end() ? 0 :1
|
||||
itr == room->report_bullet_hash.end() ? 0 :1,
|
||||
msg.pos().x(),
|
||||
msg.pos().y(),
|
||||
msg.pos().z()
|
||||
});
|
||||
#endif
|
||||
if (itr == room->report_bullet_hash.end()) {
|
||||
@ -1213,52 +1216,13 @@ void Player::_CMRequestBulletDmg(f8::MsgHdr& hdr, const cs::CMRequestBulletDmg&
|
||||
|
||||
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;
|
||||
}
|
||||
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->GetTrigger()->ShieldDestory();
|
||||
if (hold_shield_buff->meta->_buff_param1_int_list.size() > 0) {
|
||||
TryAddBuff(this, hold_shield_buff->meta->_buff_param1_int_list[0]);
|
||||
}
|
||||
c->RemoveBuffByUniId(hold_shield_buff->buff_uniid);
|
||||
}
|
||||
shield = true;
|
||||
}
|
||||
}
|
||||
if (!shield) {
|
||||
bullet->strengthen_wall = msg.strengthen_wall_uniid() ? 1 : 0;
|
||||
std::set<Entity*> objects;
|
||||
objects.insert(c);
|
||||
bullet->OnHit(objects);
|
||||
#if 0
|
||||
c->OnBulletHit(bullet);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("dmg:%f shield:%d\n",
|
||||
{
|
||||
dmg,
|
||||
shield ? 1 : 0
|
||||
});
|
||||
#endif
|
||||
}
|
||||
((Bullet*)bullet_entity)->ProcRequestBulletDmg
|
||||
(
|
||||
msg.shield_hit(),
|
||||
msg.strengthen_wall_uniid(),
|
||||
msg.target_uniid(),
|
||||
glm::vec3(msg.pos().x(), msg.pos().y(), msg.pos().z())
|
||||
);
|
||||
}
|
||||
room->report_bullet_hash.erase(msg.bullet_uniid());
|
||||
}
|
||||
|
@ -90,4 +90,5 @@ class IBullet
|
||||
virtual bool IsPreBattleBullet() = 0;
|
||||
virtual Room* GetRoom() = 0;
|
||||
virtual float GetHitRadius() = 0;
|
||||
virtual void ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos) = 0;
|
||||
};
|
||||
|
@ -289,3 +289,8 @@ float VirtualBullet::GetHitRadius()
|
||||
{
|
||||
return gun_meta->bullet_rad();
|
||||
}
|
||||
|
||||
void VirtualBullet::ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class VirtualBullet : public IBullet, public ITask
|
||||
virtual bool IsPreBattleBullet() override;
|
||||
virtual Room* GetRoom() override;
|
||||
virtual float GetHitRadius() override;
|
||||
virtual void ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos) override;
|
||||
|
||||
virtual void Update(int delta_time) override;
|
||||
virtual bool IsDone() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user