diff --git a/C++ProjectTemplate b/C++ProjectTemplate index d194c0b..d9c2abd 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index cfbb2f7..ca69d6d 100644 --- a/main.cpp +++ b/main.cpp @@ -342,7 +342,9 @@ namespace Battle{ Move(std::string name,std::string desc,int baseDmg,int randomDmg,int PPCost,int range,int channelTime,bool friendly,std::arraycomposition,Effect*eff=nullptr,bool pctDamage=false,std::vector> properties={}) :Move(name,desc,0,baseDmg,randomDmg,PPCost,range,channelTime,friendly,composition,eff,pctDamage,properties){}; Move(std::string name,std::string desc,int grade,int baseDmg,int randomDmg,int PPCost,int range,int channelTime,bool friendly,std::arraycomposition,Effect*eff=nullptr,bool pctDamage=false,std::vector> properties={}) - :name(name),grade(grade),PPCost(PPCost),desc(desc),randomDmg(randomDmg),baseDmg(baseDmg),range(range),friendly(friendly),eff(eff),channelTime(channelTime),composition(composition),pctDamage(pctDamage),properties(properties){} + :name(name),grade(grade),PPCost(PPCost),desc(desc),randomDmg(randomDmg),baseDmg(baseDmg),range(range),friendly(friendly),eff(eff),channelTime(channelTime),composition(composition),pctDamage(pctDamage),properties(properties){ + this->channelTime=180; + } }; } @@ -367,6 +369,7 @@ class Entity{ int selectedTarget = 0; Battle::Move*selectedMove = nullptr; //The index of the selected move. int channelTimeRemaining = 0; //The amount of channel time left until move can be performed. + vd2d channelPos = {0,0}; //Where are channel is happening. //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){} @@ -1115,6 +1118,7 @@ goes on a very long time, I hope you can understand this is only for testing pur SELECTED_TARGET=-4; } } 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)); + PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->obj->GetPosWithOrigin(); } else { do { SELECTED_TARGET--; @@ -1122,6 +1126,7 @@ goes on a very long time, I hope you can understand this is only for testing pur SELECTED_TARGET=BATTLE_ENCOUNTER->objs.size()-1; } } while (BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->GetHP()<=0); + PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin(); } for (int i=0;ihighlighted=false; @@ -1141,10 +1146,12 @@ goes on a very long time, I hope you can understand this is only for testing pur SELECTED_TARGET=-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)); + PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->obj->GetPosWithOrigin(); } else { do { SELECTED_TARGET=(SELECTED_TARGET+1)%BATTLE_ENCOUNTER->objs.size(); } while (BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->GetHP()<=0); + PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin(); } for (int i=0;ihighlighted=false; @@ -1311,6 +1318,21 @@ goes on a very long time, I hope you can understand this is only for testing pur for (auto&obj:OBJECTS) { obj->drawn=false; } + if (BATTLE_ENCOUNTER!=nullptr) { + SetDrawTarget(layer::DYNAMIC); + for (int i=0;iselectedMove!=nullptr&&PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->channelTimeRemaining>0&&PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->selectedMove->friendly) { + DrawTargetRangeGrid(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->selectedMove->range, + Pixel(0,128,0,255),Pixel(0,128,0,64),Pixel(90,200,90,64),true); + } + } + for (int i=0;iobjs.size();i++) { + if (BATTLE_ENCOUNTER->objs[i]->selectedMove!=nullptr&&BATTLE_ENCOUNTER->objs[i]->channelTimeRemaining>0&&!BATTLE_ENCOUNTER->objs[i]->selectedMove->friendly) { + DrawTargetRangeGrid(BATTLE_ENCOUNTER->objs[i]->channelPos,BATTLE_ENCOUNTER->objs[i]->selectedMove->range, + Pixel(128,0,0,255),Pixel(128,0,0,64),Pixel(200,90,90,64),true); + } + } + } switch (GAME_STATE) { case GameState::GAME_WORLD:{ DrawGameWorld(); @@ -2887,6 +2909,7 @@ goes on a very long time, I hope you can understand this is only for testing pur do { BATTLE_ENCOUNTER->objs[i]->selectedTarget=rand()%BATTLE_ENCOUNTER->objs.size(); } while (BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[i]->selectedTarget]->GetHP()<=0); + BATTLE_ENCOUNTER->objs[i]->channelPos=BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[i]->selectedTarget]->obj->GetPosWithOrigin(); } else { bool playerAlive=false; for (int i=0;iobjs[i]->selectedTarget=-(rand()%PARTY_MEMBER_COUNT)-1; } while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[i]->selectedTarget-1]]->GetHP()<=0); + BATTLE_ENCOUNTER->objs[i]->channelPos=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[i]->selectedTarget-1]]->obj->GetPosWithOrigin(); printf("Selected Target: %d\n",BATTLE_ENCOUNTER->objs[i]->selectedTarget); } } @@ -3222,7 +3246,7 @@ goes on a very long time, I hope you can understand this is only for testing pur return ents; } - void DrawTargetRangeGrid(vd2d pos,int range) { + void DrawTargetRangeGrid(vd2d pos,int range,Pixel outlinecol,Pixel box1col,Pixel box2col,bool connectedborder) { vi2d gridCenter = (vi2d)pos/32*32; for (int x=-range+1;x=range) { + DrawLineDecal(pos,{pos.x+size.x,pos.y},outlinecol); //Top + DrawLineDecal(pos2,{pos2.x+size2.x,pos2.y},outlinecol); //Top + } + if (abs(x-1)+abs(y)>=range) { + DrawLineDecal({pos.x,pos.y},{pos.x,pos.y+size.y},outlinecol); //Left + DrawLineDecal({pos2.x,pos2.y},{pos2.x,pos2.y+size2.y},outlinecol); //Left + } + if (abs(x)+abs(y+1)>=range) { + DrawLineDecal({pos.x,pos.y+size.y},{pos.x+size.x,pos.y+size.y},outlinecol); //Bottom + DrawLineDecal({pos2.x,pos2.y+size2.y},{pos2.x+size2.x,pos2.y+size2.y},outlinecol); //Bottom + } + if (abs(x+1)+abs(y)>=range) { + DrawLineDecal({pos.x+size.x,pos.y},{pos.x+size.x,pos.y+size.y},outlinecol); //Right + DrawLineDecal({pos2.x+size2.x,pos2.y},{pos2.x+size2.x,pos2.y+size2.y},outlinecol); //Right + } + } } } } } + void DrawTargetRangeGrid(vd2d pos,int range) { + DrawTargetRangeGrid(pos,range,Pixel(abs(cos(M_PI/240*frameCount)*128),200,0,255),Pixel(0,161,255,abs(sin(M_PI/240*frameCount)*32)),Pixel(139,234,255,abs(sin(M_PI/240*frameCount)*64)),false); + } + vi2d grid(int x, int y) { return {x*32,y*32}; }