function BlightGoldMineForPlayerBJ takes unit goldMine, player whichPlayer returns unit
local real mineX
local real mineY
local integer mineGold
local unit newMine
// Make sure we're replacing a Gold Mine and not some other type of unit.
if GetUnitTypeId(goldMine) != 'ngol' then
return null
endif
// Save the Gold Mine's properties and remove it.
set mineX = GetUnitX(goldMine)
set mineY = GetUnitY(goldMine)
set mineGold = GetResourceAmount(goldMine)
call RemoveUnit(goldMine)
// Create a Haunted Gold Mine to replace the Gold Mine.
set newMine = CreateBlightedGoldmine(whichPlayer, mineX, mineY, bj_UNIT_FACING)
call SetResourceAmount(newMine, mineGold)
return newMine
endfunction