This commit is contained in:
aozhiwei 2021-07-29 13:54:14 +00:00
parent bc1d9d6141
commit 02032c8789
10 changed files with 49 additions and 9 deletions

View File

@ -8,6 +8,7 @@
#include "metamgr.h" #include "metamgr.h"
#include "player.h" #include "player.h"
#include "app.h" #include "app.h"
#include "car.h"
const int SHUA_RANGE = 580; const int SHUA_RANGE = 580;
@ -306,6 +307,7 @@ void AndroidAI::UpdateThinking()
if (hum->room->GetGasData().gas_mode == GasInactive || if (hum->room->GetGasData().gas_mode == GasInactive ||
hum->room->IsWaitingStart() || hum->room->IsWaitingStart() ||
hum->HasBuffEffect(kBET_Jump) || hum->HasBuffEffect(kBET_Jump) ||
hum->HasBuffEffect(kBET_PeaceMode) ||
a8::HasBitFlag(hum->status, CS_DisableAttack)) { a8::HasBitFlag(hum->status, CS_DisableAttack)) {
if (hum->room->IsWaitingStart()) { if (hum->room->IsWaitingStart()) {
ChangeToStateNewAI(ASE_Idle); ChangeToStateNewAI(ASE_Idle);
@ -413,6 +415,7 @@ void AndroidAI::UpdatePursuit()
if (node_->target.Get()) { if (node_->target.Get()) {
float distance = myself->GetPos().Distance(node_->target.Get()->GetPos()); float distance = myself->GetPos().Distance(node_->target.Get()->GetPos());
if (!myself->HasBuffEffect(kBET_Jump) && if (!myself->HasBuffEffect(kBET_Jump) &&
!myself->HasBuffEffect(kBET_PeaceMode) &&
!a8::HasBitFlag(myself->status, CS_DisableAttack) && !a8::HasBitFlag(myself->status, CS_DisableAttack) &&
distance < GetAttackRange()) { distance < GetAttackRange()) {
ChangeToStateNewAI(ASE_Attack); ChangeToStateNewAI(ASE_Attack);
@ -554,6 +557,9 @@ Creature* AndroidAI::GetTarget()
if (hum->HasBuffEffect(kBET_Jump)) { if (hum->HasBuffEffect(kBET_Jump)) {
return; return;
} }
if (hum->IsCar() && hum->AsCar()->HasPassenter()) {
return;
}
if (target) { if (target) {
if (myself->GetPos().ManhattanDistance(target->GetPos()) > if (myself->GetPos().ManhattanDistance(target->GetPos()) >
myself->GetPos().ManhattanDistance(hum->GetPos())) { myself->GetPos().ManhattanDistance(hum->GetPos())) {

View File

@ -636,11 +636,6 @@ void Buff::ProcDisperse()
} }
} }
void Buff::ProcAISeting()
{
}
void Buff::CalcPassengerShotOffset() void Buff::CalcPassengerShotOffset()
{ {
if (meta->i->buff_effect() == kBET_Passenger && caster_.Get()->IsHuman()) { if (meta->i->buff_effect() == kBET_Passenger && caster_.Get()->IsHuman()) {

View File

@ -72,7 +72,6 @@ class Buff
void ProcAutoShot(); void ProcAutoShot();
void ProcBeatBack(); void ProcBeatBack();
void ProcDisperse(); void ProcDisperse();
void ProcAISeting();
void CalcPassengerShotOffset(); void CalcPassengerShotOffset();

View File

@ -38,6 +38,7 @@ class Car : public Creature
float GetMaxOil(); float GetMaxOil();
bool HasOil() { return cur_oil_ >= 0.00000001f; }; bool HasOil() { return cur_oil_ >= 0.00000001f; };
void DecOil(float dec_oil); void DecOil(float dec_oil);
bool HasPassenter() { return !passengers_.empty();};
virtual float GetRadius() override; virtual float GetRadius() override;
virtual float GetSpeed() override; virtual float GetSpeed() override;
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override; virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;

View File

@ -16,6 +16,7 @@ const int kDownBuffId = 7015;
const int kPoisioningBuffId = 7016; const int kPoisioningBuffId = 7016;
const int kRescueBuffId = 7017; const int kRescueBuffId = 7017;
const int kVertigoBuffId = 7018; const int kVertigoBuffId = 7018;
const int kPeaceModeBuffId = 7019;
enum BuffEffectType_e enum BuffEffectType_e
{ {
@ -89,7 +90,7 @@ enum BuffEffectType_e
kBET_AutoShot = 66, //自动射击 kBET_AutoShot = 66, //自动射击
kBET_BeatBack = 67, //击退 kBET_BeatBack = 67, //击退
kBET_Disperse = 68, //驱散 kBET_Disperse = 68, //驱散
kBET_AiSeting = 69, //设置ai参数 kBET_PeaceMode = 69, //和平模式
kBET_End kBET_End
}; };

View File

@ -1277,9 +1277,8 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
buff->ProcDisperse(); buff->ProcDisperse();
} }
break; break;
case kBET_AiSeting: case kBET_PeaceMode:
{ {
buff->ProcAISeting();
} }
break; break;
default: default:

View File

@ -8,6 +8,7 @@
#include "metamgr.h" #include "metamgr.h"
#include "player.h" #include "player.h"
#include "roomobstacle.h" #include "roomobstacle.h"
#include "car.h"
HeroAI::HeroAI() HeroAI::HeroAI()
{ {
@ -104,6 +105,7 @@ void HeroAI::UpdateThinking()
Hero* hero = (Hero*)owner; Hero* hero = (Hero*)owner;
if (hero->room->GetGasData().gas_mode == GasInactive || if (hero->room->GetGasData().gas_mode == GasInactive ||
hero->room->IsWaitingStart() || hero->room->IsWaitingStart() ||
hero->HasBuffEffect(kBET_PeaceMode) ||
hero->HasBuffEffect(kBET_Jump) hero->HasBuffEffect(kBET_Jump)
) { ) {
if (hero->room->IsWaitingStart()) { if (hero->room->IsWaitingStart()) {
@ -219,6 +221,7 @@ void HeroAI::UpdatePursuit()
Hero* myself = (Hero*)owner; Hero* myself = (Hero*)owner;
float distance = myself->GetPos().Distance(node_->target.Get()->GetPos()); float distance = myself->GetPos().Distance(node_->target.Get()->GetPos());
if (!myself->HasBuffEffect(kBET_Jump) && if (!myself->HasBuffEffect(kBET_Jump) &&
!myself->HasBuffEffect(kBET_PeaceMode) &&
distance < GetAttackRange()) { distance < GetAttackRange()) {
ChangeToStateAI(HSE_Attack); ChangeToStateAI(HSE_Attack);
} else { } else {
@ -392,6 +395,9 @@ Creature* HeroAI::GetTarget()
if (hum->HasBuffEffect(kBET_Jump)) { if (hum->HasBuffEffect(kBET_Jump)) {
return; return;
} }
if (hum->IsCar() && hum->AsCar()->HasPassenter()) {
return;
}
if (target) { if (target) {
if (myself->GetPos().ManhattanDistance(target->GetPos()) > if (myself->GetPos().ManhattanDistance(target->GetPos()) >
myself->GetPos().ManhattanDistance(hum->GetPos())) { myself->GetPos().ManhattanDistance(hum->GetPos())) {

View File

@ -84,6 +84,7 @@ void Hero::OnExplosionHit(Explosion* e)
if (dead) { if (dead) {
return; return;
} }
RemoveBuffByEffectId(kBET_PeaceMode);
float dmg = e->GetDmg(); float dmg = e->GetDmg();
float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) + float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) +
GetAbility()->GetAttrAbs(kHAT_Def); GetAbility()->GetAttrAbs(kHAT_Def);
@ -115,6 +116,7 @@ void Hero::OnBulletHit(Bullet* bullet)
if (IsInvincible()) { if (IsInvincible()) {
return; return;
} }
RemoveBuffByEffectId(kBET_PeaceMode);
if (!IsDead(room) && (bullet->IsBomb() || bullet->sender.Get()->team_id != team_id)) { if (!IsDead(room) && (bullet->IsBomb() || bullet->sender.Get()->team_id != team_id)) {
float dmg = bullet->GetAtk(); float dmg = bullet->GetAtk();
float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) + float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) +
@ -297,4 +299,17 @@ void Hero::InitAI()
ai->ai_meta = ai_meta; ai->ai_meta = ai_meta;
} }
ai->owner = this; ai->owner = this;
int buff_uniid = MustBeAddBuff(this,
kPeaceModeBuffId
);
if (buff_uniid) {
Buff* buff = GetBuffByUniId(buff_uniid);
if (buff) {
int peace_time = 1000 * 6;
if (ai->ai_meta->i->peace_time() > 0) {
peace_time += ai->ai_meta->i->peace_time();
}
room->xtimer.ModifyTimer(buff->remover_timer, peace_time / FRAME_RATE_MS);
}
}
} }

View File

@ -3273,6 +3273,21 @@ void Human::OnLand()
} }
SetPos(old_pos); SetPos(old_pos);
} }
if (IsAndroid()) {
int buff_uniid = MustBeAddBuff(this,
kPeaceModeBuffId
);
if (buff_uniid) {
Buff* buff = GetBuffByUniId(buff_uniid);
if (buff) {
int peace_time = 2000;
if (ai->ai_meta->i->peace_time() > 0) {
peace_time += ai->ai_meta->i->peace_time();
}
room->xtimer.ModifyTimer(buff->remover_timer, peace_time / FRAME_RATE_MS);
}
}
}
} }
void Human::NextReload(int prev_weapon_id, int prev_weapon_idx) void Human::NextReload(int prev_weapon_id, int prev_weapon_idx)
@ -3547,6 +3562,7 @@ void Human::OnBulletHit(Bullet* bullet)
bullet->sender.Get()->GetRace() == GetRace()) { bullet->sender.Get()->GetRace() == GetRace()) {
return; return;
} }
RemoveBuffByEffectId(kBET_PeaceMode);
if (!dead && (bullet->IsBomb() || bullet->sender.Get()->team_id != team_id)) { if (!dead && (bullet->IsBomb() || bullet->sender.Get()->team_id != team_id)) {
float old_hp = GetHP(); float old_hp = GetHP();
float old_max_hp = GetMaxHP(); float old_max_hp = GetMaxHP();
@ -3598,6 +3614,7 @@ void Human::OnExplosionHit(Explosion* e)
if (dead) { if (dead) {
return; return;
} }
RemoveBuffByEffectId(kBET_PeaceMode);
float dmg = e->GetDmg(); float dmg = e->GetDmg();
float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) + float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) +
GetAbility()->GetAttrAbs(kHAT_Def); GetAbility()->GetAttrAbs(kHAT_Def);

View File

@ -358,6 +358,7 @@ message AI
optional string param3 = 17; optional string param3 = 17;
optional string param4 = 18; optional string param4 = 18;
optional string param5 = 19; optional string param5 = 19;
optional int32 peace_time = 20;
} }
message Text message Text