Skip to content

Commit 6fb63dc

Browse files
unknownunknown
authored andcommitted
add die fx
1 parent 29b3700 commit 6fb63dc

File tree

7 files changed

+85
-19
lines changed

7 files changed

+85
-19
lines changed

AIControl.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,27 @@ AIControl::~AIControl(void)
2323
int AIControl::AddNPC(ACTORid npc, char * ActionFilename){
2424
ActorStateMachine* stm = new ActorStateMachine(npc, ActionFilename);
2525
this->npcStateMachineList.push_back(stm);
26+
stm->life = 10;
27+
return 0;
28+
}
29+
30+
int AIControl::AddBossNPC(ACTORid npc, char * ActionFilename){
31+
ActorStateMachine* stm = new ActorStateMachine(npc, ActionFilename);
32+
this->npcStateMachineList.push_back(stm);
33+
stm->life = 1000;
2634
return 0;
2735
}
2836

2937
void AIControl::PlayAction(int skip){
30-
for (int i = 0;i< this->npcStateMachineList.size(); i++){
38+
for (unsigned int i = 0;i< this->npcStateMachineList.size(); i++){
3139
npcStateMachineList[i]->PlayAction(skip);
3240
}
3341
}
3442
void AIControl::moveTowardLyubu() {
3543
for (int i = 0;i< this->npcStateMachineList.size(); i++){
44+
if (this->npcStateMachineList[i]->state == STATEDIE){
45+
46+
}
3647
if (npcStateMachineList[i]->CanBeControl() == FALSE){
3748
continue;
3849
}

AIControl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ class AIControl
1818
AIControl(void);
1919
virtual ~AIControl(void);
2020
int AddNPC(ACTORid ncp, char * ActionFilename);
21+
int AddBossNPC(ACTORid ncp, char * ActionFilename);
2122
void PlayAction(int skip);
2223
void moveTowardLyubu();
2324
private:
2425
ACTORid lyubuId;
26+
ACTORid boss;
27+
std::vector<ActorStateMachine *> npcDropList;
2528
};
2629

ActorStateMachine.cpp

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
extern char debug[1024];
44
extern SCENEid sID;
5-
//extern WORLDid gID;
5+
extern WORLDid gID;
66
extern AUDIOid audioG;
77
extern AUDIOid audioD;
88
using namespace std;
@@ -158,6 +158,26 @@ int ActorStateMachine::ChangeState(ActorState s, BOOL forceSet){
158158
}else if (s == STATEATTACK){
159159
// Serial attack start;
160160
this->startAttack = TRUE;
161+
}else if (s == STATEVANISH){
162+
FnWorld gw;
163+
gw.Object(gID);
164+
gw.SetTexturePath("Data\\FXs\\Textures");
165+
gw.SetObjectPath("Data\\FXs\\Models");
166+
167+
float pos[3];
168+
FnActor actor;
169+
actor.Object(this->character);
170+
actor.GetWorldPosition(pos);
171+
172+
fxDie = new eF3DFX(sID);
173+
fxDie->SetWorkPath("Data\\FXs");
174+
BOOL beOK = fxDie->Load("dust3");
175+
eF3DBaseFX *fx;
176+
int i, numFX = fxDie->NumberFXs();
177+
for (i = 0; i < numFX; i++) {
178+
fx = fxDie->GetFX(i);
179+
fx->InitPosition(pos);
180+
}
161181
}
162182
return 0;
163183
}
@@ -213,15 +233,29 @@ BOOL ActorStateMachine::PlayAction(int skip){
213233
}else if (this->state == STATEDAMAGE){
214234
BOOL ret = actor.Play(0,ONCE, (float)skip, TRUE,TRUE);
215235
if (ret == FALSE){
216-
sprintf(debug, "%s damage end\n",debug);
236+
//sprintf(debug, "%s damage end\n",debug);
217237
this->ChangeState(STATEIDLE);
218238
}
219239
}else if (this->state == STATEDIE){
220240
BOOL ret = actor.Play(0,ONCE, (float)skip, TRUE,TRUE);
221-
/*
241+
222242
if (ret == FALSE){
223243
sprintf(debug, "%s character die\n",debug);
224-
}*/
244+
this->ChangeState(STATEVANISH);
245+
}
246+
}else if (this->state == STATEVANISH){
247+
if (this->fxDie != NULL) {
248+
BOOL beOK = this->fxDie->Play((float) skip);
249+
if (!beOK) {
250+
//fxDie->Reset(); // make it from the starting position and play it again
251+
// should delete the character
252+
delete fxDie;
253+
this->fxDie = NULL;
254+
FnScene scene;
255+
scene.Object(sID);
256+
scene.DeleteActor(this->character);
257+
}
258+
}
225259
}
226260
return TRUE;
227261
}

ActorStateMachine.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include "TheFlyWin32.h"
3+
#include "FyFx.h"
34
#include <map>
45
#include <string>
56

@@ -10,6 +11,7 @@
1011
#define STATECOMBATIDEL 4
1112
#define STATEDIE 5
1213
#define STATEGUARD 6
14+
#define STATEVANISH 7
1315
typedef int ActorState;
1416

1517
#define MAXATTACK 4
@@ -20,7 +22,7 @@ typedef int ActorState;
2022
typedef int ATTACK_CODE;
2123

2224
#define OUTSHOT_DIS 200.0
23-
#define SMALL_OUTSHOT_DIS 50.0
25+
#define SMALL_OUTSHOT_DIS 25.0
2426
#define MAX_LIFE 1000.0
2527
#define ROBOT_ATTACKRANGE 18000.0
2628

@@ -40,20 +42,21 @@ class ActorStateMachine
4042
int attackKeyQueue[MAXATTACK];
4143
BOOL newAttack;
4244
BOOL effectiveAttack;
45+
int life;
4346
protected:
4447
int currentAttackIndex;
4548
int lastAttackIndex;
4649
BOOL attackDisable;
4750
BOOL startAttack;
4851
float lastAttackFrame;
49-
int life;
5052
BOOL initActionIDMap(char *ActionFilename);
5153
std::map<std::string, ACTIONid> ActionIDMap;
5254
virtual BOOL PlayAttackAction(int skip);
5355
BOOL SetNewAction(std::string systemName);
5456
virtual BOOL UpdateEffectiveAttack();
5557
OBJECTid bloodID;
5658
virtual BOOL initLife();
59+
eF3DFX *fxDie;
5760
public:
5861
ActorStateMachine(void);
5962
virtual ~ActorStateMachine(void);

BattleRoom.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ extern char debug[1024];
55

66
BattleRoom::BattleRoom(void)
77
{
8+
this->hurt = TRUE;
89
}
910

1011

@@ -30,14 +31,15 @@ void BattleRoom::RefreshArena(){
3031

3132
this->AreanList.clear();
3233
for (unsigned int i =0;i< this->npcStateMachineList.size();i++){
34+
if (this->npcStateMachineList[i]->state == STATEVANISH){
35+
continue;
36+
}
3337
npc.Object(this->npcStateMachineList[i]->character);
3438
npc.GetWorldPosition(npcPos);
35-
//this->npcStateMachineList[i]->AppendAttackCode(NORMAL_ATT);
3639

3740
if (this->CheckDistanceAndState(playerPos, npcPos,
3841
this->playerStateMachine->state, this->npcStateMachineList[i]->state ) == TRUE){
3942
this->JoinArena( this->npcStateMachineList[i] );
40-
//this->npcStateMachineList[i]->ChangeState(STATEATTACK,TRUE);
4143
}
4244
}
4345
//sprintf(debug, "%s npc state machine list size = %d\n",debug,this->npcStateMachineList.size());
@@ -91,7 +93,7 @@ void BattleRoom::PerformAttack(){
9193
if (attackPower > 0 ){
9294
// get a new victim;
9395
//sprintf(debug, "%s new victim\n",debug);
94-
if ( this->AreanList[i]->state != STATEDIE){
96+
if ( this->AreanList[i]->state != STATEDIE && this->AreanList[i]->state != STATEVANISH){
9597
this->AreanList[i]->TakeDamage(attackPower, beOutShot, pPos);
9698
}
9799
this->playerHitMap[tmpid] = TRUE;
@@ -100,6 +102,9 @@ void BattleRoom::PerformAttack(){
100102
}
101103
}
102104

105+
if (this->hurt == FALSE){
106+
return; // player won't get damage.
107+
}
103108
actor.GetWorldPosition(pPos);
104109
//this->npcHitMap.clear();
105110
for (int i= 0;i< this->AreanList.size();i++){

BattleRoom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BattleRoom
2222
BattleRoom(ActorStateMachine *playerStateMachine, std::vector<ActorStateMachine *> npcStateMachineList);
2323
void RefreshArena();
2424
void PerformAttack();
25-
25+
BOOL hurt;
2626
protected:
2727
BOOL JoinArena(ActorStateMachine * npcStm);
2828
BOOL CheckDistanceAndState(float playerPos[3], float npcPos[3], ActorState playerState,ActorState npcState );

Main.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ char loopBuff[1024] = "\0";
4545
void debug_message(char*, char*);
4646

4747
void QuitGame(WORLDid, BYTE, BOOL);
48-
void CleanDebugBuff(WORLDid, BYTE, BOOL);
48+
void FunctionKey(WORLDid, BYTE, BOOL);
4949
BOOL initLyubu();
5050
BOOL initNPC();
5151
BOOL initBattleRoom(GameControl *player, AIControl *npc);
@@ -319,7 +319,7 @@ BOOL initNPC(){
319319
robbers_count = i;
320320

321321
npc = new AIControl(lyubu);
322-
npc->AddNPC(donzo,"Data\\DozonAction.txt");
322+
npc->AddBossNPC(donzo,"Data\\DozonAction.txt");
323323

324324
for (i = 0; i < robbers_count; i++) {
325325
npc->AddNPC(robbers[i],"Data\\Robber02Action.txt");
@@ -338,9 +338,10 @@ BOOL initFX(){
338338
gw.SetTexturePath("Data\\FXs\\Textures");
339339
gw.SetObjectPath("Data\\FXs\\Models");
340340

341+
/*
341342
fx00 = new eF3DFX(sID);
342343
fx00->SetWorkPath("Data\\FXs");
343-
BOOL beOK = fx00->Load("NoPigeon");
344+
BOOL beOK = fx00->Load("Smoke_01");
344345
345346
if (beOK == FALSE){
346347
sprintf(debug, "%s fx load failed\n", debug);
@@ -351,14 +352,14 @@ BOOL initFX(){
351352
float pos[3];
352353
pos[0] = 3569.0;
353354
pos[1] = -3210.0;
354-
pos[2] = 0.0;
355+
pos[2] = 10.0;
355356
356357
eF3DBaseFX *fx;
357358
int i, numFX = fx00->NumberFXs();
358359
for (i = 0; i < numFX; i++) {
359360
fx = fx00->GetFX(i);
360361
fx->InitPosition(pos);
361-
}
362+
}*/
362363
/*
363364
FyBeginMedia("Data\\Media", 1);
364365
HWND hwnd = FyGetWindowHandle(gw.Object());
@@ -478,7 +479,8 @@ void GetPosDetail(char *buffer){
478479
BOOL BlindKeys(){
479480
FyDefineHotKey(FY_ESCAPE, QuitGame, FALSE);
480481
FyDefineHotKey(FY_F1, Reset, FALSE);
481-
FyDefineHotKey(FY_F2, CleanDebugBuff, FALSE);
482+
FyDefineHotKey(FY_F2, FunctionKey, FALSE);
483+
FyDefineHotKey(FY_F3, FunctionKey, FALSE);
482484

483485
// define some mouse functions
484486
FyBindMouseFunction(LEFT_MOUSE, InitPivot, PivotCam, NULL, NULL);
@@ -492,8 +494,16 @@ BOOL BlindKeys(){
492494
return TRUE;
493495
}
494496

495-
void CleanDebugBuff(WORLDid gID, BYTE code, BOOL value){
496-
debug[0] = '\0';
497+
void FunctionKey(WORLDid gID, BYTE code, BOOL value){
498+
if (code == FY_F2 && FyCheckHotKeyStatus(FY_F2) == TRUE){
499+
debug[0] = '\0';
500+
}else if (code == FY_F3 && FyCheckHotKeyStatus(FY_F3) == TRUE){
501+
if (bRoom->hurt == FALSE){
502+
bRoom->hurt = TRUE;
503+
}else{
504+
bRoom->hurt = FALSE;
505+
}
506+
}
497507
}
498508
//------------------------------------------------------------------------------------
499509
// timer callback function which will be invoked by TheFly3D System every 1/30 second

0 commit comments

Comments
 (0)