//地圖初始化的資料(設立16個物品和16個模擬被購買的單位)
function intz takes nothing returns nothing
set intz = CreateTrigger()
call TriggerAddAction(intz, function Trig_intz2)
endfunction
function intz2 takes nothing returns nothing
//出售單位後獲得的物品
set P[1] = 'I000' //A
set P[2] = 'I001' //B
set P[3] = 'I002' //A1
set P[4] = 'I003' //B1
set P[5] = 'I004' //A2
set P[6] = 'I005' //B2
set P[7] = 'I006' //A3
set P[8] = 'I007' //B3
set P[9] = 'I008' //A4
set P[10] = 'I009' //B4
set P[11] = 'I010' //A5
set P[12] = 'I011' //B5
set P[13] = 'I012' //A6
set P[14] = 'I013' //B6
set P[15] = 'I014' //A7
set P[16] = 'I015' //B7
//模擬的出售單位
set T[1] = 'e000' //A
set T[2] = 'e001' //B
set T[3] = 'e002' //A1
set T[4] = 'e003' //B1
set T[5] = 'e004' //A2
set T[6] = 'e005' //B2
set T[7] = 'e006' //A3
set T[8] = 'e007' //B3
set T[9] = 'e008' //A4
set T[10] = 'e009' //B4
set T[11] = 'e010' //A5
set T[12] = 'e011' //B5
set T[13] = 'e012' //A6
set T[14] = 'e013' //B6
set T[15] = 'e014' //A7
set T[16] = 'e015' //B7
endfunction
// main function (要設置gold)
function buy_item takes nothing returns nothing
set buy_item = CreateTrigger()
call TriggerRegisterUnitEvent( buy_item, gg_unit_n000_0000, EVENT_UNIT_SELL )
call TriggerAddAction(buy_item, function buy_item2)
endfunction
function buy_item2 takes nothing returns nothing
if ((IsUnitType(GetBuyingUnit(), UNIT_TYPE_HERO) == true)) then
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 16
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ((GetUnitTypeId(GetSoldUnit()) == T[bj_forLoopAIndex])) then
if ((bj_forLoopAIndex < 2)) then
if ((I[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] == false)) then
call UnitAddItemByIdSwapped( P[bj_forLoopAIndex], GetBuyingUnit() )
set I[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] = true
else
call SetPlayerStateBJ( GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD) + 100 ) )
endif
else
if ((bj_forLoopAIndex < 4)) then
if ((II[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] == false)) then
call UnitAddItemByIdSwapped( P[bj_forLoopAIndex], GetBuyingUnit() )
set II[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] = true
else
call SetPlayerStateBJ( GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD) + 100 ) )
endif
else
if ((bj_forLoopAIndex < 6)) then
if ((III[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] == false)) then
call UnitAddItemByIdSwapped( P[bj_forLoopAIndex], GetBuyingUnit() )
set III[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] = true
else
call SetPlayerStateBJ( GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD) + 100 ) )
endif
else
if ((bj_forLoopAIndex < 8)) then
if ((IIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] == false)) then
call UnitAddItemByIdSwapped( P[bj_forLoopAIndex], GetBuyingUnit() )
set IIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] = true
else
call SetPlayerStateBJ( GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD) + 100 ) )
endif
else
if ((bj_forLoopAIndex < 10)) then
if ((IIIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] == false)) then
call UnitAddItemByIdSwapped( P[bj_forLoopAIndex], GetBuyingUnit() )
set IIIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] = true
else
call SetPlayerStateBJ( GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD) + 100 ) )
endif
else
if ((bj_forLoopAIndex < 12)) then
if ((IIIIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] == false)) then
call UnitAddItemByIdSwapped( P[bj_forLoopAIndex], GetBuyingUnit() )
set IIIIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] = true
else
call SetPlayerStateBJ( GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD) + 100 ) )
endif
else
if ((bj_forLoopAIndex < 14)) then
if ((IIIIIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] == false)) then
call UnitAddItemByIdSwapped( P[bj_forLoopAIndex], GetBuyingUnit() )
set IIIIIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] = true
else
call SetPlayerStateBJ( GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD) + 100 ) )
endif
else
if ((IIIIIIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] == false)) then
call UnitAddItemByIdSwapped( P[bj_forLoopAIndex], GetBuyingUnit() )
set IIIIIIII[GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))] = true
else
call SetPlayerStateBJ( GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetOwningPlayer(GetBuyingUnit()), PLAYER_STATE_RESOURCE_GOLD) + 100 ) )
endif
endif
endif
endif
endif
endif
endif
endif
else
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
else
endif
endfunction