#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "Hello everyone and welcome to this game.\n";
cout << "In this game the aim is to attack the wolf with what you think is the best attack, goodluck!\n";
int healthme=500;
int healthit=500;
while(healthme>0 && healthit>0 ) {
cout << "Your Health is " << healthme << " and the wolfs health is " << healthit << "\n";
cout << "So, what attack do you want to hit the wolf with a weapon or with magic?";
string attack;
cin >> attack;
if (attack.find("weapon") != std::string::npos) {
cout << "What part of the wolf do you want to attack, the body or the head?\n";
string bodypart;
cin >> bodypart;
if(bodypart.find("body") != std::string::npos) {
healthit-= getdamage(50, 10);
cout << "You hit the wolf!\n";
}
else if(bodypart.find("head") != std::string::npos) {
healthit -= getdamage(100, 20);
healthme -= getdamage(20, 5);
cout << "It was a good hit, but it bites back!\n";
}
else cout << "you missed! (spelt it wrong) \n";
}
else if (attack.find("magic") != std::string::npos){
cout << "what element would you like to attack with? fire lightning, ice, water, or earth?\n";
string magic;
cin >> magic;
if(magic == "fire"){
healthit-= getdamage(50, 10);
cout << "It does good damage!\n";
}
else if(magic == "lightning"){
healthit-= getdamage(100, 10);
cout << "It does amazing damage!\n";
}
else if(magic == "earth"){
healthit-= getdamage(70, 10);
cout << "It hits hard!\n";
}
else if(magic=="ice") {
healthit -= getdamage(30, 5);
cout << "It doesn't seem to hurt much!\n";
}
else if(magic=="water") {
healthit -= getdamage(10, 2);
cout << "It seems unaffected!\n";
}
else cout << "You missed! (spelt it wrong!)\n";
}
else cout << "you took to long! (spelt wrong!)";
if(healthit>=0){
if(healthit<=100){
cout << "He is Angry now and doing more damage!\n";
healthme -= getdamage(75, 10);
}
else {
cout << "The wolf goes out to attack!\n";
healthme-= getdamage(50, 10);
}
}
}
if(healthme<=0) cout << "Your Dead... Game over i guess?";
else cout << "The wolf is dead! You Win!";
return 0;
}
// Returns a random value within DamageRange of Damagebase
int getdamage(int damagebase, int damagerange)
{
// if DamageBase is 50, and DamageRange is 10, DamageBase will be 40 here
int damagedealt = damagebase - damagerange;
// if DamageRange is 10, then this will add anywhere from 0 to 20 damage*
damagedealt += (rand() % (damagerange*2));
return damagedealt;
}
when compiling the program the error
'getdamage' identifier not found
i can't figure out whats wrong its probably something stupid but still thanks for any help anyway