Nestharus
o-o
- Reaction score
- 84
Update : )
local integer id = itemTypeId-(itemTypeId/8191)*8191
loop
exitwhen itemTypes[id] == itemTypeId or itemTypes[id] == 0
set id = id + 1
endloop
public function GetItemId takes integer itemTypeId returns integer
local integer playerGold
local integer playerWood
local integer id = itemTypeId-(itemTypeId/8191)*8191
loop
exitwhen itemTypes[id] == itemTypeId or itemTypes[id] == 0
set id = id + 35
if id > 8191 then
set id = 1
endif
endloop
if (itemTypes[id] == 0) then
set playerGold = GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD)
set playerWood = GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER)
set itemTypes[id] = itemTypeId
set currentItemType = itemTypeId
set currentItemId = id
call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD, RESOURCE_LIMIT)
call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER, RESOURCE_LIMIT)
call AddItemToStock(costRetriever, itemTypeId, 1, 1)
call IssueNeutralImmediateOrderById(playerChecker, costRetriever, itemTypeId)
set goldCost[id] = RESOURCE_LIMIT - GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD)
set woodCost[id] = RESOURCE_LIMIT - GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER)
call RemoveItemFromStock(costRetriever, itemTypeId)
call EnumItemsInRect(removalArea, null, function RemoveItems)
call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD, playerGold)
call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER, playerWood)
endif
return id
endfunction
public function GetItemId takes integer itemTypeId returns integer
local integer playerGold
local integer playerWood
local integer id = itemTypeId-(itemTypeId/8191)*8191
loop
if (itemTypes[id] == 0) then
set playerGold = GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD)
set playerWood = GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER)
set itemTypes[id] = itemTypeId
set currentItemType = itemTypeId
set currentItemId = id
call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD, RESOURCE_LIMIT)
call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER, RESOURCE_LIMIT)
call AddItemToStock(costRetriever, itemTypeId, 1, 1)
call IssueNeutralImmediateOrderById(playerChecker, costRetriever, itemTypeId)
set goldCost[id] = RESOURCE_LIMIT - GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD)
set woodCost[id] = RESOURCE_LIMIT - GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER)
call RemoveItemFromStock(costRetriever, itemTypeId)
call EnumItemsInRect(removalArea, null, function RemoveItems)
call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD, playerGold)
call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER, playerWood)
endif
exitwhen itemTypes[id] == itemTypeId // or itemTypes[id] == 0
set id = id + 35
if id > 8191 then
set id = id - 8191 // Improvement. Minimal collision chances.
endif
endloop
return id
endfunction
Settings:
*///===================================================================
//! textmacro Gcsn_USER_SETTINGS
set coordX = GetRectCenterX(bj_mapInitialPlayableArea)
set coordY = GetRectCenterY(bj_mapInitialPlayableArea)
//! endtextmacro
//! textmacro Gcsn_REGISTERED_PLAYERS
exitwhen x == GetPlayerCount()
set p = GetPlayer(x)
//! endtextmacro
//! textmacro Gcsn_EXTRA_PLAYERS
//call TriggerRegisterPlayerUnitEvent(decay, Player(15), EVENT_PLAYER_UNIT_DEATH, null)
//! endtextmacro
Aside from requireing graveyarded resources and having this settings area that makes no sense to anyone except Nestharus, this is looking pretty good.
This also still doesn't implement GetDeathBounty as an event response like I mentioned in that other thread. Please steal said code. If you fix all this maybe this can be approved.
The name must be changed from "states", as this has nothing to do with states. You should know that unit states and player states exist as native stuff in WC3.
Using standard naming conventions for your library would also be greatly appreciated and give people a chance in hell of using this (actually, the name I gave the thread dose that for you).