Spawn Issue

Danis[h]

New Member
Reaction score
19
Okay so here is the deal..

In my map I try to spawn my units via. a loop, and then I add the unit that was spawned to a unit group array where its array index is the count of how many times the loop have run through.

Now..
Based on which unitgroup the unit is in, i want to modify its mana to a certain value. However it only works for one spawn (the bottom condition.) The rest of the units aren't assigned a new mana value.

JASS:
   private function StartPathActions takes nothing returns nothing
        local location u
            if ( IsUnitInGroup(GetTriggerUnit(), udg_RunGroup[8]) == true ) then
                call SetUnitManaBJ(GetTriggerUnit(),80)
            elseif ( IsUnitInGroup(GetTriggerUnit(), udg_RunGroup[7]) == true ) then
                call SetUnitManaBJ(GetTriggerUnit(),70)
            elseif ( IsUnitInGroup(GetTriggerUnit(), udg_RunGroup[6]) == true ) then
                call SetUnitManaBJ(GetTriggerUnit(),60)
            elseif ( IsUnitInGroup(GetTriggerUnit(), udg_RunGroup[5]) == true ) then
                call SetUnitManaBJ(GetTriggerUnit(),50)
            elseif ( IsUnitInGroup(GetTriggerUnit(), udg_RunGroup[4]) == true ) then
                call SetUnitManaBJ(GetTriggerUnit(),40)
            elseif ( IsUnitInGroup(GetTriggerUnit(), udg_RunGroup[3]) == true ) then
                call SetUnitManaBJ(GetTriggerUnit(),30)
            elseif ( IsUnitInGroup(GetTriggerUnit(), udg_RunGroup[2]) == true ) then
                call SetUnitManaBJ(GetTriggerUnit(),20)
            elseif ( IsUnitInGroup(GetTriggerUnit(), udg_RunGroup[1]) == true ) then
                call SetUnitManaBJ(GetTriggerUnit(),10)
            endif
        set u = GetRectCenter(udg_Regions[R2I(GetUnitState(GetTriggerUnit(),UNIT_STATE_MANA))])
        call IssuePointOrderLocBJ( GetTriggerUnit(), "move", u )
        call RemoveLocation(u)
        set u = null
    endfunction
 

Tom Jones

N/A
Reaction score
437
Lets simplify your function a little:

JASS:
private function StartPathActions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer i = 0
    
    loop
        exitwhen IsUnitInGroup(u,udg_RunGroup<i>) == true or udg_RunGroup == null
        set i = i+1
    endloop
    if udg_RunGroup<i> != null then
        call SetUnitState(u,UNIT_STATE_MANA,10*i)
        call IssuePointOrder(u,&quot;move&quot;,GetRectCenterX(udg_Regions<i>),GetRectCenterY(udg_Regions<i>))
    endif
    set u = null
endfunction</i></i></i></i>
Note that a unit's maximum mana or life can't be modified with SetUnitState(...), SetUnitManaBJ(...) or SetUnitLifeBJ(...).

*Edit*
We have systems for setting a unit's maximum life and mana:
Bonus by Cohadar, can be found here under Resources, systems.
Unit properties I believe it's called, can be found on wc3campaigns.
 
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