generated from sigonasr2/CPlusPlusProjectTemplate
Ranges for all attacks. Removed 1 from range to make single target attacks proper.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
09ba8fd78c
commit
75cc08c316
Binary file not shown.
68
main.cpp
68
main.cpp
@ -2196,6 +2196,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
PARTY_MEMBER_OBJ[0]=obj;
|
||||
PARTY_MEMBER_ID[0]=0;
|
||||
PARTY_MEMBER_OBJ[0]->name="PLAYER";
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[0]]->obj=PARTY_MEMBER_OBJ[0];
|
||||
for (int i=toint(Flag::HAS_MAIN)+1;i<=toint(Flag::HAS_POO);i++) {
|
||||
if (GetGameFlag(i)) {
|
||||
PARTY_MEMBER_ID[PARTY_MEMBER_COUNT]=toint(PLAYER)+i-toint(Flag::HAS_MAIN);
|
||||
@ -2209,6 +2210,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
case 5:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="KING";}break;
|
||||
case 6:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="POO";}break;
|
||||
}
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[PARTY_MEMBER_COUNT]]->obj=PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT];
|
||||
PARTY_MEMBER_COUNT++;
|
||||
if (PARTY_MEMBER_COUNT==4) {
|
||||
break;
|
||||
@ -2792,8 +2794,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
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;
|
||||
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 " << PARTY_MEMBER_OBJ[-PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget-1]->name << " recovering " << healAmt << " health.\n";
|
||||
PARTY_MEMBER_STATS[-PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget-1]->AddHP(healAmt);
|
||||
for (auto&ent:GetEntitiesInRange(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
|
||||
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 " << ent->obj->name << " recovering " << healAmt << " health.\n";
|
||||
ent->AddHP(healAmt);
|
||||
}
|
||||
} 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 " << PARTY_MEMBER_OBJ[-PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget-1]->name << " but it failed.\n";
|
||||
}
|
||||
@ -2802,19 +2806,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
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;
|
||||
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";
|
||||
//Enemies have their health directly set.
|
||||
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->GetPos()/32-(vi2d)BATTLE_ENCOUNTER->objs[PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget]->obj->GetPos()/32;
|
||||
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;
|
||||
}
|
||||
for (auto&ent:GetEntitiesInRange(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
|
||||
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 " << ent->obj->name << " dealing " << dmgAmt << " health.\n";
|
||||
ent->_SetDirectHP(ent->GetHP()-dmgAmt);
|
||||
ent->obj->blinkFrames=35;
|
||||
if (ent->GetHP()<=0) {
|
||||
ent->obj->dead=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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";
|
||||
}
|
||||
@ -2825,8 +2825,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
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;
|
||||
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 " << BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget]->obj->name << " recovering " << healAmt << " health.\n";
|
||||
BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget]->AddHP(healAmt);
|
||||
for (auto&ent:GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove)) {
|
||||
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 " << ent->obj->name << " recovering " << healAmt << " health.\n";
|
||||
ent->AddHP(healAmt);
|
||||
}
|
||||
} 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 " << BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget]->obj->name << " but it failed.\n";
|
||||
}
|
||||
@ -2835,12 +2837,14 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
for (auto&ent:GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove)) {
|
||||
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 " << ent->obj->name << " dealing " << dmgAmt << " health.\n";
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget-1]]->SubtractHP(dmgAmt);
|
||||
if (ent->GetTargetHP()<0) {
|
||||
BATTLE_HIT_SCREENSHAKE=75;
|
||||
} else {
|
||||
BATTLE_HIT_SCREENSHAKE=25;
|
||||
}
|
||||
}
|
||||
} 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";
|
||||
@ -3037,6 +3041,28 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Entity*> GetEntitiesInRange(int targetEnt,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]->GetPos()/32-(vi2d)PARTY_MEMBER_OBJ[-targetEnt-1]->GetPos()/32;
|
||||
if (abs(diff.x)+abs(diff.y)<=move->range-1) {
|
||||
ents.push_back(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]);
|
||||
}
|
||||
}
|
||||
} 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->GetPos()/32-(vi2d)BATTLE_ENCOUNTER->objs[targetEnt]->obj->GetPos()/32;
|
||||
if (abs(diff.x)+abs(diff.y)<=move->range-1) {
|
||||
ents.push_back(BATTLE_ENCOUNTER->objs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ents;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user