• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

I end up with incorrect amounts of items in this item recipe script.

Status
Not open for further replies.
Level 7
Joined
Mar 16, 2014
Messages
152
Hey, I have a relatively simple trigger.

Here is the desired functionality:

If a particle item is picked up, the amount of charges in the particle combines. If the hero has over 175, 175 particles are deducted and the hero gets a shard 1. With 350 it becomes shard 2, 525 shard 3, and 700 it becomes a philosopher's stone.

This basic functionality works in-game, but for whatever reason I mess up the data of the amount of particles somewhere in the trigger. The hero gets a bigger shard/stone than they're supposed to, and they end with more particles than they're supposed to. It is very strange.

  • Phil Particles Get
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Philosopher's Particles
    • Actions
      • Trigger - Turn off (This trigger)
      • Set VariableSet TempInteger = 0
      • Set VariableSet Temp_Unit = (Hero manipulating item)
      • Set VariableSet TempInt = (Charges remaining in (Item being manipulated))
      • Game - Display to (All players) the text: (Particles Acquired: + (String(TempInt)))
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If ((Item-type of (Item carried by Temp_Unit in slot (Integer A))) Equal to Philosopher's Particles) then do (Set VariableSet TempInteger = (TempInteger + 1)) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInteger Greater than 1
        • Then - Actions
          • Item - Remove (Item being manipulated)
        • Else - Actions
      • Game - Display to (All players) the text: (Particles currently have: + (String((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((TempInt + (Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles))) + 0) Less than or equal to 174
        • Then - Actions
          • Item - Set charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles) to ((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)) + TempInt)
          • Game - Display to (All players) the text: (Ending Particle Amount: + (String((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)))))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((TempInt + (Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles))) + 0) Equal to 175
            • Then - Actions
              • Item - Remove (Item carried by Temp_Unit of type Philosopher's Particles)
              • Hero - Create Philosopher's Shard 1 and give it to Temp_Unit
              • Game - Display to (All players) the text: debug shard 1 made
              • Game - Display to (All players) the text: (Ending Particle Amount: + (String((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)))))
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((TempInt + (Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles))) + 0) Less than 350
                • Then - Actions
                  • Item - Set charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles) to ((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)) + (TempInt - 175))
                  • Set VariableSet Particle = (Item carried by Temp_Unit of type Philosopher's Particles)
                  • Hero - Drop Particle from Temp_Unit.
                  • Hero - Create Philosopher's Shard 1 and give it to Temp_Unit
                  • Game - Display to (All players) the text: debug shard 1 made
                  • Game - Display to (All players) the text: (Ending Particle Amount: + (String((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)))))
                  • Hero - Give Particle to Temp_Unit
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((TempInt + (Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles))) + 0) Less than 525
                    • Then - Actions
                      • Item - Set charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles) to ((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)) + (TempInt - 350))
                      • Set VariableSet Particle = (Item carried by Temp_Unit of type Philosopher's Particles)
                      • Hero - Drop Particle from Temp_Unit.
                      • Hero - Create Philosopher's Shard 2 and give it to Temp_Unit
                      • Game - Display to (All players) the text: debug shard 2 made
                      • Game - Display to (All players) the text: (Ending Particle Amount: + (String((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)))))
                      • Hero - Give Particle to Temp_Unit
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((TempInt + (Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles))) + 0) Less than 700
                        • Then - Actions
                          • Item - Set charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles) to ((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)) + (TempInt - 525))
                          • Set VariableSet Particle = (Item carried by Temp_Unit of type Philosopher's Particles)
                          • Hero - Drop Particle from Temp_Unit.
                          • Hero - Create Philosopher's Shard 3 and give it to Temp_Unit
                          • Game - Display to (All players) the text: debug shard 3 made
                          • Game - Display to (All players) the text: (Ending Particle Amount: + (String((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)))))
                          • Hero - Give Particle to Temp_Unit
                        • Else - Actions
                          • Item - Set charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles) to ((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)) + (TempInt - 700))
                          • Set VariableSet Particle = (Item carried by Temp_Unit of type Philosopher's Particles)
                          • Hero - Drop Particle from Temp_Unit.
                          • Hero - Create Philosopher's Stone and give it to Temp_Unit
                          • Game - Display to (All players) the text: debug stone made
                          • Game - Display to (All players) the text: (Ending Particle Amount: + (String((Charges remaining in (Item carried by Temp_Unit of type Philosopher's Particles)))))
                          • Hero - Give Particle to Temp_Unit
      • Trigger - Turn on (This trigger)
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
If you're sure the logic is sound then try using non-generic variables. Maybe another trigger that uses these variables is interfering. Also, don't use Integer A in your For Loop.

Also, I think you're counting the Item you just acquired in your For Loop:
  • If ((Item-type of (Item carried by Temp_Unit in slot (Integer A))) Equal to Philosopher's Particles) then do (Set VariableSet TempInteger = (TempInteger + 1)) else do (Do nothing)
So TempInteger will ALWAYS be at least 1.

I attached a map with a system that seems to work. I think it does exactly what you needed.
 

Attachments

  • Combine Charges Loop.w3m
    19.2 KB · Views: 13
Last edited:
Level 7
Joined
Mar 16, 2014
Messages
152
If you're sure the logic is sound then try using non-generic variables. Maybe another trigger that uses these variables is interfering. Also, don't use Integer A in your For Loop.

Also, I think you're counting the Item you just acquired in your For Loop:
  • If ((Item-type of (Item carried by Temp_Unit in slot (Integer A))) Equal to Philosopher's Particles) then do (Set VariableSet TempInteger = (TempInteger + 1)) else do (Do nothing)
So TempInteger will ALWAYS be at least 1.

I attached a map with a system that seems to work. I think it does exactly what you needed.
Thank you, your system for the most part works and is what I wanted.

The only issue is if picking up an amount of particles 175+ when you have no particles, that the shards will not get made. The check to produce shards only occurs when combining particles.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
Thank you, your system for the most part works and is what I wanted.

The only issue is if picking up an amount of particles 175+ when you have no particles, that the shards will not get made. The check to produce shards only occurs when combining particles.
Ah, I knew I was making a mistake somewhere. Try this version.

Edit: Attached a fix, hopefully it works!
 

Attachments

  • Combine Charges Loop Fix2.w3m
    19.3 KB · Views: 13
Last edited:
Status
Not open for further replies.
Top