cutechicken commited on
Commit
f77e71c
ยท
verified ยท
1 Parent(s): 6227da5

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +39 -38
game.js CHANGED
@@ -740,10 +740,8 @@ class EnemyFighter {
740
  // ์ „ํˆฌ ์‹œ์Šคํ…œ
741
  this.bullets = [];
742
  this.burstCounter = 0; // ํ˜„์žฌ ์—ฐ๋ฐœ ์นด์šดํ„ฐ
743
- this.attackCounter = 0; // ๊ณต๊ฒฉ ํšŸ์ˆ˜ ์นด์šดํ„ฐ
744
  this.lastShootTime = 0;
745
- this.evadeTimer = 0;
746
- this.isEvading = false;
747
 
748
  // ๋ถ€๋“œ๋Ÿฌ์šด ํšŒ์ „์„ ์œ„ํ•œ ๋ณ€์ˆ˜
749
  this.targetRotation = this.rotation.clone();
@@ -808,11 +806,9 @@ class EnemyFighter {
808
 
809
  const distanceToPlayer = this.position.distanceTo(playerPosition);
810
 
811
- // ์ƒํƒœ ๊ฒฐ์ •
812
- if (distanceToPlayer <= 3000 && !this.isEvading) {
813
  this.aiState = 'combat';
814
- } else if (this.isEvading) {
815
- this.aiState = 'evade';
816
  } else {
817
  this.aiState = 'patrol';
818
  }
@@ -828,9 +824,6 @@ class EnemyFighter {
828
  case 'combat':
829
  this.executeCombat(playerPosition, deltaTime);
830
  break;
831
- case 'evade':
832
- this.executeEvade(deltaTime);
833
- break;
834
  }
835
 
836
  // ๋ฌผ๋ฆฌ ์—…๋ฐ์ดํŠธ
@@ -863,32 +856,34 @@ class EnemyFighter {
863
  // ์กฐ์ค€ ์ •ํ™•๋„ ํ™•์ธ
864
  const aimAccuracy = this.calculateAimAccuracy(playerPosition);
865
 
866
- // ์ •ํ™•ํ•œ ์กฐ์ค€ ์‹œ ๋ฐœ์‚ฌ
867
- if (aimAccuracy < 0.1 && this.attackCounter < 3) {
 
 
 
 
 
 
 
 
868
  this.fireWeapon();
 
 
 
869
  }
870
 
871
- // 3๋ฒˆ ๊ณต๊ฒฉ ํ›„ ํšŒํ”ผ ๋ชจ๋“œ๋กœ ์ „ํ™˜
872
- if (this.attackCounter >= 3) {
873
- this.isEvading = true;
874
- this.evadeTimer = 3.0; // 3์ดˆ ํšŒํ”ผ
875
- this.attackCounter = 0;
876
  this.selectEvadeTarget();
 
 
 
877
  }
878
  }
879
 
880
- executeEvade(deltaTime) {
881
- // ํšŒํ”ผ ํƒ€์ด๋จธ ์—…๋ฐ์ดํŠธ
882
- this.evadeTimer -= deltaTime;
883
-
884
- if (this.evadeTimer <= 0) {
885
- this.isEvading = false;
886
- this.selectNewPatrolTarget();
887
- } else {
888
- // ํšŒํ”ผ ๋ชฉํ‘œ๋ฅผ ํ–ฅํ•ด ์ด๋™
889
- this.smoothTurnToTarget(this.targetPosition, deltaTime);
890
- }
891
- }
892
 
893
  smoothTurnToTarget(targetPos, deltaTime) {
894
  // ํƒ€๊ฒŸ ๋ฐฉํ–ฅ ๊ณ„์‚ฐ
@@ -1013,15 +1008,21 @@ class EnemyFighter {
1013
  const now = Date.now();
1014
 
1015
  // 0.1์ดˆ์— 1๋ฐœ์”ฉ, 10๋ฐœ ์—ฐ๋ฐœ
1016
- if (now - this.lastShootTime >= 100 && this.burstCounter < 10) {
1017
- this.shoot();
1018
- this.lastShootTime = now;
1019
- this.burstCounter++;
1020
-
1021
- // 10๋ฐœ ๋ฐœ์‚ฌ ์™„๋ฃŒ ์‹œ
1022
- if (this.burstCounter >= 10) {
1023
- this.burstCounter = 0;
1024
- this.attackCounter++;
 
 
 
 
 
 
1025
  }
1026
  }
1027
  }
 
740
  // ์ „ํˆฌ ์‹œ์Šคํ…œ
741
  this.bullets = [];
742
  this.burstCounter = 0; // ํ˜„์žฌ ์—ฐ๋ฐœ ์นด์šดํ„ฐ
 
743
  this.lastShootTime = 0;
744
+ this.canShoot = false; // ๋ฐœ์‚ฌ ๊ฐ€๋Šฅ ์—ฌ๋ถ€
 
745
 
746
  // ๋ถ€๋“œ๋Ÿฌ์šด ํšŒ์ „์„ ์œ„ํ•œ ๋ณ€์ˆ˜
747
  this.targetRotation = this.rotation.clone();
 
806
 
807
  const distanceToPlayer = this.position.distanceTo(playerPosition);
808
 
809
+ // ์ƒํƒœ ๊ฒฐ์ • - ๋‹จ์ˆœํ™”
810
+ if (distanceToPlayer <= 3000) {
811
  this.aiState = 'combat';
 
 
812
  } else {
813
  this.aiState = 'patrol';
814
  }
 
824
  case 'combat':
825
  this.executeCombat(playerPosition, deltaTime);
826
  break;
 
 
 
827
  }
828
 
829
  // ๋ฌผ๋ฆฌ ์—…๋ฐ์ดํŠธ
 
856
  // ์กฐ์ค€ ์ •ํ™•๋„ ํ™•์ธ
857
  const aimAccuracy = this.calculateAimAccuracy(playerPosition);
858
 
859
+ // ์ง์ง„ ์ƒํƒœ ํ™•์ธ (ํ”ผ์น˜์™€ ๋กค์ด ๊ฑฐ์˜ 0์— ๊ฐ€๊นŒ์šด์ง€)
860
+ const isPitchLevel = Math.abs(this.rotation.x) < 0.1; // ์•ฝ 5.7๋„ ์ด๋‚ด
861
+ const isRollLevel = Math.abs(this.rotation.z) < 0.1; // ์•ฝ 5.7๋„ ์ด๋‚ด
862
+ const isStraightFlying = isPitchLevel && isRollLevel;
863
+
864
+ // ์ง์ง„ ๋น„ํ–‰ ์ค‘์ด๊ณ  ์ •ํ™•ํ•œ ์กฐ์ค€ ์‹œ์—๋งŒ ๋ฐœ์‚ฌ ๊ฐ€๋Šฅ
865
+ this.canShoot = isStraightFlying && aimAccuracy < 0.15;
866
+
867
+ // ๋ฐœ์‚ฌ ์กฐ๊ฑด ์ถฉ์กฑ ์‹œ ๋ฐœ์‚ฌ
868
+ if (this.canShoot) {
869
  this.fireWeapon();
870
+ } else {
871
+ // ๋ฐœ์‚ฌํ•  ์ˆ˜ ์—†์œผ๋ฉด ์—ฐ๋ฐœ ์นด์šดํ„ฐ ๋ฆฌ์…‹
872
+ this.burstCounter = 0;
873
  }
874
 
875
+ // ๊ฑฐ๋ฆฌ์— ๋”ฐ๋ผ ์ž์œ ๋กญ๊ฒŒ ๊ธฐ๋™ ๊ฒฐ์ •
876
+ const distance = this.position.distanceTo(playerPosition);
877
+ if (distance < 500) {
878
+ // ๋„ˆ๋ฌด ๊ฐ€๊นŒ์šฐ๋ฉด ํšŒํ”ผ ๊ธฐ๋™
 
879
  this.selectEvadeTarget();
880
+ } else if (distance > 2000) {
881
+ // ๋ฉ€๋ฉด ์ ‘๊ทผ
882
+ this.targetPosition = playerPosition.clone();
883
  }
884
  }
885
 
886
+ // AI ์ƒํƒœ (ํšŒํ”ผ ๊ด€๋ จ ๋กœ์ง ์ œ๊ฑฐ, patrol๊ณผ combat๋งŒ ์œ ์ง€)
 
 
 
 
 
 
 
 
 
 
 
887
 
888
  smoothTurnToTarget(targetPos, deltaTime) {
889
  // ํƒ€๊ฒŸ ๋ฐฉํ–ฅ ๊ณ„์‚ฐ
 
1008
  const now = Date.now();
1009
 
1010
  // 0.1์ดˆ์— 1๋ฐœ์”ฉ, 10๋ฐœ ์—ฐ๋ฐœ
1011
+ if (now - this.lastShootTime >= 100) {
1012
+ // ๋ฐœ์‚ฌ ์ง์ „์— ๋‹ค์‹œ ํ•œ๋ฒˆ ์ง์ง„ ์ƒํƒœ ํ™•์ธ
1013
+ const isPitchLevel = Math.abs(this.rotation.x) < 0.1;
1014
+ const isRollLevel = Math.abs(this.rotation.z) < 0.1;
1015
+
1016
+ if (isPitchLevel && isRollLevel) {
1017
+ this.shoot();
1018
+ this.lastShootTime = now;
1019
+ this.burstCounter++;
1020
+
1021
+ // 10๋ฐœ ๋ฐœ์‚ฌ ์™„๋ฃŒ ์‹œ ์ž ์‹œ ํœด์‹
1022
+ if (this.burstCounter >= 10) {
1023
+ this.burstCounter = 0;
1024
+ this.lastShootTime = now + 1000; // 1์ดˆ ๋Œ€๊ธฐ
1025
+ }
1026
  }
1027
  }
1028
  }