• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] 'Expected returns'

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
Hi People

An other Question:

I made a custom function that calculates some stats.
It takes 5 parameters, StatType, EV, IV, CurStat, level.
Now i have to call it 4 times, everytime i give it the 5 parameters, but it keeps telling me i dont give enough parameters!
The code is almost the same as last time, just a few adjustments
(I used GC and H22I because Hashtable wasnt recognized and GetHandleId as well,,)
This is the problem part of the code:
JASS:
    private function InitCalcStat takes integer StatType, integer EV, integer IV, integer CurStat, integer level returns integer
        local integer returning = ((IV + 2 * CurStat + (EV/4)) * level/100)
        if StatType == STAT_AT or StatType == STAT_DF or StatType == STAT_SP then
            return ((returning + 5) * 1)
        elseif StatType == STAT_HP then
            return (returning + 10 + level)
        endif
        return 0
    endfunction
    
    function InitStats takes unit u returns nothing
        local string ID = I2S(H22I(u))
        local integer   AT = InitCalcStat(STAT_AT, 0,0, GetHeroStr(u), GetHeroLevel(u))
        local integer   DF = InitCalcStat(STAT_DF, 0,0, GetHeroInt(u), GetHeroLevel(u))
        local integer   SP = InitCalcStat(STAT_SP, 0,0, GetHeroAgi(u), GetHeroLevel(u))
        local integer   HP = InitCalcStat(STAT_HP, 0,0, R2I(GetUnitState(u, UNIT_STATE_MAX_LIFE)), GetHeroLevel(u))
        call    StoreReal(table, ID, I2S(STAT_HP), HP)
        call StoreInteger(table, ID, I2S(STAT_AT), AT)
        call StoreInteger(table, ID, I2S(STAT_DF), DF)
        call StoreInteger(table, ID, I2S(STAT_SP), SP)
        call    StoreReal(table, ID, I2S(EV_AT), 0)
        call StoreInteger(table, ID, I2S(EV_AT), 0)
        call StoreInteger(table, ID, I2S(EV_DF), 0)
        call StoreInteger(table, ID, I2S(EV_SP), 0)
        call    StoreReal(table, ID, I2S(IV_AT), 0)
        call StoreInteger(table, ID, I2S(IV_AT), 0)
        call StoreInteger(table, ID, I2S(IV_DF), 0)
        call StoreInteger(table, ID, I2S(IV_SP), 0)
    endfunction

Can anyone help? Or is it just some problem with PJass/JassHelper?

JASS:
library Stats initializer Init
    globals
        private gamecache table
        constant integer STAT_HP = 1
        constant integer STAT_AT = 2
        constant integer STAT_DF = 3
        constant integer STAT_SP = 4
        constant integer EV_HP = 5
        constant integer EV_AT = 6
        constant integer EV_DF = 7
        constant integer EV_SP = 8
        constant integer IV_HP = 9
        constant integer IV_AT = 10
        constant integer IV_DF = 11
        constant integer IV_SP = 12
    endglobals
    
    private function H22I takes handle h returns integer
        return h
        return 0
    endfunction
    
    private function InitCalcStat takes integer StatType, integer EV, integer IV, integer CurStat, integer level returns integer
        local integer returning = ((IV + 2 * CurStat + (EV/4)) * level/100)
        if StatType == STAT_AT or StatType == STAT_DF or StatType == STAT_SP then
            return ((returning + 5) * 1)
        elseif StatType == STAT_HP then
            return (returning + 10 + level)
        endif
        return 0
    endfunction
    
    function InitStats takes unit u returns nothing
        local string ID = I2S(H22I(u))
        local integer   AT = InitCalcStat(STAT_AT, 0,0, GetHeroStr(u), GetHeroLevel(u))
        local integer   DF = InitCalcStat(STAT_DF, 0,0, GetHeroInt(u), GetHeroLevel(u))
        local integer   SP = InitCalcStat(STAT_SP, 0,0, GetHeroAgi(u), GetHeroLevel(u))
        local integer   HP = InitCalcStat(STAT_HP, 0,0, R2I(GetUnitState(u, UNIT_STATE_MAX_LIFE)), GetHeroLevel(u))
        call    StoreReal(table, ID, I2S(STAT_HP), HP)
        call StoreInteger(table, ID, I2S(STAT_AT), AT)
        call StoreInteger(table, ID, I2S(STAT_DF), DF)
        call StoreInteger(table, ID, I2S(STAT_SP), SP)
        call    StoreReal(table, ID, I2S(EV_AT), 0)
        call StoreInteger(table, ID, I2S(EV_AT), 0)
        call StoreInteger(table, ID, I2S(EV_DF), 0)
        call StoreInteger(table, ID, I2S(EV_SP), 0)
        call    StoreReal(table, ID, I2S(IV_AT), 0)
        call StoreInteger(table, ID, I2S(IV_AT), 0)
        call StoreInteger(table, ID, I2S(IV_DF), 0)
        call StoreInteger(table, ID, I2S(IV_SP), 0)
    endfunction
    private function Init takes nothing returns nothing
        set table = InitGameCache()
    endfunction
endlibrary

-Yixx,,-



-Previous question and code-


Today i was coding some stuff for my map, and i encoutered an error i could not understand.
'Expected returns'
But this is the code:
JASS:
private function InitCalcStat takes integer StatType, integer EV, integer IV integer CurStat, unit u returns integer
        local integer level = GetHeroLevel(u)
        local integer returning = ((IV + 2 * CurStat + (EV/4)) * level/100)
        if StatType == STAT_AT or StatType == STAT_DF or StatType == STAT_SP then
            return ((returning + 5) * 1)
        elseif StatType == STAT_HP then
            return (returning + 10 + level)
        else
            return 0
        endif
        return 0
    endfunction

This is the function where the error popped up. The line was the one where i declare it (private function InitCalcStat takes ..... )

JASS:
library Stats initializer Init
    globals
        private hashtable table
        constant integer STAT_HP = 1
        constant integer STAT_AT = 2
        constant integer STAT_DF = 3
        constant integer STAT_SP = 4
        constant integer EV_HP = 5
        constant integer EV_AT = 6
        constant integer EV_DF = 7
        constant integer EV_SP = 8
        constant integer IV_HP = 9
        constant integer IV_AT = 10
        constant integer IV_DF = 11
        constant integer IV_SP = 12
    endglobals
 
    private function InitCalcStat takes integer StatType, integer EV, integer IV integer CurStat, unit u returns integer
        local integer level = GetHeroLevel(u)
        local integer returning = ((IV + 2 * CurStat + (EV/4)) * level/100)
        if StatType == STAT_AT or StatType == STAT_DF or StatType == STAT_SP then
            return ((returning + 5) * 1)
        elseif StatType == STAT_HP then
            return (returning + 10 + level)
        else
            return 0
        endif
        return 0
    endfunction
 
    function InitStats takes unit u returns nothing
        local integer ID = GetHandleId(u)
        local integer   AT = InitCalcStat(STAT_AT, 0,0, GetHeroStr(u), u)
        local integer   DF = InitCalcStat(STAT_DF, 0,0, GetHeroInt(u), u)
        local integer   SP = InitCalcStat(STAT_SP, 0,0, GetHeroAgi(u), u)
        local integer   HP = InitCalcStat(STAT_HP, 0,0, R2I(GetUnitState(u, UNIT_STATE_MAX_LIFE)), u)
        call    SaveReal(table, ID, STAT_HP, HP)
        call SaveInteger(table, ID, STAT_AT, AT)
        call SaveInteger(table, ID, STAT_DF, DF)
        call SaveInteger(table, ID, STAT_SP, SP)
        call    SaveReal(table, ID, EV_AT, 0)
        call SaveInteger(table, ID, EV_AT, 0)
        call SaveInteger(table, ID, EV_DF, 0)
        call SaveInteger(table, ID, EV_SP, 0)
        call    SaveReal(table, ID, IV_AT, 0)
        call SaveInteger(table, ID, IV_AT, 0)
        call SaveInteger(table, ID, IV_DF, 0)
        call SaveInteger(table, ID, IV_SP, 0)
    endfunction
    private function Init takes nothing returns nothing
        set table = InitHashTable()
    endfunction
endlibrary

I hope you can explain me why it pops up =S,,
Thanks in advance! =)

-Yixx,,-
 
Last edited:
Status
Not open for further replies.
Top