View Full Version: Bug in the Code

ivan >>Trouble Shooting and Bugs >>Bug in the Code


TheFallenOne222- 04-05-2005
Bug in the Code
This has probably already been caught for next version, but I figured I'd post it anyways. This code: int blinkdog::TakeHit(character* Enemy, item* Weapon, bodypart* EnemyBodyPart, v2 HitPos, double Damage, double ToHitValue, int Success, int Type, int Direction, truth Critical, truth ForceHit) { int Return = nonhumanoid::TakeHit(Enemy, Weapon, EnemyBodyPart, HitPos, Damage, ToHitValue, Success, Type, Direction, Critical, ForceHit); if(Return != HAS_DIED) { if(!(RAND() & 15) && SummonFriend()) return Return; if((RAND() & 1 && StateIsActivated(PANIC)) || (!(RAND() & 3) && IsInBadCondition()) || !(RAND() & 15)); MonsterTeleport("terrified yelp"); } return Return; } has an empty control statement in the middle of it, which doesn't look like the intent. Here's the problem: if((RAND() & 1 && StateIsActivated(PANIC)) || (!(RAND() & 3) && IsInBadCondition()) || !(RAND() & 15)); MonsterTeleport("terrified yelp"); It should be: if((RAND() & 1 && StateIsActivated(PANIC)) || (!(RAND() & 3) && IsInBadCondition()) || !(RAND() & 15)) MonsterTeleport("terrified yelp");

Skavian- 04-05-2005

Crazy coders. I looked at your problem very hard, and tried to come up with a reason why it might cause something or another to explode in the game. All I can think of is that it might punctuate and connect two independent clauses, but that might just be the English student speaking in me.

TheFallenOne222- 04-05-2005

Crazy coders. I looked at your problem very hard, and tried to come up with a reason why it might cause something or another to explode in the game. All I can think of is that it might punctuate and connect two independent clauses, but that might just be the English student speaking in me. lol, well, the only difference in what is actually there and what should be there is the additional ; in the original code. In C++, that's essentially an "end of statement" character, so what it's doing is it's saying in the original code: If <stuff> then do nothing. MonsterTeleport('terrified yelp"); When it should be saying this: If <stuff> then MonsterTeleport("terrified yelp"); So essentially it's not even checking to see if the monster should be teleporting, it is just teleporting it whenever it gets hit.

Atomic- 04-05-2005

Is IVAN done in C or C++?

TheFallenOne222- 04-05-2005

Is IVAN done in C or C++? Hmm, looks like C++...

hexi- 04-06-2005

Kind of funny how well the blink dogs behave even with our buggy code :) Thanks for the report!

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.