• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Exchanging items interface

Status
Not open for further replies.
Level 3
Joined
Jul 15, 2014
Messages
39
I was thinking about creating a map where u can trade items in stacks. Like wood for food etc, with changing exchange rates. And u can trade with any unit controlled by ai on the map.

Here's in 5 articles what i think i would like to make possible:
1. A hero controlled by player comes close to a unit that has items (unit is not controlled by player).
2. Player clicks on an item in that unit. That item will be item for exchange #1.
3. Player clicks on an item in his hero inventory. That item is for exchange #2.
4. At that point in scoreboard or somewhere else player can see exchange rate which that unit desires (stored in some variable).
5. Player can then click at his ability - buy to exchange #1 for #2 at the rate.

Maybe there are implemented similar pieces of code that i can use?

And if no the question would be:
Can article 2 be done? How do i click at other player's unit item and get it as a variable?
I dont see any related events - like mouse click in some region of interface...
On other articles it seems ill be able to do it.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Here's how I would do it:

AI merchants would have the items available for sale with no cost, no buy items ability, and 1 inventory slot.
1. Drop the stack you want to sell on the merchant. They stack will sit in the merchant's inventory until you conclude the trade.
2. Once the merchant has this item, his shop list gets populated. The charges available for each item would be how many you would receive, based on the amount in the stack you gave the merchant.
3. Click one of these to conclude the trade.

There should be a Cancel button that would return your item stack.

EDIT: To answer your question, you'd have to give each item an ability that does nothing. I suggest the ability Charge Gold and Lumber, with stats set to 0. When this ability is used, you'll have to increase the number of charges in the item to replenish that lost by clicking it.
The event will be "unit starts the effect of an ability", with the condition being to check for this ability.
 
Level 3
Joined
Jun 18, 2014
Messages
30
I have an idea, I don't know if it is 100% succesful or if it is possible (xD).

Make a NPC that can sell items like a shop and add an inventory to this unit, but make sure what the NPC can't sell the items (I mean something like a deactivated shop).
Now the NPC can receive your items, put the item #1 in the inventory of the unit and save it in a variable, when the item is in the NPC's inventory active the shop and you can see the tradeable items, and purchase the item #2, save it in a variable the item and the NPC that sell you the item, now the item #2 is in your inventory and the #1 on NPC's inventory.

Now you have two possible ways that can you accept/cancel the trade:

1. Make two abilities and add these to your hero, if you click in ability 1; accept the trade and remove the item #2 from the shop and add the #1 with the variables, remove the item #1 from the NPC's inventory.
If you click in ability 2; you cancel the trade, remove the item #2 from your inventory and return item #1 with the variables.

2. Make just 1 ability and add this to your hero, if you click in the ability; accept the trade (equal to the first method).
Now, if you want cancel the trade just sell the item #2 and use triggers to cover this action and return automaticaly the item 1# from the NPC's inventory.
 
Level 3
Joined
Jul 15, 2014
Messages
39
that seem to be better way than i thought up, less clicks and more intuitively understandable
gona try it, will it be alright if all units gona be shops, like 1000 shops? shouldnt get too much resources
 
Level 3
Joined
Jun 18, 2014
Messages
30
what method?
I think my way needs just 3 actions.
Put the item #1 on the NPC's inventory (1)
Buy the item #2 (2) - (or cancel now the trade and you have just do 2 actions)
Accept or cancel (3)

But rulerofiron99 method is another good way.

Anyway you can modify our ideas to make a better solution.
 
Level 3
Joined
Jul 15, 2014
Messages
39
what method?
I think my way needs just 3 actions.
Put the item #1 on the NPC's inventory (1)
Buy the item #2 (2) - (or cancel now the trade and you have just do 2 actions)
Accept or cancel (3)

But rulerofiron99 method is another good way.

Anyway you can modify our ideas to make a better solution.

Well ur suggestions are kind of the same, but his is more thoroughly described - he says how exchange rates gona be presented to player.
 
Level 3
Joined
Jul 15, 2014
Messages
39
here's a little problem with my implementation of your suggestions.
what if there are multiple human players near same npc and trying to trade with him

1) player 1 drops an item on the merchant npc.
2) trading is initiated = the items to buy like in shop appears according to exchange rating
3) before the player 1 clicks to buy wanted item other players can click buy

The problem is all other players can click to buy items, can i limit that to only the player who dropped the first item?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
You could make a dummy shop unit.

When you initiate trade and select the shop unit, create an invisible dummy unit and select it for the player. This dummy shop will have the items for sale.

Alternatively, you could disable other players from trading with the shop by deselecting the shop for them if they ever attempt to select it.
 
Level 3
Joined
Jul 15, 2014
Messages
39
Damn, i stumbled upon a bug in ability of shop-unit to pick the hero to trade with.

Bug appears when shop-unit has inventory. Player can drop items from it - he has full controll of inventory. Can even send shop units owned by other players to go pick up items in any point of map.

This is so messy. I need shop-unit to have inventory, so that u can see what resources it has.

Attaching my map if u are curious in bug (Not sure if it is known). Notice how u can send brown player's unit to go pick/drop items because he has inventory and ability to pick hero (?required? to be able to trade like a shop).
 

Attachments

  • RomanEconomy.w3x
    38.6 KB · Views: 36
Level 25
Joined
Jul 10, 2006
Messages
3,315
What allows neutral units to be moved around are:
Select Hero ability
Shop Sharing ability

If you're using the dummy shop method, the original unit doesn't even need these abilities. The only ability this unit needs is Inventory.

1. You drop your item on the unit.
2. Dummy shop is created.
3. Dummy shop is selected for player.
 
Level 3
Joined
Jul 15, 2014
Messages
39
oh, that should work
but next problem:
Should I place the dummy shop on some unreachable place on the map, or move it next to the unit every exchange?

Seems less messy if i dont move it around every time, but how do i cast with triggers the shop ability to pick hero?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
You should move it on top of the neutral unit.

If you set the dummy's model to ".mdx" (no model), it cannot be drag-selected, so the only way to select it would be to redirect a selection of the neutral unit.

1. Save your dummy shop to a variable, e.g. PlayerShop[player id]
2. Trigger:
Event - Player selects a unit
Condition - Unit is a neutral unit in trade
Action - Selection - Select PlayerShop[player id] for triggering player
 
Level 3
Joined
Jul 15, 2014
Messages
39
So I am stuck again.
Is it possible to use 2 dimensional array in worldeditor?
I have an array of items that are sold. ItemsSold[6]
I need to make an array with 10 entries of these arrays.
ItemsSoldinCurrentExchange[10][6]
So that i have 1 array of ItemsSold[6] for each of 10 players with easy access in case i know player number.
 
Level 3
Joined
Jul 15, 2014
Messages
39
I read some tutorials on hashtables, but then i cant find any hastables functions in my worldeditor.
And when i load maps from tutorials it says something like "trigger function is absent in the database: InitHashtableBJ" and other functions.
Is it normal, or maybe something wrong with my warcraft version?
I noticed in all tutorials there are screenshots of the triggers that i dont have, but some mention it might be related to different version of the game, and all the tutorials are dated like 2009-2010. Are hashtables supposed to work through triggers in latest version 1.26a?
 
Last edited:
Level 3
Joined
Jul 15, 2014
Messages
39
Do you think if i do map with using all these new functions in this pack, will people without the pack able to run the map on the clean war3 1.26a version?

Damnit, these hashtables are hard to get to understand. I uploaded the JassNewGenPack 5d, but no new functions about hashtables is added in gui atleast. And i cant add new varibale hashtable with gui. And even if i try to load the maps from hastable tutorials with new editor it gives same errors like "trigger function is absent in the database: InitHashtableBJ" and doesnt load the map.

And the bad thing all the tutorals are from 2008-2010 and using old versions of warcraft
 
Last edited:
Level 3
Joined
Jul 15, 2014
Messages
39
I think i might try to use a massive 1-dimensional array instead of a 2-dimensional one.
Like instead of 10x6 elements use 60 elements. But that will take some more calculations inside the cycle
 
Status
Not open for further replies.
Top