| 08-05-2006, 07:05 AM | #1 |
I don't see why this script is causing alot of parse errors: JASS:function GetRestState takes unit pplayer returns integer //return return 1 endfunction function UnitClassification takes unit target returns string //return return "elite" endfunction function CalcXp takes unit target, unit pplayer returns real local integer t = GetHeroLevel(target) local integer p = GetHeroLevel(pplayer) local real g local real xp local real z if ( t == -1 ) then return 0 endif if ( t == p ) then set xp = ((p * 5) + 45) endif if ( t > p ) then set xp = ((p * 5) + 45) * (1 + 0.05 * (t - p)) endif if ( t < p ) then // need gray level "g" if (p < 6) then set g = 0 endif if (p > 5 and p < 40) then set g = (p - 5 - I2R(R2I(p/10))) endif if (p > 39) then set g = (p - 1 - I2R(R2I(p/5))) endif if (t > g) then // need zero difference "z" if (p < 8) then set z = 5 endif if (p > 7 and p < 10) then set z = 6 endif if (p > 9 and p < 12 ) then set z = 7 endif if (p > 11 and p < 16 ) then set z = 8 endif if (p > 15 and p < 20 ) then set z = 9 endif if (p > 19 and p < 40 ) then set z = (9 + I2R(R2I(p/10))) endif if (p > 39) then set z = (5 + I2R(R2I(p/5))) endif set xp = ((p * 5 + 45) * (1 - (p - t) / z)) else // t <= g, mob is Gray set xp = 0 endif endif set xp = (I2R(R2I(xp+0.5))) // result is rounded before calculating rest bonus if ( GetRestState(pplayer) == 1) then set xp = (xp * 2) endif if ( UnitClassification(target) == "elite" ) then set xp = (xp * 2) // what about "worldboss", "rareelite"... not sure how the XP scales endif if (xp > 0) then return xp else return 0 endif //return endfunction |
| 08-05-2006, 07:06 AM | #2 |
Left out set keywords. Use PJASS! |
| 08-05-2006, 07:12 AM | #3 |
still getting the errors Errors: Parse error undeclared variable: p missing endfunction statement outside of function but WE says Invalid type for specified operator p.s. i'm using JassShopPro |
| 08-05-2006, 06:18 PM | #4 |
You never declared z. |
| 08-05-2006, 06:50 PM | #5 |
still getting the errors |
| 08-05-2006, 07:13 PM | #6 | |
Quote:
QFT. If you'd have fixed it, you'd have bothered to update the post so we knew what we were debugging, right...? No? Anyway, you need a return at the end of that I think. Don't ask why, just try it. |
| 08-05-2006, 07:58 PM | #7 |
I have a return at the end: JASS:if (xp > 0) then return xp else return 0 endif |
| 08-05-2006, 08:02 PM | #8 |
No, you don't. Not at the end-end. I've had issues with that in the past. |
| 08-05-2006, 09:07 PM | #9 |
even after adding a return to the very end i still get a Line 85: Cannot convert integer to real but line 85 is a endfunction here is the updated code: JASS:function GetRestState takes unit pplayer returns integer //return return 1 endfunction function UnitClassification takes unit target returns string //return return "elite" endfunction function CalcXp takes unit target, unit pplayer returns real local integer t = GetHeroLevel(target) local integer p = GetHeroLevel(pplayer) local real g local real xp local real z if ( t == -1 ) then return 0 endif if ( t == p ) then set xp = ((p * 5) + 45) endif if ( t > p ) then set xp = ((p * 5) + 45) * (1 + 0.05 * (t - p)) endif if ( t < p ) then // need gray level "g" if (p < 6) then set g = 0 endif if (p > 5 and p < 40) then set g = (p - 5 - I2R(R2I(p/10))) endif if (p > 39) then set g = (p - 1 - I2R(R2I(p/5))) endif if (t > g) then // need zero difference "z" if (p < 8) then set z = 5 endif if (p > 7 and p < 10) then set z = 6 endif if (p > 9 and p < 12 ) then set z = 7 endif if (p > 11 and p < 16 ) then set z = 8 endif if (p > 15 and p < 20 ) then set z = 9 endif if (p > 19 and p < 40 ) then set z = (9 + I2R(R2I(p/10))) endif if (p > 39) then set z = (5 + I2R(R2I(p/5))) endif set xp = ((p * 5 + 45) * (1 - (p - t) / z)) else // t <= g, mob is Gray set xp = 0 endif endif set xp = (I2R(R2I(xp+0.5))) // result is rounded before calculating rest bonus if ( GetRestState(pplayer) == 1) then set xp = (xp * 2) endif if ( UnitClassification(target) == "elite" ) then set xp = (xp * 2) // what about "worldboss", "rareelite"... not sure how the XP scales endif if (xp > 0) then return xp else return 0 endif //return return 0 endfunction |
| 08-05-2006, 09:30 PM | #10 |
Try return 0.0, shouldn't make any difference though. |
| 08-05-2006, 09:54 PM | #11 |
that worked also this works: JASS:function GetRestState takes unit pplayer returns integer //return return 1 endfunction function UnitClassification takes unit target returns string //return return "elite" endfunction function CalcXp takes unit target, unit pplayer returns real local integer t = GetHeroLevel(target) local integer p = GetHeroLevel(pplayer) local real g local real xp local real z if ( t == -1 ) then return 0 endif if ( t == p ) then set xp = ((p * 5) + 45) endif if ( t > p ) then set xp = ((p * 5) + 45) * (1 + 0.05 * (t - p)) endif if ( t < p ) then // need gray level "g" if (p < 6) then set g = 0 endif if (p > 5 and p < 40) then set g = (p - 5 - I2R(R2I(p/10))) endif if (p > 39) then set g = (p - 1 - I2R(R2I(p/5))) endif if (t > g) then // need zero difference "z" if (p < 8) then set z = 5 endif if (p > 7 and p < 10) then set z = 6 endif if (p > 9 and p < 12 ) then set z = 7 endif if (p > 11 and p < 16 ) then set z = 8 endif if (p > 15 and p < 20 ) then set z = 9 endif if (p > 19 and p < 40 ) then set z = (9 + I2R(R2I(p/10))) endif if (p > 39) then set z = (5 + I2R(R2I(p/5))) endif set xp = ((p * 5 + 45) * (1 - (p - t) / z)) else // t <= g, mob is Gray set xp = 0 endif endif set xp = (I2R(R2I(xp+0.5))) // result is rounded before calculating rest bonus if ( GetRestState(pplayer) == 1) then set xp = (xp * 2) endif if ( UnitClassification(target) == "elite" ) then set xp = (xp * 2) // what about "worldboss", "rareelite"... not sure how the XP scales endif if (xp > 0) then return xp else return 0.0 endif //return endfunction |
| 08-06-2006, 11:34 AM | #12 |
Yea, whenever it says Cannot convert integer to real, just type a dot (full stop (.)) after the number, and its converted. It can be a pain, once you understand all the error types and how to fix them, you will have no problems. |
