Xenon's Damage Calculator
Hello, I'm Xenon, and I recently made a Damage Calculator in C++ primarily for my own use, but I thought I'll post it here to get some suggestions and of course, you can use it as well if you like it. I have only added the important items and effects that we generally see in the OU environment since we do not usually see much of type boosting items, hustle, slow start or Pokémons holding metronome and so on.
Hello, I'm Xenon, and I recently made a Damage Calculator in C++ primarily for my own use, but I thought I'll post it here to get some suggestions and of course, you can use it as well if you like it. I have only added the important items and effects that we generally see in the OU environment since we do not usually see much of type boosting items, hustle, slow start or Pokémons holding metronome and so on.
Download Now!
The file that you will download is zipped in .rar format, so you will need WinRAR to open it (get it here if you don't have it).
The Pro's and Con's of this Calculator in my Opinion :
Pro's :
1. It is quite user friendly in my opinion, even if you can not use the mouse.
2. The calculator will not ask you for too many inputs and test your patience, since I already mentioned that this calculator is meant only for standard OU battle scenarios and will ask you only for the important values.
3. The calculator will suggest how many more EVs the attacking Pokémon needs to KO the opponent or how many EVs the defending Pokémon needs to survive the attack (i've not seen this feature in most of the calculators, so thought it would be helpful ^^).
An example of how a Zapdos (252 HP/ 0 Def) takes damage from a Gyarados's Stone Edge (1 Dragon Dance, 0 Atk, Adamant) :
The Pro's and Con's of this Calculator in my Opinion :
Pro's :
1. It is quite user friendly in my opinion, even if you can not use the mouse.
2. The calculator will not ask you for too many inputs and test your patience, since I already mentioned that this calculator is meant only for standard OU battle scenarios and will ask you only for the important values.
3. The calculator will suggest how many more EVs the attacking Pokémon needs to KO the opponent or how many EVs the defending Pokémon needs to survive the attack (i've not seen this feature in most of the calculators, so thought it would be helpful ^^).
An example of how a Zapdos (252 HP/ 0 Def) takes damage from a Gyarados's Stone Edge (1 Dragon Dance, 0 Atk, Adamant) :

Con's :
1. Since it is written in C++, it will not look flashy or attractive :(
2. This calculator does not ask for conditions like Burn, Choice Band and Choice Specs even though they are very commonly seen.
The reason behind this :
For burn status, all you have to do is enter -2 in the attacking stat modifier, +1 for Choice Band / Specs. So it is kind of easy to enter those data and i did not find any point in adding one more variable for them.
3. No 2vs2 battle mode, though i plan on adding it in the future versions.
4. For some alignment purposes, i have used Turbo C++, and hence the source code will not work on Dev C++ and many more which do not run on DOS - based screens.
Edit : This calculator does not work on Linux. I'll make some changes to hopefully make it work on Linux by 2 days ^^
The Source Code (phew, 329 lines takes quite some time to type...) :
Well, thats it i guess. Any suggestions on features or making the program more efficient are welcome.
Also, please notify me in case of any errors.
Thank You
1. Since it is written in C++, it will not look flashy or attractive :(
2. This calculator does not ask for conditions like Burn, Choice Band and Choice Specs even though they are very commonly seen.
The reason behind this :
For burn status, all you have to do is enter -2 in the attacking stat modifier, +1 for Choice Band / Specs. So it is kind of easy to enter those data and i did not find any point in adding one more variable for them.
3. No 2vs2 battle mode, though i plan on adding it in the future versions.
4. For some alignment purposes, i have used Turbo C++, and hence the source code will not work on Dev C++ and many more which do not run on DOS - based screens.
Edit : This calculator does not work on Linux. I'll make some changes to hopefully make it work on Linux by 2 days ^^
The Source Code (phew, 329 lines takes quite some time to type...) :
Code:
#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <dos.h>
#include <process.h>
void dcalculator();
void menu();
void introduction()
{
clrscr();
cout<<"\n\n\n\t\t *Xenon's Damage Calculator v2.0*";
cout<<"\n\n\nThis is a Damage calculator based on the damage formula of Pok‚mon Diamond/Pearl";
cout<<"\nAll the conditions in the standard OU environment have been added.";
cout<<"\nMost of the special conditions involving Ditto's metal powder, Pikachu's light\nball and many more scenarios which are not seen in the OU environment have not\nbeen added.";
cout<<"\nIf your Pok‚mon is holding a Choice Band / Choice Specs, just add +1 to your\nattacking status modifiers.";
cout<<"\nThis Program will not work for 2vs2 battles.";
cout<<"\n\n\n\t Thank You for spending your time reading this page ";
cout<<"\n\n\n\nIn case of any errors, please PM me if you are in Smogon, or contact me at\ndarksceptile@live.com";
cout<<"\n\n\n\n\t\tPress any Key to Return to the Menu";
getch();
menu();
}
void cred()
{
clrscr();
cout<<"\n\n\n\t\t *Xenon's Damage Calculator v2.0*";
cout<<"\n\n\n\n\n\n\t\t\t\tCredits\n\n\n";
for(int a=0;a<78;a++)
cout<<"-";
cout<<"\n1. X-Act : For using the D/P formula he posted in Smogon.";
cout<<"\n2. Obi : I wrote this program after i saw him make a Damage Calculator in C++.\n";
for(a=0;a<78;a++)
cout<<"_";
cout<<"\n\n\n\n\t\t Press any Key to Return to the Menu";
getch();
menu();
}
void menu()
{
clrscr();
char ans;
cout<<"\n\n\n\t ##### #### ## ## ### ### ### #### #### ##\n";
cout<<"\t ## ## ###### ## ## ## ### ## ###### ## ## ##\n";
cout<<"\t ## ## ## ## ## ## ### ## # ## ## ## ## ####\n";
cout<<"\t ##### ## ## #### # # ## ## ## ## ## ###\n";
cout<<"\t ## ## ## ## ## #### ## ## ## ## ## ##\n";
cout<<"\t ## ###### ## ## ## ## ## ## ## ## ##\n";
cout<<"\t ## #### ## ## #### ## ## #### ## ##\n";
cout<<"\n\n\n\n\t\t *Xenon's Damage Calculator v1.40*";
cout<<"\n\n\n\n\t\t\t\tMENU";
cout<<"\n\n\t\t";
for(int a=0;a<36;a++)
cout<<"-";
cout<<"\n\t\t| 1. Introduction |";
cout<<"\n\n\t\t| 2. Use Damage Calculator | ";
cout<<"\n\n\t\t| 3. Credits |";
cout<<"\n\n\t\t| 4. Exit |";
cout<<"\n\t\t";
for(a=0;a<36;a++)
cout<<"_";
cout<<"\n\n\t\tInput : ";
cin>>ans;
if(ans=='1')
introduction();
else if(ans=='2')
dcalculator();
else if(ans=='3')
cred();
else if(ans=='4')
{
cout<<"\n\n\tThank You for using Xenon's Damage Calculator v2.00";
getch();
exit(1);
}
else
{
cout<<"\n\n\tWrong Input ! Please Choose Again.";
getch();
menu();
}
}
void dcalculator()
{
clrscr();
int lvl,atk,bp,def,a,mindamage,maxdamage,middamage,critmin,critmax;
float hp,eff,stab,rmin,rmax,pmin,pmax,cmin,cmax,amod,dmod,rl,itm,mod3;
char ch;
rl=1.00;
itm=1.00;
mod3=1.00;
cout<<"\n\n\n\t\t *Xenon's Damage Calculator v2.00*";
cout<<"\n\n\nEnter the level of the attacking Pok‚mon : ";
cin>>lvl;
cout<<"\nEnter the attacking stat of the attacking Pok‚mon: ";
cin>>atk;
cout<<"\nEnter the attacking stat modifier (-6 to +6) : ";
cin>>amod;
if(amod>0)
{
atk*=(1+(amod/2));
}
if(amod<0)
{
atk*=(2/(2-amod));
}
cout<<"\nEnter the Base Power of the move used : ";
cin>>bp;
cout<<"\nIs the move STABed (y or n) ? ";
cin>>ch;
if(ch=='y')
stab=1.5;
else
stab=1;
cout<<"\nEnter the HP of the defending Pok‚mon : ";
cin>>hp;
cout<<"\nEnter the defending stat of the defending Pok‚mon : ";
cin>>def;
cout<<"\nEnter the defending stat modifier (-6 to +6) : ";
cin>>dmod;
if(dmod>0)
{
def=def*(1+(dmod/2));
}
if(dmod<0)
{
def=def*(2/(2-dmod));
}
cout<<"\nEnter how effective is the attack on the opponent ->";
cout<<"\n1. 2x Not Effective\n2. Not Effective\n3. Normal\n4. Super Effective\n5. 2x Super Effective";
cout<<"\nInput : ";
cin>>a;
switch(a)
{
case 1: eff=0.25; break;
case 2: eff=0.50; break;
case 3: eff=1.00; break;
case 4: eff=2.00; break;
case 5: eff=4.00; break;
}
cout<<"\nDo you want to add any more conditions (y or n) ? ";
cin>>ch;
if(ch=='y')
{
cout<<"\nIs Light Screen / Reflect in play (y or n) ? ";
cin>>ch;
if(ch=='y')
rl=0.50;
cout<<"\nIs the attacking Pok‚mon equipped with Life Orb (y or n) ? ";
cin>>ch;
if(ch=='y')
itm=1.30;
cout<<"\nIs the Pok‚mon attacking using an Expert Belt (y or n) ? ";
cin>>ch;
if(ch=='y')
mod3=1.20;
cout<<"\nIs the defending Pok‚mon holding a Resistance Berry (y or n) ? ";
cin>>ch;
if(ch=='y')
mod3=0.50;
}
mindamage=(floor(((floor((floor((floor((floor((lvl*0.40)+2))*bp*atk/50))/def))*rl))+2)*0.85*itm))*eff*stab*mod3;
maxdamage=(floor(((floor((floor((floor((floor((lvl*0.40)+2))*bp*atk/50))/def))*rl))+2)*1.00*itm))*eff*stab*mod3;
critmin=(floor(((floor((floor((floor((floor((lvl*0.40)+2))*bp*atk/50))/def))*rl))+2)*1.70*itm))*eff*stab*mod3;
critmax=(floor(((floor((floor((floor((floor((lvl*0.40)+2))*bp*atk/50))/def))*rl))+2)*2.00*itm))*eff*stab*mod3;
pmin=(mindamage/hp)*100.00;
pmax=(maxdamage/hp)*100.00;
cmin=(critmin/hp)*100.00;
cmax=(critmax/hp)*100.00;
cout<<"\n\n\n\n\t\tProcessing...";
delay(1000);
clrscr();
cout<<"\n\n\n\t\t *Xenon's Damage Calculator v1.40*";
cout<<"\n\nAttacking Pok‚mon\t\t\tDefending Pok‚mon";
cout<<"\n\nLevel : "<<lvl;
gotoxy(41,8);
cout<<"HP : "<<hp;
cout<<"\nAtk / Sp.Atk : "<<atk;
if(amod>0)
cout<<" (after +"<<amod<<")";
if(amod<0)
cout<<" (after -"<<amod<<")";
gotoxy(41,9);
cout<<"Def / Sp.Def : "<<def;
if(dmod>0)
cout<<" (after +"<<dmod<<")";
if(dmod<0)
cout<<" (after -"<<dmod<<")";
cout<<"\nBase Power : "<<bp;
cout<<"\nSTAB : ";
if(ch=='y')
cout<<"Yes";
else
cout<<"No";
gotoxy(41,10);
cout<<"Effectiveness : "<<eff<<"x";
cout<<"\n\n\n\n\n\n\n\n\t\tDamage -> "<<mindamage<<" - "<<maxdamage;
cout<<"\n\t\tWhich is, "<<pmin<<"% - "<<pmax<<"%";
int damagep,damagepm,f=0,k=0,natk,ndef,aev=0,dev=0;
natk=atk;
if(pmax<100.00)
{
while(f!=1)
{
damagep=(floor(((floor((floor((floor((floor((lvl*0.40)+2))*bp*natk/50))/def))*rl))+2)*1.00*itm))*eff*stab*mod3;
damagepm=(floor(((floor((floor((floor((floor((lvl*0.40)+2))*bp*natk/50))/def))*rl))+2)*0.85*itm))*eff*stab*mod3;
if(damagep<hp && k==0)
{
++natk;
aev=aev+4;
}
if(damagepm<hp && k==1)
{
++natk;
aev=aev+4;
}
if(damagepm>=hp && k==1)
{
f=1;
if(aev<=252)
cout<<"\nThe attacking Pok‚mon needs atmost "<<aev<<" more attack EVs to KO the opponent.";
if(aev>252)
cout<<"\n\nThe attacking Pok‚mon might not KO the opponent even with 252 more attack EVs.";
}
if(damagep>=hp && k==0)
{
k=1;
if(aev<=252 && aev!=0)
cout<<"\n\nThe attacking Pok‚mon needs atleast "<<aev<<" more attack EVs to KO the opponent.\n";
if(aev>252)
{
f=1;
cout<<"\n\nThe attacking Pok‚mon will not KO the opponent even with 252 more attack EVs.";
}
}
}
}
f=0;
k=0;
ndef=def;
if(pmax>=100.00)
{
while(f!=1)
{
damagep=(floor(((floor((floor((floor((floor((lvl*0.40)+2))*bp*atk/50))/ndef))*rl))+2)*1.00*itm))*eff*stab*mod3;
damagepm=(floor(((floor((floor((floor((floor((lvl*0.40)+2))*bp*atk/50))/ndef))*rl))+2)*0.85*itm))*eff*stab*mod3;
if(damagepm>=hp && k==0)
{
++ndef;
dev=dev+4;
}
if(damagep>=hp && k==1)
{
++ndef;
dev=dev+4;
}
if(damagep<hp && k==1)
{
f=1;
if(dev<=252)
cout<<"\nThe defending Pok‚mon needs atmost "<<dev<<" more defence EVs to survive the attack.";
if(dev>252)
cout<<"\n\nThe defending Pok‚mon may not survive the attack even with 252 more defence EVs.";
}
if(damagepm<hp && k==0)
{
k=1;
if(dev<=252 && dev!=0)
cout<<"\n\nThe defending Pok‚mon needs atleast "<<dev<<" more defence EVs to survive the attack.\n";
if(dev>252)
{
f=1;
cout<<"\n\nThe defending Pok‚mon won't survive the attack even with 252 more attack EVs.";
}
}
}
}
cout<<"\n\n\t\tCritical Hit -> "<<critmin<<" - "<<critmax;
cout<<"\n\t\tWhich is, "<<cmin<<"% - "<<cmax<<"%";
cout<<"\n\n\n\n\n\n\tDo you want do do more calculations (y or n) ?";
cin>>ch;
if(ch=='y')
dcalculator();
getch();
menu();
}
void main()
{
menu();
}
Also, please notify me in case of any errors.
Thank You