| 11-05-2008, 08:23 PM | #1 |
Yes, how to replenish items in a shop? I've been searching around in WE but I haven't found anything yet... Edit - I found some functions that I think should do that but I can't get them to work.. Here's my code: JASS:library BuyItem initializer InitTrig //! textmacro BuyItem takes ID, gCost, lCost if GetItemTypeId(i) == $ID$ then if rg >= $gCost$ and rl >= $lCost$ then call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, rg - $gCost$) call SetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER, rl - $lCost$) else call RemoveItem(i) call BJDebugMsg("Sorry, not enough gold/wood to buy that item") call AddItemToStock(gg_unit_h000_0002, $ID$, 1, 1) endif endif //! endtextmacro private function Act takes nothing returns boolean local item i = GetSoldItem() local unit u = GetBuyingUnit() local player p = GetOwningPlayer(u) local integer rg = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) local integer rl = GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) //! runtextmacro BuyItem("'I000'", "300", "300") set i = null set u = null set p = null return false endfunction private function InitTrig takes nothing returns nothing local trigger Trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(Trig, EVENT_PLAYER_UNIT_SELL_ITEM) call TriggerAddCondition(Trig, Condition(function Act)) endfunction endlibrary Edit - .. added the "Sell item" ability to the shop, so now the item replenish but I still have the item that's restocking in the shop when I buy it... and when I buy the second the item it doesn't get removed by my trigger. |
| 11-06-2008, 11:47 PM | #2 |
Well, the line is under the items statistics by the name of 'stock replenish interval' If I remember correctly. Now this is the amount in seconds as to how long it takes 1 'charge' of this item to replenish. You can also set the stock maximum as well, as well as the stock start delay. Again its all under the items tab for the specific item. If you want something to be able to accept items to sell, then I think the option is under the unit itself as to wheather it can have items sold to it. |
| 11-07-2008, 10:27 AM | #3 |
That's not the problem, if you read the code then you see that I remove the item if the user has less then 300 gold to simulate not having enough gold. But now I need to replenish it so you can't go there and buy all items to spoil it for other players, and therefore I try to trigger it this way. |
| 11-08-2008, 04:44 AM | #4 |
Should Have been more specific as to what you wanted. Although speaking from a players perspective I would find it annoying If I could not see the entire shops stock. Say theres a good item that would fit whatever stratagy or plan I have going, and say Im 50 gold short of said item, I do not see item, so I take a less desirable but still useful to the plan item, but not perfect. When I find out about this item I would most likley be at least a little annoyed depending on the type of map, and whether or not I can sell it for full price. If you are worried about somebody drianing a shops stock and ruining it for other players, just make the item restock instantly, or remove thier ability to purchase more when they have purchased a certian amount. |
| 11-08-2008, 04:27 PM | #5 |
.. if I would make them restock instantly, then I would need to trigger the whole restocking process since the items needs to have cooldowns. And, I will include the item costs in the tooltips. |
| 11-10-2008, 05:03 PM | #6 |
I still need help. Edit - Problem solved.. I need to add items by triggers to be able to remove them with triggers. |
