Hope your ready :P

/* THIS PROGRAM IS INCOMPLETE!!
PLEASE DON'T CORRECT THE EMPTY FUNCTIONS!!
Thanks,
Spartan118*/




#include <iostream>
#include <string>
#include <windows.h>
#include "H:\profile\desktop\rawrr\lvp\random.h"
#include "H:\profile\desktop\rawrr\lvp\conio.h"
#include <fstream>
using namespace std;
void combat()
{
	randomize();
	string object;
	cout << "Entering combat." << endl;
	cout << "You are behind " << object;
	int rnddmg = random(100) +1;
	if ((rnddmg >= 1)||(rnddmg < 26))
		object = "a Wall";
	else if ((rnddmg >= 26)||(rnddmg < 51))
		object = "air";
}



void damagecalculation (string enemyHas, int enemyHealth, double enemyShields, int enemyArmour, 
						double dmg, double speed, int eShields, string playerHas, string playerhas, int playerShields,
						int playerHealth, int playerArmour, int pShields, string enemy, string munition,
						string enemyhas)
{
	double totaldamage, totalshields;
	if ((enemyHas == "Armour")&&(enemyhas == "Armour"))
	{
		totaldamage = (enemyArmour - dmg);
		if (dmg > enemyArmour)
			totaldamage = (enemyArmour + enemyHealth - dmg);
		if (enemyHealth > 100)
			enemyArmour = (enemyHealth - 100);
		if ((enemy == "Battle Droid")||(enemy == "Super Battle Droid")||(enemy == "Destroyer Droid")&&(munition == "Bullets"))
			totaldamage = (totaldamage - 100);
		else if ((enemy == "Battle Droid")||(enemy == "Super Battle Droid")||(enemy == "Destroyer Droid")&&(munition == "Plasma"))
		{
			totaldamage = (totaldamage + 100);
			cout << "The enemy has melted!!" << endl;
		}
	}			
	//************************
	
	if ((enemyHas == "Shields")&&(enemyhas == "Shields"))
	{
		totaldamage = (enemyShields - dmg); //Damage impacts shields before armour
		if ((enemyShields == 0)||(enemyShields < totaldamage)) //if the enemies shields are less than the total damage done
		{
			totaldamage = (enemyShields + enemyArmour - dmg); //Program adds armour to shield value and depletes armour
			if (enemyShields > eShields)
			{
				totalshields = (enemyShields - eShields);
				enemyShields = totalshields; //Shield value becomes remainder
			}
		}
	}
	if ((enemyArmour == 0)&&(enemyShields == 0)) //enemy death
	{
		totaldamage = (enemyHealth - dmg);
		if (enemyHealth == 0)
			cout << "Enemy Defeated." << endl;
	}
	//**************************

	if ((playerHas == "Armour")||(playerhas == "Armour"))
	{
		totaldamage = (playerArmour - dmg);
		if (dmg > playerArmour)	
		{
			totaldamage = (playerArmour + playerHealth - dmg);
			if (playerHealth > 100)
				playerArmour = (playerHealth - 100);
		}
	}
	if ((playerHas == "Shields")||(playerhas == "Shields"))
	{
		totaldamage = (playerShields - dmg); //Damage impacts shields before armour
		if ((playerShields == 0)||(playerShields < totaldamage)) //if the enemies shields are less than the total damage done
		{
			totaldamage = (playerShields + playerArmour - dmg); //Program adds armour to shield value and depletes armour
			if (enemyShields > eShields)
			{
				totalshields = (playerShields - pShields);
				playerShields = totalshields; //Shield value becomes remainder
			}
		}
	}
}
void Encounter (string enemy, string enemyHas, string enemyhas, string playerHas, string playerhas, int playerShields,
				int pShields, string munition, int enemyHealth, int enemyShields, int enemyArmour, double dmg,
				double speed, int eShields, int playerHealth, int playerArmour)
{	
	randomize();
	int enemychance = random(100) +1;
	if ((enemychance >= 1)||(enemychance < 26))
		enemy = "Super Battle Droid";
	else if ((enemychance >= 26)||(enemychance < 37))
		enemy = "Destroyer Droid";
	else if ((enemychance >= 37)||(enemychance < 41))
		enemy = "Jedi";
	else if ((enemychance >= 41)||(enemychance < 45))
		enemy = "Sith";
	else if ((enemychance >= 45)||(enemychance < 71))
		enemy = "Clone Trooper, Elite";
	else if ((enemychance >= 72)||(enemychance <= 100))
	{
		randomize();
		int rrk = random(100) +1;
		if((rrk >= 1)||(rrk < 51))
			enemy = "Battle Droid";
		else if((rrk >= 51)||(rrk <= 100))
			enemy = "Clone Trooper, Regular";
	}


	damagecalculation(enemyHas, enemyHealth, enemyShields, enemyArmour, dmg, speed, eShields, playerHas, playerShields,
						playerHealth, playerhas, playerArmour, pShields, enemy, munition, enemyhas);
}

void enemyStats(double dmg, double speed, string enemyHas, string enemyhas)
{
	string enemy;
	int enemyShields, enemyArmour, enemyHealth;
	int eShields;
	if (enemy == "Clone Trooper, Regular")
	{
		enemyShields = 25;
		eShields = 25;
		enemyArmour = 100;
		enemyHealth = 50;
		enemyHas = "Shields";
		enemyhas = "Armour";
		dmg = 15;
		speed = 25;
	}
	else if (enemy == "Clone Trooper, Elite")
	{
		enemyShields = 40;
		eShields = 40;
		enemyArmour = 105;
		enemyHealth = 75;
		enemyHas = "Shields";
		enemyhas = "Armour";
	}
	else if (enemy == "Battle Droid")
	{
		enemyShields = 0;
		eShields = 0;
		enemyArmour = 130;
		enemyHealth = 25;
		enemyHas = "Armour";
	}
			
}



void CharacterStats (int specialcharacter, string playerHas, string playerhas)
{
	int playerHealth, playerArmour, playerShields, pShields;
	char a;
	if (specialcharacter == 2)
	{
		do
		{
			cout << "You chose the Master Chief" << endl;
			cout << "Stats: " << endl;
			cout << "*****" << endl;
			playerHealth = 100;
			playerArmour = 150;
			playerShields = 175;
			pShields = 175;
			playerHas = ("Shields");
			playerhas = ("Armour");
			cout << playerHealth << ", " << playerArmour << ", " << playerShields << ", your character has " << playerHas << ", Your character also has " << playerhas << endl;
			cout << "Is this the character you wish to choose? ";
			cin >> a;
		} while ((a == 'y')||(a == 'Y'));
	}
	if (specialcharacter == 3)
	{
		cout << "You have selected the Arbiter." << endl;
		cout << "Stats" << endl;
		cout << "*****" << endl;
		playerHealth = 105;
		playerArmour = 115;
		playerShields = 180;
		pShields = 180;
		playerHas = ("Shields");
		playerhas = ("Armour");
	//enemyStats();
	}
}

void WepStats (string Weapon, string Weapon2, string Weapon3)
{
	string grenadethrow;
	string munition;
	int maxGrenades;
	int startGrenades;
	int maxClip; /*Clips you can hold*/ int maxShell; //Shotgun-Specific
	int maxClipSize; /*Rounds per Clip*/ int maxShellSize; //Shotgun-Specific
	int battery; //Battery size (plasma weapons only)
	int dmg; //Damage per shot
	int speed; // Rate of Fire
	if (Weapon == "MA37 Assault Rifle")
	{
		dmg = 30; maxClip = 11;
		speed = 40; maxClipSize = 32;
		munition = "Bullets";
	}
	if (Weapon == "Type-25 Plasma Rifle")
	{
		dmg = 40; battery = 100;
		speed = 30; munition = "Plasma";
	}
	if (Weapon == "M45 TS Shotgun")
	{
		dmg = 20; maxShell = 24;
		speed = 10; maxShellSize = 6;
	}
	if (Weapon == "Surface-to-Surface Rocket Launcher")
	{
		dmg = 90; maxClip = 6; //Six rockets
		cout << "Game Over" << endl;
		speed = 10; maxClipSize = 2; //2 rockets per clip
		munition = "Rockets";
	}
	if (Weapon == "Type-33 Fuel Rod Cannon")
	{
		dmg = 69; maxClip = 25;
		speed = 15; maxClipSize = 5; //125 Fuel Rod shots
		munition = "Fuel Rods";
	}
	if (Weapon == "Model 6 Spartan Laser")
	{
		dmg = 95; battery = 100;
		//Overheat();
		//Charge();
		speed = 50;
		munition = "Laser";
	}
	if (Weapon == "SRS99D-AM Sniper Rifle")
	{
		dmg = 50; maxClip = 25;
		speed = 25; maxClipSize = 4;
		munition = "Bullets";
	}
	if (Weapon == "M392 DMR")
	{
		dmg = 25; maxClip = 48;
		speed = 30; maxClipSize = 12;
		munition = "Bullets";
	}
	if (Weapon2 == "M6G Sidearm")
	{
		dmg = 60; maxClip = 4;
		speed = 32; maxClipSize = 8;
		munition = "Bullets";
	}
	if (Weapon2 == "Type-25 Plasma Pistol")
	{
		dmg = 40; battery = 100;
		speed = 32;
		munition = "Plasma";
	}
	if (Weapon3 == "Frag Grenades")
	{
		dmg = 50;
		maxGrenades = 3;
		startGrenades = 2;
	}
	if (Weapon3 == "Plasma Grenades")
	{
		dmg = 50;
		if (grenadethrow == "Stick")
			dmg = 100;
	}
	//CharacterStats(specialcharacter);
}
void SpecialCharacter (int choosecharacter, string playerHas, string playerhas)
{
	int specialcharacter;
	string Weapon;
	string Weapon2;
	string Weapon3;
	char ans;
	cout << "Choose your special Character: " << endl;
	cout << "1. Duck Dodgers" << endl;
	cout << "2. Master Chief, SPARTAN-117" << endl;
	cout << "3. Thel 'Vadme, the Arbiter" << endl;
	cin >> specialcharacter;
	if ((specialcharacter == 2)||(specialcharacter == 3))
	{
		CharacterStats (specialcharacter, playerHas, playerhas);
		do
		{
			int kyprs;
			int kyprs2;
			int kyprs3;
			system("cls");
			cout << "Choose your primary weapon: " << endl;
			Sleep(1500);
			cout << "Assault Weapons" << endl;
			cout << "***********" << endl;
			cout << "1. MA37 Assault System" << endl;
			cout << "2. Type-25 Directed Energy Rifle (Plasma Rifle)" << endl;
			cout << endl;
			Sleep(1500);
			cout << "Close-Assault Weapons" << endl;
			cout << "***********" << endl;
			cout << "3. M45 TS Close Assault System" << endl;
			cout << endl;
			Sleep(1500);
			cout << "Heavy Weapons" << endl;
			cout << "***********" << endl;
			cout << "4. Surface-to-Surface Rocket, Medium Anti-Vehicle/Assault Weapon" << endl;
			cout << "5. Type-33 Guided Munitions Launcher" << endl;
			cout << "6. Weapon/Anti-Vehicle Model 6 Grindell/Galilean Nonlinear Rifle" << endl;
			cout << endl;
			Sleep(1500);
			cout << "Long Range" << endl;
			cout << "***********" << endl;
			cout << "7. Sniper Rifle System 99d Anti-Materiel" << endl;
			cout << "8. M392 Designated Marksman Rifle" << endl;
			cout << endl;
			cout << "--> ";
			cin >> kyprs;
			system("cls");
			if (kyprs == 1)
				Weapon = "MA37 Assault Rifle";
			else if (kyprs == 2)
				Weapon = "Type-25 Plasma Rifle";
			else if (kyprs == 3)
				Weapon = "M45 TS Shotgun";
			else if (kyprs == 4)
				Weapon = "Surface-to-Surface Rocket Launcher";
			else if (kyprs == 5)
				Weapon = "Type-33 Fuel Rod Cannon";
			else if (kyprs == 6)
				Weapon = "Model 6 Spartan Laser";
			else if (kyprs == 7)
				Weapon = "SRS99D-AM Sniper Rifle";
			else if (kyprs == 8)
				Weapon = "M392 DMR";
				Sleep(1500);
				cout << "Choose a secondary weapon: " << endl;
				cout << "Sidearms" << endl;
				cout << "******" << endl;
				cout << "1. M6G Personal Defence Weapon System" << endl;
				cout << "2. Type-25 Directed Energy Pistol" << endl;
				cout << endl;
				cout << "--> ";
				cin >> kyprs2;
				Sleep(1500);
				system("cls");
				if (kyprs2 == 1)
					Weapon2 = "M6G Sidearm";
				else if (kyprs == 2)
					Weapon2 = "Type-25 Plasma Pistol";
				Sleep(1500);
				cout << "Choose a grenade: " << endl;
				cout << "1. M9 High-Explosive Dual-Purpose Grenade" << endl;
				cout << "2. Type-1 Antipersonnel Grenade" << endl;
				cout << endl;
				cout << "--> ";
				cin >> kyprs3;
				system("cls");
				if (kyprs3 == 1)
					Weapon3 = "Frag Grenades";
				else if (kyprs3 == 2)
					Weapon3 = "Plasma Grenades";
				Sleep(1500);
				cout << "The weapons you have chosen are: " << endl << "Primary Weapon: " << Weapon << endl;
				cout << "Secondary Weapon: " << Weapon2 << endl; 
				cout <<  "Grenades: " << Weapon3 << endl;
				cout << "Is this correct? " << endl;
				cout << "--> ";
				cin >> ans;
		} while ((ans == 'n')||(ans == 'N'));
		if ((ans == 'Y')||(ans == 'y'))
		{
			WepStats(Weapon, Weapon2, Weapon3);
		}
	}
}

void ChooseCharacter (int choosecharacter, string playerHas, string playerhas)
{
	cout << "Choose your character: " << endl;
	cout << "1. Han Solo" << endl;
	cout << "2. Darth Vader" << endl;
	cout << "3. Random Character" << endl;
	cout << "4. Special Character" << endl;
	cin >> choosecharacter;
	if (choosecharacter == 4)
		SpecialCharacter(choosecharacter, playerHas, playerhas);
}





void playerAction (string Weapon, string Weapon2, string Weapon3, string enemyHas, int enemyHealth, int enemyShields, 
				   int enemyArmour, double dmg, double speed, int eShields, string playerHas, int playerShields, 
				   int playerHealth, int playerArmour, int pShields)
{
	int grenadethrow;
	string playeraction;
	WepStats(Weapon, Weapon2, Weapon3);
	randomize();
	int grenade = random(100) +1;
	if ((grenade >= 1)||(grenade <= 100)&&(Weapon3 == "Frag Grenades"))
	{	
		grenadethrow = 50;
		playeraction = "Using Grenade";
	}
	else if ((grenade >=1)||(grenade < 75)&&(Weapon3 == "Plasma Grenade"))
	{
		grenadethrow = 50;
		playeraction = "Using Grenade";
	}
	else if ((grenade >= 75)||(grenade <=100)&&(Weapon3 == "Plasma Grenade"))
	{
		grenadethrow = 100;
		playeraction = "Stuck!";
	}
}
//*********************



void finalcutscene()
{
}
void finalboss()
{
	finalcutscene();
}
void finallevel()
{
	finalboss();
}
void secondlastCutscene()
{
	finallevel();
}
void lvl3()
{
	secondlastCutscene();
}

void levelthree()
{
	lvl3();
}

void cutscene3()
{
	levelthree();
}



void lvl2 ()
{
	cutscene3();
}

void leveltwo()
{
}


void cutscene2()
{

	leveltwo();
}
void lvl1 () //Level one functions
{
	cutscene2();
}


void levelone (string Weapon, string Weapon2, string Weapon3, string enemyHas, int enemyHealth, int enemyShields, 
			   int enemyArmour, double dmg, double speed, int eShields, string playerHas, int playerShields, 
			   int playerHealth, int playerArmour, int pShields) //the actual level
{
	//Encounter();
	playerAction(Weapon, Weapon2, Weapon3, enemyHas, enemyHealth, enemyShields,
				 enemyArmour, dmg, speed, eShields, playerHas, playerShields,
				 playerHealth, playerArmour, pShields);
	lvl1();
}
void CutsceneOne(string Weapon, string Weapon2, string Weapon3, string enemyHas, int enemyHealth, int enemyShields, 
			     int enemyArmour, double dmg, double speed, int eShields, string playerHas, int playerShields, 
			     int playerHealth, int playerArmour, int pShields)
{


	levelone(Weapon, Weapon2, Weapon3, enemyHas, enemyHealth, enemyShields,
			 enemyArmour, dmg, speed, eShields, playerHas, playerShields,
			 playerHealth, playerArmour, pShields);
}



void openCutscene(string Weapon, string Weapon2, string Weapon3, string enemyHas, int enemyHealth, int enemyShields, 
			   int enemyArmour, double dmg, double speed, int eShields, string playerHas, int playerShields, 
			   int playerHealth, int playerArmour, int pShields)
{




	CutsceneOne(Weapon, Weapon2, Weapon3, enemyHas, enemyHealth, enemyShields,
				 enemyArmour, dmg, speed, eShields, playerHas, playerShields,
				 playerHealth, playerArmour, pShields);
}

int main (int choosecharacter, string playerHas, string playerhas)
{
	ChooseCharacter(choosecharacter, playerHas, playerhas);
	return 0;
}
//©Copywrite spartan118©, any unauthorized distribution of this code WILL RESULT in persecution to the fullest extent of the law.

The one SINGLE error I can't fix is:

functions.cpp(119) : error C2664: 'damagecalculation' : cannot convert parameter 9 from 'int' to 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'

Oh and this is a project (game) using text so any suggestions would be pro =D

spartan118

The error is pretty detailed. Somewhere in the damagecalculation function you're trying to assign an integer to a string object. Check the function call to and verify your types.

Edited 6 Years Ago by Narue: n/a

void damagecalculation (string enemyHas, int enemyHealth, double enemyShields, int enemyArmour, 
						double dmg, double speed, int eShields, string playerHas, string playerhas, int playerShields,
						int playerHealth, int playerArmour, int pShields, string enemy, string munition,
						string enemyhas)
{
	double totaldamage, totalshields;
	if ((enemyHas == "Armour")&&(enemyhas == "Armour"))
	{
		totaldamage = (enemyArmour - dmg);
		if (dmg > enemyArmour)
			totaldamage = (enemyArmour + enemyHealth - dmg);
		if (enemyHealth > 100)
			enemyArmour = (enemyHealth - 100);
		if ((enemy == "Battle Droid")||(enemy == "Super Battle Droid")||(enemy == "Destroyer Droid")&&(munition == "Bullets"))
			totaldamage = (totaldamage - 100);
		else if ((enemy == "Battle Droid")||(enemy == "Super Battle Droid")||(enemy == "Destroyer Droid")&&(munition == "Plasma"))
		{
			totaldamage = (totaldamage + 100);
			cout << "The enemy has melted!!" << endl;
		}
	}			
	//************************
	
	if ((enemyHas == "Shields")&&(enemyhas == "Shields"))
	{
		totaldamage = (enemyShields - dmg); //Damage impacts shields before armour
		if ((enemyShields == 0)||(enemyShields < totaldamage)) //if the enemies shields are less than the total damage done
		{
			totaldamage = (enemyShields + enemyArmour - dmg); //Program adds armour to shield value and depletes armour
			if (enemyShields > eShields)
			{
				totalshields = (enemyShields - eShields);
				enemyShields = totalshields; //Shield value becomes remainder
			}
		}
	}
	if ((enemyArmour == 0)&&(enemyShields == 0)) //enemy death
	{
		totaldamage = (enemyHealth - dmg);
		if (enemyHealth == 0)
			cout << "Enemy Defeated." << endl;
	}
	//**************************

	if ((playerHas == "Armour")||(playerhas == "Armour"))
	{
		totaldamage = (playerArmour - dmg);
		if (dmg > playerArmour)	
		{
			totaldamage = (playerArmour + playerHealth - dmg);
			if (playerHealth > 100)
				playerArmour = (playerHealth - 100);
		}
	}
	if ((playerHas == "Shields")||(playerhas == "Shields"))
	{
		totaldamage = (playerShields - dmg); //Damage impacts shields before armour
		if ((playerShields == 0)||(playerShields < totaldamage)) //if the enemies shields are less than the total damage done
		{
			totaldamage = (playerShields + playerArmour - dmg); //Program adds armour to shield value and depletes armour
			if (enemyShields > eShields)
			{
				totalshields = (playerShields - pShields);
				playerShields = totalshields; //Shield value becomes remainder
			}
		}
	}
}

Hmm, now where is that error....

Edited 6 Years Ago by spartan118: n/a

Check the parameters that you are passing when you call the function damagecalculate and then check how you have defined the function
PS: Do you actually need to pass so many parameters into a function. You are bound to make a mistake. Cant you roll them up into a struct or something ?

I'm a beginner in C++, could you give me an example of using struct for variables? I'll take it from there.

Maybe this will help you ...

struct test
{
     int a;
     char b;
     float c;
};

void func(test* t1)
{
    cout<<t1->a<<"  "<<t1->b<<"  "<<t1->c<<endl;
}


int main() 
{
    test t1;
    t1.a= 5;
    t1.b= 'A';
    t1.c= 4.5;
    func(&t1);
    cin.get();
}

Edited 6 Years Ago by abhimanipal: n/a

This article has been dead for over six months. Start a new discussion instead.