• 🏆 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!

How to detect and make unit can't buy same items

Status
Not open for further replies.
Level 1
Joined
Mar 22, 2020
Messages
2
Hello, I'm a newbie, I have a question.

I have 3 items:
+ Item A : increase 1 dmg
+ Item B : increase 2 dmg
+ Item C : increase 3 dmg

3 items are same type (increase damage), how to make hero cannot buy two of three items and show text. (example : "Cannot buy same type")

Thank you.
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
Welcome to the Hive!
  • Prevent Buying Same Item Type
    • Events
      • Unit - A unit owned by Neutral Passif Sells an item (from shop)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item A
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item B) Equal to TRUE
              • ((Buying unit) has an item of type Item C) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item B
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item A) Equal to TRUE
              • ((Buying unit) has an item of type Item C) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item C
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item A) Equal to TRUE
              • ((Buying unit) has an item of type Item B) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
This trigger will prevent the hero from buying item B and C if he already has item A in his inventory while still being able to buy more of item A.
 

Attachments

  • Prevent Buying Same Item.w3x
    17.3 KB · Views: 24
Last edited:
Level 2
Joined
Mar 1, 2020
Messages
22
Welcome to the Hive!
  • Prevent Buying Same Item Type
    • Events
      • Unit - A unit owned by Neutral Passif Sells an item (from shop)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item A
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item B) Equal to TRUE
              • ((Buying unit) has an item of type Item C) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item B
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item A) Equal to TRUE
              • ((Buying unit) has an item of type Item C) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item C
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item A) Equal to TRUE
              • ((Buying unit) has an item of type Item B) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
This trigger will prevent the hero from buying item B and C if he already has item A in his inventory while still being able to buy more of item A.

Hi, I have a same question about item. I want a item give bear unit bonus Exp every 10 seconds. How to do that
 
Level 1
Joined
Mar 22, 2020
Messages
2
Welcome to the Hive!
  • Prevent Buying Same Item Type
    • Events
      • Unit - A unit owned by Neutral Passif Sells an item (from shop)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item A
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item B) Equal to TRUE
              • ((Buying unit) has an item of type Item C) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item B
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item A) Equal to TRUE
              • ((Buying unit) has an item of type Item C) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Item C
          • Or - Any (Conditions) are true
            • Conditions
              • ((Buying unit) has an item of type Item A) Equal to TRUE
              • ((Buying unit) has an item of type Item B) Equal to TRUE
        • Then - Actions
          • Item - Remove (Sold Item)
          • Game - Display to (All players) the text: Cannot buy same type
        • Else - Actions
This trigger will prevent the hero from buying item B and C if he already has item A in his inventory while still being able to buy more of item A.
it worked. Thank you
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
Hi, I have a same question about item. I want a item give bear unit bonus Exp every 10 seconds. How to do that
You mean give bonus exp to a unit every 10 seconds if it carries a special item? Like this :
  • Add Bonus Exp
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
      • (Paladin 0005 <gen> has an item of type Crown of kings +5) Equal to TRUE
    • Actions
      • Hero - Add 100 experience to Paladin 0005 <gen>, Show level-up graphics
This trigger works for one unit only, it you want to make it generic do this :
  • Add Bonus Exp Generic
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A hero) Equal to TRUE)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has an item of type Crown of kings +5) Equal to TRUE
            • Then - Actions
              • Hero - Add 100 experience to (Picked unit), Show level-up graphics
            • Else - Actions
 
Level 2
Joined
Mar 1, 2020
Messages
22
You mean give bonus exp to a unit every 10 seconds if it carries a special item? Like this :
  • Add Bonus Exp
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
      • (Paladin 0005 <gen> has an item of type Crown of kings +5) Equal to TRUE
    • Actions
      • Hero - Add 100 experience to Paladin 0005 <gen>, Show level-up graphics
This trigger works for one unit only, it you want to make it generic do this :
  • Add Bonus Exp Generic
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A hero) Equal to TRUE)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has an item of type Crown of kings +5) Equal to TRUE
            • Then - Actions
              • Hero - Add 100 experience to (Picked unit), Show level-up graphics
            • Else - Actions
Thank you. Can you explain this script? I dont understand
"set bj_wantDestroyGroup = true"
 
Status
Not open for further replies.
Top