Rolling PP counter implemented and refactored

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent bb7bea1fac
commit 89c480ceab
  1. BIN
      C++ProjectTemplate
  2. BIN
      assets/pixel.png
  3. 28
      encounters.h
  4. 1
      layers.h
  5. 274
      main.cpp

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

@ -20,10 +20,10 @@ class Entity{
private: private:
int HP=0; int HP=0;
int targetHP=0; int targetHP=0;
public:
int maxHP=0;
int PP=0; int PP=0;
int targetPP=0; int targetPP=0;
public:
int maxHP=0;
int maxPP=0; int maxPP=0;
std::array<int,4>resistances={0,0,0,0}; std::array<int,4>resistances={0,0,0,0};
int speed=0; int speed=0;
@ -60,10 +60,22 @@ class Entity{
int GetHP() { int GetHP() {
return HP; return HP;
} }
//Get the PP that the rolling counter is moving towards.
int GetTargetPP() {
return targetPP;
}
//Gets the current actual pp of the target.
int GetPP() {
return PP;
}
//Sets the rolling counter target to this health value. //Sets the rolling counter target to this health value.
void SetTargetHP(int hp) { void SetTargetHP(int hp) {
targetHP=hp; targetHP=hp;
} }
//Sets the rolling counter target to this pp value.
void SetTargetPP(int pp) {
targetPP=pp;
}
//Subtracts from the rolling counter target from this health value. //Subtracts from the rolling counter target from this health value.
void SubtractHP(int hp) { void SubtractHP(int hp) {
targetHP-=hp; targetHP-=hp;
@ -72,10 +84,22 @@ class Entity{
void AddHP(int hp) { void AddHP(int hp) {
targetHP=std::clamp(targetHP+hp,0,maxHP); targetHP=std::clamp(targetHP+hp,0,maxHP);
} }
//Subtracts from the rolling counter target from this pp value.
void SubtractPP(int pp) {
targetPP=std::clamp(targetPP-pp,0,maxPP);
}
//Adds to the rolling counter target from this pp value.
void AddPP(int pp) {
targetPP=std::clamp(targetPP+pp,0,maxPP);
}
//THIS IS FOR SPECIAL USE CASES ONLY! Normally you want to touch the rolling counter amount instead using SetTargetHP()! //THIS IS FOR SPECIAL USE CASES ONLY! Normally you want to touch the rolling counter amount instead using SetTargetHP()!
void _SetDirectHP(int hp) { void _SetDirectHP(int hp) {
HP=hp; HP=hp;
} }
//THIS IS FOR SPECIAL USE CASES ONLY! Normally you want to touch the rolling counter amount instead using SetTargetPP()!
void _SetDirectPP(int pp) {
PP=pp;
}
}; };
class Encounter{ class Encounter{

@ -3,7 +3,6 @@
namespace layer{ namespace layer{
enum layer{ enum layer{
INTERFACE2, //The highest layer, even better than the interface layer.
INTERFACE, //Interface items should be on this layer. On top of everything. INTERFACE, //Interface items should be on this layer. On top of everything.
COLLISION, //Collision checking layer. This layer is COLLISION, //Collision checking layer. This layer is
HIGH, HIGH,

@ -202,7 +202,7 @@ public:
{ {
srand(time(NULL)); srand(time(NULL));
GAME=this; GAME=this;
for (int i=1;i<7;i++) { for (int i=1;i<6;i++) {
CreateLayer(); CreateLayer();
EnableLayer(i,true); EnableLayer(i,true);
} }
@ -279,8 +279,6 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
keyUpdates(); keyUpdates();
SetDrawTarget(nullptr); SetDrawTarget(nullptr);
Clear(BLANK); Clear(BLANK);
SetDrawTarget(layer::INTERFACE);
Clear(BLANK);
SetDrawTarget(layer::COLLISION); SetDrawTarget(layer::COLLISION);
if (EDITING_LAYER!=layer::COLLISION) { if (EDITING_LAYER!=layer::COLLISION) {
Clear(MAGENTA); Clear(MAGENTA);
@ -429,15 +427,15 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
switch (j) { switch (j) {
case 0:{ case 0:{
player_rollhp_display[i][j]=member->GetHP()%10; player_rollhp_display[i][j]=member->GetHP()%10;
player_rollpp_display[i][j]=member->PP%10; player_rollpp_display[i][j]=member->GetPP()%10;
}break; }break;
case 1:{ case 1:{
player_rollhp_display[i][j]=member->GetHP()/10%10; player_rollhp_display[i][j]=member->GetHP()/10%10;
player_rollpp_display[i][j]=member->PP/10%10; player_rollpp_display[i][j]=member->GetPP()/10%10;
}break; }break;
case 2:{ case 2:{
player_rollhp_display[i][j]=member->GetHP()/100%10; player_rollhp_display[i][j]=member->GetHP()/100%10;
player_rollpp_display[i][j]=member->PP/100%10; player_rollpp_display[i][j]=member->GetPP()/100%10;
}break; }break;
} }
} }
@ -857,6 +855,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} }
if (ACTIONKEYPRESSED) { if (ACTIONKEYPRESSED) {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget=SELECTED_TARGET; PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget=SELECTED_TARGET;
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->SubtractPP(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->PPCost);
ConfirmPlayerTargetSelection(); ConfirmPlayerTargetSelection();
BATTLE_STATE=BattleState::WAIT; BATTLE_STATE=BattleState::WAIT;
} }
@ -1223,7 +1222,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if (BATTLE_ENCOUNTER!=nullptr) { if (BATTLE_ENCOUNTER!=nullptr) {
SetDrawTarget(layer::HIGH); SetDrawTarget(layer::HIGH);
if (BATTLE_STATE==BattleState::SELECT_ACTION||BATTLE_STATE==BattleState::POWER_SELECT||BATTLE_STATE==BattleState::GRADE_SELECT||BATTLE_STATE==BattleState::ITEM_SELECT) { if (BATTLE_STATE==BattleState::SELECT_ACTION||BATTLE_STATE==BattleState::POWER_SELECT||BATTLE_STATE==BattleState::GRADE_SELECT||BATTLE_STATE==BattleState::ITEM_SELECT) {
DrawDialogBox({1,1},{(int)(WIDTH*0.75),HEIGHT/6},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128)); DrawDialogBox({1,1},{(int)(WIDTH*0.75),HEIGHT/6},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
const std::string labels[6]={"Power","Attack","Item","Defend","Move","Run"}; const std::string labels[6]={"Power","Attack","Item","Defend","Move","Run"};
for (int i=0;i<6;i+=2) { for (int i=0;i<6;i+=2) {
DrawStringPropDecal({static_cast<float>(3+8+i/2*64),9},labels[i]); DrawStringPropDecal({static_cast<float>(3+8+i/2*64),9},labels[i]);
@ -1233,35 +1232,38 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} }
if (BATTLE_STATE==BattleState::POWER_SELECT||BATTLE_STATE==BattleState::GRADE_SELECT) { if (BATTLE_STATE==BattleState::POWER_SELECT||BATTLE_STATE==BattleState::GRADE_SELECT) {
SetDrawTarget(layer::INTERFACE); SetDrawTarget(layer::INTERFACE);
DrawDialogBox({1,1},{(int)(WIDTH/2),HEIGHT/4},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128)); DrawDialogBox({1,1},{(int)(WIDTH/2),HEIGHT/4},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
vd2d descBoxPos = {WIDTH-(int)(WIDTH/2.5)-2,1}; vd2d descBoxPos = {WIDTH-(int)(WIDTH/2.5)-2,1};
vi2d textStartingOffset = {4,4}; 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)); DrawDialogBox(descBoxPos,{(int)(WIDTH/2.5),HEIGHT/4},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
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}); 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}; 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)); DrawDialogBox(ppCostBoxPos,{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawStringPropDecal(ppCostBoxPos+textStartingOffset,"PP Cost",WHITE,{0.7,0.8}); DrawStringPropDecal(ppCostBoxPos+textStartingOffset,"PP Cost",WHITE,{0.7,0.8});
std::string label = std::to_string(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->PPCost); std::string label = std::to_string(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->PPCost);
DrawStringPropDecal({static_cast<float>(ppCostBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*1.5),static_cast<float>(ppCostBoxPos.y+textStartingOffset.y+8)},label,WHITE,{1.5,1.5}); DrawStringPropDecal({static_cast<float>(ppCostBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*1.5),static_cast<float>(ppCostBoxPos.y+textStartingOffset.y+8)},label,WHITE,{1.5,1.5});
vd2d damageBoxPos = {WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+2}; vd2d damageBoxPos = {WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+2};
DrawDialogBox({WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+2},{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawStringPropDecal(damageBoxPos+textStartingOffset,"Damage",WHITE,{0.7,0.8}); DrawStringPropDecal(damageBoxPos+textStartingOffset,"Damage",WHITE,{0.7,0.8});
label = (BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->baseDmg!=0)?std::to_string(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->baseDmg+PARTY_MEMBER_STATS[-CURRENT_TURN-1]->baseAtk)+"~"+std::to_string(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->randomDmg+BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->baseDmg+PARTY_MEMBER_STATS[-CURRENT_TURN-1]->baseAtk):"N/A"; label = (BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->baseDmg!=0)?std::to_string(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->baseDmg+PARTY_MEMBER_STATS[-CURRENT_TURN-1]->baseAtk)+"~"+std::to_string(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->randomDmg+BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->baseDmg+PARTY_MEMBER_STATS[-CURRENT_TURN-1]->baseAtk):"N/A";
DrawStringPropDecal({static_cast<float>(damageBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5))),static_cast<float>(damageBoxPos.y+textStartingOffset.y+8)},label,WHITE,{static_cast<float>(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5)),1.5}); DrawStringPropDecal({static_cast<float>(damageBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5))),static_cast<float>(damageBoxPos.y+textStartingOffset.y+8)},label,WHITE,{static_cast<float>(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5)),1.5});
DrawDialogBox({WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+2},{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128));
vd2d rangeBoxPos = {WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+HEIGHT/8+3}; vd2d rangeBoxPos = {WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+HEIGHT/8+3};
DrawDialogBox({WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+HEIGHT/8+3},{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawStringPropDecal(rangeBoxPos+textStartingOffset,"Range",WHITE,{0.7,0.8}); DrawStringPropDecal(rangeBoxPos+textStartingOffset,"Range",WHITE,{0.7,0.8});
label = std::to_string(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->range); label = std::to_string(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->range);
DrawStringPropDecal({static_cast<float>(rangeBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5))),static_cast<float>(rangeBoxPos.y+textStartingOffset.y+8)},label,WHITE,{static_cast<float>(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5)),1.5}); DrawStringPropDecal({static_cast<float>(rangeBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5))),static_cast<float>(rangeBoxPos.y+textStartingOffset.y+8)},label,WHITE,{static_cast<float>(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5)),1.5});
DrawDialogBox({WIDTH-WIDTH/3+WIDTH/6-1,HEIGHT/4+HEIGHT/8+3},{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128));
vd2d channelTimeBoxPos = {WIDTH-WIDTH/3-1,HEIGHT/4+HEIGHT/8+3}; vd2d channelTimeBoxPos = {WIDTH-WIDTH/3-1,HEIGHT/4+HEIGHT/8+3};
DrawDialogBox({WIDTH-WIDTH/3-1,HEIGHT/4+HEIGHT/8+3},{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawStringPropDecal(channelTimeBoxPos+textStartingOffset,"Cast",WHITE,{0.7,0.8}); DrawStringPropDecal(channelTimeBoxPos+textStartingOffset,"Cast",WHITE,{0.7,0.8});
label = std::to_string((float)BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->channelTime/60).erase(3); label = std::to_string((float)BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->channelTime/60).erase(3);
DrawStringPropDecal({static_cast<float>(channelTimeBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5))),static_cast<float>(channelTimeBoxPos.y+textStartingOffset.y+8)},label,WHITE,{static_cast<float>(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5)),1.5}); DrawStringPropDecal({static_cast<float>(channelTimeBoxPos.x+textStartingOffset.x+(WIDTH/6)-8-GetTextSizeProp(label).x*(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5))),static_cast<float>(channelTimeBoxPos.y+textStartingOffset.y+8)},label,WHITE,{static_cast<float>(std::min((double)((WIDTH/6)-8)/GetTextSizeProp(label).x,1.5)),1.5});
DrawDialogBox({WIDTH-WIDTH/3-1,HEIGHT/4+HEIGHT/8+3},{(int)(WIDTH/6),HEIGHT/8},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128));
int counter=0; int counter=0;
int displayLimit=0; int displayLimit=0;
for (int i=0;i<BATTLE_MOVELIST_DISPLAY.size();i++) { for (int i=0;i<BATTLE_MOVELIST_DISPLAY.size();i++) {
@ -1302,25 +1304,6 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} }
} }
} }
if (BATTLE_STATE==BattleState::ITEM_SELECT) {
SetDrawTarget(layer::INTERFACE2);
DrawDecal({static_cast<float>(8+(ITEM_SELECTION_CURSOR)%2*(WIDTH-8)/2),static_cast<float>(12*((ITEM_SELECTION_CURSOR-ITEM_SELECTION_OFFSET)/2)+8)},SPRITES["cursor.png"]);
DrawDialogBox({4,4},{(int)(WIDTH-8),(int)(HEIGHT/2)},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128));
DrawDialogBox({(int)(WIDTH*(3.0F/8)),HEIGHT/2+4},{(int)(WIDTH*(5.0F/8)-4),(int)(HEIGHT/4)},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128));
DrawStringPropDecal({(int)(WIDTH*(3.0F/8))+4,HEIGHT/2+8},Wrap(PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->description,(int)(WIDTH*(5.0F/8))-4,true,{1,1}));
for (int i=0;i<18;i++) {
if (ITEM_SELECTION_OFFSET+i<PARTY_INVENTORY.size()) {
DrawStringDecal({static_cast<float>(16+i%2*(WIDTH-8)/2),static_cast<float>(12*(i/2)+8)},PARTY_INVENTORY[ITEM_SELECTION_OFFSET+i]->name);
}
}
if (ITEM_SELECTION_OFFSET>0) {
DrawRotatedDecal({WIDTH-20,8},SPRITES["cursor.png"],-M_PI_2,{4,4});
}
if (ITEM_SELECTION_OFFSET+18<PARTY_INVENTORY.size()) {
DrawRotatedDecal({WIDTH-20,4+HEIGHT/2-4},SPRITES["cursor.png"],M_PI_2,{4,4});
}
SetDrawTarget(layer::INTERFACE);
}
if (BATTLE_STATE==BattleState::TARGET_SELECT) { if (BATTLE_STATE==BattleState::TARGET_SELECT) {
SetDrawTarget(layer::GROUND); SetDrawTarget(layer::GROUND);
if (SELECTED_TARGET<0) { if (SELECTED_TARGET<0) {
@ -1423,7 +1406,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} }
} }
DrawStringDecal(mpTextPos,"PP",BLACK); DrawStringDecal(mpTextPos,"PP",BLACK);
DrawRollingCounter(mpTextPos,member->PP,player_rollpp_display[i],player_rollpp_counter[i]); DrawRollingCounter(mpTextPos,member->GetPP(),player_rollpp_display[i],player_rollpp_counter[i]);
} }
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) { for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
Entity*obj = BATTLE_ENCOUNTER->objs[i]; Entity*obj = BATTLE_ENCOUNTER->objs[i];
@ -1444,6 +1427,23 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} }
} }
} }
if (BATTLE_STATE==BattleState::ITEM_SELECT) {
DrawDialogBox({4,4},{(int)(WIDTH-8),(int)(HEIGHT/2)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawDialogBox({(int)(WIDTH*(3.0F/8)),HEIGHT/2+4},{(int)(WIDTH*(5.0F/8)-4),(int)(HEIGHT/4)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawDecal({static_cast<float>(8+(ITEM_SELECTION_CURSOR)%2*(WIDTH-8)/2),static_cast<float>(12*((ITEM_SELECTION_CURSOR-ITEM_SELECTION_OFFSET)/2)+8)},SPRITES["cursor.png"]);
DrawStringPropDecal({(int)(WIDTH*(3.0F/8))+4,HEIGHT/2+8},Wrap(PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->description,(int)(WIDTH*(5.0F/8))-4,true,{1,1}));
for (int i=0;i<18;i++) {
if (ITEM_SELECTION_OFFSET+i<PARTY_INVENTORY.size()) {
DrawStringDecal({static_cast<float>(16+i%2*(WIDTH-8)/2),static_cast<float>(12*(i/2)+8)},PARTY_INVENTORY[ITEM_SELECTION_OFFSET+i]->name);
}
}
if (ITEM_SELECTION_OFFSET>0) {
DrawRotatedDecal({WIDTH-20,8},SPRITES["cursor.png"],-M_PI_2,{4,4});
}
if (ITEM_SELECTION_OFFSET+18<PARTY_INVENTORY.size()) {
DrawRotatedDecal({WIDTH-20,4+HEIGHT/2-4},SPRITES["cursor.png"],M_PI_2,{4,4});
}
}
} }
//////////////////INTERFACE LAYER. //////////////////INTERFACE LAYER.
@ -1469,7 +1469,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
DrawStringPropDecal(numb->pos-cameraPos-textSize/2,(numb->damage>=0)?"-"+std::to_string(numb->damage):"+"+std::to_string(-numb->damage),Pixel(255,255,255,abs(sin((M_PI*frameCount)/30)*128)),{1,2}); DrawStringPropDecal(numb->pos-cameraPos-textSize/2,(numb->damage>=0)?"-"+std::to_string(numb->damage):"+"+std::to_string(-numb->damage),Pixel(255,255,255,abs(sin((M_PI*frameCount)/30)*128)),{1,2});
} }
if (messageBoxVisible) { if (messageBoxVisible) {
DrawDialogBox({1,1},{WIDTH/2,HEIGHT/4},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128)); DrawDialogBox({1,1},{WIDTH/2,HEIGHT/4},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawStringPropDecal({6,6},messageBoxText); DrawStringPropDecal({6,6},messageBoxText);
} }
for (int i=0;i<PARTICLES.size();i++) { for (int i=0;i<PARTICLES.size();i++) {
@ -1918,6 +1918,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
CreateSprite("targetRange.png"); CreateSprite("targetRange.png");
CreateSprite("crosshair.png"); CreateSprite("crosshair.png");
CreateSprite("arrow_connector.png"); CreateSprite("arrow_connector.png");
CreateSprite("pixel.png");
} }
void SetupObjectInfo() { void SetupObjectInfo() {
@ -2294,14 +2295,14 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} }
void DrawDialogBox(const vi2d &pos, const vi2d &size, Pixel p = WHITE, Pixel p2 = DARK_GREY, Pixel p3 = VERY_DARK_GREY) { void DrawDialogBox(const vi2d &pos, const vi2d &size, Pixel p = WHITE, Pixel p2 = DARK_GREY, Pixel p3 = VERY_DARK_GREY) {
FillRect({(int)pos.x,(int)pos.y},size,p2); DrawDecal({(float)pos.x,(float)pos.y},SPRITES["pixel.png"],size,p2);
FillRect({(int)pos.x+1,(int)pos.y+1},{(int)size.x-2,(int)size.y-2},p); DrawDecal({(float)pos.x+1,(float)pos.y+1},SPRITES["pixel.png"],{(float)size.x-2,(float)size.y-2},p);
FillRect({(int)pos.x+2,(int)pos.y+2},{(int)size.x-4,(int)size.y-4},p3); DrawDecal({(float)pos.x+2,(float)pos.y+2},SPRITES["pixel.png"],{(float)size.x-4,(float)size.y-4},p3);
FillRect({(int)pos.x+3,(int)pos.y+3},{(int)size.x-5,(int)size.y-5},p); DrawDecal({(float)pos.x+3,(float)pos.y+3},SPRITES["pixel.png"],{(float)size.x-5,(float)size.y-5},p);
Draw({pos.x,pos.y},Pixel(77, 51, 125)); DrawDecal({(float)pos.x,(float)pos.y},SPRITES["pixel.png"],{1,1},Pixel(77, 51, 125));
Draw({pos.x+size.x-1,pos.y+size.y-1},Pixel(77, 51, 125)); DrawDecal({(float)(pos.x+size.x-1),(float)(pos.y+size.y-1)},SPRITES["pixel.png"],{1,1},Pixel(77, 51, 125));
Draw({pos.x+size.x-1,pos.y},Pixel(77, 51, 125)); DrawDecal({(float)(pos.x+size.x-1),(float)(pos.y)},SPRITES["pixel.png"],{1,1},Pixel(77, 51, 125));
Draw({pos.x,pos.y+size.y-1},Pixel(77, 51, 125)); DrawDecal({(float)(pos.x),(float)(pos.y+size.y-1)},SPRITES["pixel.png"],{1,1},Pixel(77, 51, 125));
} }
void StartCutscene(Cutscene*cutscene) { void StartCutscene(Cutscene*cutscene) {
@ -2414,7 +2415,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
for (int i=0;i<ENCOUNTER_LIST[id]->objs.size();i++) { for (int i=0;i<ENCOUNTER_LIST[id]->objs.size();i++) {
Entity*ent=ENCOUNTER_LIST[id]->objs[i]; Entity*ent=ENCOUNTER_LIST[id]->objs[i];
Object*newObj=new Object(ent->obj->id,ent->obj->name,ent->obj->GetPos(),ent->obj->spr,ent->obj->GetScale(),ent->obj->color,ent->obj->animationSpd,ent->obj->temp); Object*newObj=new Object(ent->obj->id,ent->obj->name,ent->obj->GetPos(),ent->obj->spr,ent->obj->GetScale(),ent->obj->color,ent->obj->animationSpd,ent->obj->temp);
ents.push_back(new Entity(newObj,ent->GetHP(),ent->maxHP,ent->PP,ent->maxPP,ent->baseAtk,ent->resistances,ent->speed,ent->moveSet,ent->inventory,ent->equipment,ent->damageReduction,ent->smart,ent->dumb)); ents.push_back(new Entity(newObj,ent->GetHP(),ent->maxHP,ent->GetPP(),ent->maxPP,ent->baseAtk,ent->resistances,ent->speed,ent->moveSet,ent->inventory,ent->equipment,ent->damageReduction,ent->smart,ent->dumb));
} }
Encounter*data=new Encounter(id,pos,ENCOUNTER_LIST[id]->playerPos,ents,chance); Encounter*data=new Encounter(id,pos,ENCOUNTER_LIST[id]->playerPos,ents,chance);
data->chance=chance; data->chance=chance;
@ -2539,88 +2540,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} }
} }
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 (player_rollhp_counter[i][0]<=0&&player_rollwait_counter[i]==0) { HandleRollingCounters(i,player_rollhp_counter,player_rollhp_display,member,member->maxHP,member->GetHP(),member->GetTargetHP());
player_rollhp_display[i][0]--; HandleRollingCounters(i,player_rollpp_counter,player_rollpp_display,member,member->maxPP,member->GetPP(),member->GetTargetPP(),true);
player_rollhp_counter[i][0]=13;
member->_SetDirectHP(member->GetHP()-1);
if (player_rollhp_display[i][0]<0) {
player_rollhp_display[i][0]=9;
player_rollhp_counter[i][0]=13;
player_rollhp_display[i][1]--;
player_rollhp_counter[i][1]=13;
if (player_rollhp_display[i][1]<0) {
player_rollhp_display[i][1]=9;
player_rollhp_counter[i][1]=13;
player_rollhp_display[i][2]--;
player_rollhp_counter[i][2]=13;
}
}
}
if (player_rollhp_counter[i][0]>0) {
if (member->GetTargetHP()<-member->maxHP) {
player_rollhp_counter[i][0]-=HEALTH_ROLLING_SPEED+(member->maxHP-member->GetTargetHP())/10;
} else
if (member->GetTargetHP()<0) {
player_rollhp_counter[i][0]-=HEALTH_ROLLING_SPEED+(member->maxHP-member->GetTargetHP())/20;
} else {
player_rollhp_counter[i][0]-=HEALTH_ROLLING_SPEED;
}
}
if (player_rollhp_counter[i][1]>0) {
player_rollhp_counter[i][1]--;
}
if (player_rollhp_counter[i][2]>0) {
player_rollhp_counter[i][2]--;
}
} else
if (member->GetHP()<member->GetTargetHP()) {
if (player_rollhp_counter[i][0]>=0&&player_rollwait_counter[i]==0) {
player_rollhp_display[i][0]++;
player_rollhp_counter[i][0]=-13;
member->_SetDirectHP(member->GetHP()+1);
if (player_rollhp_display[i][0]>9) {
player_rollhp_display[i][0]=0;
player_rollhp_counter[i][0]=-13;
player_rollhp_display[i][1]++;
player_rollhp_counter[i][1]=-13;
if (player_rollhp_display[i][1]>9) {
player_rollhp_display[i][1]=0;
player_rollhp_counter[i][1]=-13;
player_rollhp_display[i][2]++;
player_rollhp_counter[i][2]=-13;
}
}
}
if (player_rollhp_counter[i][0]<0) {
player_rollhp_counter[i][0]+=HEALTH_ROLLING_SPEED;
}
if (player_rollhp_counter[i][1]<0) {
player_rollhp_counter[i][1]++;
}
if (player_rollhp_counter[i][2]<0) {
player_rollhp_counter[i][2]++;
}
} else {
if (player_rollhp_counter[i][0]<0) {
player_rollhp_counter[i][0]++;
}
if (player_rollhp_counter[i][1]<0) {
player_rollhp_counter[i][1]++;
}
if (player_rollhp_counter[i][2]<0) {
player_rollhp_counter[i][2]++;
}
if (player_rollhp_counter[i][0]>0) {
player_rollhp_counter[i][0]--;
}
if (player_rollhp_counter[i][1]>0) {
player_rollhp_counter[i][1]--;
}
if (player_rollhp_counter[i][2]>0) {
player_rollhp_counter[i][2]--;
}
}
if (player_rollwait_counter[i]==0) { if (player_rollwait_counter[i]==0) {
player_rollwait_counter[i]=BATTLE_ROLLING_COUNTER_WAITTIME*13; player_rollwait_counter[i]=BATTLE_ROLLING_COUNTER_WAITTIME*13;
@ -2888,6 +2810,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} else { } else {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->SetTargetHP(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->GetHP()); PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->SetTargetHP(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->GetHP());
} }
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->_SetDirectPP(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->GetTargetPP());
} }
} }
} }
@ -3318,6 +3241,107 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} }
} }
} }
void HandleRollingCounters(int i,int(&counter)[4][3],int(&display)[4][3],Entity*member,int maxVal,int currentVal,int targetVal,bool pp=false) {
if (currentVal>std::clamp(targetVal,0,targetVal)) {
if (counter[i][0]<=0&&player_rollwait_counter[i]==0) {
display[i][0]--;
counter[i][0]=13;
if (!pp) {
member->_SetDirectHP(currentVal-1);
} else {
member->_SetDirectPP(currentVal-1);
}
if (display[i][0]<0) {
display[i][0]=9;
counter[i][0]=13;
display[i][1]--;
counter[i][1]=13;
if (display[i][1]<0) {
display[i][1]=9;
counter[i][1]=13;
display[i][2]--;
counter[i][2]=13;
}
}
}
if (counter[i][0]>0) {
if (targetVal<-maxVal) {
counter[i][0]-=HEALTH_ROLLING_SPEED+(maxVal-targetVal)/10;
} else
if (targetVal<0) {
counter[i][0]-=HEALTH_ROLLING_SPEED+(maxVal-targetVal)/20;
} else {
if (!pp) {
counter[i][0]-=HEALTH_ROLLING_SPEED;
} else {
counter[i][0]-=HEALTH_ROLLING_SPEED*5;
}
}
}
if (counter[i][1]>0) {
counter[i][1]--;
}
if (counter[i][2]>0) {
counter[i][2]--;
}
} else
if (currentVal<targetVal) {
if (counter[i][0]>=0&&player_rollwait_counter[i]==0) {
display[i][0]++;
counter[i][0]=-13;
if (!pp) {
member->_SetDirectHP(currentVal+1);
} else {
member->_SetDirectPP(currentVal+1);
}
if (display[i][0]>9) {
display[i][0]=0;
counter[i][0]=-13;
display[i][1]++;
counter[i][1]=-13;
if (display[i][1]>9) {
display[i][1]=0;
counter[i][1]=-13;
display[i][2]++;
counter[i][2]=-13;
}
}
}
if (counter[i][0]<0) {
if (!pp) {
counter[i][0]+=HEALTH_ROLLING_SPEED;
} else {
counter[i][0]+=HEALTH_ROLLING_SPEED*5;
}
}
if (counter[i][1]<0) {
counter[i][1]++;
}
if (counter[i][2]<0) {
counter[i][2]++;
}
} else {
if (counter[i][0]<0) {
counter[i][0]++;
}
if (counter[i][1]<0) {
counter[i][1]++;
}
if (counter[i][2]<0) {
counter[i][2]++;
}
if (counter[i][0]>0) {
counter[i][0]--;
}
if (counter[i][1]>0) {
counter[i][1]--;
}
if (counter[i][2]>0) {
counter[i][2]--;
}
}
}
}; };

Loading…
Cancel
Save