Preserve Miner's order

Learn about and comment on the next version of EotA in development.
Post Reply
Message
Author
User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Preserve Miner's order

#1 Post by Perhaps »

This code is pseudo MUI, it can support up to 8190 miners total (which can never happen), for any team/race configuration, player, etc. Just replace 'hfoo', 'earc', and 'uabo'.

Code: Select all

struct MinerSelectData
    integer oUD
    
    integer OID
    location OL
    real OLX
    real OLY
    widget OT
    
endstruct

Code: Select all

//SELECTION FUNCTIONS
function MinerSelect takes unit u, player p returns nothing
    local integer oUD = GetUnitUserData(u)
    local MinerSelectData ms
    
    if GetPlayerTeam(p) == GetPlayerTeam(GetOwningPlayer(u)) then
        if oUD == 0 then
            set ms = MinerSelectData.create()
            call SetUnitUserData( u, ms )
            call SetUnitOwner( u, p, true)
            set ms.oUD = oUD
        endif
    endif
endfunction
//END SELECTION FUNCTIONS

function SelRoute takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetTriggerPlayer()
    
    if GetUnitTypeId(u) == 'hfoo' then
        call MinerSelect(u, p)
    endif
    if GetUnitTypeId(u) == 'earc' then
        call MinerSelect(u, p)
    endif
    if GetUnitTypeId(u) == 'uabo' then
        call MinerSelect(u, p)
    endif
endfunction

//===========================================================================
function InitTrig_Selection takes nothing returns nothing
    set gg_trg_Selection = CreateTrigger(  )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(0), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(1), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(2), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(3), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(4), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(5), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(6), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(7), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(8), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(9), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(10), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Selection, Player(11), true )
    call TriggerAddAction( gg_trg_Selection, function SelRoute )
endfunction

Code: Select all

function MinerOrder takes unit u, player p, integer ot, widget tw, location tl returns nothing
    local MinerSelectData ms = GetUnitUserData(u)
    set ms.OID = ot
    set ms.OL = tl
    set ms.OLX = GetLocationX(tl)
    set ms.OLY = GetLocationY(tl)
    set ms.OT = tw
    
endfunction
//END ORDER FUNCTION

function OrderRoute takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetTriggerPlayer()
    local location tl = GetOrderPointLoc()
    local widget tw = GetOrderTarget()
    local integer ot = GetIssuedOrderId()
    
    if GetUnitTypeId(u) == 'hfoo' then
        call MinerOrder(u, p, ot, tw, tl)
    endif
    if GetUnitTypeId(u) == 'earc' then
        call MinerOrder(u, p, ot, tw, tl)
    endif
    if GetUnitTypeId(u) == 'uabo' then
        call MinerOrder(u, p, ot, tw, tl)
    endif
endfunction

//===========================================================================
function InitTrig_Order takes nothing returns nothing
    set gg_trg_Order = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Order, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Order, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerAddAction( gg_trg_Order, function OrderRoute )
endfunction

Code: Select all

//DESELECTION FUNCTIONS
function F2cP takes player p returns player
    local integer i = GetPlayerTeam(p)
    
    if i == 0 then
        return Player(0)
    elseif i == 1 then
        return Player(1)
    endif
    return Player(12)
    
endfunction

function MinerDeselect takes unit u, player p returns nothing
    local MinerSelectData ms = GetUnitUserData(u)
    
    if GetPlayerTeam(p) == GetPlayerTeam(GetOwningPlayer(u)) then
        call SetUnitOwner( u, F2cP(p), true )
        if ms.OT == null then
            call IssuePointOrderById( u, ms.OID, ms.OLX, ms.OLY )
        elseif ms.OL == null then
            call IssueTargetOrderById( u, ms.OID, ms.OT )
        endif
        call SetUnitUserData( u, ms.oUD )
        set ms.oUD = 0
        set ms.OID = 0
        set ms.OL = null
        set ms.OLX = 0
        set ms.OLY = 0
        set ms.OT = null
        call ms.destroy()
    endif
    
endfunction
//END DESELECTION FUNCTIONS

function DSelRoute takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetTriggerPlayer()
    
    if GetUnitTypeId(u) == 'hfoo' then
        call MinerDeselect(u, p)
    endif
    if GetUnitTypeId(u) == 'earc' then
        call MinerDeselect(u, p)
    endif
    if GetUnitTypeId(u) == 'uabo' then
        call MinerDeselect(u, p)
    endif

endfunction

//===========================================================================
function InitTrig_Deselection takes nothing returns nothing
    set gg_trg_Deselection = CreateTrigger(  )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(0), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(1), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(2), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(3), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(4), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(5), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(6), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(7), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(8), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(9), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(10), false )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Deselection, Player(11), false )
    call TriggerAddAction( gg_trg_Deselection, function DSelRoute )
endfunction

Image

User avatar
Dekar
Jelly Doughnut
Posts: 1433
Joined: May 27th, 2006, 8:13 am
Realm: Northrend (Europe)
Battle.net name: Dekar
Location: Germany

Re: Preserve Miner's order

#2 Post by Dekar »

Now make it without using UnitUserData for bonus points.
<EotA@Azeroth> YAKS GO MOOOOOOOOOOOOOOOOOOOOOOOO

Dekar: the ultimate ocean themed hero should buff and depend on spawn waves!
DarnYak: why is that
Dekar: WAVES
Dekar: :D
DarnYak: i was afraid that was the answer

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Preserve Miner's order

#3 Post by DarnYak »

I'm not really sure why the current one doesn't work, but mine's a hell of a lot shorter ;P Just haven't had time to figure it out yet.

But everyone seems to hate gloom's miners anyway, so i dont know if it'll last

Thanks though

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Preserve Miner's order

#4 Post by Perhaps »

I could do it without vJass, but why would I want to do the extra steps that would more than likely end up the same way as structures work in Jass. Just get Newgen, it has a better interface for Jass (and of course vJass) anyways.

My first guess is that you try to access the unit's order data after being transfered, in which case is a null value.

It's a good design, probably the fastest map, and anything is better than Candleburg. The current problem for the current Gloomite shit. The workers not retaining given orders making you have to babysit them to their destination makes it flow horribly. Then there's not being able to find the fuckers, there should be some sort of ping function for them like "-o". Then of course there's no control over mining aside for the current clunky control. Being able to manually spawn miners would be really nice to have.
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Preserve Miner's order

#5 Post by DarnYak »

I access it, transfer, then reapply it.

I have NewGen, I just don't like using the completely new language features. Why? A mix of consistnancy (all the old code doesn't have it), a bit of worry if it stops getting developed (this has gotten worse after having so many WoW mods I rely on just stop getting updated), and a large amount of mystery as to exactly what the resulting code is doing (I have enough problems with raw jass). If it were a part fo actual jass i would certainly abuse it to hell, but as it is i'd rather stick to more or less what jass provides.

That's not to say i don't use some simplier features which make life a lot easier, like global blocks anywhere.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Preserve Miner's order

#6 Post by Perhaps »

"a bit of worry if it stops getting developed", that pretty much the first party editor itself, excluding removing features to force you to buy the expansion. But with the way Newgen is right now, it doesn't really need anymore developing.

As long as you're diligent about nullifying/destroying, you should be problem free. MaD Balls, MaD OS, and their current map are pretty much fully coded in vJass and they work just fine. You can also see what goes on with vJass, just place a syntax error or an undeclared variable and you can scroll through the Jass.
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Preserve Miner's order

#7 Post by DarnYak »

Just fyi, fixing this is getting pushed back to 1.12c. That version's going to be dedicated to overhauling Kedge so i'll throw gloom fixes or changes there too.

I'll probably keep gloomite in some form, but alter the way it gets mined significantly (probably something along the lines of mini auto spawned 'outposts' so that its a "hold this spot as long as possible")

DarnYak

Post Reply