添加坦克持续伤害
This commit is contained in:
parent
4777c5515f
commit
56d09e273f
@ -922,7 +922,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i
|
|||||||
health = MetaMgr::Instance()->GetSysParamAsInt("downed_recover_hp");
|
health = MetaMgr::Instance()->GetSysParamAsInt("downed_recover_hp");
|
||||||
downed = true;
|
downed = true;
|
||||||
downed_timer = room->xtimer.AddRepeatTimerAndAttach(
|
downed_timer = room->xtimer.AddRepeatTimerAndAttach(
|
||||||
SERVER_FRAME_RATE,
|
SERVER_FRAME_RATE * MetaMgr::Instance()->tank_damage_interval,
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
.SetSender(this)
|
.SetSender(this)
|
||||||
.SetParam1(killer_id)
|
.SetParam1(killer_id)
|
||||||
@ -1997,13 +1997,46 @@ int Human::SkinLv()
|
|||||||
|
|
||||||
void Human::CheckSkinTank()
|
void Human::CheckSkinTank()
|
||||||
{
|
{
|
||||||
|
auto dechp_func =
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Human* hum = (Human*)param.sender.GetUserData();
|
||||||
|
if (hum->dead ||
|
||||||
|
!hum->last_tank_attacker ||
|
||||||
|
hum->last_tank_attacker->dead ||
|
||||||
|
hum->last_tank_attacker->skin_tank.skin_id == 0 ||
|
||||||
|
hum->last_tank_attack_idx != param.param1.GetInt64()
|
||||||
|
) {
|
||||||
|
hum->last_tank_attacker = nullptr;
|
||||||
|
hum->last_tank_attack_idx = 0;
|
||||||
|
hum->room->xtimer.DeleteTimer(hum->room->xtimer.GetRunningTimer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float old_rad = hum->last_tank_attacker->self_collider_->rad;
|
||||||
|
if (!hum->TestCollision(hum->last_tank_attacker)) {
|
||||||
|
hum->last_tank_attacker->self_collider_->rad = old_rad;
|
||||||
|
hum->last_tank_attacker = nullptr;
|
||||||
|
hum->last_tank_attack_idx = 0;
|
||||||
|
hum->room->xtimer.DeleteTimer(hum->room->xtimer.GetRunningTimer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hum->last_tank_attacker->self_collider_->rad = old_rad;
|
||||||
|
hum->DecHP(MetaMgr::Instance()->tank_damage2,
|
||||||
|
hum->last_tank_attacker->entity_uniid,
|
||||||
|
hum->last_tank_attacker->name,
|
||||||
|
VW_Tank);
|
||||||
|
};
|
||||||
|
|
||||||
if (tank_weapon.meta) {
|
if (tank_weapon.meta) {
|
||||||
float old_rad = self_collider_->rad;
|
float old_rad = self_collider_->rad;
|
||||||
self_collider_->rad = tank_weapon.meta->i->rad2();
|
self_collider_->rad = tank_weapon.meta->i->rad2();
|
||||||
std::set<Human*> objects;
|
std::set<Human*> objects;
|
||||||
for (auto& grid : grid_list) {
|
for (auto& grid : grid_list) {
|
||||||
for (Human* hum: grid->human_list) {
|
for (Human* hum: grid->human_list) {
|
||||||
if (hum != this && !hum->dead && !hum->tank_weapon.meta &&
|
if (hum != this &&
|
||||||
|
!hum->dead &&
|
||||||
|
!hum->tank_weapon.meta &&
|
||||||
|
hum->last_tank_attacker != this &&
|
||||||
(hum->team_id == 0 || team_id != hum->team_id)) {
|
(hum->team_id == 0 || team_id != hum->team_id)) {
|
||||||
if (TestCollision(hum)) {
|
if (TestCollision(hum)) {
|
||||||
objects.insert(hum);
|
objects.insert(hum);
|
||||||
@ -2012,7 +2045,20 @@ void Human::CheckSkinTank()
|
|||||||
}
|
}
|
||||||
}//end for
|
}//end for
|
||||||
for (Human* hum : objects) {
|
for (Human* hum : objects) {
|
||||||
hum->BeKill(entity_uniid, name, VW_Tank);
|
hum->last_tank_attacker = this;
|
||||||
|
hum->last_tank_attack_idx = App::Instance()->NewUuid();
|
||||||
|
hum->DecHP(MetaMgr::Instance()->tank_damage1,
|
||||||
|
entity_uniid,
|
||||||
|
name,
|
||||||
|
VW_Tank);
|
||||||
|
room->xtimer.AddRepeatTimerAndAttach(
|
||||||
|
SERVER_FRAME_RATE,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(hum)
|
||||||
|
.SetParam1(hum->last_tank_attack_idx),
|
||||||
|
dechp_func,
|
||||||
|
&hum->xtimer_attacher.timer_list_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self_collider_->rad = old_rad;
|
self_collider_->rad = old_rad;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,8 @@ class Human : public Entity
|
|||||||
|
|
||||||
std::set<Human*>* team_members = nullptr;
|
std::set<Human*>* team_members = nullptr;
|
||||||
std::set<Human*> kill_humans;
|
std::set<Human*> kill_humans;
|
||||||
|
Human* last_tank_attacker = nullptr;
|
||||||
|
long long last_tank_attack_idx = 0;
|
||||||
|
|
||||||
bool shot_start = false;
|
bool shot_start = false;
|
||||||
bool shot_hold = false;
|
bool shot_hold = false;
|
||||||
|
@ -119,6 +119,7 @@ public:
|
|||||||
MetaMgr::Instance()->fighting_mode = MetaMgr::Instance()->GetSysParamAsInt("fighting_mode", 1);
|
MetaMgr::Instance()->fighting_mode = MetaMgr::Instance()->GetSysParamAsInt("fighting_mode", 1);
|
||||||
MetaMgr::Instance()->tank_damage1 = MetaMgr::Instance()->GetSysParamAsInt("tank_damage1");
|
MetaMgr::Instance()->tank_damage1 = MetaMgr::Instance()->GetSysParamAsInt("tank_damage1");
|
||||||
MetaMgr::Instance()->tank_damage2 = MetaMgr::Instance()->GetSysParamAsInt("tank_damage2");
|
MetaMgr::Instance()->tank_damage2 = MetaMgr::Instance()->GetSysParamAsInt("tank_damage2");
|
||||||
|
MetaMgr::Instance()->tank_damage_interval = MetaMgr::Instance()->GetSysParamAsInt("tank_damage_interval", 1);
|
||||||
MetaMgr::Instance()->average_oil = MetaMgr::Instance()->GetSysParamAsInt("average_oil");
|
MetaMgr::Instance()->average_oil = MetaMgr::Instance()->GetSysParamAsInt("average_oil");
|
||||||
MetaMgr::Instance()->max_oil = MetaMgr::Instance()->GetSysParamAsInt("max_oil");
|
MetaMgr::Instance()->max_oil = MetaMgr::Instance()->GetSysParamAsInt("max_oil");
|
||||||
if (MetaMgr::Instance()->K < 0.01f) {
|
if (MetaMgr::Instance()->K < 0.01f) {
|
||||||
|
@ -50,6 +50,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
|||||||
int fighting_mode = 0;
|
int fighting_mode = 0;
|
||||||
float tank_damage1 = 0.0f;
|
float tank_damage1 = 0.0f;
|
||||||
float tank_damage2 = 0.0f;
|
float tank_damage2 = 0.0f;
|
||||||
|
float tank_damage_interval = 0.0f;
|
||||||
float average_oil = 0.0f;
|
float average_oil = 0.0f;
|
||||||
float max_oil = 0.0f;
|
float max_oil = 0.0f;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user