|
@@ -21,13 +21,14 @@ export class TornadoAIComponent extends TornadoComponent {
|
|
moveDuration: number = 3; //移动行为持续时间(秒)
|
|
moveDuration: number = 3; //移动行为持续时间(秒)
|
|
escapeDuration: number = 5; //逃离行为持续时间(秒)
|
|
escapeDuration: number = 5; //逃离行为持续时间(秒)
|
|
chaseDuration: number = 20; //追击行为持续时间(秒)
|
|
chaseDuration: number = 20; //追击行为持续时间(秒)
|
|
- chaseAIProbability: number = 1; //是否追击 AI 的概率 1是100%
|
|
|
|
- chasePlayerProbability: number = 1; //是否追击玩家的概率
|
|
|
|
|
|
+ chaseAIProbability: number = 0; //是否追击 AI 的概率
|
|
|
|
+ chasePlayerProbability: number = 0; //是否追击玩家的概率
|
|
|
|
|
|
isChasing: boolean = false; // 是否追击中
|
|
isChasing: boolean = false; // 是否追击中
|
|
isEscaping: boolean = false; // 是否逃跑中
|
|
isEscaping: boolean = false; // 是否逃跑中
|
|
targetNode: Node | null = null; // 目标
|
|
targetNode: Node | null = null; // 目标
|
|
|
|
|
|
|
|
+ moveProbability: number = 0.5; //移动概率
|
|
behaviorType: BehaviorType = BehaviorType.Move; // 行为类型
|
|
behaviorType: BehaviorType = BehaviorType.Move; // 行为类型
|
|
|
|
|
|
protected async start() {
|
|
protected async start() {
|
|
@@ -42,16 +43,25 @@ export class TornadoAIComponent extends TornadoComponent {
|
|
}
|
|
}
|
|
|
|
|
|
private initAIPlayer() {
|
|
private initAIPlayer() {
|
|
- this.playerInfo.nickName = 'asfasf'
|
|
|
|
|
|
+ const aiConfig = PlayerMgr.inst.getRandomAIConfig();
|
|
|
|
+ console.log(aiConfig);
|
|
|
|
+ //text:名称 range:检测半径 move_juge:移动概率 move_time:移动时间 escape_time:逃跑时间 pursuit_1:追击玩家概率 pursuit_2:追击AI概率 pursuit_time:追击时间
|
|
|
|
+ const { text, range, move_juge, move_time, escape_time, pursuit_1, pursuit_2, pursuit_time } = aiConfig.data;
|
|
|
|
+ this.playerInfo.nickName = text;
|
|
this.playerInfo.level = 2;
|
|
this.playerInfo.level = 2;
|
|
this.currentLv = this.playerInfo.level;
|
|
this.currentLv = this.playerInfo.level;
|
|
|
|
|
|
|
|
+ this.moveDuration = Math.floor(move_time[0] + Math.random() * (move_time[1] - move_time[0] + 1));
|
|
|
|
+ this.escapeDuration = Math.floor(escape_time[0] + Math.random() * (escape_time[1] - escape_time[0] + 1));
|
|
|
|
+ this.chaseDuration = Math.floor(pursuit_time[0] + Math.random() * (pursuit_time[1] - pursuit_time[0] + 1));
|
|
|
|
+ this.chaseAIProbability = pursuit_1;
|
|
|
|
+ this.chasePlayerProbability = pursuit_2;
|
|
|
|
+ this.moveProbability = move_juge;
|
|
|
|
+
|
|
this.nextExp = this.attributeBonusMgr.getExpNeed(this.currentLv + 1);
|
|
this.nextExp = this.attributeBonusMgr.getExpNeed(this.currentLv + 1);
|
|
this.attack = this.attributeBonusMgr.getStormSunderAttack(this.currentLv, true);
|
|
this.attack = this.attributeBonusMgr.getStormSunderAttack(this.currentLv, true);
|
|
this.speed = this.attributeBonusMgr.getStormSunderSpeed(this.currentLv, true);
|
|
this.speed = this.attributeBonusMgr.getStormSunderSpeed(this.currentLv, true);
|
|
|
|
|
|
- this.attack = 10000; //测试
|
|
|
|
-
|
|
|
|
console.log(`AI 攻击力:${this.attack} 速度:${this.speed} 下一级经验:${this.nextExp}`)
|
|
console.log(`AI 攻击力:${this.attack} 速度:${this.speed} 下一级经验:${this.nextExp}`)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -59,10 +69,8 @@ export class TornadoAIComponent extends TornadoComponent {
|
|
private decideAction() {
|
|
private decideAction() {
|
|
if (this.playerStatus == PlayerStatus.DIE) return; // AI 死亡时不执行行为
|
|
if (this.playerStatus == PlayerStatus.DIE) return; // AI 死亡时不执行行为
|
|
|
|
|
|
- // DOTO 目前固定 100% 选择移动行为(未来可修改概率)
|
|
|
|
- const actionType = this.behaviorType;
|
|
|
|
-
|
|
|
|
- if (actionType === BehaviorType.Move) {
|
|
|
|
|
|
+ const move = Math.random() * 100 < this.moveProbability;
|
|
|
|
+ if (move) {
|
|
this.randomMove();
|
|
this.randomMove();
|
|
} else {
|
|
} else {
|
|
const closestItem = PropMgr.inst.getNearestProp(this.node);
|
|
const closestItem = PropMgr.inst.getNearestProp(this.node);
|
|
@@ -128,7 +136,6 @@ export class TornadoAIComponent extends TornadoComponent {
|
|
|
|
|
|
protected addExpByKill() {
|
|
protected addExpByKill() {
|
|
super.addExpByKill(true);
|
|
super.addExpByKill(true);
|
|
-
|
|
|
|
console.log(`AI 当前经验:${this.currentExp}`);
|
|
console.log(`AI 当前经验:${this.currentExp}`);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -149,13 +156,13 @@ export class TornadoAIComponent extends TornadoComponent {
|
|
this.escapeFrom(targetTornado.node);
|
|
this.escapeFrom(targetTornado.node);
|
|
} else if (targetLv < this.currentLv) {
|
|
} else if (targetLv < this.currentLv) {
|
|
// 目标等级比自己低 → 先判断是否追击
|
|
// 目标等级比自己低 → 先判断是否追击
|
|
- if (Math.random() < this.chaseAIProbability) {
|
|
|
|
|
|
+ if (Math.random() * 100 < this.chaseAIProbability) {
|
|
if (isTargetAI) {
|
|
if (isTargetAI) {
|
|
// 目标是 AI,直接追击
|
|
// 目标是 AI,直接追击
|
|
this.chaseTarget(targetTornado.node);
|
|
this.chaseTarget(targetTornado.node);
|
|
} else {
|
|
} else {
|
|
// 目标是玩家,进一步判断是否追击
|
|
// 目标是玩家,进一步判断是否追击
|
|
- if (Math.random() < this.chasePlayerProbability) {
|
|
|
|
|
|
+ if (Math.random() * 100 < this.chasePlayerProbability) {
|
|
this.chaseTarget(targetTornado.node);
|
|
this.chaseTarget(targetTornado.node);
|
|
} else {
|
|
} else {
|
|
// 不追击,则保持当前行为到持续时间结束
|
|
// 不追击,则保持当前行为到持续时间结束
|