Skip to content

Commit 50af7d4

Browse files
unknownunknown
authored andcommitted
I don't know what will happen
1 parent ba9ff3f commit 50af7d4

File tree

6 files changed

+49
-26
lines changed

6 files changed

+49
-26
lines changed

ActorStateMachine.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ActorStateMachine::ActorStateMachine(ACTORid character, char * ActionFilename){
3030
}
3131

3232
BOOL ActorStateMachine::initLife(){
33-
this->life = 100;
33+
this->life = (int) MAX_LIFE;
3434

3535
FnScene scene;
3636
scene.Object(sID);
@@ -124,10 +124,10 @@ int ActorStateMachine::ChangeState(ActorState s, BOOL forceSet){
124124
FnActor actor;
125125
actor.Object(this->character);
126126
actor.MoveForward(-MOVE_LENGTH,TRUE, FALSE, 0.0, TRUE);
127-
//this->SetNewAction("LightDamage");
127+
this->SetNewAction("LightDamage");
128128
this->currentAttackIndex = 0;
129129
this->lastAttackIndex = 0;
130-
this->SetNewAction("HeavyDamage");
130+
//this->SetNewAction("HeavyDamage");
131131
}else if (s == STATEDIE){
132132
this->SetNewAction("Die");
133133
}
@@ -278,7 +278,11 @@ BOOL ActorStateMachine::UpdateEffectiveAttack(){
278278
return FALSE;
279279
}
280280

281-
int ActorStateMachine::AttackEnemy(float enemyPos[3]){
281+
int ActorStateMachine::AttackEnemy(float enemyPos[3], BOOL *beOutShot){
282+
// beOutShot is a parameter
283+
if (beOutShot != NULL){
284+
*beOutShot = FALSE;
285+
}
282286
// the return value is the attack power
283287
return FALSE;
284288
}
@@ -290,17 +294,15 @@ void ActorStateMachine::TakeDamage(float damage, BOOL beShot, float *attackerPos
290294
float dir[3];
291295
actor.GetWorldPosition(pos);
292296
actor.GetWorldDirection(dir, NULL);
293-
if (attackerPos !=NULL){
297+
if (beShot == TRUE && attackerPos !=NULL){
294298
float newDir[3];
295299
newDir[0] = attackerPos[0] - pos[0];
296300
newDir[1] = attackerPos[1] - pos[1];
297301
newDir[2] = 0.0f;
298302
actor.SetWorldDirection(newDir,NULL);
299-
if (beShot == TRUE){
300-
actor.MoveForward(-OUTSHOT_DIS,TRUE, FALSE, 0.0, TRUE);
301-
}else{
302-
actor.MoveForward(-1.0f,TRUE, FALSE, 0.0, TRUE);
303-
}
303+
//if (beShot == TRUE){
304+
//actor.MoveForward(-OUTSHOT_DIS,TRUE, FALSE, 0.0, TRUE);
305+
//}
304306
actor.SetWorldDirection(dir,NULL);
305307
}
306308
this->life -= damage;

ActorStateMachine.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ typedef int ActorState;
1919
#define ULTIMATE_ATT 2
2020
typedef int ATTACK_CODE;
2121

22-
#define OUTSHOT_DIS 100.0
23-
#define MAX_LIFE 100.0
22+
#define OUTSHOT_DIS 200.0
23+
#define MAX_LIFE 1000.0
2424

2525
// actor free meaning it can do anything by the controller.
2626
// actor stay meaning that it can't be move beacuse of being attacked.
@@ -60,7 +60,7 @@ class ActorStateMachine
6060
BOOL AppendAttackCode(ATTACK_CODE code);
6161
virtual BOOL PlayAction(int skip);
6262
BOOL CheckEffectiveAttack();
63-
virtual int AttackEnemy(float enemyPos[3]);
63+
virtual int AttackEnemy(float enemyPos[3], BOOL *beOutShot = NULL); // beOutShot will be assgin a value after the call
6464
virtual void TakeDamage(float damage, BOOL beShot, float* attackerPos);
6565
};
6666

BattleRoom.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ void BattleRoom::PerformAttack(){
8181

8282
FnActor npc;
8383
float nPos[3];
84-
84+
int beOutShot;
8585
for (int i= 0;i< this->AreanList.size();i++){
8686
ACTORid tmpid = AreanList[i]->character;
8787
if (playerHitMap.find(tmpid) == playerHitMap.end()){
8888
npc.Object(tmpid);
8989
npc.GetWorldPosition(nPos);
90-
int attackPower = this->playerStateMachine->AttackEnemy(nPos);
90+
int attackPower = this->playerStateMachine->AttackEnemy(nPos, &beOutShot);
9191
if (attackPower > 0 ){
9292
// get a new victim;
9393
sprintf(debug, "%s new victim\n",debug);
9494
if ( this->AreanList[i]->state != STATEDIE){
95-
this->AreanList[i]->TakeDamage(attackPower, TRUE, pPos);
95+
this->AreanList[i]->TakeDamage(attackPower, beOutShot, pPos);
9696
//this->AreanList[i]->ChangeState(STATEDAMAGE,TRUE);
9797
}
9898
this->playerHitMap[tmpid] = TRUE;

Data/Robber02Action.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ N2 NormalAttack1
55
N3 NormalAttack2
66
N4 HeavyAttack1
77
H1 HeavyAttack1
8-
HeavyDamage Damage1
9-
LightDamage Damage2
8+
HeavyDamage Damage2
9+
LightDamage Damage1
1010
Die Dead

LyubuStateMachine.cpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ void LyubuStateMachine::setAttackState(void) { //set var attackState
4949
attackState = TRUE;
5050
}
5151
*/
52+
5253
BOOL LyubuStateMachine::PlayAttackAction(int skip){
53-
//duplicate with parrent's PlayAttackAction
54-
//this function can be removed (in future);
54+
// the difference from parent function is that this function contain the sound fx
5555
FnActor actor;
5656
actor.Object(this->character);
5757
ACTIONid actionID;
@@ -127,9 +127,17 @@ BOOL LyubuStateMachine::UpdateEffectiveAttack(){
127127
actor.Object(this->character);
128128
float frame = actor.QueryCurrentFrame(0);
129129
//sprintf(debug, "%s frame:%lf\n", debug, frame );
130-
if (this->attackKeyQueue[currentAttackIndex] == HEAVY_ATT){
130+
if (this->attackKeyQueue[currentAttackIndex] == ULTIMATE_ATT){
131+
if (frame > 20.0){
132+
this->newAttack = TRUE;
133+
this->effectiveAttack = TRUE;
134+
}
135+
}else if (this->attackKeyQueue[currentAttackIndex] == HEAVY_ATT){
131136
if (frame > 20.0){
132137
this->effectiveAttack = TRUE;
138+
}else if (frame > 50.0){
139+
this->newAttack = TRUE;
140+
this->effectiveAttack = TRUE;
133141
}
134142
}else if (this->currentAttackIndex > 0){
135143
if (frame > 10.0){
@@ -141,13 +149,14 @@ BOOL LyubuStateMachine::UpdateEffectiveAttack(){
141149
return FALSE;
142150
}
143151

144-
int LyubuStateMachine::AttackEnemy(float enemyPos[3]){
152+
int LyubuStateMachine::AttackEnemy(float enemyPos[3], BOOL *beOutShot){
145153
// the return value is the attack power
146154
FnActor actor;
147155
actor.Object(this->character);
148156
float attackerPos[3], attackerDir[3];
149157
actor.GetWorldPosition(attackerPos);
150158
actor.GetWorldDirection(attackerDir,NULL);
159+
float frame = actor.QueryCurrentFrame(0);
151160

152161
float dist = 0.0;
153162
for (int i = 0;i< 3;i++){
@@ -169,11 +178,23 @@ int LyubuStateMachine::AttackEnemy(float enemyPos[3]){
169178
}
170179
cosine = dotProduct / sqrt(length);
171180
//sprintf(debug, "%s cosine = %lf\n",debug,cosine);
181+
182+
if (this->attackKeyQueue[currentAttackIndex] == HEAVY_ATT || currentAttackIndex == MAXATTACK -1){
183+
*beOutShot = TRUE;
184+
}else {
185+
*beOutShot = FALSE;
186+
}
187+
172188
if (this->currentAttackIndex == 0){
173189
if (this->attackKeyQueue[currentAttackIndex] == ULTIMATE_ATT){
174-
sprintf(debug, "%s attack power = %d\n",debug,10);
175-
return 10;
176-
}else if (cosine > 0.8){
190+
if (frame > 100){ // almost finish attack
191+
*beOutShot = TRUE;
192+
sprintf(debug, "%s attack power = %d\n",debug,10);
193+
return 10;
194+
}
195+
sprintf(debug, "%s attack power = %d\n",debug,1);
196+
return 1;
197+
}else if (cosine > 0.8){ // normal or heavy attack, only attack the front side enemy
177198
sprintf(debug, "%s attack power = %d\n",debug,1);
178199
return 1;
179200
}

LyubuStateMachine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class LyubuStateMachine :
1313
virtual ~LyubuStateMachine(void);
1414
LyubuStateMachine(ACTORid character, char *ActionFilename);
1515
virtual BOOL PlayAttackAction(int skip);
16-
int AttackEnemy(float enemyPos[3]);
16+
virtual int AttackEnemy(float enemyPos[3], BOOL *beOutShot = NULL);
1717
protected:
1818
virtual BOOL UpdateEffectiveAttack();
1919
AUDIOid audioN1;

0 commit comments

Comments
 (0)