Dec 3, 2016 at 12:50am UTC
So average stuff going on with me trying to figure out the errors I've got and then I got a new error saying there were unresolved External symbols. Any ideas>
(I have enough code that it wont all show here, so I'm posting the source.cpp here and ill fit one header file with it and the rest Ill comment)
Header
Weapons.H
#pragma once
#include <string>
#ifndef WEAPONS_H
#define WEAPONS_H
//Melee first, beginning with swords
class swords
{
public:
void setSwordDamage(float const strengthEffect, float const sharpnessEffect)
{
sworddamage = (strengthEffect + sharpnessEffect)*3;
}
float getSwordDamage() const
{
return sworddamage;
}
void setSwordDurability(float const x)
{
sworddurability = x;
}
float getSwordDurability() const
{
return sworddurability;
}
void setSwordLength(float x)
{
length = x;
}
float getSwordLength()
{
return length;
}
float getSwordWeight()
{
return (getSwordDamage() + getSwordDurability() + getSwordLength()) / 3.0f;
}
private:
float sworddamage;
float sworddurability;
float length;
float swordweight;
};
//wand class
class wand
{
public:
void setWandRange(int varX, int level)
{
wandrange = varX * level;
}
int getWandRange()
{
return wandrange;
}
void setWandDurability(int const varX)
{
wanddurability = varX;
}
int getWandDurability() const
{
return wanddurability;
}
void setWandEffect(std::string const effect)
{
wandeffect = effect;
}
std::string getWandEffect() const
{
return wandeffect;
}
void setWandWeight(float const varX)
{
wandweight = varX;
}
float getWandWeight() const
{
return wandweight;
}
private:
int wandrange;
int wanddurability;
int wanddamage;
float wandweight;
//Effect of slowness, fire, poison, and summoning.
std::string wandeffect;
};
//Bows
class bow
{
public:
void setBowRange(int varX, int level)
{
bowrange = (varX * level);
}
int getBowRange()
{
return bowrange;
}
void setBowDurability(int varX)
{
bowdurability = varX;
}
int getBowDurability()
{
return bowdurability;
}
void setBowAccuracy(float varX, float varY, float bowdurabilityoriginal, float level)
{
if (bowdurability/bowdurabilityoriginal > 0.75)
{
bowaccuracy = ((varX + varY) * level) / 100;
if (bowaccuracy > 1)
{
bowaccuracy = 1;
}
}
else if (bowdurability / bowdurabilityoriginal > 0.5)
{
bowaccuracy = ((varX + varY) * level) / 200;
if (bowaccuracy > 0.6)
{
bowaccuracy = 0.6;
}
}
else
{
bowaccuracy = ((varX + varY) * level) / 400;
if (bowaccuracy > 0.4)
{
bowaccuracy > 0.4;
}
}
}
float getBowAccuracy()
{
return bowaccuracy;
}
void setBowDamage(float varX, float varY, float durabilityoriginal, float level)
{
if (level >= 1 && level <= 10)
{
bowdamage = (varX * varY) * (getBowDurability() / durabilityoriginal);
}
else if (level >= 11 && level <= 25)
{
bowdamage = ((varX * varY) * (getBowDurability() / durabilityoriginal)) *(level - 10);
}
else
{
bowdamage = ((varX * varY) * (getBowDurability() / durabilityoriginal)) * (level - 10) * 2;
}
}
float getBowDamage()
{
return bowdamage;
}
int setBowAmmo(int ammo)
{
bowammo = ammo;
}
int getBowAmmo()
{
return bowammo;
}
int setBowWeight(float weight)
{
bowweight = weight;
}
float getBowWeight()
{
return bowweight;
}
private:
int bowrange;
int bowdurability;
float bowaccuracy;
float bowdamage;
int bowammo;
float bowweight;
};
#endif
Source.cpp
#include <iostream>
#include <string>
#include "Weapons.h"
#include "Enemies.h"
#include "Consumables.h"
int PlayerLevel = 2;
int healthpotcount = 0;
int money = 0;
std::string name;
std::string choice1;
char choice2;
std::string choice3;
std::string choice4;
//will be completed once all variables and classes are completed.
void shopkeep(int money, int invspace, std::string name, std::string classname);
int main()
{
long PlayerLevel = 50;
int strength = 5;
int numofattackonweapon;
swords TrainingSword;
TrainingSword.setSwordDamage(strength, 10);
TrainingSword.setSwordDurability(50);
TrainingSword.setSwordLength(2);
landenemy Muural;
Muural.SetEnemyDamage(6, 4, 3, PlayerLevel);
std::cout << "Muural deals " << Muural.GetEnemyDamage() << " damage at level 2." << std::endl;
std::cout << TrainingSword.getSwordWeight() << std::endl;
std::cin >> money;
return 0;
}
Dec 3, 2016 at 12:51am UTC
Other two header files:
Consumables.H
#pragma once
#ifndef CONSUMABLES_H
#define CONSUMABLES_H
class consumables
{
public:
void setPrice(int varX)
{
price = varX;
}
int getPrice()
{
return price;
}
void setHealthIncrease(int varX)
{
healthincrease = varX;
}
int getHealthIncrease()
{
return healthincrease;
}
void setWeight(int varX)
{
weight = varX;
}
int getWeight()
{
return weight;
}
private:
int price;
int healthincrease;
int weight;
};
#endif
Enemies.h
#pragma once
#include <string>
#include <cmath>
#ifndef ENEMIES_H
#define ENEMIES_H
//Enemies, beginning with land based entities
class landenemy
{
public:
void SetEnemyLevel(int playerlevel)
{
EnemyLevel = playerlevel;
}
int GetEnemyLevel()
{
return EnemyLevel;
}
void SetEnemyDamage(float DamageVarX, float DamageVarY, float DamageVarZ, float level)
{
if (level >= 1 && level <= 10)
{
enemydamage = (DamageVarX * DamageVarY)*(DamageVarZ / DamageVarX);
}
else if (level >= 11 && level <= 25)
{
enemydamage = (DamageVarX*(DamageVarZ) * DamageVarY) + ((pow(1.5 , (level - DamageVarY))) / DamageVarZ);
}
else
{
enemydamage = (DamageVarX*DamageVarY) + (level*DamageVarZ)*((pow(3,(DamageVarY)))/(pow(2,(DamageVarY)))/3);
}
}
float GetEnemyDamage()
{
return enemydamage;
}
void SetEnemyHealth(float HealthVarX, float HealthVarY, float level)
{
if (level >= 1 && level <= 10)
{
enemyhealth = ((HealthVarX + HealthVarY)*level) / 2;
}
else if (level >= 11 && level <= 25)
{
enemyhealth = ((HealthVarX + HealthVarY)*level) * 2 * HealthVarX;
}
else
{
enemyhealth = ((HealthVarX - HealthVarY)*level - HealthVarX);
}
}
float GetEnemyHealth()
{
return enemyhealth;
}
void SetEnemyDefense(int enemylevel)
{
enemydefense = enemylevel;
}
int GetEnemyDefense()
{
return enemydefense;
}
void SetEnemySpeed(float enemydamage)
{
enemyspeed = enemydamage / 100;
if (enemyspeed > 0.5)
{
enemyspeed = 0.5 * enemyspeed;
if (enemyspeed > 0.5)
{
enemyspeed = 0.5;
}
}
}
float GetEnemySpeed()
{
return enemyspeed;
}
void SetEnemyDistance(int level)
{
level = level + 5;
enemydistance = rand() % level;
}
int GetEnemyDistance()
{
return enemydistance;
}
void setexperiencedrop(int varX, int varY, int level)
{
if (level >= 5)
{
experiencedrop = varX;
}
else
{
experiencedrop = varX*(level - varY);
}
}
int getExperienceDrop()
{
return experiencedrop;
}
void setMoneyDrop(int varX)
{
moneydrop = varX;
}
int getMoneyDrop()
{
return moneydrop;
}
private:
float enemyhealth;
float enemydamage;
int enemydefense;
int EnemyLevel;
float enemyspeed;
int enemydistance;
int experiencedrop;
int moneydrop;
std::string name;
};
#endif
Dec 3, 2016 at 2:58am UTC
What would allow us to help you most would be if you posted the most relevant piece of information, namely the error itself.
Dec 3, 2016 at 5:37am UTC
That did solve it...so yea this was me being stupid and not commenting out a function I knew I was gonna save for later, so yea.