• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to make a Gamble Shop?

Status
Not open for further replies.
Level 4
Joined
Jul 28, 2009
Messages
67
Hi guys, it's been a while since I've been on the forums again, but I'm stuck yet one more time. I'm in the middle of making an Arena style map and I wish to add certain shops in each team's base. I wanted to create a shop where a player could spend a certain amount of money and receive a totally random item, like a gamble shop.

Any ideas? All the help is appreciated!
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
You could add each item to and item-type array and then create a random item type:

  • Set Item_Type[1] = Alleria's Flute of Accuracy
  • Hero - Create Item_Type[(Random integer number between 1 and 10)] and give it to (Buying Unit)
You would obviously change 10 to however many items you have. I'm sure there are other much easier ways to do it though.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
To make it simply use jass function, exactly the same one the 'Random Item' (from item's palete) uses:

<for GUI we gonna use 'Loc' type>:
  • Set p = <position>
  • Custom script: call CreateItemLoc(ChooseRandomItem(1), udg_p )
  • Custom script: call RemoveLocation(udg_p)
Although as you can see, script creates random item of given level - even the 'Random Item' does that, because strictly 'random' doens't exist.
 
Last edited:

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
System idea credits mr.bean987


here is finished gamble you got to modify the items.
  • Gamble shop
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Gamble
    • Actions
      • -------- Add items here --------
      • Set Gamble_item[1] = Claws of Attack +15
      • Set Gamble_item[2] = Crown of Kings +5
      • Set Gamble_item[3] = Kelen's Dagger of Escape
      • Set Gamble_item[4] = Orb of Frost
      • Set Gamble_item[5] = Mask of Death
      • -------- number of items here --------
      • Set Gamble_number = (Random integer number between 1 and 5)
      • -------- Dont move this --------
      • Hero - Create Gamble_item[Gamble_number] and give it to (Buying unit)
      • Item - Remove (Sold Item)
map is here just copy the trigger into your map
 

Attachments

  • gamble request.w3x
    17 KB · Views: 47
Level 17
Joined
Feb 11, 2011
Messages
1,860
You should do this in 2 separate triggers, 1 runs at map initialization and the other when someone buys the Gamble item:

  • Map Setup
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set Gamble_item[1] = Claws of Attack +15
      • Set Gamble_item[2] = Crown of Kings +5
      • Set Gamble_item[3] = Kelen's Dagger of Escape
      • Set Gamble_item[4] = Orb of Frost
      • Set Gamble_item[5] = Mask of Death
  • Gamble shop
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Gamble
    • Actions
      • Hero - Drop (Item being manipulated) from (Buying unit)
      • Hero - Create Gamble_item[Random number between 1 and 5] and give it to (Buying unit)
      • Item - Remove (Last dropped item)
 
Status
Not open for further replies.
Top