Hallo Hive.
This is a script I wroted so you can get:
ItemGoldCost, ItemLumberCost, ItemGoldValue, ItemLumberValue, that blizzard did not implent in natives.
So I did a little work arround, and it works perfectly for me. But before im
releasing it in the jass section, I want you to test it.
Installation
1. Create a new blank map
2. Copy this script to the map header
3. Use for example to write down the cost & and values into variables.
Thank you for your time
This is a script I wroted so you can get:
ItemGoldCost, ItemLumberCost, ItemGoldValue, ItemLumberValue, that blizzard did not implent in natives.
So I did a little work arround, and it works perfectly for me. But before im
releasing it in the jass section, I want you to test it.
Installation
1. Create a new blank map
2. Copy this script to the map header
JASS:
//===========================================================================================================================================
// Name: GetItemValueSystem =
// Author: MeKC =
// Version: v.1.0 =
//===========================================================================================================================================
//=========================================================================================================================
// Global Variables
//=========================================================================================================================
globals
real udg_givsPOSX = 0
real udg_givsPOSY = 0
integer udg_givsITEM = 0
integer udg_givsSHOP = 'hvlt'
integer udg_givsHERO = 'Hpal'
player udg_givsPLAYER = Player(12)
endglobals
//=========================================================================================================================
// GetItemCost
//=========================================================================================================================
function EnumItemCost takes nothing returns nothing
if GetItemTypeId(GetEnumItem()) == udg_givsITEM then
call RemoveItem(GetEnumItem())
endif
endfunction
function GetItemGoldCost takes integer i returns integer
local integer cost = 0
local integer gold = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD)
local integer wood = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER)
local rect point = Rect(udg_givsPOSX-700,udg_givsPOSY-700,udg_givsPOSX+700,udg_givsPOSY+700)
local unit shop = CreateUnit(udg_givsPLAYER,udg_givsSHOP,udg_givsPOSX,udg_givsPOSY,90)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD,1000000)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER,1000000)
call UnitAddAbility(shop,'Asid')
call AddItemToStock(shop,i,1,1)
call IssueImmediateOrderById(shop,i)
set cost = 1000000 - GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD,gold)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER,wood)
set udg_givsITEM = i
call EnumItemsInRect(point,null,function EnumItemCost)
call RemoveRect(point)
call RemoveUnit(shop)
set shop = null
set point = null
return cost
endfunction
function GetItemLumberCost takes integer i returns integer
local integer cost = 0
local integer gold = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD)
local integer wood = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER)
local rect point = Rect(udg_givsPOSX-700,udg_givsPOSY-700,udg_givsPOSX+700,udg_givsPOSY+700)
local unit shop = CreateUnit(udg_givsPLAYER,udg_givsSHOP,udg_givsPOSX,udg_givsPOSY,90)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD,1000000)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER,1000000)
call UnitAddAbility(shop,'Asid')
call AddItemToStock(shop,i,1,1)
call IssueImmediateOrderById(shop,i)
set cost = 1000000 - GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD,gold)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER,wood)
set udg_givsITEM = i
call EnumItemsInRect(point,null,function EnumItemCost)
call RemoveRect(point)
call RemoveUnit(shop)
set shop = null
set point = null
return cost
endfunction
function GetItemGoldValue takes integer i returns integer
local integer value = 0
local integer gold = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD)
local integer wood = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER)
local unit hero = CreateUnit(udg_givsPLAYER,udg_givsHERO,udg_givsPOSX+128,udg_givsPOSY-97,90)
local unit shop = CreateUnit(udg_givsPLAYER,udg_givsSHOP,udg_givsPOSX,udg_givsPOSY,90)
local item sell = UnitAddItemByIdSwapped(i,hero)
call UnitDropItemTarget(hero,sell,shop)
set value = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD) - gold
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD,gold)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER,wood)
call RemoveUnit(hero)
call RemoveUnit(shop)
call RemoveItem(sell)
set hero = null
set shop = null
set sell = null
return value
endfunction
function GetItemLumberValue takes integer i returns integer
local integer value = 0
local integer gold = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD)
local integer wood = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER)
local unit hero = CreateUnit(udg_givsPLAYER,udg_givsHERO,udg_givsPOSX+128,udg_givsPOSY-97,90)
local unit shop = CreateUnit(udg_givsPLAYER,udg_givsSHOP,udg_givsPOSX,udg_givsPOSY,90)
local item sell = UnitAddItemByIdSwapped(i,hero)
call UnitDropItemTarget(hero,sell,shop)
set value = GetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER) - wood
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_GOLD,gold)
call SetPlayerState(udg_givsPLAYER,PLAYER_STATE_RESOURCE_LUMBER,wood)
call RemoveUnit(hero)
call RemoveUnit(shop)
call RemoveItem(sell)
set hero = null
set shop = null
set sell = null
return value
endfunction
//=========================================================================================================================
//
//=========================================================================================================================
JASS:
local integer a = GetItemGoldCost('ratc')
local integer b = GetItemLumberCost('ratc')
local integer c = GetItemGoldValue('ratc')
local integer d = GetItemLumberValue('ratc')
Thank you for your time