mob/proc
train()
if(tfocus == "bal")
if((rpu == 1) && (rewardpoints > 0) && (traing == 0))
TrainingBonus()
traing = 1
str += (strmod * tb) * 0.4000
end += (endmod * tb) * 0.4000
dex += (dexmod * tb) * 0.4000
apn += (strmod * tb) * 0.4000
apn += (endmod * tb) * 0.4000
apn += (dexmod * tb) * 0.4000
ustats()
rewardpoints -= 1
spawn(100) traing = 0
else if(traing == 0)
TrainingBonus()
traing = 1
str += (strmod * tb) * 0.1667
end += (endmod * tb) * 0.1667
dex += (dexmod * tb) * 0.1667
apn += (strmod * tb) * 0.1667
apn += (endmod * tb) * 0.1667
apn += (dexmod * tb) * 0.1667
ustats()
spawn(100) traing = 0
if(tfocus == "str")
if((rpu == 1) && (rewardpoints > 0) && (traing == 0))
TrainingBonus()
traing = 1
str += (strmod * tb) * 0.8000
apn += (strmod * tb) * 0.8000
ustats()
rewardpoints -= 1
spawn(100) traing = 0
else if(traing == 0)
TrainingBonus()
traing = 1
str += (strmod * tb) * 0.3334
apn += (strmod * tb) * 0.3334
ustats()
spawn(100) traing = 0
if(tfocus == "end")
if((rpu == 1) && (rewardpoints > 0) && (traing == 0))
TrainingBonus()
traing = 1
end += (endmod * tb) * 0.8000
apn += (endmod * tb) * 0.8000
ustats()
rewardpoints -= 1
spawn(100) traing = 0
else if(traing == 0)
TrainingBonus()
traing = 1
end += (endmod * tb) * 0.3334
apn += (endmod * tb) * 0.3334
ustats()
spawn(100) traing = 0
if(tfocus == "dex")
if((rpu == 1) && (rewardpoints > 0) && (traing == 0))
TrainingBonus()
traing = 1
dex += (dexmod * tb) * 0.8000
apn += (dexmod * tb) * 0.8000
ustats()
rewardpoints -= 1
spawn(100) traing = 0
else if(traing == 0)
TrainingBonus()
traing = 1
dex += (dexmod * tb) * 0.3334
apn += (dexmod * tb) * 0.3334
ustats()
spawn(100) traing = 0
How do I go about making this all neat and optimized? When trying to do this, only the generic way came to mind but I'm sure there are better ways to do it.
|
// Danger! Untested code. Beware what Lige said: The fact that I am crazy does not mean that others will be so keen to help you in the future. |
Thanks, I have a question though. Isn't the priority of ">" low? I usually put brackets around ">" because it messes up my if conditions. I never thought about putting conditions into vars either. Also I need to practice using !var and var more often for checks. Also the same with -- or ++ for adding onto vars. Thanks for the help.
|
In response to Gluscap
|
|
Gluscap wrote:
Thanks, I have a question though. No problem. Isn't the priority of ">" low? I usually put brackets around ">" because it messes up my if conditions. Brackets are typically employed when you're performing mathematical operations inside an if statement. Take the following condition: if (1 + 2 * 3 == 9) // true or false? If you enter into a case such as the above then you should employ brackets to enforce one operation above the other. For instance: if ((1 + 2) * 3 == 9) // true: do 1 + 2 first (= 3), then * 3 (= 9) I'm too lazy to remember what the order of operations is, and I consider it a fools errand to memorize it. My reasoning is that your code must be readable by anyone you share it with, even your future self who may have forgotten the order of operations. In short: when in doubt, use brackets. It's better to be clear than to leave things open to interpretation. I never thought about putting conditions into vars either. By putting it in a variable you have a reference to your (complex) condition. If the condition ever changes, you'll only need to change a single line of code. Do give it a meaningful name though. I named it "cond" (= "condition") because I don't know what it means. You'll want to rename it to something that makes more sense and/or add a comment that says what the condition is for. Also I need to practice using !var and var more often for checks. Also the same with -- or ++ for adding onto vars. Thanks for the help. If you're dealing with booleans you should use !var and var in your checks. I'd also recommend using TRUE and FALSE and I've modified my original post accordingly. Most of the time I don't even bother using shorthand. My personal preference is to write code like dex = dex + (dexmod * tb) * multiplier instead of dex += (dexmod * tb) * multiplier because to me it's more clear what happens to the variable than by using the shorthand version. |
I sat here debating on whether or not to provide code, but I'd rather explain it to you and hope you put forth effort into fixing your issue as opposed to providing copy/paste snippets.