• Create Account

### #ActualAmeise

Posted 29 June 2012 - 09:10 AM

I am just going to repeat what you have already been told, where you have your if (attack == "a weapon" , should be if (attack == "a weapon" || "weapon" || "the weapon").
Also where you first create healthme and healthit declare the amount there.... int Healthme = 500;

You should really look into the different operator's and method's of calling loops

That will simply resolve to 'true' for every execution as his last form would. You are executing attack == "a weapon", which calls std::string's overloaded == operator, and returns true or false. However, it then will execute [true | false] | "weapon". "weapon" is not going to be nullptr, therefor, you are bitwise ORing a [true | false] (generally represented as 0x1 and 0x0) against a guaranteed non-nullptr value, giving you a value that is guaranteed to NOT be 0. You then do it again with "the weapon".

The way that doesn't fail is:

if (attack == "a weapon" || attack == "weapon" || attack == "the weapon")


However, judging by the the set of strings, I wouldn't be surprised if one could get away with

if (attack.find("weapon") != std::string::npos)


### #2Ameise

Posted 29 June 2012 - 09:10 AM

I am just going to repeat what you have already been told, where you have your if (attack == "a weapon" , should be if (attack == "a weapon" || "weapon" || "the weapon").
Also where you first create healthme and healthit declare the amount there.... int Healthme = 500;

You should really look into the different operator's and method's of calling loops

That will simply resolve to 'true' for every execution as his last form would. You are executing attack == "a weapon", which calls std::string's overloaded == operator, and returns true or false. However, it then will execute [true | false] | "weapon". "weapon" is not going to be nullptr, therefor, you are bitwise ORing a [true | false] (generally represented as 0x1 and 0x0) against a guaranteed non-nullptr value, giving you a value that is guaranteed to NOT be 0. You then do it again with "the weapon".

The way that doesn't fail is:

if (attack == "a weapon" || attack == "weapon" || attack == "the weapon")


However, judging by the the se of strings, I wouldn't be surprised if one could get away with

if (attack.find("weapon") != std::string::npos)


### #1Ameise

Posted 29 June 2012 - 09:10 AM

I am just going to repeat what you have already been told, where you have your if (attack == "a weapon" , should be if (attack == "a weapon" || "weapon" || "the weapon").
Also where you first create healthme and healthit declare the amount there.... int Healthme = 500;

You should really look into the different operator's and method's of calling loops

That will simply resolve to 'true' for every execution as his last form would. You are executing attack == "a weapon", which calls std::string's overloaded == operator, and returns true or false. However, it then will execute [true | false] | "weapon". "weapon" is not going to be nullptr, therefor, you are bitwise ORing a [true | false] (generally represented as 0x1 and 0x0) against a guaranteed non-nullptr value, giving you a value that is guaranteed to NOT be 0. You then do it again with "the weapon".

The way that doesn't fail is:

PARTNERS