Group Picking Problem

Evoroth

New Member
Reaction score
11
Ok, this trigger is supposed to distribute 100 lumber to players, different amounts depending on how many unit the player has in a specific region. For example, player 1 has 3 units, player 2 has 2, and player 3 has 5. Since player 1 has 30% of the units in the region, he gets 30 lumber, player 2 gets 20, and player 3 gets 50.

But it gives wrong values. I know the issue is somewhere in the group picking functions.

Many thanks!

JASS:
function Danke takes nothing returns boolean
    return GetUnitState(GetEnumUnit(),UNIT_STATE_LIFE) > and RectContainsUnit(udg_GenericRegion,GetEnumUnit())
endfunction

function Ja_Das_Ist_Gut takes nothing returns nothing
    local location l
    local integer array p
    local integer i = 0
    local integer m
    local group g = CreateGroup()
    loop  
    set bj_groupCountUnits = 0
    call GroupEnumUnitsOfPlayer(g,Player(i),Condition(function Danke))
    call ForGroup(g,function CountUnitsInGroupEnum)
    set p<i> = bj_groupCountUnits
    call DisplayTextToForce(GetPlayersAll(),I2S(p<i>))
    set i = i + 1
    exitwhen i == 4
    endloop
    set m = p[0] + p[1] + p[2] + p[3]+ 100 / m * p<i>)
    set i = 0
    if m != 0 then
    loop
    call SetPlayerState(Player(i),PLAYER_STATE_RESOURCE_LUMBER,GetPlayerState(Player(i),PLAYER_STATE_RESOURCE_LUMBER) 
    set i = i + 1
    exitwhen i == 4
    endloop
    endif
    call DestroyGroup(g)
endfunction</i></i></i>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top