diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 714a038..9f3c53a 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/assets/targetCircle.png b/assets/targetCircle.png new file mode 100644 index 0000000..52e9701 Binary files /dev/null and b/assets/targetCircle.png differ diff --git a/assets/targetRange.png b/assets/targetRange.png new file mode 100644 index 0000000..9991447 Binary files /dev/null and b/assets/targetRange.png differ diff --git a/main.cpp b/main.cpp index 9e4bff5..ff4e5c2 100644 --- a/main.cpp +++ b/main.cpp @@ -263,12 +263,14 @@ enum class Property{ POISON, REGEN, DEFENSE_UP, + REVIVE, }; enum class BattleMoveName{ TESTMOVE1, TESTMOVE2, TESTMOVE3, + BASH, HAILSTORM_A, HAILSTORM_B, HAILSTORM_G, @@ -346,6 +348,7 @@ class Entity{ int atb=0; //When this value reaches 1000, it's this entity's turn. Object* obj; std::vector moveSet; + int selectedTarget = 0; //Used for initializing players. Entity(int HP,int maxHP,int PP,int maxPP,int baseAtk,std::arrayresistances,int speed,std::vectormoveSet,int damageReduction=0,bool smart=false,bool dumb=false) :Entity(nullptr,HP,maxHP,PP,maxPP,baseAtk,resistances,speed,moveSet,damageReduction,smart,dumb){} @@ -459,7 +462,7 @@ public: 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_rollpp_display[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; - int SELECTED_TEST_TARGET=0; + int SELECTED_TARGET=0; //Battle target that is selected. 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 BATTLE_SELECTION_CURSOR=0; @@ -474,6 +477,7 @@ public: }; int POWER_SELECTION_OFFSET[4]={0,0,0,0}; + bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things. @@ -771,9 +775,6 @@ goes on a very long time, I hope you can understand this is only for testing pur } } }break; - case BattleState::SELECT_ACTION:{ - - }break; } } @@ -1271,6 +1272,65 @@ goes on a very long time, I hope you can understand this is only for testing pur if (LeftPressed()) { POWER_GRADE_CURSOR[-CURRENT_TURN-1]=std::clamp(POWER_GRADE_CURSOR[-CURRENT_TURN-1]-1,0,(int)(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]].size())-1); } + if (ACTIONKEYPRESSED) { + BATTLE_STATE=BattleState::TARGET_SELECT; + //Set Default Target. + if (BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->friendly) { + for (int i=0;iHP>0||getProperty(Property::REVIVE,BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]])) { + SELECTED_TARGET=-i-1; + break; + } + } + } else { + for (int i=0;iobjs.size();i++) { + if (BATTLE_ENCOUNTER->objs[i]->HP>0) { + SELECTED_TARGET=i; + break; + } + } + } + } + } + }break; + case BattleState::TARGET_SELECT:{ + if (LeftPressed()) { + if (BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->friendly) { + do { + SELECTED_TARGET++; + if (SELECTED_TARGET==0) { + SELECTED_TARGET=-4; + } + } while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->HP<=0&&!getProperty(Property::REVIVE,BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]])); + } else { + do { + SELECTED_TARGET--; + if (SELECTED_TARGET<0) { + SELECTED_TARGET=BATTLE_ENCOUNTER->objs.size()-1; + } + } while (BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->HP<=0); + } + } + if (RightPressed()) { + if (BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->friendly) { + do { + SELECTED_TARGET-=1; + if (SELECTED_TARGET<-PARTY_MEMBER_COUNT) { + SELECTED_TARGET=-1; + } + } while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->HP<=0&&!getProperty(Property::REVIVE,BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]])); + } else { + do { + SELECTED_TARGET=(SELECTED_TARGET+1)%BATTLE_ENCOUNTER->objs.size(); + } while (BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->HP<=0); + } + } + if (UpPressed()) { + if (BATTLE_SELECTION_CURSOR==0) { //Power was selected, so go back to the powers menu. + BATTLE_STATE = BattleState::GRADE_SELECT; + } else { //This was a standard attack, go back to main menu. + BATTLE_STATE=BattleState::SELECT_ACTION; + } } }break; } @@ -1584,7 +1644,18 @@ goes on a very long time, I hope you can understand this is only for testing pur } } } + if (BATTLE_STATE==BattleState::TARGET_SELECT) { + SetDrawTarget(layer::GROUND); + if (SELECTED_TARGET<0) { + DrawDecal(PARTY_MEMBER_OBJ[-SELECTED_TARGET-1]->GetPos()-cameraPos,SPRITES["targetCircle.png"],{PARTY_MEMBER_OBJ[-SELECTED_TARGET-1]->spr->width/(double)SPRITES["targetCircle.png"]->sprite->width,PARTY_MEMBER_OBJ[-SELECTED_TARGET-1]->spr->spr->sprite->height/(double)SPRITES["targetCircle.png"]->sprite->height},GREEN); + } else { + vd2d scale = {BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->spr->width/(double)SPRITES["targetCircle.png"]->sprite->width,BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->spr->spr->sprite->height/(double)SPRITES["targetCircle.png"]->sprite->height}; + vi2d size = {SPRITES["targetCircle.png"]->sprite->width,SPRITES["targetCircle.png"]->sprite->height}; + DrawDecal(BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPos()+BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->originPoint-cameraPos-size/2*scale,SPRITES["targetCircle.png"],scale,YELLOW); + } + } if (BATTLE_STATE!=BattleState::MOVE_CAMERA) { + SetDrawTarget(layer::INTERFACE); for (int i=0;iproperties.size();i++) { + std::pair p = move->properties[i]; + if (p.first==prop) { + return p.second; + } + } + return -1; + } };