@@ -15,6 +15,11 @@ Last Updated : 1010, 2004, C.Wang
15
15
#include " BattleRoom.h"
16
16
#include " FyFx.h"
17
17
#include " FyMedia.h"
18
+ #include < iostream>
19
+ #include < fstream>
20
+ #include < string>
21
+ using namespace std ;
22
+ extern int errno;
18
23
19
24
int oldX, oldY, oldXM, oldYM, oldXMM, oldYMM;
20
25
@@ -24,7 +29,8 @@ SCENEid sID;
24
29
OBJECTid nID, cID, lID;
25
30
OBJECTid tID;
26
31
ACTORid lyubu;
27
- ACTORid donzo, robber;
32
+ ACTORid donzo, robbers[100 ];
33
+ int robbers_count = 0 ;
28
34
KeyboardControl *kc;
29
35
AIControl *npc;
30
36
BattleRoom *bRoom;
@@ -266,44 +272,56 @@ BOOL initNPC(){
266
272
if (actor.Play (0 ,START, 0.0 , FALSE ,TRUE ) == FALSE ){
267
273
sprintf (debug, " %s play action failed\n " , debug);
268
274
}
269
-
270
- robber = scene.LoadActor (" Robber02" );
271
- if (robber == FAILED_ID){
272
- sprintf (debug, " %s Robber02 load fail\n " , debug);
273
- return FALSE ;
275
+
276
+ ifstream fin;
277
+ fin.open (" Data\\ npcPos.txt" );
278
+ if (!fin.is_open ()) {
279
+ sprintf (debug, " %s open file error\n " , debug);
280
+ sprintf (debug, " %s %s\n " , debug, strerror (errno));
274
281
}
275
- FnActor actor_robber;
276
- actor_robber.Object (robber);
277
- float pos_robber[3 ];
278
- pos_robber[0 ] = 3569.0 ;
279
- pos_robber[1 ] = -3010 ;
282
+ float pos_robber[3 ];
280
283
pos_robber[2 ] = 100 ;
281
- actor_robber.SetPosition (pos_robber);
284
+ int i = 0 ;
285
+ FnActor actor_robbers[100 ];
286
+ while (fin >> pos_robber[0 ] && fin >> pos_robber[1 ]) {
287
+ sprintf (debug, " %s in the loading npc while loop\n " , debug);
288
+ robbers[i] = scene.LoadActor (" Robber02" );
289
+ if (robbers[i] == FAILED_ID){
290
+ sprintf (debug, " %s Robber02 load fail\n " , debug);
291
+ return FALSE ;
292
+ }
282
293
283
- flag = actor_robber.PutOnTerrain (tID,FALSE ,0.0 );
294
+ actor_robbers[i].Object (robbers[i]);
295
+ actor_robbers[i].SetPosition (pos_robber);
296
+
297
+ flag = actor_robbers[i].PutOnTerrain (tID,FALSE ,0.0 );
284
298
285
- if (flag == FALSE ){
286
- return FALSE ;
287
- }
288
- // set donzo idle action
289
- ACTIONid idleID_robber = actor_robber.GetBodyAction (NULL ," CombatIdle" );
290
-
291
- // actor.MakeCurrentAction(0,NULL,idleID,0.0,TRUE);
292
- // if (actor.MakeCurrentAction(0,NULL,FAILED_ID) == FAILED_ID){
293
- if (actor_robber.MakeCurrentAction (0 ,NULL ,idleID_robber) == FAILED_ID){
294
- sprintf (debug, " %s make current fail\n " , debug);
295
- }else {
296
- sprintf (debug, " %s make action success\n " , debug);
297
- }
299
+ if (flag == FALSE ){
300
+ return FALSE ;
301
+ }
302
+ ACTIONid idleID_robber = actor_robbers[i].GetBodyAction (NULL ," CombatIdle" );
298
303
299
- if (actor_robber.Play (0 ,START, 0.0 , FALSE ,TRUE ) == FALSE ){
300
- sprintf (debug, " %s play action failed\n " , debug);
301
- }
302
-
304
+ // actor.MakeCurrentAction(0,NULL,idleID,0.0,TRUE);
305
+ // if (actor.MakeCurrentAction(0,NULL,FAILED_ID) == FAILED_ID){
306
+ if (actor_robbers[i].MakeCurrentAction (0 ,NULL ,idleID_robber) == FAILED_ID){
307
+ sprintf (debug, " %s make current fail\n " , debug);
308
+ }else {
309
+ sprintf (debug, " %s make action success\n " , debug);
310
+ }
311
+
312
+ if (actor_robbers[i].Play (0 ,START, 0.0 , FALSE ,TRUE ) == FALSE ){
313
+ sprintf (debug, " %s play action failed\n " , debug);
314
+ }
315
+ i++;
316
+ }
317
+ robbers_count = i;
303
318
304
319
npc = new AIControl (lyubu);
305
320
npc->AddNPC (donzo," Data\\ DozonAction.txt" );
306
- npc->AddNPC (robber," Data\\ Robber02Action.txt" );
321
+
322
+ for (i = 0 ; i < robbers_count; i++) {
323
+ npc->AddNPC (robbers[i]," Data\\ Robber02Action.txt" );
324
+ }
307
325
return TRUE ;
308
326
}
309
327
@@ -349,7 +367,10 @@ void Reset(WORLDid gID, BYTE code, BOOL value){
349
367
scene.Object (sID );
350
368
scene.DeleteActor (lyubu);
351
369
scene.DeleteActor (donzo);
352
- scene.DeleteActor (robber);
370
+ int i;
371
+ for (i = 0 ; i < robbers_count; i++) {
372
+ scene.DeleteActor (robbers[i]);
373
+ }
353
374
debug[0 ] = ' \0 ' ;
354
375
ActorStateMachine * lyubuState = kc->mainChar ;
355
376
delete lyubuState;
0 commit comments