Deele
New Member
- Reaction score
- 0
Any way to set data for unit/item using raw data names?
private constant integer unit_id = 039;####039;
Flare said:You could use gamecache, and convert the rawcode to string using I2S and use that value as one key - you could declare a struct with all the required item properties e.g.
JASS:library ItemData initializer Init globals private gamecache itemDataCache private constant string ITEM_DATA_KEY = "ItemProperties" endglobals struct ItemData integer cost real weight //if you wanted items to have a mass, which would have an impact on the carrying units speed or something integer sellPrice //etc endstruct function GetItemData takes integer itemId returns ItemData return ItemData (GetStoredInteger (itemDataCache, I2S (itemId), ITEM_DATA_KEY)) endfunction function SetItemData takes integer itemId, integer cost, real weight, integer sellPrice returns nothing local string s = I2S (itemId) local ItemData a if GetStoredInteger (itemDataCache, s, ITEM_DATA_KEY) == 0 then set a = ItemData.create () set a.cost = cost set a.weight = weight set a.sellPrice = sellPrice call StoreInteger (itemDataCache, s, ITEM_DATA_KEY, integer (a)) endif endfunction private function Init takes nothing returns nothing call FlushGameCache(InitGameCache("Item.cache")) set itemDataCache=InitGameCache("Item.cache") endfunction endlibrary
Although, that does generalize item properties, so if a hero has an ability that allows him to buy items for less/sell them for more, you won't be able to incorporate it directly into this without affecting every other item of that type. If you want something which allows each individual item to have it's own unique properties, use Get/SetItemUserData as Viikuna suggested
For example, tinting of unit CAN be changed, cause that is done in GEM TD, when game starts...
Maybe that is just a multiple units, each set to different tint and when timer comes, they are "replaced" and selected by trigger...