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

Help with Buying Unit

Status
Not open for further replies.
Level 8
Joined
Jun 26, 2019
Messages
318
Hello all. I need help with Buying Unit I am working on for a shop with ships. I want the shop to have 2 requirements before sell a ship to buy a new ship for players. "Change ship." So. The 2 requirements I want on players for their ships are: The ship's LIFE % has to be at max (100%) and all the player's ship's abilities has to be finished cooling down. I tried this and it didn't work. Help please? Thank you.

  • Shops Not Buyable1
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Percentage life of (Buying unit)) Equal to 100.00
              • (Ability Cooldown of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00
              • Or - Any (Conditions) are true
                • Conditions
                  • (Selling unit) Equal to Main Harbor 0018 <gen>
                  • (Selling unit) Equal to Main Harbor 0020 <gen>
    • Actions
      • Player - Add (Integer((Current life of (Sold Item)))) to (Owner of (Buying unit)).Current gold
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-class of (Sold Item)) Equal to Campaign
        • Then - Actions
          • Player - Add (0 - (Integer((Current life of (Sold Item))))) to (Owner of (Buying unit)).Current gold
        • Else - Actions
      • Game - Display to (Player group((Owner of (Buying unit)))) the text: |cffFF3333Your ship...
      • Wait 0.10 seconds
      • Item - Remove (Sold Item)
 
Level 2
Joined
Feb 14, 2020
Messages
19
Hello all. I need help with Buying Unit I am working on for a shop with ships. I want the shop to have 2 requirements before sell a ship to buy a new ship for players. "Change ship." So. The 2 requirements I want on players for their ships are: The ship's LIFE % has to be at max (100%) and all the player's ship's abilities has to be finished cooling down. I tried this and it didn't work. Help please? Thank you.

What you are doing is checking the actual cooldown of an ability. Such as the cooldown of Blizzard, which is 6 seconds.
  • (Ability Cooldown of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00
What you want to do is check the remaining cooldown.
  • (Ability Cooldown Remaining of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00

This part
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • And - All (Conditions) are true
          • Conditions
            • (Percentage life of (Buying unit)) Equal to 100.00
            • (Ability Cooldown of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00
            • Or - Any (Conditions) are true
              • Conditions
                • (Selling unit) Equal to Main Harbor 0018 <gen>
                • (Selling unit) Equal to Main Harbor 0020 <gen>
Should look like this
  • Conditions
    • (Percentage life of (Buying unit)) Equal to 100.00
    • (Ability Cooldown Remaining of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00
    • Or - Any (Conditions) are true
      • Conditions
        • (Selling unit) Equal to Main Harbor 0018 <gen>
        • (Selling unit) Equal to Main Harbor 0020 <gen>
 
Last edited:
Level 20
Joined
Jul 10, 2009
Messages
479
Does the shop sell units?
If so, try using the event "A unit sells a unit" (and refer to the sold unit instead of the sold item within the trigger actions).

A few other things:
  1. You don't need the upper "Or" and "And" block in the conditions, as they don't change the logic.
  2. You currently remove the new ship, when a player meets your requirements. Did't you say that you want to remove it, when he does not meet them?
  3. I'm not sure, if "Sold Item" or "Sold unit" can be used after Waits (like Triggering Unit). You might need to use a local variable instead.
  4. Have you thought about what happens, when the buying unit doesn't have the ability "Captain's Cannon"?
 
Level 8
Joined
Jun 26, 2019
Messages
318
Does the shop sell units?
If so, try using the event "A unit sells a unit" (and refer to the sold unit instead of the sold item within the trigger actions).

A few other things:
  1. You don't need the upper "Or" and "And" block in the conditions, as they don't change the logic.
  2. You currently remove the new ship, when a player meets your requirements. Did't you say that you want to remove it, when he does not meet them?
  3. I'm not sure, if "Sold Item" or "Sold unit" can be used after Waits (like Triggering Unit). You might need to use a local variable instead.
  4. Have you thought about what happens, when the buying unit doesn't have the ability "Captain's Cannon"?
I am trying to find a trigger that will check all abilities to make sure they are all cooldown before buying a new ship. Yes. I am talking about the buyer has to meet the requirements before sold ship. The HP has to be at max because player could just buy same ship again to get HP healed up instantly at the nearly end game, you know? And, players could just buy same ship to refresh the abilities quickly than cooldowning.
 
Level 20
Joined
Jul 10, 2009
Messages
479
Wouldn't you need the Or though to check which is the triggering unit? Since it can't be both at the same time?
I was referring to the upper Or-block (directly below "Conditions"), which is redundant.
As you said, the lower Or-block (containing the Main Harbor stuff) is necessary, because only one Main Harbor will trigger the event at a time.
 
Level 8
Joined
Jun 26, 2019
Messages
318
What you are doing is checking the actual cooldown of an ability. Such as the cooldown of Blizzard, which is 6 seconds.
  • (Ability Cooldown of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00
What you want to do is check the remaining cooldown.
  • (Ability Cooldown Remaining of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00

This part
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • And - All (Conditions) are true
          • Conditions
            • (Percentage life of (Buying unit)) Equal to 100.00
            • (Ability Cooldown of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00
            • Or - Any (Conditions) are true
              • Conditions
                • (Selling unit) Equal to Main Harbor 0018 <gen>
                • (Selling unit) Equal to Main Harbor 0020 <gen>
Should look like this
  • Conditions
    • (Percentage life of (Buying unit)) Equal to 100.00
    • (Ability Cooldown Remaining of (Buying unit) for ability Captain's Cannon , Level: 1.) Equal to 0.00
    • Or - Any (Conditions) are true
      • Conditions
        • (Selling unit) Equal to Main Harbor 0018 <gen>
        • (Selling unit) Equal to Main Harbor 0020 <gen>
Hey, it's still not working... :(
 
Level 2
Joined
Feb 14, 2020
Messages
19
Hey, it's still not working... :(

Nah, it works. I just tried it. The issue if it is not working is because of your actions or additional conditions. Please provide how your new trigger looks.

I attached a test map showing that it is indeed working.

EDIT: ill take a look at your map

@Biglover

Here the test map and see if you can fix it.

Alright I took a look and found several issues.

1. Your shops are selling units, not items. That is the main reason your triggers arent firing. The conditions you have setup are fine. The event is not working.
2. Your shops are being used by multiple triggers. "Change Ship", "Shops not buyable" and "Shops not buyable1". Shops not buyable wont fire since you have it set to item and not unit.
However the "Change ship" trigger will fire no matter what because it lacks conditions.

I personally believe the problem was approached in a wrong manner. But that is just my personal opinion.

Now, I did a very quick Blizzard style fix so you at least have something working as your base.
I put your conditions in change ship trigger instead, moved down the ability checks so we can remove the unit if it doesnt pass the conditions.

Other than that, you got a shit ton of leaks and unnecessary shit, but who cares. One step at time. If you get stuck again, ask and ill be there.

Uploaded.
 

Attachments

  • cooldownRemaining.w3m
    13.9 KB · Views: 16
  • Change Ship Test.w3x
    8.6 MB · Views: 19
Last edited:
Level 8
Joined
Jun 26, 2019
Messages
318
Finally! It's perfect! But, I still have to fix the Not Buyable Shop because I want prevent enemy players buying in the allied base shops to buy a new ship. Because I want name of shop at top of the shop, not computer's name "South Empire," you know? Thanks, man. I will still figure out how to fix Not Buyable Shop trigger.
 
Status
Not open for further replies.
Top