Gold Mine for the Orc

Status
Not open for further replies.
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hello guys I just wanted to ask, is it possible for the orc race to have something like the enchanted or haunted gold mine at the start of the melee game? Without replacing or switching of any races.
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
You can probably change the buildings or the ability to make something like enchanted or haunted gold mine.

I create a custom building from the entangled gold mine and name it new gold mine, problem is how to make it appear when the game starts. You know that when you chose Night Elf or Undead and when the game starts, you can see that there's already an entangled gold mine or haunted gold mine.
 
Level 20
Joined
Jul 14, 2011
Messages
877
Put this in your map header:
JASS:
function CheckForOrc takes nothing returns nothing
    // Set to 'false' if you don't want to transfer the unit to the player
    local boolean toTransfer = true
    // Replace 'ofor' with the rawcode of your new goldmine
    local integer newMine = 'ofor'
    local integer i = 0
    local player p
    local race r
    local unit u
    loop
        set p = Player(i)
        set r = GetPlayerRace(p)
        if (r == RACE_ORC) then
            set u = MeleeFindNearestMine(GetStartLocationLoc(GetPlayerStartLocation(p)), 2000)
            if u != null then
                if toTransfer then
                    call SetUnitOwner(u, p, true)
                endif
                call ReplaceUnitBJ(u, newMine, 3)
            endif
        endif
        set i = i + 1
        exitwhen i == 12
    endloop
endfunction
Configure it and then do this at map init:
  • Custom script: call CheckForOrc()
If you want I make it a bit more configurable but I'm too lazy to replace the BJ's right now
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
877
Apparently, I forgot to update the function, so here it is:

JASS:
function ChangeStartingMine takes player p, integer newMine, boolean toTransfer returns nothing
    local integer i = 0
    local integer id
    local real x
    local real y
    local real lx
    local real ly
    local real cDist
    local real mDist = -1
    local unit u
    local unit fogu
    local location l = GetStartLocationLoc(GetPlayerStartLocation(p))
    local group g = CreateGroup()
    set lx = GetLocationX(l)
    set ly = GetLocationY(l)
    call GroupEnumUnitsInRange(g, lx, ly, 2000, null)
    loop
        set fogu = FirstOfGroup(g)
        set id = GetUnitTypeId(fogu)
        if id == 'ngol' or id == 'ugol' or id == 'egol' then
            set x = GetUnitX(fogu)
            set y = GetUnitY(fogu)
            set cDist = SquareRoot((lx - x)*(lx - x) + (ly - y)*(ly - y))
            if (mDist < 0) or (cDist < mDist) then
                set u = fogu
                set mDist = cDist
            endif
        endif
        exitwhen fogu == null
        call GroupRemoveUnit(g, fogu)
    endloop
    if u != null then
        if toTransfer then
            call SetUnitOwner(u, p, true)
        endif
        set x = GetUnitX(u)
        set y = GetUnitY(u)
        call RemoveUnit(u)
        if toTransfer then
            call CreateUnit(p, newMine, x, y, 270)
        else
            call CreateUnit(Player(15), newMine, x, y, 270)
        endif
    endif
    call RemoveLocation(l)
endfunction

WHAT DOES IT DO?
It will replace the nearest (entangled/haunted/normal) gold mine in 2000 range(default melee gold mine range) to player p's starting location with an integer newMine(rawcode of the new unit). If boolean toTransfer is true, the new mine will be transfered to player p.
If you use the regular map initialization trigger, make sure to run this after it. Else, units wont appear between the main building and the mine (and possibly other problems).

HOW TO USE:
In order to use this 'snippet', or whatever you wanna call it, you need to first put it in your map header (Trigger Editor > Map Name).

Then you need to change the starting mines, you should loop through all players yourself and call the function like this: call ChangeStartingMine(<Player>, <New Mine Rawcode>, <Transfer Boolean>)(use custom script if you use GUI). This is so you make the conditions yourself. Whether it be a dialog selection, or something else - you wont have to edit the function.

Example usage:
JASS:
loop
    set p = Player(i)
    if GetPlayerRace(p) == RACE_ORC and SomeBooleanArrayThatYouHaveSetPreviously[i] then
        call ChangeStartingMine(p, 'ofor', true)
        //Replaces player p's mine with a War Mill and transfers it to him
    endif
    exitwhen i == 12
    set i = i + 1
endloop
 
Last edited:
Status
Not open for further replies.
Top