Upgrading Ability and more stuff

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
I have a research in my map that upgrades the lumbering on your workers but I have a problem.

To make it perfect I want it to be like this:

1. You finishes the research
2. Your units gets ordered to return their current lumber
3. When they've returned the lumber their ability gets upgraded and they are assigned to a new target..

I know how to do the assign new stuff, but how would I do the return and then upgrading when they've returned? (I don't want the player to lose any lumber because they've researched this.)


Working pieces of code would make wonder as a help.

Edit - The best thing would be if I could do this without any events since then the trigger would be forced to run though out the entire game and cause more load than it ever should do.
 

Exide

I am amazingly focused right now!
Reaction score
448
>I know how to do the assign new stuff, but how would I do the return and then upgrading when they've returned? (I don't want the player to lose any lumber because they've researched this.)
-Why would they lose lumber?

You can pick every unit owned by (Owner of (Triggering unit)) with orderId 852018 (harvest), and order them to "returnresources".
The problem is that players usually right-click ("smart", 851971) on trees, in order to make their workers gather resources. Additionally, it's the same orderId for gathering lumber and gold.
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
> Why would they lose lumber?

Because when you replace the ability then they will start gathering lumber from 0 again instead of just continuing.



The problem is to upgrade them, I want to upgrade them when they've returned their current lumber but without it forcing me to create a trigger that somehow(I don't know how) registers when they've returned it.
 

Exide

I am amazingly focused right now!
Reaction score
448
Well, this trigger will order your units that are harvesting to returnresource when a certain upgrade has been researched. But as I said, it has got flaws.
Maybe you can work something out, though.

JASS:

globals
    group array udg_HarvestGroup
endglobals


function Trig_Finish_Research_Conditions takes nothing returns boolean
    return ( GetResearched() == 'R000' )
endfunction

function CheckOrderId_func takes nothing returns nothing
    if (GetUnitCurrentOrder(GetEnumUnit()) == 852018) then
        call GroupAddUnit(udg_HarvestGroup[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], GetEnumUnit())
    endif
endfunction


function Trig_Finish_Research_Copy_Func004A takes nothing returns nothing
    call IssueImmediateOrderBJ( GetEnumUnit(), "returnresources" )
endfunction


function Trig_Finish_Research_Actions takes nothing returns nothing
    local group g = CreateGroup()
    set g = GetUnitsOfPlayerAll(GetOwningPlayer(GetTriggerUnit()))
    
    call ForGroup(g, function CheckOrderId_func)
    call ForGroup(udg_HarvestGroup[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], function Trig_Finish_Research_Copy_Func004A)
        
    call DestroyGroup(g)
    set g = null
endfunction

//===========================================================================
function InitTrig_Finish_Research takes nothing returns nothing
    local trigger Finish_Research = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( Finish_Research, EVENT_PLAYER_UNIT_RESEARCH_FINISH )
    call TriggerAddCondition( Finish_Research, Condition( function Trig_Finish_Research_Conditions ) )
    call TriggerAddAction( Finish_Research, function Trig_Finish_Research_Actions )
endfunction


'R000' is the certain upgrade.
 
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