• 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.

[Trigger] Custom Shop Question

Status
Not open for further replies.
Level 4
Joined
Sep 6, 2012
Messages
88
Hi guys !

Currently I'm making a custom Neutral shop that sells one item only. Generally, all players can buy from it. However, if a player meets a specific condition, I want to prevent them from being able to buy from this shop until the condition effect wears out. So, can anyone teach me how to create a trigger that can do this job for me ?

Thank you very much !
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Two ways:

1. Make a trigger that, when that player buys the item, removes it and refunds them.

2. Replace the shop with a "dummy" shop, and place a shop (with no model) that will contain the item at the same place. Then make a trigger that when a player selects the dummy shop, if they don't have the condition, the real shop is selected for them.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
The easiest way to do it would to be like this

  • Melee Initialization
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • ((Owner of (Buying unit)) is in CannotBuy) Equal to True
    • Actions
      • Player - Add 100 to (Owner of (Buying unit)) Current gold
      • Item - Remove (Item carried by (Buying unit) of type yourItemType)
Though this runs into two problems

1) The buyer has no idea that he was refunded the item. You could just put a text message after saying you cant buy

2) This will consume charges from the item shop.

An additional (but possibly buggy) solution would be to do this. When you would like to disable it for an item, set the myPlayer variable ("player" type) to the player and set the myShop variable ("unit" type) to the shop and run this function

  • Actions
    • Custom script: if GetLocalPlayer() = udg_myPlayer then
    • Custom script: call UnitAddAbility(udg_myShop,'Aloc')
    • Custom script: endif
and to remove this (make sure variables are the same)

  • Actions
    • Custom script: if GetLocalPlayer() = udg_myPlayer then
    • Custom script: call UnitRemoveAbility(udg_myShop,'Aloc')
    • Custom script: endif
although im not sure how its going to work. What this basically does it it makes the shop unselectable for only myPlayer.

now a question for more experienced coders - Does the "locust" ability disable pathing? If it does, i can fix the trigger.

and to
 
Level 4
Joined
Sep 6, 2012
Messages
88
@rulerofiron99: I have a little question, how can I put 2 units on the same spot ? I have tried but they don't seem to look like merged.

@Arhowk: Thank you for your suggestions. However the "refund" method doesn't work well for me when the player doesn't have enough gold to pay the initial fee before being refunded. Also, if possible I'd really like to avoid custom scripting if possible since I'm not a good enough coder to write them on my own.
 
Last edited:
Level 4
Joined
Sep 6, 2012
Messages
88
I made changes to make it possible to pile one on top of the other. However, it's impossible for me to place them exactly in the same spot. I don't know why. Thanks for the help !

Edit: I found out that they never look stacked unless I set these 2 units Pathing - Collision Size and Pathing Map to same values. The problem got solved ! Thank you very much ^^
 
Status
Not open for further replies.
Top