Rolling damage counters and turn-based handling completed

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 0fe0477d78
commit bcf1107267
  1. BIN
      C++ProjectTemplate
  2. 102
      main.cpp

Binary file not shown.

@ -504,6 +504,7 @@ public:
int player_rollpp_counter[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; int player_rollpp_counter[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
int player_rollhp_display[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; int player_rollhp_display[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
int player_rollpp_display[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; int player_rollpp_display[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
int player_rollwait_counter[4] = {0,0,0,0};
int SELECTED_TARGET=0; //Battle target that is selected. int SELECTED_TARGET=0; //Battle target that is selected.
int BATTLE_TARGET=-99; //Negative numbers for players and positive numbers for enemy targets. int BATTLE_TARGET=-99; //Negative numbers for players and positive numbers for enemy targets.
int CURRENT_TURN=-99; //Who's turn we are enacting. int CURRENT_TURN=-99; //Who's turn we are enacting.
@ -519,9 +520,7 @@ public:
}; };
int POWER_SELECTION_OFFSET[4]={0,0,0,0}; int POWER_SELECTION_OFFSET[4]={0,0,0,0};
int BATTLE_ANIMATION_TIMER=0; int BATTLE_ANIMATION_TIMER=0;
int BATTLE_ROLLING_COUNTER_WAITTIME = 0; //Number of frames to wait for each rolling counter.
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things. bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
@ -667,48 +666,17 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
if (BATTLE_ENCOUNTER!=nullptr) { if (BATTLE_ENCOUNTER!=nullptr) {
switch (BATTLE_STATE) {
case BattleState::MOVE_CAMERA:{
bool allDone=true;
if (!MoveCameraTowardsPoint(BATTLE_ENCOUNTER->pos,PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD)) {
allDone=false;
}
for (int i=0;i<PARTY_MEMBER_COUNT;i++) { for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
if (!MoveObjectTowardsPoint(PARTY_MEMBER_OBJ[i],BATTLE_ENCOUNTER->playerPos[i]+BATTLE_ENCOUNTER->pos,PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD)) { if (player_rollwait_counter[i]>0) {
allDone=false; if (BATTLE_ROLLING_COUNTER_WAITTIME==0) {
} player_rollwait_counter[i]=0;
} } else {
if (allDone) { player_rollwait_counter[i]--;
CAMERA_WAIT_TIMER++;
if (CAMERA_WAIT_TIMER>=CAMERA_WAIT_TIME) {
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]];
for (int j=0;j<3;j++) {
switch (j) {
case 0:{
player_rollhp_display[i][j]=member->GetHP()%10;
player_rollpp_display[i][j]=member->PP%10;
}break;
case 1:{
player_rollhp_display[i][j]=member->GetHP()/10%10;
player_rollpp_display[i][j]=member->PP/10%10;
}break;
case 2:{
player_rollhp_display[i][j]=member->GetHP()/100%10;
player_rollpp_display[i][j]=member->PP/100%10;
}break;
}
}
BATTLE_STATE=BattleState::WAIT;
}
} }
} }
}break;
case BattleState::WAIT:{
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]; Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]];
if (member->GetHP()>std::clamp(member->GetTargetHP(),0,member->GetTargetHP())) { if (member->GetHP()>std::clamp(member->GetTargetHP(),0,member->GetTargetHP())) {
if (player_rollhp_counter[i][0]<=0) { if (player_rollhp_counter[i][0]<=0&&player_rollwait_counter[i]==0) {
player_rollhp_display[i][0]--; player_rollhp_display[i][0]--;
player_rollhp_counter[i][0]=13; player_rollhp_counter[i][0]=13;
member->_SetDirectHP(member->GetHP()-1); member->_SetDirectHP(member->GetHP()-1);
@ -743,7 +711,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
} else } else
if (member->GetHP()<member->GetTargetHP()) { if (member->GetHP()<member->GetTargetHP()) {
if (player_rollhp_counter[i][0]>=0) { if (player_rollhp_counter[i][0]>=0&&player_rollwait_counter[i]==0) {
player_rollhp_display[i][0]++; player_rollhp_display[i][0]++;
player_rollhp_counter[i][0]=-13; player_rollhp_counter[i][0]=-13;
member->_SetDirectHP(member->GetHP()+1); member->_SetDirectHP(member->GetHP()+1);
@ -789,7 +757,50 @@ goes on a very long time, I hope you can understand this is only for testing pur
player_rollhp_counter[i][2]--; player_rollhp_counter[i][2]--;
} }
} }
if (player_rollwait_counter[i]==0) {
player_rollwait_counter[i]=BATTLE_ROLLING_COUNTER_WAITTIME*13;
}
}
switch (BATTLE_STATE) {
case BattleState::MOVE_CAMERA:{
bool allDone=true;
if (!MoveCameraTowardsPoint(BATTLE_ENCOUNTER->pos,PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD)) {
allDone=false;
}
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
if (!MoveObjectTowardsPoint(PARTY_MEMBER_OBJ[i],BATTLE_ENCOUNTER->playerPos[i]+BATTLE_ENCOUNTER->pos,PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD)) {
allDone=false;
} }
}
if (allDone) {
CAMERA_WAIT_TIMER++;
if (CAMERA_WAIT_TIMER>=CAMERA_WAIT_TIME) {
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]];
for (int j=0;j<3;j++) {
switch (j) {
case 0:{
player_rollhp_display[i][j]=member->GetHP()%10;
player_rollpp_display[i][j]=member->PP%10;
}break;
case 1:{
player_rollhp_display[i][j]=member->GetHP()/10%10;
player_rollpp_display[i][j]=member->PP/10%10;
}break;
case 2:{
player_rollhp_display[i][j]=member->GetHP()/100%10;
player_rollpp_display[i][j]=member->PP/100%10;
}break;
}
}
BATTLE_STATE=BattleState::WAIT;
}
}
}
}break;
case BattleState::WAIT:{
BATTLE_ROLLING_COUNTER_WAITTIME=0;
bool done=false; bool done=false;
if (!done) { if (!done) {
for (int i=0;i<4;i++) { for (int i=0;i<4;i++) {
@ -882,6 +893,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
}break; }break;
case BattleState::WAIT_ANIMATION:{ case BattleState::WAIT_ANIMATION:{
BATTLE_ROLLING_COUNTER_WAITTIME=5;
BATTLE_ANIMATION_TIMER++; BATTLE_ANIMATION_TIMER++;
if (BATTLE_ANIMATION_TIMER==90) { if (BATTLE_ANIMATION_TIMER==90) {
if (CURRENT_TURN<0) { if (CURRENT_TURN<0) {
@ -927,7 +939,6 @@ goes on a very long time, I hope you can understand this is only for testing pur
+BATTLE_ENCOUNTER->objs[CURRENT_TURN]->baseAtk; +BATTLE_ENCOUNTER->objs[CURRENT_TURN]->baseAtk;
printf("Damage: %d\n",dmgAmt); printf("Damage: %d\n",dmgAmt);
std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << PARTY_MEMBER_OBJ[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]->name << " dealing " << dmgAmt << " health.\n"; std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << PARTY_MEMBER_OBJ[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]->name << " dealing " << dmgAmt << " health.\n";
printf("Now subtract.\n");
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]]->SubtractHP(dmgAmt); PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]]->SubtractHP(dmgAmt);
} else { } else {
std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << PARTY_MEMBER_OBJ[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]->name << " but it failed.\n"; std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << PARTY_MEMBER_OBJ[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]->name << " but it failed.\n";
@ -949,6 +960,13 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
} }
}break; }break;
case BattleState::SELECT_ACTION:
case BattleState::ITEM_SELECT:
case BattleState::GRADE_SELECT:
case BattleState::TARGET_SELECT:
case BattleState::POWER_SELECT:{
BATTLE_ROLLING_COUNTER_WAITTIME=5;
}break;
} }
} }

Loading…
Cancel
Save