Fix up default target selection channel position range

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 9a509bf76f
commit 6474c724b9
  1. BIN
      C++ProjectTemplate
  2. 22
      main.cpp

Binary file not shown.

@ -1134,7 +1134,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
BATTLE_ENCOUNTER->objs[i]->obj->highlighted=false;
}
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
ent->obj->highlighted=true;
}
}
@ -1159,7 +1159,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
BATTLE_ENCOUNTER->objs[i]->obj->highlighted=false;
}
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
ent->obj->highlighted=true;
}
}
@ -2954,7 +2954,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
if (CURRENT_TURN<0) {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->friendly) {
if (PARTY_MEMBER_STATS[-PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget-1]->GetHP()>0) {
for (auto&ent:GetEntitiesInRange(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
for (auto&ent:GetEntitiesInRange(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
int healAmt = PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->baseDmg+
((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;
@ -2972,7 +2972,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
} else {
if (BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->GetHP()>0) {
//Enemies have their health directly set.
for (auto&ent:GetEntitiesInRange(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
for (auto&ent:GetEntitiesInRange(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
int dmgAmt = PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->baseDmg+
((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;
@ -2993,7 +2993,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
} else {
if (BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->friendly) {
if (BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget]->GetHP()>0) {
for (auto&ent:GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove)) {
for (auto&ent:GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->channelPos,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove)) {
int healAmt = BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->baseDmg+
((rand()%BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->randomDmg>0)?rand()%BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->randomDmg:0)
+BATTLE_ENCOUNTER->objs[CURRENT_TURN]->baseAtk;
@ -3008,7 +3008,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
} else {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]]->GetHP()>0) {
for (auto&ent:GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove)) {
for (auto&ent:GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->channelPos,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove)) {
int dmgAmt = BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->baseDmg+
((rand()%BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->randomDmg>0)?rand()%BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->randomDmg:0)
+BATTLE_ENCOUNTER->objs[CURRENT_TURN]->baseAtk;
@ -3211,6 +3211,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
break;
}
}
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->obj->GetPosWithOrigin();
} else {
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
if (BATTLE_ENCOUNTER->objs[i]->GetHP()>0) {
@ -3218,18 +3219,19 @@ goes on a very long time, I hope you can understand this is only for testing pur
break;
}
}
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin();
}
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
ent->obj->highlighted=true;
}
}
std::vector<Entity*> GetEntitiesInRange(int targetEnt,Battle::Move*move) {
std::vector<Entity*> GetEntitiesInRange(int targetEnt, vd2d channelPos, Battle::Move*move) {
std::vector<Entity*>ents;
if (targetEnt<0) {
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
//See if this target is also in range.
vi2d diff=(vi2d)PARTY_MEMBER_OBJ[i]->GetPosWithOrigin()/32-(vi2d)PARTY_MEMBER_OBJ[-targetEnt-1]->GetPosWithOrigin()/32;
vi2d diff=(vi2d)PARTY_MEMBER_OBJ[i]->GetPosWithOrigin()/32-(vi2d)channelPos/32;
if (abs(diff.x)+abs(diff.y)<=move->range-1) {
ents.push_back(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]);
}
@ -3237,7 +3239,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
} else {
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
//See if this target is also in range.
vi2d diff=(vi2d)BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()/32-(vi2d)BATTLE_ENCOUNTER->objs[targetEnt]->obj->GetPosWithOrigin()/32;
vi2d diff=(vi2d)BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()/32-(vi2d)channelPos/32;
if (abs(diff.x)+abs(diff.y)<=move->range-1) {
ents.push_back(BATTLE_ENCOUNTER->objs[i]);
}

Loading…
Cancel
Save