Disable buying item?

Crusher

You can change this now in User CP.
Reaction score
121
Okay, so I want basically to disable to buy my Tome of Experience once when my hero reaches level 21.

So far I have this:

Trigger:
  • Tome Exp Stop
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Experience
      • (Level of (Triggering unit)) Equal to 21
    • Actions
      • Item - Remove (Item being manipulated)
      • Game - Display to (All players controlled by a ((Owner of (Triggering unit)) controller) player) the text: You can't buy this ...
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Something like this maybe ? :eek:

Trigger:
  • Disable Experience Pickup
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Item-type of (Target item of issued order)) Equal to Tome of Experience
    • Actions
      • Unit - Pause (Triggering unit)
      • Unit - Order (Triggering unit) to Stop
      • Unit - Unpause (Triggering unit)
 

Argentine

New Member
Reaction score
2
fixed your problem :)

I have tested and retested these triggers. I used two very simple triggers to reach our goal.
The first trigger I use sets a "custom value" for any hero which gains a level. The custom value will be set as it's NEW hero level (the level it is after it has gained it's level) This trigger can be used to give triggers a value to refer to as hero level in any situation i can think of, and it's incredibly simple.

Trigger:
  • hero levels
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Unit - Set the custom value of (Leveling Hero) to (Hero level of (Leveling Hero))


Events
Unit - A unit Gains a level
- this will cause the trigger to "fire" once a hero has gained a level, after his level was gained successfully.

This trigger does not require a condition, but you may find a use for one and add it if it applies.

Now on to the actions.
Actions
Unit - Set the custom value of (Leveling Hero) to (Hero level of (Leveling Hero))
- This trigger action is so simple it explains itself. The hero will now and forever have a custom value which is equal to it's current hero level.

Now for our second trigger. This trigger will cause the purchase of the tome of experience to "fail". Detailed explanations of the trigger are underneath the trigger code.

Trigger:
  • hero cant buy tomeofexp
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Buying unit) is A Hero) Equal to True
          • ((Item-type of (Sold Item)) Equal to Tome of Experience) or ((Item-type of (Sold Item)) Equal to Tome of Greater Experience)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Custom value of (Buying unit)) Greater than or equal to 21
        • Then - Actions
          • Player - Disable Item Experience Gain for (Owner of (Buying unit))
          • Player - Disable Item Experience Gain (Greater) for (Owner of (Buying unit))
          • Item - Remove (Sold Item)
          • Game - Display to (Player group((Owner of (Buying unit)))) the text: You can no longer p...
        • Else - Actions
          • Do nothing


Events
Unit - A unit Sells an item (from shop) -
This event will "fire" the trigger when the shop sells the item to a unit.

Conditions
And - All (Conditions) are true -
This condition "all" is the best to use for multiple conditions. occasionally using multiple seperate conditions without being under an "all" category can cause the trigger to be messy and sometimes fail.

underneath "all" i put these: Conditions
((Buying unit) is A Hero) Equal to True
This will make the trigger check that the buying unit is a hero.

((Item-type of (Sold Item)) Equal to Tome of Experience) or ((Item-type of (Sold Item)) Equal to Tome of Greater Experience)
- This will check that our item type is a tome of experience OR a tome of greater experience. Note that i initially used the "or" trigger for this (and i used the "or" within the "ALL conditions field")

Now i will explain our actions.

Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions) This is the best way to check additional "conditions" after the initial conditions were all met.

If - Conditions
(Custom value of (Buying unit)) Greater than or equal to 21
Earlier we made a custom value trigger for our hero. This checks that the hero's "custom value" (in this case = to his hero level) is 21 or higher.

Then - Actions
Player - Disable Item Experience Gain for (Owner of (Buying unit)) - This will disable the ability that is triggered from purchasing or using a tome of experience, causing the item to be used and purchased, but not have any effect on the hero.

Tomes cast a "spell" on our hero when they are picked up or purchased. The "spell" gives us the end result, in this case the gaining of experience. this trigger simply disables the ability of the spell from affecting our hero.


Player - Disable Item Experience Gain (Greater) for (Owner of (Buying unit)) this does the same as the above action for a greater tome of experience ability. (assuming you do not want this to be used either)

Item - Remove (Sold Item) I am not even certain this is needed, but it will make sure the item will in no way be created.

Game - Display to (Player group((Owner of (Buying unit)))) the text: You can no longer purchase Tomes of Experience. just explains to the player owning the unit that bought the item that they can not buy it.
Else - Actions
Do nothing
- This makes sure the trigger will have no effect if the secondary conditions (the conditions set within "if,then,else" parameters, are not true.

IMPORTANT NOTE: This trigger will still use the item from the shop and spend the player's gold!!!!!

You will want to include in your trigger a "then" ACTION (under the if/then/else) which will give the player back the amount of gold which the tome of experience costs on your specific map, like so:
Trigger:
  • Player - Add "X amount" to (Owner of (Buying unit)) Current gold
)

I do not know how to return the item to the stock of a shop when this trigger fires. For instance there are 5 tomes of experience available and the level 21 hero buys one... there will then be only 4 to buy even though the purchase "failed".

The reason your original trigger failed was because you can only remove and item once it has gone onto the map plane or into the inventory of a unit, however, tomes are used as soon as they are acquired by a hero and thus never enter the inventory, and never enter the map plane if purchased from a shop.

Komaqtion's trigger would not work with purchasing the item from a shop, and although it would stop a unit from using a tome which is on the ground already, or "the map plane", if a player were to rapidly click on the tome while standing right next to it he would probably cause memory leaks or possibly get the hero to use the tome of experience despite the trigger.
 

Ayanami

칼리
Reaction score
288
@Argentine, hmm a very detailed explanation. But you could have fixed his trigger by fixing 1 small line.

Trigger:
  • Conditions
    • (Hero level of (Triggering unit)) Greater than or equal to 21


It should be Hero level and not level. Level refers to the unit level. Hero level can be found under integer comparison under "Hero".
 

Argentine

New Member
Reaction score
2
@Argentine, hmm a very detailed explanation. But you could have fixed his trigger by fixing 1 small line.

Trigger:
  • Conditions
    • (Hero level of (Triggering unit)) Greater than or equal to 21


It should be Hero level and not level. Level refers to the unit level. Hero level can be found under integer comparison under "Hero".

Thanks but I changed that line in his trigger, tested it and it wasn't working for me the way he wanted it to work.

Also, Thank you and you're welcome, Crusher.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top