I tried putting a function in a private member of a class and I am getting all kinds of errors. I don't think I am doing it the right way. Can someone please help. This is how I have it set up.
This is giving me so many errors....I hade to cut and past from my orginal code so throw out all the syntax errors and/or missing {}.Code:class Weapons { public: Weapons(); char getWeaponValue(); //Legendary, Epic, unique, rare, magical, normal char getWeaponType(); //Sword, mace, staff char getWeaponName(); //Name the weapon int getWeaponStats(); // damage, +mods and durability int getWeaponLevel(); // level of the weapon void whoCanDrop(); //check to see which mobs can drop it private: string WeaponName; string WeaponType; string WeaponValue; int WeaponStats; int WeaponDamage; int WeaponDurability; int WeaponLevel; char CanIDropIt; }; int Weapons::getWeaponStats() { int x; //random variable to create random numbers int y; //random variable to decide stat int z; //random variable to decide number of a single stat srand(time(0)); if (WeaponType == "Sword" && WeaponValue == "Normal" && Clvl <= 3) { WeaponStats = 0; WeaponDamage = 1 + (rand() % 10) - Clvl; WeaponDurability = 1 + rand() % 20; } if (WeaponType == "Sword" && WeaponValue == "Normal" && Clvl <= 5) { WeaponStats = 0; WeaponDamage = Clvl + (rand() % 20); WeaponDurability = 1 + rand() % 30; } if (WeaponType == "Sword" && WeaponValue == "Normal" && Clvl <= 10) { WeaponStats = 0; WeaponDamage = Clvl + (rand() % 40); WeaponDurability = 1 + rand() % 50; } RandmStats(); //WeaponStats = 0; WeaponDamage = 1 + (rand() % 10) - Clvl; WeaponDurability = 1 + rand() % 20; } } }; int RandmStats() { //------------------------------ Function I want to make starts here if (WeaponType == "Sword" && WeaponValue == "Magical" && Clvl <= 3) { if (WeaponName == "Sword of the bear") // +str(lots), +hp(lots) and small amount of +agi(small) { x = 1 + (rand() % 5) - 2; // how many mods switch (x) { case 1: y = 1 + rand() % 6; // which mod it gets 1 = str 2 = hp 3 = agi 4 = str&hp 5 = hp&agi 6 = all if (y == 1) { z = 1 + rand() % 4; // z = the amount of the specified mod if (z == 1) { WeaponMod1 = 3 + Clvl; } if (z == 2) { WeaponMod1 = 5 + Clvl; } if (z == 3) { WeaponMod1 = 7 + Clvl; } if (y == 2) { z = 1 + rand() % 4; if (z == 1) { WeaponMod2 = 5 + Clvl; } if (z == 2) { WeaponMod2 = 10 + Clvl; } if (z == 3) { WeaponMod3 = 15 + Clvl; } } if (y == 3) { z = 1 + rand() % 4; if (z == 1) WeaponMod4 = 2; if (z == 2) WeaponMod4 = 4; if (z == 3) WeaponMod4 = 6; } if (y == 4) { z = 1 + rand() % 4; if (z == 1) { WeaponMod1 = 3 + Clvl; WeaponMod2 = 5 + Clvl; } if (z == 2) { WeaponMod1 = 5 + Clvl; WeaponMod2 = 10 + Clvl; } if ( z == 3) { WeaponMod1 = 7 + Clvl; WeaponMod2 = 15 + Clvl; } } if (y == 5) { z = 1 + rand() % 4; if (z == 1) { WeaponMod2 = 5 + Clvl; WeaponMod4 = 2; } if (z == 2) { WeaponMod2 = 10 + Clvl; WeaponMod4 = 4; } if (z == 3) { WeaponMod2 = 15 + Clvl; WeaponMod4 = 6; } } if (y == 6) { z = 1 + rand() % 4; if (z == 1) { WeaponMod1 = 3 + Clvl; WeaponMod2 = 5 + Clvl; WeaponMod4 = 2; } if (z == 2) { WeaponMod1 = 5 + Clvl; WeaponMod2 = 10 + Clvl; WeaponMod4 = 5; } if (z == 3) { WeaponMod1 = 7 + Clvl; WeaponMod2 = 15 + Clvl; WeaponMod4 = 7; } } } } // ----------------End the function I want to make
EDITED: Posted the code on how I am trying to get it to work.



LinkBack URL
About LinkBacks



I think I have just been working on this for to long. Thanks, it seems so simple now.