|
|
|
@ -305,6 +305,19 @@ enum class BattleMoveName{ |
|
|
|
|
PKFIRE_O, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
using convert_t = std::codecvt_utf8<wchar_t>; |
|
|
|
|
std::wstring_convert<convert_t, wchar_t> strconverter; |
|
|
|
|
|
|
|
|
|
std::string to_string(std::wstring wstr) |
|
|
|
|
{ |
|
|
|
|
return strconverter.to_bytes(wstr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::wstring to_wstring(std::string str) |
|
|
|
|
{ |
|
|
|
|
return strconverter.from_bytes(str); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
namespace Battle{ |
|
|
|
|
class Move{ |
|
|
|
|
public: |
|
|
|
@ -349,7 +362,7 @@ class Entity{ |
|
|
|
|
Object* obj; |
|
|
|
|
std::vector<Battle::Move*> moveSet; |
|
|
|
|
int selectedTarget = 0; |
|
|
|
|
int selectedMove = -1; //The index of the selected move.
|
|
|
|
|
Battle::Move*selectedMove = nullptr; //The index of the selected move.
|
|
|
|
|
int channelTimeRemaining = 0; //The amount of channel time left until move can be performed.
|
|
|
|
|
//Used for initializing players.
|
|
|
|
|
Entity(int HP,int maxHP,int PP,int maxPP,int baseAtk,std::array<int,4>resistances,int speed,std::vector<Battle::Move*>moveSet,int damageReduction=0,bool smart=false,bool dumb=false) |
|
|
|
@ -478,6 +491,7 @@ public: |
|
|
|
|
{α,0},{β,1},{γ,2},{Ω,3},{Σ,4}, |
|
|
|
|
}; |
|
|
|
|
int POWER_SELECTION_OFFSET[4]={0,0,0,0}; |
|
|
|
|
int BATTLE_ANIMATION_TIMER=0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -750,16 +764,51 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
bool done=false; |
|
|
|
|
for (int i=0;i<4;i++) { |
|
|
|
|
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->atb>=1000) { |
|
|
|
|
printf("%s ready.\n",PARTY_MEMBER_OBJ[i]->name.c_str()); |
|
|
|
|
CURRENT_TURN=-i-1; |
|
|
|
|
BATTLE_STATE=BattleState::SELECT_ACTION; |
|
|
|
|
BATTLE_SELECTION_CURSOR=0; |
|
|
|
|
done=true; |
|
|
|
|
break; |
|
|
|
|
} else { |
|
|
|
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->atb+=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->speed; |
|
|
|
|
if (!done) { |
|
|
|
|
for (int i=0;i<4;i++) { |
|
|
|
|
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->selectedMove!=nullptr) { |
|
|
|
|
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->channelTimeRemaining>0) { |
|
|
|
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->channelTimeRemaining--; |
|
|
|
|
} else { |
|
|
|
|
//Attack is being done.
|
|
|
|
|
printf("%s performs %s.\n",PARTY_MEMBER_OBJ[i]->name.c_str(),PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->selectedMove->name.c_str()); |
|
|
|
|
BATTLE_STATE=BattleState::WAIT_ANIMATION; |
|
|
|
|
BATTLE_ANIMATION_TIMER=0; |
|
|
|
|
CURRENT_TURN=-i-1; |
|
|
|
|
done=true; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!done) { |
|
|
|
|
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) { |
|
|
|
|
if (BATTLE_ENCOUNTER->objs[i]->selectedMove!=nullptr) { |
|
|
|
|
if (BATTLE_ENCOUNTER->objs[i]->channelTimeRemaining>0) { |
|
|
|
|
BATTLE_ENCOUNTER->objs[i]->channelTimeRemaining--; |
|
|
|
|
} else { |
|
|
|
|
CURRENT_TURN=i; |
|
|
|
|
printf("%s performs %s.\n",BATTLE_ENCOUNTER->objs[i]->obj->name.c_str(),BATTLE_ENCOUNTER->objs[i]->selectedMove->name.c_str()); |
|
|
|
|
BATTLE_STATE=BattleState::WAIT_ANIMATION; |
|
|
|
|
BATTLE_ANIMATION_TIMER=0; |
|
|
|
|
done=true; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!done) { |
|
|
|
|
for (int i=0;i<4;i++) { |
|
|
|
|
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->atb>=1000) { |
|
|
|
|
printf("%s ready.\n",PARTY_MEMBER_OBJ[i]->name.c_str()); |
|
|
|
|
CURRENT_TURN=-i-1; |
|
|
|
|
BATTLE_STATE=BattleState::SELECT_ACTION; |
|
|
|
|
BATTLE_SELECTION_CURSOR=0; |
|
|
|
|
done=true; |
|
|
|
|
break; |
|
|
|
|
} else { |
|
|
|
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->atb+=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->speed; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!done) { |
|
|
|
@ -767,7 +816,11 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
if (BATTLE_ENCOUNTER->objs[i]->atb>=1000) { |
|
|
|
|
printf("%s (%d) ready.\n",BATTLE_ENCOUNTER->objs[i]->obj->name.c_str(),i); |
|
|
|
|
CURRENT_TURN=i; |
|
|
|
|
BATTLE_STATE=BattleState::SELECT_ACTION; |
|
|
|
|
//Enemy picks a random move from the movelist. And a random target.
|
|
|
|
|
BATTLE_ENCOUNTER->objs[i]->selectedMove=BATTLE_ENCOUNTER->objs[i]->moveSet[rand()%BATTLE_ENCOUNTER->objs[i]->moveSet.size()]; |
|
|
|
|
BATTLE_ENCOUNTER->objs[i]->channelTimeRemaining=BATTLE_ENCOUNTER->objs[i]->selectedMove->channelTime; |
|
|
|
|
printf(" %s chose move %s.\n",BATTLE_ENCOUNTER->objs[i]->obj->name.c_str(),BATTLE_ENCOUNTER->objs[i]->selectedMove->name.c_str()); |
|
|
|
|
BATTLE_STATE=BattleState::WAIT; |
|
|
|
|
BATTLE_SELECTION_CURSOR=0; |
|
|
|
|
done=true; |
|
|
|
|
break; |
|
|
|
@ -777,6 +830,20 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case BattleState::WAIT_ANIMATION:{ |
|
|
|
|
BATTLE_ANIMATION_TIMER++; |
|
|
|
|
if (BATTLE_ANIMATION_TIMER>120) { |
|
|
|
|
//Turn's done!
|
|
|
|
|
if (CURRENT_TURN<0) { |
|
|
|
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=nullptr; |
|
|
|
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->atb=0; |
|
|
|
|
BATTLE_STATE=BattleState::WAIT; |
|
|
|
|
} else { |
|
|
|
|
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove=nullptr; |
|
|
|
|
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->atb=0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1334,6 +1401,12 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
BATTLE_STATE=BattleState::SELECT_ACTION; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (ACTIONKEYPRESSED) { |
|
|
|
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget=SELECTED_TARGET; |
|
|
|
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelTimeRemaining=BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->channelTime; |
|
|
|
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]; |
|
|
|
|
BATTLE_STATE=BattleState::WAIT; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1588,7 +1661,7 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
vd2d descBoxPos = {WIDTH-(int)(WIDTH/2.5)-2,1}; |
|
|
|
|
vi2d textStartingOffset = {4,4}; |
|
|
|
|
DrawDialogBox(descBoxPos,{(int)(WIDTH/2.5),HEIGHT/4},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128)); |
|
|
|
|
DrawStringPropDecal(descBoxPos+textStartingOffset,Wrap(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][0]->desc,{((int)(WIDTH/2.5-8))/0.8,(HEIGHT/4-8)/0.8},true),WHITE,{0.8,0.8}); |
|
|
|
|
DrawStringPropDecal(descBoxPos+textStartingOffset,Wrap(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][0]->desc,((int)(WIDTH/2.5-8)),true,{0.8,0.8}),WHITE,{0.8,0.8}); |
|
|
|
|
vd2d ppCostBoxPos = {WIDTH-WIDTH/3-2,HEIGHT/4+2}; |
|
|
|
|
DrawDialogBox(ppCostBoxPos,{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128)); |
|
|
|
|
DrawStringPropDecal(ppCostBoxPos+textStartingOffset,"PP Cost",WHITE,{0.7,0.8}); |
|
|
|
@ -1662,6 +1735,16 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
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::WAIT_ANIMATION) { |
|
|
|
|
SetDrawTarget(layer::INTERFACE); |
|
|
|
|
std::wstring label=L""; |
|
|
|
|
if (CURRENT_TURN<0) { |
|
|
|
|
label=to_wstring(PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name)+L" uses "+to_wstring(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name)+L" "+((PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade!=0)?std::wstring(1,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade):L""); |
|
|
|
|
} else { |
|
|
|
|
label=to_wstring(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name)+L" uses "+to_wstring(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name)+L" "+((BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade!=0)?std::wstring(1,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade):L""); |
|
|
|
|
} |
|
|
|
|
//DrawFancyStringDecal({2,2},Wrap(label,ScreenWidth()-2,false,{2,2}),WHITE,{2,2});
|
|
|
|
|
} |
|
|
|
|
if (BATTLE_STATE!=BattleState::MOVE_CAMERA) { |
|
|
|
|
SetDrawTarget(layer::INTERFACE); |
|
|
|
|
for (int i=0;i<PARTY_MEMBER_COUNT;i++) { |
|
|
|
@ -2632,9 +2715,13 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
CAMERA_WAIT_TIMER=0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string Wrap(std::string str,vd2d size,bool proportional) { |
|
|
|
|
std::string Wrap(std::string str,int width,bool proportional,vd2d scale) { |
|
|
|
|
return to_string(Wrap(to_wstring(str),width,proportional,scale)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::wstring Wrap(std::wstring str,int width,bool proportional,vd2d scale) { |
|
|
|
|
int marker=0; |
|
|
|
|
std::string newStr=""; |
|
|
|
|
std::wstring newStr=L""; |
|
|
|
|
bool firstChar=false; |
|
|
|
|
while (marker<str.length()) { |
|
|
|
|
if (firstChar||!firstChar&&str[marker]!=' ') { |
|
|
|
@ -2642,11 +2729,11 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
} |
|
|
|
|
vd2d siz; |
|
|
|
|
if (proportional) { |
|
|
|
|
siz=GetTextSizeProp(newStr); |
|
|
|
|
siz={GetTextSizeProp(to_string(newStr)).x*scale.x,GetTextSizeProp(to_string(newStr)).y*scale.y}; |
|
|
|
|
} else { |
|
|
|
|
siz=GetTextSize(newStr); |
|
|
|
|
siz={GetTextSize(to_string(newStr)).x*scale.x,GetTextSize(to_string(newStr)).y*scale.y}; |
|
|
|
|
} |
|
|
|
|
if (siz.x>size.x) { |
|
|
|
|
if (siz.x>width) { |
|
|
|
|
do { |
|
|
|
|
if (newStr[newStr.length()-1]!=' ') { |
|
|
|
|
marker--; |
|
|
|
|