Skip to content

Commit ab04e02

Browse files
committed
Merge pull request #13 from trantorLiu/master
好了
2 parents 338ad7b + d2143f2 commit ab04e02

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

AIControl.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ void AIControl::moveTowardLyubu() {
6767

6868
//sprintf(debug, "%s x = %f y = %f z = %f\n",debug, lyubuPos[0], lyubuPos[1], lyubuPos[2]);
6969

70-
if (distance > ATTACK_DISTANCE && distance < KEEP_TRACK_DISTANCE) {
70+
if (distance > ATTACK_DISTANCE && ((npcStateMachineList[i] == this->bossStateMachine && distance < BOSS_KEEP_TRACK_DISTANCE) || distance < KEEP_TRACK_DISTANCE)) {
7171
//turn toward lyubu
7272
float newFDir[3], normalize, offset;
73-
srand ( time(NULL) );
74-
offset = rand() % NPC_MOVE_OFFSET + 1;
75-
lyubuPos[0] += offset;
76-
lyubuPos[1] += offset;
77-
lyubuPos[2] += offset;
73+
if (npcStateMachineList[i] != this->bossStateMachine) {
74+
srand ( time(NULL) + i);
75+
offset = rand() % NPC_MOVE_OFFSET + 1;
76+
lyubuPos[0] += offset;
77+
lyubuPos[1] += offset;
78+
lyubuPos[2] += offset;
79+
}
7880

7981
newFDir[0] = lyubuPos[0] - npcPos[0];
8082
newFDir[1] = lyubuPos[1] - npcPos[1];
@@ -117,7 +119,14 @@ void AIControl::moveTowardLyubu() {
117119
npc.SetWorldDirection(newFDir, npcUDir);
118120

119121
//sprintf(debug, "%s distance = %f\n",debug,distance);
120-
npcStateMachineList[i]->AppendAttackCode(NORMAL_ATT);
122+
srand ( time(NULL) + i);
123+
float rate = rand() % 100;
124+
if (rate > GUARD_RATE) {
125+
npcStateMachineList[i]->AppendAttackCode(NORMAL_ATT);
126+
}
127+
else {
128+
npcStateMachineList[i]->CharacterSetGuard();
129+
}
121130
}
122131
else {
123132
npcStateMachineList[i]->CharacterSetIdle();

AIControl.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
#include <vector>
55

66
#define MOVE_DISTANCE 5
7-
#define KEEP_TRACK_DISTANCE 1500
7+
#define KEEP_TRACK_DISTANCE 800
8+
#define BOSS_KEEP_TRACK_DISTANCE 2000
89
#define ATTACK_DISTANCE 100
9-
#define NPC_MOVE_OFFSET 100
10+
#define NPC_MOVE_OFFSET 150
11+
#define GUARD_RATE 40
12+
1013

1114
//class AIControl :
1215
//public GameControl

Data/npcPos.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
3889 -3418
21
3842 -3381
3-
3926 -3257
2+
3926 -3257
3+
3051 -2530
4+
2861 -2600
5+
975 -2879
6+
3481 -4299
7+
3112 -3761
8+
101 -2011
9+
-754 -2286
10+
-883 -2132
11+
-619 -2256
12+
-617 -2256
13+
-706 -2176

Main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ BOOL initNPC(){
249249
FnActor actor;
250250
actor.Object(donzo);
251251
float pos[3];
252-
pos[0] = 3569.0;
253-
pos[1] = -3010;
252+
pos[0] = -909;
253+
pos[1] = -2300;
254254
pos[2] = 100;
255255
actor.SetPosition(pos);
256256

@@ -292,6 +292,9 @@ BOOL initNPC(){
292292
sprintf(debug, "%s Robber02 load fail\n", debug);
293293
return FALSE;
294294
}
295+
else {
296+
sprintf(debug, "%s Robber02 load success\n", debug);
297+
}
295298

296299
actor_robbers[i].Object(robbers[i]);
297300
actor_robbers[i].SetPosition(pos_robber);

0 commit comments

Comments
 (0)