1
This commit is contained in:
parent
0835f3359b
commit
2f7c124e1c
@ -515,7 +515,7 @@ void AndroidNewAI::UpdateAttack()
|
|||||||
case kShotClick:
|
case kShotClick:
|
||||||
{
|
{
|
||||||
if (ai_meta->i->attack_interval() > 0) {
|
if (ai_meta->i->attack_interval() > 0) {
|
||||||
if (node_.shot_times < ai_meta->i->attack_times()) {
|
if (node_.shot_times < GetAttackTimes()) {
|
||||||
DoShotNewAI();
|
DoShotNewAI();
|
||||||
} else {
|
} else {
|
||||||
ChangeToStateNewAI(ASE_Idle);
|
ChangeToStateNewAI(ASE_Idle);
|
||||||
@ -724,10 +724,12 @@ void AndroidNewAI::DoShotNewAI()
|
|||||||
std::abs(shot_dir.y) > FLT_EPSILON) {
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
shot_dir.Normalize();
|
shot_dir.Normalize();
|
||||||
if (ai_meta->i->shot_offset_angle() > 0) {
|
if (ai_meta->i->shot_offset_angle() > 0) {
|
||||||
|
int shot_offset_angle = a8::RandEx(ai_meta->i->shot_offset_angle(),
|
||||||
|
1);
|
||||||
if (rand() % 10 < 3) {
|
if (rand() % 10 < 3) {
|
||||||
shot_dir.Rotate(ai_meta->i->shot_offset_angle() / 180.0f);
|
shot_dir.Rotate(shot_offset_angle / 180.0f);
|
||||||
} else {
|
} else {
|
||||||
shot_dir.Rotate(ai_meta->i->shot_offset_angle() / -180.0f);
|
shot_dir.Rotate(shot_offset_angle / -180.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a8::Vec2 old_attack_dir = myself->attack_dir;
|
a8::Vec2 old_attack_dir = myself->attack_dir;
|
||||||
@ -743,3 +745,13 @@ void AndroidNewAI::DoShotNewAI()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AndroidNewAI::GetAttackTimes()
|
||||||
|
{
|
||||||
|
Human* myself = (Human*)owner;
|
||||||
|
if (myself->curr_weapon) {
|
||||||
|
return std::min(ai_meta->i->attack_times(), myself->curr_weapon->GetClipVolume());
|
||||||
|
} else {
|
||||||
|
return ai_meta->i->attack_times();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -73,6 +73,7 @@ private:
|
|||||||
|
|
||||||
Human* GetTarget();
|
Human* GetTarget();
|
||||||
float GetAttackRange();
|
float GetAttackRange();
|
||||||
|
int GetAttackTimes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OldAiData old_ai_data_;
|
OldAiData old_ai_data_;
|
||||||
|
@ -87,3 +87,4 @@ a8::Vec2 BornPoint::RandPoint() const
|
|||||||
}
|
}
|
||||||
return born_point;
|
return born_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ message AI
|
|||||||
optional int32 attack_interval = 3;
|
optional int32 attack_interval = 3;
|
||||||
optional int32 attack_times = 4;
|
optional int32 attack_times = 4;
|
||||||
optional int32 attack_type = 5;
|
optional int32 attack_type = 5;
|
||||||
optional float shot_offset_angle = 6;
|
optional int32 shot_offset_angle = 6;
|
||||||
optional string random_move_idle_time = 8;
|
optional string random_move_idle_time = 8;
|
||||||
optional string random_move_time = 9;
|
optional string random_move_time = 9;
|
||||||
optional int32 attack_range = 10;
|
optional int32 attack_range = 10;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user