Enemy ranges

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 2df115153a
commit 09ba8fd78c
  1. BIN
      C++ProjectTemplate
  2. 2
      assets/maps/map0
  3. 1
      encounters.h
  4. 195
      main.cpp

Binary file not shown.

@ -83,4 +83,4 @@ OBJECT160.000000;256.000000;8
ENCOUNTER64.000000;512.000000;90;2 ENCOUNTER64.000000;512.000000;90;2
ENCOUNTER64.000000;256.000000;50;1 ENCOUNTER64.000000;256.000000;50;1
ENCOUNTER192.000000;352.000000;100;1 ENCOUNTER192.000000;352.000000;100;1
ENCOUNTER128.000000;0.000000;25;2 ENCOUNTER480.000000;160.000000;100;3

@ -3,5 +3,6 @@ namespace encounter{
ENCOUNTER_1, ENCOUNTER_1,
ENCOUNTER_2, ENCOUNTER_2,
ENCOUNTER_3, ENCOUNTER_3,
ENCOUNTER_4,
}; };
} }

@ -100,6 +100,7 @@ class Object{
bool temp=false; //If set to true, it's marked for deletion after cutscene handling. bool temp=false; //If set to true, it's marked for deletion after cutscene handling.
bool enc=false; //If set to true, it's not included in the main list of entities for map saving because it's from an encounter. bool enc=false; //If set to true, it's not included in the main list of entities for map saving because it's from an encounter.
bool dead=false; //If set to true, this object was properly part of an Entity and got declared as dead. bool dead=false; //If set to true, this object was properly part of an Entity and got declared as dead.
int blinkFrames=0; //Frame count of how much time is left for the image to be blinking. Used when enemies take damage.
//animationSpd is how long to wait before switching frames. //animationSpd is how long to wait before switching frames.
bool Collision(vd2d pos) { bool Collision(vd2d pos) {
GAME->SetDrawTarget(layer::COLLISION); GAME->SetDrawTarget(layer::COLLISION);
@ -340,9 +341,7 @@ namespace Battle{
Move(std::string name,std::string desc,int baseDmg,int randomDmg,int PPCost,int range,int channelTime,bool friendly,std::array<int,4>composition,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={}) Move(std::string name,std::string desc,int baseDmg,int randomDmg,int PPCost,int range,int channelTime,bool friendly,std::array<int,4>composition,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={})
:Move(name,desc,0,baseDmg,randomDmg,PPCost,range,channelTime,friendly,composition,pctDamage,properties){}; :Move(name,desc,0,baseDmg,randomDmg,PPCost,range,channelTime,friendly,composition,pctDamage,properties){};
Move(std::string name,std::string desc,int grade,int baseDmg,int randomDmg,int PPCost,int range,int channelTime,bool friendly,std::array<int,4>composition,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={}) Move(std::string name,std::string desc,int grade,int baseDmg,int randomDmg,int PPCost,int range,int channelTime,bool friendly,std::array<int,4>composition,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={})
:name(name),grade(grade),PPCost(PPCost),desc(desc),randomDmg(randomDmg),baseDmg(baseDmg),range(range),friendly(friendly),channelTime(channelTime),composition(composition),pctDamage(pctDamage),properties(properties){ :name(name),grade(grade),PPCost(PPCost),desc(desc),randomDmg(randomDmg),baseDmg(baseDmg),range(range),friendly(friendly),channelTime(channelTime),composition(composition),pctDamage(pctDamage),properties(properties){}
this->channelTime=300;
}
}; };
} }
@ -397,7 +396,7 @@ class Entity{
} }
//Adds to the rolling counter target from this health value. //Adds to the rolling counter target from this health value.
void AddHP(int hp) { void AddHP(int hp) {
targetHP=std::clamp(HP+hp,0,maxHP); targetHP=std::clamp(targetHP+hp,0,maxHP);
} }
//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) {
@ -521,6 +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. int BATTLE_ROLLING_COUNTER_WAITTIME = 0; //Number of frames to wait for each rolling counter.
int BATTLE_HIT_SCREENSHAKE = 0; //Amount of time the screen will rapidly shake as getting hit.
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.
@ -955,15 +955,19 @@ goes on a very long time, I hope you can understand this is only for testing pur
}break; }break;
case 1:{ //Attack selected. case 1:{ //Attack selected.
BATTLE_STATE=BattleState::TARGET_SELECT; BATTLE_STATE=BattleState::TARGET_SELECT;
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=MOVELIST[BattleMoveName::BASH];
SetupTargetSelect();
}break; }break;
case 2:{ //Items selected. case 2:{ //Items selected.
BATTLE_STATE=BattleState::ITEM_SELECT; DisplayMessageBox("Not implemented yet.");
//BATTLE_STATE=BattleState::ITEM_SELECT;
}break; }break;
case 3:{ //Defend selected. case 3:{ //Defend selected.
DisplayMessageBox("Not implemented yet."); DisplayMessageBox("Not implemented yet.");
}break; }break;
case 4:{ //Move selected. case 4:{ //Move selected.
BATTLE_STATE=BattleState::MOVE_SELECT; DisplayMessageBox("Not implemented yet.");
//BATTLE_STATE=BattleState::MOVE_SELECT;
}break; }break;
case 5:{ //Run selected. case 5:{ //Run selected.
DisplayMessageBox("Not implemented yet."); DisplayMessageBox("Not implemented yet.");
@ -1044,35 +1048,20 @@ goes on a very long time, I hope you can understand this is only for testing pur
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); 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) { if (ACTIONKEYPRESSED) {
BATTLE_STATE=BattleState::TARGET_SELECT; 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]];
//Set Default Target. SetupTargetSelect();
if (BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->friendly) {
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->GetHP()>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;i<BATTLE_ENCOUNTER->objs.size();i++) {
if (BATTLE_ENCOUNTER->objs[i]->GetHP()>0) {
SELECTED_TARGET=i;
break;
}
}
}
} }
} }
}break; }break;
case BattleState::TARGET_SELECT:{ case BattleState::TARGET_SELECT:{
if (LeftPressed()) { if (LeftPressed()) {
if (BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->friendly) { if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->friendly) {
do { do {
SELECTED_TARGET++; SELECTED_TARGET++;
if (SELECTED_TARGET==0) { if (SELECTED_TARGET==0) {
SELECTED_TARGET=-4; SELECTED_TARGET=-4;
} }
} while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->GetHP()<=0&&!getProperty(Property::REVIVE,BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]])); } while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->GetHP()<=0&&!getProperty(Property::REVIVE,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove));
} else { } else {
do { do {
SELECTED_TARGET--; SELECTED_TARGET--;
@ -1083,13 +1072,13 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
} }
if (RightPressed()) { if (RightPressed()) {
if (BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->friendly) { if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->friendly) {
do { do {
SELECTED_TARGET-=1; SELECTED_TARGET-=1;
if (SELECTED_TARGET<-PARTY_MEMBER_COUNT) { if (SELECTED_TARGET<-PARTY_MEMBER_COUNT) {
SELECTED_TARGET=-1; SELECTED_TARGET=-1;
} }
} while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->GetHP()<=0&&!getProperty(Property::REVIVE,BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]])); } while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->GetHP()<=0&&!getProperty(Property::REVIVE,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove));
} else { } else {
do { do {
SELECTED_TARGET=(SELECTED_TARGET+1)%BATTLE_ENCOUNTER->objs.size(); SELECTED_TARGET=(SELECTED_TARGET+1)%BATTLE_ENCOUNTER->objs.size();
@ -1105,8 +1094,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
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]]->channelTimeRemaining=BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->channelTime; if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove==nullptr) { //We have to check for this because other actions will need a target select and will override this.
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]]; 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]];
}
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelTimeRemaining=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->channelTime;
BATTLE_STATE=BattleState::WAIT; BATTLE_STATE=BattleState::WAIT;
} }
}break; }break;
@ -1175,6 +1166,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
if (GetKey(ESCAPE).bPressed) { if (GetKey(ESCAPE).bPressed) {
GAME_STATE=GameState::OBJ_SELECT; GAME_STATE=GameState::OBJ_SELECT;
} }
if (EDITING_LAYER==layer::ENCOUNTER&&GetMouse(0).bPressed) {
for (int i=0;i<CURRENT_MAP->encounters.size();i++) {
if(CURRENT_MAP->encounters[i]->pos==HIGHLIGHTED_TILE*32) {
EDITING_ENCOUNTER=CURRENT_MAP->encounters[i];
TextEntryEnable(true);
break;
}
}
} else
if (EDITING_LAYER==layer::ENCOUNTER&&GetMouse(0).bPressed) { if (EDITING_LAYER==layer::ENCOUNTER&&GetMouse(0).bPressed) {
LoadEncounter(CURRENT_MAP,HIGHLIGHTED_TILE*32,ENCOUNTER_LIST[ENCOUNTER_SELECTED]->chance,ENCOUNTER_SELECTED,true); LoadEncounter(CURRENT_MAP,HIGHLIGHTED_TILE*32,ENCOUNTER_LIST[ENCOUNTER_SELECTED]->chance,ENCOUNTER_SELECTED,true);
} else } else
@ -1195,15 +1195,6 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
} }
} else } else
if (EDITING_LAYER==layer::ENCOUNTER&&GetMouse(2).bPressed) {
for (int i=0;i<CURRENT_MAP->encounters.size();i++) {
if(CURRENT_MAP->encounters[i]->pos==HIGHLIGHTED_TILE*32) {
EDITING_ENCOUNTER=CURRENT_MAP->encounters[i];
TextEntryEnable(true);
break;
}
}
} else
if (EDITING_LAYER==layer::OBJECT&&GetMouse(0).bPressed) { if (EDITING_LAYER==layer::OBJECT&&GetMouse(0).bPressed) {
AddObjectToWorld(CreateObject(SELECTED_OBJ_ID,HIGHLIGHTED_TILE*32)); AddObjectToWorld(CreateObject(SELECTED_OBJ_ID,HIGHLIGHTED_TILE*32));
} else } else
@ -1402,12 +1393,12 @@ goes on a very long time, I hope you can understand this is only for testing pur
for (int i=0;i<moves.size();i++) { for (int i=0;i<moves.size();i++) {
if (BATTLE_STATE==BattleState::GRADE_SELECT&&POWER_SELECTION_CURSOR[-CURRENT_TURN-1]==counter) { if (BATTLE_STATE==BattleState::GRADE_SELECT&&POWER_SELECTION_CURSOR[-CURRENT_TURN-1]==counter) {
if (POWER_GRADE_CURSOR[-CURRENT_TURN-1]==i) { if (POWER_GRADE_CURSOR[-CURRENT_TURN-1]==i) {
DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade)); DrawFancyStringDecal({8+WIDTH/4+12+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade));
} else { } else {
DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade),DARK_GREY); DrawFancyStringDecal({8+WIDTH/4+12+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade),DARK_GREY);
} }
} else { } else {
DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade)); DrawFancyStringDecal({8+WIDTH/4+12+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade));
} }
} }
} }
@ -1449,35 +1440,50 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
if (BATTLE_STATE!=BattleState::MOVE_CAMERA) { if (BATTLE_STATE!=BattleState::MOVE_CAMERA) {
SetDrawTarget(layer::INTERFACE); SetDrawTarget(layer::INTERFACE);
vi2d screenShakeOffset = {0,0};
cameraPos = BATTLE_ENCOUNTER->pos;
if (BATTLE_HIT_SCREENSHAKE>0) {
BATTLE_HIT_SCREENSHAKE--;
if (BATTLE_HIT_SCREENSHAKE%2==0) {
screenShakeOffset = {0,2};
} else {
screenShakeOffset = {0,-2};
}
}
cameraPos+=screenShakeOffset;
for (int i=0;i<PARTY_MEMBER_COUNT;i++) { 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]];
Object*obj=PARTY_MEMBER_OBJ[i]; Object*obj=PARTY_MEMBER_OBJ[i];
olc::vi2d box = {(128-32*PARTY_MEMBER_COUNT)+i*64,160}; vi2d box = {(128-32*PARTY_MEMBER_COUNT)+i*64,160};
box+=screenShakeOffset;
if (CURRENT_TURN==-i-1) { if (CURRENT_TURN==-i-1) {
box.y-=20; box.y-=20;
} }
drawCheckerboardBox(box,{59,59},olc::Pixel(180,159,194),olc::Pixel(200,179,214),{6,6}); if (CURRENT_TURN>=0&&BATTLE_STATE==BattleState::WAIT_ANIMATION&&BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget==-i-1) {
drawCheckerboardBox(box,{59,59},Pixel(180,159,194),Pixel(200,179,214),{6,6},RED,DARK_RED);
} else {
drawCheckerboardBox(box,{59,59},Pixel(180,159,194),Pixel(200,179,214),{6,6});
}
if (member->selectedMove==nullptr) { if (member->selectedMove==nullptr) {
DrawStringDecal({(float)(box.x+6),(float)(box.y+6)},obj->name,olc::BLACK); DrawStringDecal({(float)(box.x+6),(float)(box.y+6)},obj->name,BLACK);
} else { } else {
DrawStringDecal({(float)(box.x+6),(float)(box.y+4)},obj->name,olc::BLACK,{1,0.8}); DrawStringDecal({(float)(box.x+6),(float)(box.y+4)},obj->name,BLACK,{1,0.8});
} }
DrawPartialDecal({(float)(box.x+4),(float)(box.y+5+8+2)},SPRITES["atbbar_back.png"],{0,0},{member->atb/1000.0*SPRITES["atbbar_back.png"]->sprite->width,SPRITES["atbbar_back.png"]->sprite->height}); DrawPartialDecal({(float)(box.x+4),(float)(box.y+5+8+2)},SPRITES["atbbar_back.png"],{0,0},{member->atb/1000.0*SPRITES["atbbar_back.png"]->sprite->width,SPRITES["atbbar_back.png"]->sprite->height});
DrawDecal({(float)(box.x+4),(float)(box.y+5+8+2)},SPRITES["atbbar_front.png"]); DrawDecal({(float)(box.x+4),(float)(box.y+5+8+2)},SPRITES["atbbar_front.png"]);
if (member->selectedMove!=nullptr) { if (member->selectedMove!=nullptr) {
DrawPartialDecal({(float)(box.x+4),(float)(box.y+5+8+2)},SPRITES["atbbar_back.png"],{0,0},{(1-((float)member->channelTimeRemaining/member->selectedMove->channelTime))*SPRITES["atbbar_back.png"]->sprite->width,SPRITES["atbbar_back.png"]->sprite->height},{1,1},GREEN*0.7); DrawPartialDecal({(float)(box.x+4),(float)(box.y+5+8+2)},SPRITES["atbbar_back.png"],{0,0},{(1-((float)member->channelTimeRemaining/member->selectedMove->channelTime))*SPRITES["atbbar_back.png"]->sprite->width,SPRITES["atbbar_back.png"]->sprite->height},{1,1},GREEN*0.7);
std::wstring label=to_wstring(member->selectedMove->name); std::wstring label=to_wstring(member->selectedMove->name);
label+=L" ";
if (member->selectedMove->grade!=0) { if (member->selectedMove->grade!=0) {
label+=L" ";
label+=member->selectedMove->grade; label+=member->selectedMove->grade;
} }
vd2d textOffset=GetTextSize(to_string(label))*0.6; vd2d textOffset=GetTextSize(to_string(label))*0.6;
textOffset.y+=10; textOffset.y+=10;
textOffset.x+=5;
vd2d barPos = {(float)(box.x+4),(float)(box.y+5+8+2)}; vd2d barPos = {(float)(box.x+4),(float)(box.y+5+8+2)};
DrawFancyStringDecal(barPos-textOffset/2,label,BLACK,{(float)54/GetTextSize(to_string(label)).x,0.6}); DrawFancyStringDecal(barPos-textOffset/2,label,BLACK,{std::min((float)54/GetTextSize(to_string(label)).x,(float)1),0.6});
} }
const olc::vi2d hpTextPos = {box.x+5,box.y+25}; const vi2d hpTextPos = {box.x+5,box.y+25};
for (int x=-1;x<=1;x++) { for (int x=-1;x<=1;x++) {
for (int y=-1;y<=1;y++) { for (int y=-1;y<=1;y++) {
if (x!=0&&y!=0) { if (x!=0&&y!=0) {
@ -1485,9 +1491,9 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
} }
} }
DrawStringDecal(hpTextPos,"HP",olc::BLACK); DrawStringDecal(hpTextPos,"HP",BLACK);
DrawRollingCounter(hpTextPos,member->GetHP(),player_rollhp_display[i],player_rollhp_counter[i]); DrawRollingCounter(hpTextPos,member->GetHP(),player_rollhp_display[i],player_rollhp_counter[i]);
const olc::vi2d mpTextPos = {box.x+5,hpTextPos.y+17}; const vi2d mpTextPos = {box.x+5,hpTextPos.y+17};
for (int x=-1;x<=1;x++) { for (int x=-1;x<=1;x++) {
for (int y=-1;y<=1;y++) { for (int y=-1;y<=1;y++) {
if (x!=0&&y!=0) { if (x!=0&&y!=0) {
@ -1495,7 +1501,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
} }
} }
DrawStringDecal(mpTextPos,"PP",olc::BLACK); DrawStringDecal(mpTextPos,"PP",BLACK);
DrawRollingCounter(mpTextPos,member->PP,player_rollpp_display[i],player_rollpp_counter[i]); DrawRollingCounter(mpTextPos,member->PP,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++) {
@ -1533,8 +1539,13 @@ goes on a very long time, I hope you can understand this is only for testing pur
for (auto&obj:OBJECTS) { for (auto&obj:OBJECTS) {
if (!obj->drawn&&(!obj->dead||EDITING_LAYER==layer::ENCOUNTER)&&obj->GetPos().y+obj->originPoint.y>(y+yTileOffset)*32&&obj->GetPos().y+obj->originPoint.y<=(y+yTileOffset+1)*32) { if (!obj->drawn&&(!obj->dead||EDITING_LAYER==layer::ENCOUNTER)&&obj->GetPos().y+obj->originPoint.y>(y+yTileOffset)*32&&obj->GetPos().y+obj->originPoint.y<=(y+yTileOffset+1)*32) {
obj->drawn=true; obj->drawn=true;
SetDrawTarget(layer::DYNAMIC); if (obj->blinkFrames>0) {
DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(float)((obj->frameIndex%obj->spr->frames)*obj->spr->width),0},{(float)obj->spr->width,(float)obj->spr->spr->sprite->height},obj->GetScale(),obj->color); obj->blinkFrames--;
}
if (obj->blinkFrames==0||obj->blinkFrames>0&&obj->blinkFrames%3==0) {
SetDrawTarget(layer::DYNAMIC);
DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(float)((obj->frameIndex%obj->spr->frames)*obj->spr->width),0},{(float)obj->spr->width,(float)obj->spr->spr->sprite->height},obj->GetScale(),obj->color);
}
} }
} }
for (int x=-1;x<WIDTH/32+2;x++) { for (int x=-1;x<WIDTH/32+2;x++) {
@ -1569,17 +1580,17 @@ goes on a very long time, I hope you can understand this is only for testing pur
vf2d newpos=pos; vf2d newpos=pos;
for (int i=0;i<sText.length();i++) { for (int i=0;i<sText.length();i++) {
if (sText[i]>=128) { if (sText[i]>=128) {
newpos.x+=8*scale.x;
DrawPartialDecal(newpos,SPRITES["additionalFont.png"],additionalChars[sText[i]],{8,8},scale,col); DrawPartialDecal(newpos,SPRITES["additionalFont.png"],additionalChars[sText[i]],{8,8},scale,col);
newpos.x+=8*scale.x;
} else } else
if (sText[i]!='\n') { if (sText[i]!='\n') {
newpos.x+=8*scale.x;
DrawStringDecal(newpos,std::string(1,sText[i]),col,scale); DrawStringDecal(newpos,std::string(1,sText[i]),col,scale);
newpos.x+=8*scale.x;
} else } else
if (sText[i]=='\n') { if (sText[i]=='\n') {
DrawStringDecal(newpos,std::string(1,sText[i]),col,scale);
newpos.x=pos.x; newpos.x=pos.x;
newpos.y+=8*scale.y; newpos.y+=8*scale.y;
DrawStringDecal(newpos,std::string(1,sText[i]),col,scale);
} }
} }
} }
@ -2152,6 +2163,31 @@ goes on a very long time, I hope you can understand this is only for testing pur
MOVELIST[BattleMoveName::TESTMOVE3], MOVELIST[BattleMoveName::TESTMOVE3],
}), }),
}));//ENCOUNTER_3 }));//ENCOUNTER_3
ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_4,{0,0},std::array<vd2d,4>{vd2d
{10,24},{30,24},{50,24},{70,24}},
std::vector<Entity*>{
new Entity(new Object(
NPC1_4,"Test Obj",{170,48},ANIMATIONS["player.png"],{1,1},MAGENTA),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
new Entity(new Object(
NPC1_4,"Test Obj",{200,48},ANIMATIONS["player.png"],{1,1},MAGENTA),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
new Entity(new Object(
NPC1_4,"Test Obj",{100,160},ANIMATIONS["player.png"],{1,1},MAGENTA),
70, 70, 10, 10, 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3],
}),
}));//ENCOUNTER_4
} }
Object* AddObjectToWorld(Object*obj) { Object* AddObjectToWorld(Object*obj) {
@ -2489,7 +2525,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
return newStr; return newStr;
} }
//Returns -1 if not found. //Returns 0 if not found.
int getProperty(Property prop,Battle::Move*move) { int getProperty(Property prop,Battle::Move*move) {
for (int i=0;i<move->properties.size();i++) { for (int i=0;i<move->properties.size();i++) {
std::pair<Property,int> p = move->properties[i]; std::pair<Property,int> p = move->properties[i];
@ -2497,7 +2533,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
return p.second; return p.second;
} }
} }
return -1; return 0;
} }
void HandleBattle() { void HandleBattle() {
@ -2767,11 +2803,17 @@ goes on a very long time, I hope you can understand this is only for testing pur
((PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->randomDmg>0)?rand()%PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->randomDmg:0) ((PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->randomDmg>0)?rand()%PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->randomDmg:0)
+PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->baseAtk; +PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->baseAtk;
std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->obj->name << " dealing " << dmgAmt << " health.\n"; std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->obj->name << " dealing " << dmgAmt << " health.\n";
BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->_SetDirectHP( //Enemies have their health directly set.
BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->GetHP()-dmgAmt for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
); //Enemies have their health directly set. //See if this target is also in range.
if (BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->GetHP()<=0) { vi2d diff=(vi2d)BATTLE_ENCOUNTER->objs[i]->obj->GetPos()/32-(vi2d)BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->obj->GetPos()/32;
BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->obj->dead=true; if (abs(diff.x)+abs(diff.y)<=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->range) {
BATTLE_ENCOUNTER->objs[i]->_SetDirectHP(BATTLE_ENCOUNTER->objs[i]->GetHP()-dmgAmt);
BATTLE_ENCOUNTER->objs[i]->obj->blinkFrames=35;
if (BATTLE_ENCOUNTER->objs[i]->GetHP()<=0) {
BATTLE_ENCOUNTER->objs[i]->obj->dead=true;
}
}
} }
} else { } else {
std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->obj->name << " but it failed.\n"; std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->obj->name << " but it failed.\n";
@ -2795,6 +2837,11 @@ 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;
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";
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);
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]]->GetTargetHP()<0) {
BATTLE_HIT_SCREENSHAKE=75;
} else {
BATTLE_HIT_SCREENSHAKE=25;
}
} 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";
} }
@ -2970,6 +3017,26 @@ goes on a very long time, I hope you can understand this is only for testing pur
} }
} }
} }
void SetupTargetSelect() {
BATTLE_STATE=BattleState::TARGET_SELECT;
//Set Default Target.
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->friendly) {
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->GetHP()>0||getProperty(Property::REVIVE,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
SELECTED_TARGET=-i-1;
break;
}
}
} else {
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
if (BATTLE_ENCOUNTER->objs[i]->GetHP()>0) {
SELECTED_TARGET=i;
break;
}
}
}
}
}; };

Loading…
Cancel
Save