I've got an odd problem and I'm not sure what is causing it.
I've created a new skill to tan skins. I have it using add_timer to add a delay, pretty much so that the commands can't be stacked as that would cause the process to stop. Anyway, that part works just fine. When the timer ends and returns to the skill function I have a series of if checks against number_percent to see if the process failed or not.
Pseudo code for those checks looks something like this:
Testing this code for several hours, I noticed the skill was failing fairly often, so I raised the values 85, 90 and 95 to 93, 95, 97 respectively. That didn't cause the fail rate to lessen any. This is where the odd part comes in. I added a variable declaration to the top of the function like "int perc = number_percent();" I then replaced all the number_percents in the switch cases with perc so the value wouldn't be different for each case. This didn't change anything. My objects were still getting extracted at an almost 100% rate.
I ran this through gdb to check the value of the variable. I set a break point on the function and went to test it. The break point was reached so I checked the current values of all the variables in the function with "info locals" All of the variables showed up except for the "perc" variable I added. Doing a "list" showed that it was there and declared. I tried "p perc" but gdb just gives the response 'No symbol "perc" in current context.'
That didn't help. I changed the if checks within the switch to read <= 7, 5, 3 and declared perc as "int perc = 10;" Even that didn't change anything. The skill still failed and destroyed the object every time, even though 10 is clearly not less than 7, 5 or 3.
So, why is this variable not showing up in the scope of this function?
I've created a new skill to tan skins. I have it using add_timer to add a delay, pretty much so that the commands can't be stacked as that would cause the process to stop. Anyway, that part works just fine. When the timer ends and returns to the skill function I have a series of if checks against number_percent to see if the process failed or not.
Pseudo code for those checks looks something like this:
if(number_percent > learned[skill]) // check random number vs learned percent
{
switch(objvalue) // object state
{
case 1: // various "fail" messages
print "You failed"
if(number_percent > 85) // chance to ruin/destroy item
extract_obj(obj)
return
case 2:
print "You failed"
if(number_percent > 90)
extract_obj(obj)
return
case 3:
print "You failed"
if(number_percent > 95)
extract_obj(obj)
return
}
}Testing this code for several hours, I noticed the skill was failing fairly often, so I raised the values 85, 90 and 95 to 93, 95, 97 respectively. That didn't cause the fail rate to lessen any. This is where the odd part comes in. I added a variable declaration to the top of the function like "int perc = number_percent();" I then replaced all the number_percents in the switch cases with perc so the value wouldn't be different for each case. This didn't change anything. My objects were still getting extracted at an almost 100% rate.
I ran this through gdb to check the value of the variable. I set a break point on the function and went to test it. The break point was reached so I checked the current values of all the variables in the function with "info locals" All of the variables showed up except for the "perc" variable I added. Doing a "list" showed that it was there and declared. I tried "p perc" but gdb just gives the response 'No symbol "perc" in current context.'
That didn't help. I changed the if checks within the switch to read <= 7, 5, 3 and declared perc as "int perc = 10;" Even that didn't change anything. The skill still failed and destroyed the object every time, even though 10 is clearly not less than 7, 5 or 3.
So, why is this variable not showing up in the scope of this function?