1
This commit is contained in:
parent
89aeefdab0
commit
796e9e02f4
@ -232,9 +232,6 @@ void Car::OnBulletHit(Bullet* bullet)
|
|||||||
|
|
||||||
void Car::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id)
|
void Car::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
|
||||||
dec_hp *= 5;
|
|
||||||
#endif
|
|
||||||
if (dec_hp < 0.001f) {
|
if (dec_hp < 0.001f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -247,13 +244,13 @@ void Car::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int
|
|||||||
room->frame_event.AddHpChg(GetWeakPtrRef());
|
room->frame_event.AddHpChg(GetWeakPtrRef());
|
||||||
float hp_rate = GetHP() / GetMaxHP();
|
float hp_rate = GetHP() / GetMaxHP();
|
||||||
int new_buff_idx = cur_buff_idx_;
|
int new_buff_idx = cur_buff_idx_;
|
||||||
while (new_buff_idx < meta->car_buff_list.size()) {
|
while (new_buff_idx + 1 < meta->car_buff_list.size()) {
|
||||||
if (hp_rate > std::get<0>(meta->car_buff_list[new_buff_idx])) {
|
if (hp_rate > std::get<0>(meta->car_buff_list[new_buff_idx + 1])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++new_buff_idx;
|
++new_buff_idx;
|
||||||
}
|
}
|
||||||
if (new_buff_idx != cur_buff_id_) {
|
if (new_buff_idx != cur_buff_idx_) {
|
||||||
if (cur_buff_id_ != 0) {
|
if (cur_buff_id_ != 0) {
|
||||||
RemoveBuffById(cur_buff_id_);
|
RemoveBuffById(cur_buff_id_);
|
||||||
}
|
}
|
||||||
@ -272,11 +269,13 @@ void Car::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
|||||||
RemoveFromAroundPlayers(room);
|
RemoveFromAroundPlayers(room);
|
||||||
room->grid_service->RemoveCreature(this);
|
room->grid_service->RemoveCreature(this);
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
|
int team_id = 0;
|
||||||
for (Human* passenger : passengers_) {
|
for (Human* passenger : passengers_) {
|
||||||
if (meta->i->buffid()) {
|
if (meta->i->buffid()) {
|
||||||
passenger->RemoveBuffById(meta->i->buffid());
|
passenger->RemoveBuffById(meta->i->buffid());
|
||||||
passenger->RecalcSelfCollider();
|
passenger->RecalcSelfCollider();
|
||||||
}
|
}
|
||||||
|
team_id = passenger->team_id;
|
||||||
passenger->SetCar(nullptr);
|
passenger->SetCar(nullptr);
|
||||||
passenger->SetSeat(0);
|
passenger->SetSeat(0);
|
||||||
passenger->second_weapon = Weapon();
|
passenger->second_weapon = Weapon();
|
||||||
@ -285,7 +284,7 @@ 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);
|
room->frame_event.AddCarChg(passenger);
|
||||||
}
|
}
|
||||||
Explosion();
|
Explosion(team_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Car::GetAabbBox(AabbCollider& aabb_box)
|
void Car::GetAabbBox(AabbCollider& aabb_box)
|
||||||
@ -298,12 +297,42 @@ void Car::GetAabbBox(AabbCollider& aabb_box)
|
|||||||
aabb_box._max.y = hero_meta_->i->radius();
|
aabb_box._max.y = hero_meta_->i->radius();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Car::Explosion()
|
void Car::Explosion(int team_id)
|
||||||
{
|
{
|
||||||
|
if (meta->i->explosion_range() <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::set<Creature*> objects;
|
||||||
TouchProperTargets
|
TouchProperTargets
|
||||||
(
|
(
|
||||||
[] (Creature* c, bool& stop)
|
[this, &objects, team_id] (Creature* c, bool& stop)
|
||||||
{
|
{
|
||||||
|
float distance = (c->GetPos() - GetPos()).Norm();
|
||||||
|
if (team_id != c->team_id && distance < meta->i->explosion_range()) {
|
||||||
|
objects.insert(c);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
room->frame_event.AddExplosionEx(GetWeakPtrRef(),
|
||||||
|
0,
|
||||||
|
GetPos(),
|
||||||
|
meta->i->explosion_effect());
|
||||||
|
for (auto& target : objects) {
|
||||||
|
switch (target->GetEntityType()) {
|
||||||
|
case ET_Player:
|
||||||
|
{
|
||||||
|
Human* hum = (Human*)target;
|
||||||
|
if (!hum->dead) {
|
||||||
|
float dmg = meta->i->atk();
|
||||||
|
float def = hum->ability.def;
|
||||||
|
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
|
||||||
|
hum->DecHP(finaly_dmg, VP_Mine, TEXT("battle_server_killer_mine", "地雷"), VW_Mine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class Car : public Creature
|
|||||||
private:
|
private:
|
||||||
int AllocSeat();
|
int AllocSeat();
|
||||||
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
||||||
void Explosion();
|
void Explosion(int team_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long born_frameno_ = 0;
|
long long born_frameno_ = 0;
|
||||||
|
@ -213,6 +213,22 @@ namespace MetaData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (i->equip_type() == EQUIP_TYPE_CAR) {
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(i->param1(), strings, '|');
|
||||||
|
for (auto& str : strings) {
|
||||||
|
std::vector<std::string> strings2;
|
||||||
|
a8::Split(str, strings2, ':');
|
||||||
|
if (strings2.size() >= 2) {
|
||||||
|
car_buff_list.push_back
|
||||||
|
(std::make_tuple
|
||||||
|
(
|
||||||
|
(float)a8::XValue(strings2[0]).GetDouble(),
|
||||||
|
a8::XValue(strings2[1]).GetInt())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Equip::GetWeaponIdx()
|
int Equip::GetWeaponIdx()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user