| 05-23-2006, 07:54 AM | #1 |
How do I trigger a unit to pawn an item in its inventory to a neutral store? I want to have a simple system for refunding the cost of an item when it can't be purchased for lack of recipe ingredients or other restrictions. I figure if I just immediately pawn the item back and then create the item and pawn it a second time (at 50% refund rate) then the player will get all their gold/lumber back. If there is a better solution than that, I would like to know that too. |
| 05-23-2006, 08:42 AM | #2 |
Remove the item and give the player back the gold? (There are a couple of ways to get the gold cost of an item: store it's gold value in the item level field (with shift-click), or import the GetItemGoldCost function from common.ai) |
| 05-23-2006, 11:47 AM | #3 |
How to import funcs of common.ai? |
| 05-23-2006, 02:10 PM | #4 |
Copy the function declaration from common.ai into an exported common.j and import the new common.j file into your map (I think it has to go under Scripts\common.j). Note: This only works for a few functions, noteably GetUnitGold/LumberCost and GetItemGold/LumberCost. |
| 05-23-2006, 05:07 PM | #5 |
hmm. would that not extremly blast the mapsize? |
| 05-23-2006, 06:13 PM | #6 |
It has a high possability, its 152kb as it is. Will probaly not gain another kb when you put the code in, just a few bytes, but yes, mapsize will greatly increase. The game holds a common.j anyways, im sure it just ovrerides it while playing it |
| 05-23-2006, 06:40 PM | #7 |
No, it will not increase the map size a lot. Text files compress very well in the MPQ format (last time I checked it added about 14kb). Also, unless blizzard changed something in a patch very recently, it overwrites the patch's common.j. |
| 05-24-2006, 01:46 AM | #8 |
I take it you can't trigger a pawn order. I did a search in the common.ai and there was no GetItemAnything. The only function with the word "item" in it was SetHeroesTakeItems. I am not familiar with importing scripts I suppose there is a tutorial somwhere? Is there any side effects? |
| 05-24-2006, 02:36 PM | #9 |
JASS:native UnitDropItemTarget takes unit whichUnit,item whichItem,widget target returns boolean store the gold before he pawned the item, then pawn it with the trigger, you can now get the amount of gold he got by pawning it, so just add it with a trigger again and you'll pawn all the gold back. You can otherwise store the gold cost of the item into its HP value, when its purchesed, set the HP back to 75, or remove it and refund (item HP) gold if needed. |
| 05-24-2006, 03:15 PM | #10 |
Hmm, I'm sure I remembered there being an item gold cost one :S. Anyway, instead of that, try storing the gold cost of all your items in their item level field (using shift-click to allow large numbers). You can get the level at run-time, and can use that to refund the player. |
| 05-24-2006, 05:45 PM | #11 |
its not quiet that easy, the shop has to hero select the unit before you can have him sell an item, otherwise the item will drop to the floor and no money will be gained. Try it if you don't believe me. |
| 05-24-2006, 08:13 PM | #12 |
weaaddar you are saying the shop has to "hero select" the unit before the unit can pawn the item using UnitDropItemTarget like shadow1500 suggested? Wouldn't the unit already be selected since they just bought the item from the shop? And if not, how would I make the shop do that? I will test this out after work... |
| 05-25-2006, 09:18 AM | #13 |
Alright, I got it working. I had to find the order string for "select hero" which turned out to be neutralinteract. Once I made sure to hero select the pawning unit then that UnitDropItemTarget trigger worked as weaaddar predicted. Unfortunately it shows the gold bounty effect. I made an invisible unit pawn the item to another invisible unit in the corner of the map, but you can still see the +250 gold floating up thru the fog of war if you try. If anybody knows how to get rid of that it would help me sleep a little better at night. ![]() |
