• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Another problem

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
I have a couple questions. It seems that I have no idea why this is returning "0" :

JASS:
function Trig_Spawn_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local integer i = GetUnitPointValue(u) 
    local real x
    local real y
    set udg_Income[GetPlayerId(p)] = ( udg_Income[GetPlayerId(p)] + i)
    call MultiboardSetItemValueBJ( bj_lastCreatedMultiboard , 2, udg_row [GetPlayerId(p)], I2S(udg_Income[GetPlayerId(p)]) )
    set udg_NextLine = GetPlayerId(p)
    set x = (GetRandomReal(GetRectMinX(udg_EndRegion[udg_NextLine]), GetRectMaxX(udg_EndRegion[udg_NextLine])))
    set y = (GetRandomReal(GetRectMinY(udg_EndRegion[udg_NextLine]), GetRectMaxY(udg_EndRegion[udg_NextLine])))
    call SetUnitPosition (u, x,y)
    set u = null
    set p = null
endfunction

Now, I also checked the function of this:
JASS:
    call MultiboardSetItemValueBJ( bj_lastCreatedMultiboard , 2, udg_row [GetPlayerId(p)], I2S(udg_Income[GetPlayerId(p)]) )

JASS:
function MultiboardSetItemValueBJ takes multiboard mb, integer col, integer row, string val returns nothing
    local integer curRow = 0
    local integer curCol = 0
    local integer numRows = MultiboardGetRowCount(mb)
    local integer numCols = MultiboardGetColumnCount(mb)
    local multiboarditem mbitem = null

    // Loop over rows, using 1-based index
    loop
        set curRow = curRow + 1
        exitwhen curRow > numRows

        // Apply setting to the requested row, or all rows (if row is 0)
        if (row == 0 or row == curRow) then
            // Loop over columns, using 1-based index
            set curCol = 0
            loop
                set curCol = curCol + 1
                exitwhen curCol > numCols

                // Apply setting to the requested column, or all columns (if col is 0)
                if (col == 0 or col == curCol) then
                    set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
                    call MultiboardSetItemValue(mbitem, val)
                    call MultiboardReleaseItem(mbitem)
                endif
            endloop
        endif
    endloop
endfunction

Im afraid I have NO idea what transpired here. I wanted to make it so that it would go to column 2 and row (udg_row) but I have no idea how to convert it in this function above. Any help on this would be much appreciated.
 
Level 9
Joined
Jun 7, 2008
Messages
440
no. "udg_row[GetPlayerId(player 0)] = 2"
This is preset during map initialization. The Multiboard is created, and I see the entire multiboard fully, as It should be. When I spawn a unit, the trigger fires. And all numbers in column 2 are set to the Players income. Perhaps I am doing something wrong. I dunno. As to the space, well it really doesn't matter I retyped it and added the space. Its efficient to not have the space, I know.
 
no. "udg_row[GetPlayerId(player 0)] = 2"
This is preset during map initialization. The Multiboard is created, and I see the entire multiboard fully, as It should be. When I spawn a unit, the trigger fires. And all numbers in column 2 are set to the Players income. Perhaps I am doing something wrong. I dunno. As to the space, well it really doesn't matter I retyped it and added the space. Its efficient to not have the space, I know.

okay... I just based it on the above trigger... so what you mean is that the incomes of all players are set to the value of the owner of the unitspawned?

oh wait.. udg_row is an array right? maybe you hadn't set the array size to at least the max number of players? it bugs sometimes if you use an index higher than the initialized size...
 
"udg_Income"

You need to initiliase that array, which is why it would always remain 0. Make it an array of size 12 in the variable editor to accomplish this.

JASS:
function Trig_Spawn_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer id = GetPlayerId(GetOwningPlayer(u))
    local real x = (GetRandomReal(GetRectMinX(udg_EndRegion[id]), GetRectMaxX(udg_EndRegion[id])))
    local real y = (GetRandomReal(GetRectMinY(udg_EndRegion[id]), GetRectMaxY(udg_EndRegion[id])))
    call SetUnitPosition(u, x,y)
    set udg_NextLine = id
    set udg_Income[id] = udg_Income[id] + GetUnitPointValue(u)
    set u = null
    call MultiboardSetItemValueBJ(bj_lastCreatedMultiboard, 2, udg_row[id], I2S(udg_Income[id]))
endfunction
 
Level 9
Joined
Jun 7, 2008
Messages
440
Yes, I am sure. I set them both to an array of 11 as the last player (Brown) is computer will not be seen at all on the multiboard. On the side note, can anyone explain the other part of my problem to me? Im confused on how to navigate it.

EDIT: Another conflicting trigger, the first problem has been solved.
 
Level 9
Joined
Jun 7, 2008
Messages
440
the first part was solved.

the second part is this:
JASS:
function MultiboardSetItemValueBJ takes multiboard mb, integer col, integer row, string val returns nothing
    local integer curRow = 0
    local integer curCol = 0
    local integer numRows = MultiboardGetRowCount(mb)
    local integer numCols = MultiboardGetColumnCount(mb)
    local multiboarditem mbitem = null

    // Loop over rows, using 1-based index
    loop
        set curRow = curRow + 1
        exitwhen curRow > numRows

        // Apply setting to the requested row, or all rows (if row is 0)
        if (row == 0 or row == curRow) then
            // Loop over columns, using 1-based index
            set curCol = 0
            loop
                set curCol = curCol + 1
                exitwhen curCol > numCols

                // Apply setting to the requested column, or all columns (if col is 0)
                if (col == 0 or col == curCol) then
                    set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
                    call MultiboardSetItemValue(mbitem, val)
                    call MultiboardReleaseItem(mbitem)
                endif
            endloop
        endif
    endloop
endfunction

Can Anyone help to explain what all this means?
 
Okay, so if I wanted to change the object on column 3 row 2, how would I go about this?

I think you could do this directly
JASS:
local multiboarditem mbitem = null
set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
call MultiboardSetItemValue(mbitem, val)
call MultiboardReleaseItem(mbitem)

so something like

JASS:
local multiboarditem mbitem = null
set mbitem = MultiboardGetItem(mb, 1, 2)
call MultiboardSetItemValue(mbitem, value)
call MultiboardReleaseItem(mbitem)

just reduce the number by 1 for the column and row... coz the numbering is the same as players

player 1 = Player(0)

row 1 = Row(0)
 
Status
Not open for further replies.
Top