• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] I'm new at it and...

Status
Not open for further replies.
Level 16
Joined
Sep 26, 2005
Messages
1,088
I don't get it what's wrong:

JASS:
public function DamageCalc takes unit DSource, unit DTarget, string DType, real Dwd, real Dstrd, real Dagid, real Dintd returns real
   local real dmg = 0
   set dmg = Dwd * GetRandomReal(udg_CombatDamageMin[GetUnitUserData(DSource)], udg_CombatDamageMax[GetUnitUserData(DSource)])
   set dmg = dmg + ( Dstrd * I2R(GetHeroStatBJ(bj_HEROSTAT_STR, DSource, true)) ) + ( Dagid * I2R(GetHeroStatBJ(bj_HEROSTAT_AGI, DSource, true)) ) + ( Dintd * I2R(GetHeroStatBJ(bj_HEROSTAT_INT, DSource, true)) )
   return dmg
endfunction

It's a function that calculates damage based on weapon damage (CombatDamageMin and CombatDamageMax, two reals that are linked to unit's custom value) and unit's strength, agility and intelligence, but since I'm new to JASS, and this is my first attempt at making my own function, I don't know what's wrong.
I want to make it possible for every other function to call this one so I guess it has to be public.
 
Level 16
Joined
Sep 26, 2005
Messages
1,088
can any1 tell me where's that bloody endless loop because I can't find it -.-

JASS:
        set s2 = ""
        set i = 1
        set n = StringLength( s )
        loop
            exitwhen i == n + 1
            set d = f642dec( SubStringBJ(s, i, i) )
            set s2 = s2 + dec2bin ( d, 6 )
            set i = i + 1
        endloop
        set s = s2


JASS:
function f642dec takes string s returns integer
    local integer i
    local integer x = 0
    set i = 1
    loop
        exitwhen i == 65
        if SubStringBJ( udg_SaveTempString_Copy, i, i ) == s then
            set x = i - 1
        endif
        set i = i + 1
    endloop
    return x
endfunction

JASS:
function dec2bin takes integer n, integer b returns string
    local string s = ""
    loop
        exitwhen n == 0
        if mod(n, 2) == 1 then
            set s = "1" + s
        else
            set s = "0" + s
        endif
        set b = b - 1
        set n = n / 2
    endloop
    loop
        exitwhen b == 0
            set s = "0" + s
        set b = b - 1
    endloop
    return s
endfunction

and udg_SaveTempString is

JASS:
udg_SaveTempString_Copy = 03CFG$KL1#M2NZa49de@fP&UIJ8EXYopVWbcqrsQRSTDAB5Htuvghijk6mn7wxyz
 
Level 16
Joined
Sep 26, 2005
Messages
1,088
JASS:
if GetLocalPlayer() == GetOwningPlayer(GetOrderedUnit()) then
    SomeCodeOfMine(whatever)
endif

Shouldn't this function SomeCodeOfMine(whatever) be executed for owner of event response - ordered unit's owner only? I can't get it to work... It keeps executing that function to all players. To be precise SomeCodeOfMine actually displays certain Multiboard containing some info about items.
So please people, give me a hint...
 
Level 16
Joined
Sep 26, 2005
Messages
1,088
Nope, the problem remains but in a different shape:
This table still appears to all players, then gets hidden for all players (so all other players lose their current tables), and then it appears for local player. -.-
I used the code mentioned above in 2 more places but the only difference is that it's not the GetOwningPlayer(GetOrderedUnit()) but GetTriggerPlayer() or using loop and comparing indexes, and it worked perfectly... Until now. -.-
 
Level 16
Joined
Sep 26, 2005
Messages
1,088
Finally got it working:
Made this multiboard at a same time when I made the other ones (at map init), hid the table (just like others) and instead of making new one in trigger, I changed number of rows and columns, changed its content and displayed it to GetOwningPlayer(GetTriggerUnit()) only, and it works flawlessly. Tnx for help guys.
 
Status
Not open for further replies.
Top