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

[Trigger] Recipe overlaps, making my system useless

Status
Not open for further replies.
Level 6
Joined
Feb 5, 2017
Messages
32
I've recently made a Recipe System, it's easy to use and flexible, but it works as long as you don't have recipes with similar items, which is bogging me.

The Recipe System

Problem:

  • Inventory System Run
    • Events
    • Conditions
    • Actions
      • Set InventorySystem_Recap = 0
      • -------- Conteo de los objetos --------
      • For each (Integer A) from 1 to 6, do (Actions)
        • Bucle: Actions
          • Set InventorySystem_GoodToGo = False
          • For each (Integer B) from 1 to InventorySystem_Max, do (Actions)
            • Loop: Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If: Conditions
                  • InventorySystem_GoodToGo Equal to False
                  • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to InventorySystem_Objects[(Integer B)]
                • Then: Actions
                  • Set InventorySystem_GoodToGo = True
                  • Set InventorySystem_Recap = (InventorySystem_Recap + 1)
                • Else: Actions
      • -------- Creación del objeto --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If: Conditions
          • InventorySystem_Recap Equal to InventorySystem_Max
        • Then: Actions
          • For each (Integer A) from 1 to InventorySystem_Max, do (Actions)
            • Loop: Actions
              • Item - Remove (Item carried by (Triggering unit) of type InventorySystem_Objects[(Integer A)])
          • Special Effect - Create a special effect at (Position of (Triggering unit)) using InventorySystem_Model
          • Special Effect - Destroy (Last created special effect)
          • Hero - Create InventorySystem_FinalObject and give it to (Triggering unit)
        • Else: Actions

  • Item Base A
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Ring of Protection +1
          • (Item-type of (Item being manipulated)) Equal to Rock
    • Actions
      • -------- How many items are we combining?--------
      • Set InventorySystem_Max = 2
      • -------- Object List --------
      • Set InventorySystem_Objects[1] = Ring of Protection +1
      • Set InventorySystem_Objects[2] = Rock
      • -------- Final Item --------
      • Set InventorySystem_FinalObject = Infernal Stone
      • -------- Model. --------
      • Set InventorySystem_Model = Abilities\Spells\Items\AIlm\AIlmTarget.mdl
      • -------- - --------
      • -------- Detonador para las recetas --------
      • -------- No borrar --------
      • Trigger - Run Inventory System Run <gen> (checking conditions)

I can redo the system on JASS but i think it might ruin the easy process of making a recipe with the base trigger.
Is there any solution to this system without recurring to a complete overhaul? I was thinking of registering the recipes on init and using hashtables, but wouldn't it cause leaks?
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Using a Hashtable the way it's meant to be used will not cause leaks. Speaking of which, you're leaking a Point with your Special Effect and I suggest using more variables to optimize the Inventory System Run trigger. (Triggering unit) and Integer A/B should probably have their own unique variables.

Also, I made a system for this a little while back which is a bit ugly but pretty dynamic and powerful. It appears as though you're on an older version of Warcraft 3 otherwise I would upload it here. Maybe I'll post the triggers when I get the chance (it's messy but works great).
 
Level 19
Joined
Feb 27, 2019
Messages
590
This seems to work.
  • For each (Integer A) from 1 to 6, do (Actions)
    • Loop - Actions
      • Set VariableSet InventorySystem_GoodToGo = False
      • For each (Integer B) from 1 to InventorySystem_Max, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • InventorySystem_GoodToGo Equal to False
              • InventorySystem_ObjectsMarked[(Integer B)] Equal to False
              • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to InventorySystem_Objects[(Integer B)]
            • Then - Actions
              • Set VariableSet InventorySystem_GoodToGo = True
              • Set VariableSet InventorySystem_ObjectsMarked[(Integer B)] = True
              • Set VariableSet InventorySystem_Recap = (InventorySystem_Recap + 1)
            • Else - Actions
  • For each (Integer A) from 1 to InventorySystem_Max, do (Actions)
    • Loop - Actions
      • Set VariableSet InventorySystem_ObjectsMarked[(Integer A)] = False
 
Status
Not open for further replies.
Top