1
This commit is contained in:
parent
e5f590b9d1
commit
f4a4f60553
@ -61,7 +61,7 @@
|
||||
</node>
|
||||
<node class="DecoratorWeight" id="14">
|
||||
<property DecorateWhenChildEnds="false" />
|
||||
<property Weight="const int 0" />
|
||||
<property Weight="const int 5" />
|
||||
<node class="Action" id="15">
|
||||
<property Method="Self.AndroidAgent::DoAttack()" />
|
||||
<property ResultOption="BT_INVALID" />
|
||||
@ -69,7 +69,7 @@
|
||||
</node>
|
||||
<node class="DecoratorWeight" id="20">
|
||||
<property DecorateWhenChildEnds="false" />
|
||||
<property Weight="const int 0" />
|
||||
<property Weight="const int 1" />
|
||||
<node class="IfElse" id="21">
|
||||
<node class="Condition" id="22">
|
||||
<property Operator="Equal" />
|
||||
|
@ -244,39 +244,14 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
|
||||
(
|
||||
CreatureWeakPtr owner;
|
||||
CreatureWeakPtr target;
|
||||
CreatureWeakPtr last_attacker;
|
||||
long long last_attacked_frameno = 0;
|
||||
long long last_frameno = 0;
|
||||
long long last_pursuit_frameno = 0;
|
||||
std::weak_ptr<EventHandlerPtr> handler;
|
||||
);
|
||||
|
||||
context->owner = GetOwner()->GetWeakPtrRef();
|
||||
context->target = enemy->GetWeakPtrRef();
|
||||
context->last_frameno = GetOwner()->room->GetFrameNo();
|
||||
context->last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
#if 0
|
||||
context->handler = GetOwner()->GetTrigger()->AddListener
|
||||
(
|
||||
kAttacked,
|
||||
[context_wp = context->GetWp()] (const a8::Args& args)
|
||||
{
|
||||
if (!context_wp.expired()) {
|
||||
auto context = context_wp.lock();
|
||||
Creature* c = args.Get<Creature*>(0);
|
||||
context->last_attacker = c->GetWeakPtrRef();
|
||||
context->last_attacked_frameno = c->room->GetFrameNo();
|
||||
}
|
||||
});
|
||||
context->_destory_cb =
|
||||
(
|
||||
[context = context.get()] ()
|
||||
{
|
||||
if (context->owner.Get()) {
|
||||
context->owner.Get()->GetTrigger()->RemoveEventHandler(context->handler);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
||||
auto co = std::make_shared<BtCoroutine>(context, "CoPursuit");
|
||||
co->runing_cb =
|
||||
@ -294,19 +269,20 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
|
||||
context->last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
} else {
|
||||
bool is_shot = false;
|
||||
if (GlmHelper::Norm(dir) > 300) {
|
||||
float distance = GlmHelper::Norm(dir) - GetAttackRange();
|
||||
if (distance > 0.001f) {
|
||||
if (GetOwner()->GetMovement()->GetPathSize() < 1) {
|
||||
GlmHelper::Normalize(dir);
|
||||
GetOwner()->SetMoveDir(dir);
|
||||
GetOwner()->SetAttackDir(dir);
|
||||
GetOwner()->GetMovement()->CalcTargetPos(200);
|
||||
GetOwner()->GetMovement()->CalcTargetPos(distance + 60);
|
||||
context->last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
} else {
|
||||
if (GetOwner()->room->GetFrameNo() - context->last_pursuit_frameno > SERVER_FRAME_RATE * 1) {
|
||||
GlmHelper::Normalize(dir);
|
||||
GetOwner()->SetMoveDir(dir);
|
||||
GetOwner()->SetAttackDir(dir);
|
||||
GetOwner()->GetMovement()->CalcTargetPos(200);
|
||||
GetOwner()->GetMovement()->CalcTargetPos(distance + 60);
|
||||
context->last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user