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

[math] trigger

Status
Not open for further replies.
Level 18
Joined
Mar 16, 2008
Messages
721
EDIT: meant to post in world editor help zone

trying to make a trigger that 'crafts' an item if the hero has at least twenty charges sum of two items > or = 20 then the trigger goes off and it works. But i was wondering how i could make it remove a total of twenty of either item, but not more incase they have an excess. So it would need to remove 20 of one type if it was using solely reagent A but what if it's say 10 of A and 11 of B any other combination? I think someone with a better understanding of math could figure out how to express this more elegantly. Can anyone think of any solution that wouldn't involve making a trigger for every possible combination in excess of a sum of 20?

Does this make any sense?

Reagent A is called Artifact Shard and reagent B is called Midnight Ankh.

  • Create Black Artifact
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Not equal to Wagon
      • (Unit-type of (Hero manipulating item)) Not equal to King's Castle
      • ((Hero manipulating item) has an item of type Black Orb) Equal to True
      • ((Charges remaining in (Item carried by (Hero manipulating item) of type Artifact Shard)) + (Charges remaining in (Item carried by (Hero manipulating item) of type Midnight Ankh))) Greater than or equal to 20
      • ((Hero manipulating item) has an item of type Corrupted Ashbringer, Black Artifact Blade) Equal to False
    • Actions
      • Custom script: call DestroyInteger(udg_Shards_plus_Midnightankhs)
      • Set VariableSet Shards_plus_Midnightankhs = ((Charges remaining in (Item carried by (Hero manipulating item) of type Artifact Shard)) + (Charges remaining in (Item carried by (Hero manipulating item) of type Midnight Ankh)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Shards_plus_Midnightankhs Equal to 20
        • Then - Actions
          • Item - Set charges remaining in (Item carried by (Hero manipulating item) of type Artifact Shard) to ((Charges remaining in (Item carried by (Hero manipulating item) of type Artifact Shard)) - 20)
          • Item - Remove (Item carried by (Hero manipulating item) of type Artifact Shard)
          • Item - Set charges remaining in (Item carried by (Hero manipulating item) of type Midnight Ankh) to ((Charges remaining in (Item carried by (Hero manipulating item) of type Midnight Ankh)) - 20)
          • Item - Remove (Item carried by (Hero manipulating item) of type Midnight Ankh)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Shards_plus_Midnightankhs Greater than 20
        • Then - Actions
          • Item - Set charges remaining in (Item carried by (Hero manipulating item) of type Midnight Ankh) to (Shards_plus_Midnightankhs - 20)
          • Item - Set charges remaining in (Item carried by (Hero manipulating item) of type Artifact Shard) to ((Charges remaining in (Item carried by (Hero manipulating item) of type Artifact Shard)) - 20)
          • Item - Remove (Item carried by (Hero manipulating item) of type Artifact Shard)
        • Else - Actions
          • Do nothing
      • Hero - Create Corrupted Ashbringer, Black Artifact Blade and give it to (Hero manipulating item)
      • Quest - Display to (All players) the Quest Update message: A |cff333333Black K...
      • Neutral Building - Enable Way Gate 0688 <gen>
      • Animation - Reset Way Gate 0688 <gen>'s animation
      • Neutral Building - Enable Way Gate 0690 <gen>
      • Animation - Reset Way Gate 0690 <gen>'s animation
      • Neutral Building - Enable Way Gate 0691 <gen>
      • Animation - Reset Way Gate 0691 <gen>'s animation
      • Neutral Building - Enable Way Gate 0259 <gen>
      • Animation - Reset Way Gate 0259 <gen>'s animation
      • Destructible - Open Iron Gate (Vertical) 4193 <gen>
      • Destructible - Open Gate (Vertical) 1093 <gen>
      • Destructible - Open Elven Gate (Horizontal) 1652 <gen>
      • Destructible - Open Ice Rock Gate (Vertical) 3260 <gen>
      • Destructible - Open Ice Rock Gate (Horizontal) 3202 <gen>
      • Destructible - Open Ice Rock Gate (Vertical) 3203 <gen>
      • Destructible - Open Ice Rock Gate (Horizontal) 3259 <gen>
      • Cinematic - Ping minimap for Winning_Group_Var at (Center of NE Gateway <gen>) for 5.00 seconds
      • Cinematic - Ping minimap for Winning_Group_Var at (Center of NW Gateway <gen>) for 5.00 seconds
      • Cinematic - Ping minimap for Winning_Group_Var at (Center of SE Gateway <gen>) for 5.00 seconds
      • Cinematic - Ping minimap for Winning_Group_Var at (Center of SW Gateway <gen>) for 5.00 seconds
      • Cinematic - Ping minimap for Losing_Group_Var at (Center of NE Gateway <gen>) for 5.00 seconds
      • Cinematic - Ping minimap for Losing_Group_Var at (Center of NW Gateway <gen>) for 5.00 seconds
      • Cinematic - Ping minimap for Losing_Group_Var at (Center of SE Gateway <gen>) for 5.00 seconds
      • Cinematic - Ping minimap for Losing_Group_Var at (Center of SW Gateway <gen>) for 5.00 seconds
      • Trigger - Turn on Black Artifact Already Made <gen>
      • Trigger - Turn off (This trigger)
 
Last edited:
What is the priority of the removal of both reagents? Is reagent A gets priority or the other way?

What happens in each of these scenarios?

Reagent AReagent B
1110
1011
620
206

If Reagent A is the priority, then the answer for each:
1 Reagent B
1 Reagent B
14 Reagent B
6 Reagent B

If Reagent B:
1 Reagent A
1 Reagent A
6 Reagent A
14 Reagent A

Now, if they're balanced. It gets trickier, and I'm not sure the best math for "balanced" proportion. The trickiest scenario is if the reagent number is odd, making it challenging to calculate.
 
Status
Not open for further replies.
Top