File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 1
1
#include " AIControl.h"
2
2
3
+ using namespace std ;
4
+ extern char debug[1024 ];
3
5
4
- AIControl::AIControl (void )
6
+ AIControl::AIControl (int id )
5
7
{
8
+ this ->lyubuId = id;
6
9
}
7
10
8
11
@@ -23,4 +26,30 @@ void AIControl::PlayAction(int skip){
23
26
for (int i = 0 ;i< this ->npcStateMachineList .size (); i++){
24
27
npcStateMachineList[i]->PlayAction (skip);
25
28
}
29
+ }
30
+ float AIControl::distanceBetweenLyubu () {
31
+ for (int i = 0 ;i< this ->npcStateMachineList .size (); i++){
32
+ int npcId = npcStateMachineList[i]->character ;
33
+
34
+ FnActor lyubu;
35
+ FnActor npc;
36
+ lyubu.Object (this ->lyubuId );
37
+ npc.Object (npcId);
38
+
39
+ float lyubuPos[3 ];
40
+ float npcPos[3 ];
41
+
42
+ lyubu.GetWorldPosition (lyubuPos);
43
+ npc.GetWorldPosition (npcPos);
44
+
45
+ float distance;
46
+ distance = sqrt ((npcPos[0 ] - lyubuPos[0 ]) * (npcPos[0 ] - lyubuPos[0 ])
47
+ + (npcPos[0 ] - lyubuPos[0 ]) * (npcPos[0 ] - lyubuPos[0 ])
48
+ + (npcPos[0 ] - lyubuPos[0 ]) * (npcPos[0 ] - lyubuPos[0 ]));
49
+
50
+ sprintf (debug, " %s distance = %f\n " ,debug,distance);
51
+
52
+ return distance;
53
+
54
+ }
26
55
}
Original file line number Diff line number Diff line change 8
8
class AIControl
9
9
{
10
10
public:
11
+ AIControl (int );
11
12
std::vector<ActorStateMachine *> npcStateMachineList;
12
13
AIControl (void );
13
14
virtual ~AIControl (void );
14
15
int AddNPC (ACTORid ncp, char * ActionFilename);
15
16
void PlayAction (int skip);
17
+ float distanceBetweenLyubu ();
18
+ private:
19
+ int lyubuId;
16
20
};
17
21
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ BOOL initNPC(){
301
301
}
302
302
303
303
304
- npc = new AIControl ();
304
+ npc = new AIControl (lyubu );
305
305
npc->AddNPC (donzo," Data\\ DozonAction.txt" );
306
306
npc->AddNPC (robber," Data\\ Robber02Action.txt" );
307
307
return TRUE ;
@@ -447,6 +447,8 @@ void GameAI(int skip)
447
447
kc->Command ();
448
448
bRoom->RefreshArena ();
449
449
kc->CamPointToActor ();
450
+ npc->distanceBetweenLyubu ();
451
+
450
452
}
451
453
452
454
void Render (int skip){
You can’t perform that action at this time.
0 commit comments