エネミー化したlanhuaがバリアを攻撃しない問題
Description
・normalAttackのrangeを200にすると攻撃し出す
・speed:0 の近接攻撃じゃなく、遠距離攻撃などなら攻撃してる
これはlanhuaが、というよりエネミー全体の問題。
原因を調査し修正する
Comments (6)
設定ミスがあって当たらないというのもありますが、それ以外にもバリアに攻撃しない原因があるので調査中です
sample.ts
{
enemyId: "enemy-1",
relativeYPos: 0.2,
ticks: 60,
},
・このエネミー1体だけsample.tsで登場させる
・characterFormationは空の配列にする
・攻撃はnormalAttackだけとし、パラメータは以下の通り(近接攻撃を想定)
enemies.ts
normalAttack: {
name: "",
delayTicks: 10,
chargeTicks: 120,
range: 100,
projectileParams: {
projectileType: "normal",
friendly: true,
isPassThroughBarrier: false,
speed: 0,
size: { width: 16, height: 16 },
collision: {
radius: 20,
offsetY: 0,
},
positionOffset: {
x: 80,
y: 0,
},
inFlightMotion: SingleBunnyMotion,
explodedMotion: undefined,
penetration: {
damageIntervalTicks: 999,
initialSkipTicks: 0,
},
plungingFire: false,
elementalId: "none",
lifetime: 10,
onHit: [
{
effectId: "damage",
params: { amount: 100 },
},
{
effectId: "knockback",
params: { level: 3 },
},
],
}
},
この様な条件でテストした場合、エネミーが攻撃も移動もせず、上記の場所でidleとwalkをひたすら繰り返すことになる
調べたところ、selectTargetNearest で、altaをターゲットとして見つけられてない様子。
enemy-entity.ts
// アルタとの距離をチェック
if (altaEntity) {
const altaPosition = getEntityCollisionCenter(altaEntity);
const distance = calculateDistance(enemyCenter, altaPosition);
const withinDistance = distance <= searchDistance;
const inRange = isInSearchRange(
enemyCenter,
forward,
altaPosition,
searchRange
);
console.log('withinDistance:',withinDistance)//false
console.log('inRange:',inRange)//false
console.log('distance < minDistance:',distance < minDistance)//true
if (withinDistance && inRange && distance < minDistance) {
minDistance = distance;
nearestTarget = {
type: "alta",
entity: altaEntity,
position: altaPosition,
distance,
};
}
}
// ここの判定を無しにすれば、一定距離直進したあとaltaに向かってくれた
if (withinDistance && inRange && distance < minDistance) {
ターゲットの優先度としては、altaよりもfighterが優先されている(altaよりあとに判定されてnearestTargetに与えられている)ようなので、たとえ無条件でaltaを狙う様になったとしても、近くにfighterがいればそっちにいくはず。。
なので、ここのif文をなくして仕舞えば解決しそう。
バリアもターゲットとして狙う様に修正する [優先]
- ファイター
- アルタ
- バリア
ファイターもいないし、アルタも遠いなら、バリアを狙う。
バリアを狙うようにしたところで、バリアから遠い位置で移動が止まってしまうとそこでスタックする。
なので、fitherもaltaも見つからない場合は距離に関係なくbarrierに向かって移動するようにすべきかと思う
…と思ったが、バリアが壊れてアルタが狙える様になった時に、アルタが射程外だと結局スタックするので、狙えるものがない場合はアルタに向かって突っ込むが正解だと思う
この実装で行きます。
解決