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

Shop System Help

Status
Not open for further replies.
Level 3
Joined
Nov 21, 2016
Messages
30
So i have that dynamic shop system but i can't get it to work as intended first i have a DB of the products and the materials

  • ItenVarset
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Agility Relic
      • Set AttackSpeed[ItemArray] = 36
      • Set ItemValue[ItemArray] = 5
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Agility Stone
      • Set AttackSpeed[ItemArray] = 15
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Clarity Shard
      • Set ManaRegen[ItemArray] = 150
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Clarity Stone
      • Set ManaRegen[ItemArray] = 195
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Health Crystal
      • Set Health[ItemArray] = 230
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Health Relic
      • Set Health[ItemArray] = 380
      • Set ItemValue[ItemArray] = 5
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Health Shard
      • Set Health[ItemArray] = 85
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Mana Crystal
      • Set Mana[ItemArray] = 150
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Mana Shard
      • Set Mana[ItemArray] = 85
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Mana Stone
      • Set Mana[ItemArray] = 105
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Power Crystal
      • Set Damage[ItemArray] = 16
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Power Relic
      • Set Damage[ItemArray] = 27
      • Set ItemValue[ItemArray] = 5
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Power Shard
      • Set Damage[ItemArray] = 6
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Vitality Shard
      • Set LifeRegen[ItemArray] = 2
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • -------- -------------------------------------------------------------------- --------
      • Set ItemArray = (ItemArray + 1)
      • Set ItemType[ItemArray] = Vitality Stone
      • Set LifeRegen[ItemArray] = 4
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = 25
      • -------- ------------------------------------Basics End's Here-------------------------------- --------
      • Set ItemType[ItemArray] = Throwing Axe
      • Set ItemRecipe[ItemArray] = Throwing Axe (Recipe)
      • Set ItemValue[ItemArray] = 1
      • Set ItemCost[ItemArray] = 0
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Blood Pendant
      • Set ItemRecipe[ItemArray] = Blood Pendant (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Glacial Gem
      • Set ItemRecipe[ItemArray] = Glacial Gem (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Sage Circlet
      • Set ItemRecipe[ItemArray] = Sage Circlet (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Fel Blade
      • Set ItemRecipe[ItemArray] = Fel Blade (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Silver Buckler
      • Set ItemRecipe[ItemArray] = Silver Buckler (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Enduring Helm
      • Set ItemRecipe[ItemArray] = Enduring Helm (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 1
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Reaper's Scythe
      • Set ItemRecipe[ItemArray] = Reaper's Scythe (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Elder Stone
      • Set ItemRecipe[ItemArray] = Elder Stone (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Healing Rod
      • Set ItemRecipe[ItemArray] = Healing Rod (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Empowered Bracer
      • Set ItemRecipe[ItemArray] = Empowered Bracer (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Cleric Chalice
      • Set ItemRecipe[ItemArray] = Cleric Chalice (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Dampening Cloak
      • Set ItemRecipe[ItemArray] = Dampening Cloak (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Captain's Crest
      • Set ItemRecipe[ItemArray] = Captain's Crest (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 2
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Crystalline Shiv
      • Set ItemRecipe[ItemArray] = Crystalline Shiv (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Windrush
      • Set ItemRecipe[ItemArray] = Windrush (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Archmage's Ring
      • Set ItemRecipe[ItemArray] = Archmage's Ring (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Seer's Eye
      • Set ItemRecipe[ItemArray] = Seer's Eye (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Arcane Emblem
      • Set ItemRecipe[ItemArray] = Arcane Emblem (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
      • Set ItemType[ItemArray] = Ranger's Vest
      • Set ItemRecipe[ItemArray] = Ranger's Vest (Recipe)
      • Set ItemCost[ItemArray] = 0
      • Set ItemValue[ItemArray] = 3
      • Set ItemId[ItemArray] = ItemArray
      • Set ItemArray = (ItemArray + 1)
      • -------- -------------------------------------------------------------------- --------
then i have i trigger to set some values

  • VarSet
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 100, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ItemType[(Integer A)] Equal to (Item-type of (Sold Item))
                  • ItemRecipe[(Integer A)] Equal to (Item-type of (Sold Item))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-class of (Sold Item)) Equal to Permanent
                • Then - Actions
                  • Item - Set the custom value of (Sold Item) to ItemId[(Integer A)]
                • Else - Actions
                  • Item - Set the custom value of (Sold Item) to ItemId[(Integer A)]
            • Else - Actions
then finally the recipes actual trigger

  • ShopNovo
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Campaign
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 6, do (Actions)
            • Loop - Actions
              • For each (Integer d) from 1 to 6, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-class of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Permanent
                      • (Item-class of (Item carried by (Triggering unit) in slot (Integer B))) Equal to Permanent
                      • (Item-class of (Item carried by (Triggering unit) in slot d)) Equal to Permanent
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Integer A) Not equal to (Integer B)
                          • (Integer A) Not equal to d
                          • d Not equal to (Integer B)
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (ItemValue[(Custom value of (Item carried by (Triggering unit) in slot (Integer B)))] + (ItemValue[(Custom value of (Item carried by (Triggering unit) in slot d))] + ItemValue[(Custom value of (Item carried by (Triggering unit) in slot (Integer A)))])) Equal to ItemValue[(Custom value of (Item being manipulated))]
                            • Then - Actions
                              • Hashtable - Save ItemValue[(Custom value of (Item carried by (Triggering unit) in slot (Integer A)))] as 1 of (Key (Item carried by (Triggering unit) in slot (Integer A))) in ShopHash
                              • Hashtable - Save ItemValue[(Custom value of (Item carried by (Triggering unit) in slot (Integer B)))] as 2 of (Key (Item carried by (Triggering unit) in slot (Integer B))) in ShopHash
                              • Hashtable - Save ItemValue[(Custom value of (Item carried by (Triggering unit) in slot d))] as 3 of (Key (Item carried by (Triggering unit) in slot d)) in ShopHash
                              • Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                              • Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                              • Item - Remove (Item carried by (Triggering unit) in slot d)
                              • Hero - Create ItemType[(Custom value of (Item being manipulated))] and give it to (Triggering unit)
                              • Item - Remove (Item being manipulated)
                              • Skip remaining actions
                            • Else - Actions
                        • Else - Actions
                    • Else - Actions
and yes i'm creating that hash first

but sometimes the final item won't come or the recipe isn't removed
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
In this line, both halves of the if-tree do the same thing, so I'm unsure why you're checking if it's a Permanent item. And in fact ItemId[(Integer A)] is always going to be = (Integer A), based on how you set it up above. IMO ItemId is a useless variable.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Item-class of (Sold Item)) Equal to Permanent
    • Then - Actions
      • Item - Set the custom value of (Sold Item) to ItemId[(Integer A)]
    • Else - Actions
      • Item - Set the custom value of (Sold Item) to ItemId[(Integer A)]
As for the actual problem: it's only 6^3 = 216 possible comparisons at maximum, but I'd bet you're hitting the op limit somewhere along the line because of forLoopIntegerA/B() calls (I recommend usually using your own integer variable for loops). In general I am not a fan of the way you're combining items based on checking "ItemValue[A] + ItemValue[B] + ItemValue[d] = ItemValue[Recipe]" because it doesn't look like your ItemValue values are each unique prime numbers, which you would have to use for a system like that to be foolproof. If you're not using unique primes, then A+B+d = R might be true for multiple different combations of A, B, and d... so different component items could get you the same end result!

I believe you could do this much more intelligently by making more liberal use of your hashtable. For each recipe I would store these things in a Recipes hashtable:
  • The recipe item-type (what units buy)
  • The item-type it should make
  • The number of items that make up the recipe (unnecessary if all recipes are the same # of items)
  • Recipe item 1, 2, 3... N
However this gets to be kind of dumb because GUI thinks Item-Type variables are different from integers... but JASS knows they're all the same. So there are no HashTable functions to save Item-types (because you can save ints instead) and you end up needing to convert between them with some stupid custom scripts
  • Actions
    • -------- For making a Mask of Death from 3 items: Crown of Kings, Blood Key, Skeletal Artifact --------
    • Set IT_TYPE = Mask of Death (Recipe)
    • Custom script: set udg_FAKE_IT = udg_IT_TYPE
    • Custom script: set udg_IT_TYPE_KEY = udg_IT_TYPE
    • Hashtable - Save FAKE_IT as (Key RecipeItem) of IT_TYPE_KEY in YourHashtable
    • -------- --------
    • Set IT_TYPE = Mask of Death
    • Custom script: set udg_FAKE_IT = udg_IT_TYPE
    • Hashtable - Save FAKE_IT as (Key MadeItem) of IT_TYPE_KEY in YourHashtable
    • -------- --------
    • Hashtable - Save 3 as (Key TotalParts) of IT_TYPE_KEY in YourHashtable
    • -------- --------
    • Set IT_TYPE = Crown of Kings +5
    • Custom script: set udg_FAKE_IT = udg_IT_TYPE
    • Hashtable - Save FAKE_IT as (Key Parts1) of IT_TYPE_KEY in YourHashtable
    • -------- --------
    • Set IT_TYPE = Blood Key
    • Custom script: set udg_FAKE_IT = udg_IT_TYPE
    • Hashtable - Save FAKE_IT as (Key Parts2) of IT_TYPE_KEY in YourHashtable
    • -------- --------
    • Set IT_TYPE = Skeletal Artifact
    • Custom script: set udg_FAKE_IT = udg_IT_TYPE
    • Hashtable - Save FAKE_IT as (Key Parts3) of IT_TYPE_KEY in YourHashtable
    • -------- --------
This does ultimately save you effort in the long run because you'll be able to much more easily check if the unit has the right items:

  • Item Combine Trigger
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set IT_TYPE = (Item-type of (Item being manipulated))
      • Custom script: set udg_IT_TYPE_KEY = udg_IT_TYPE
      • Set NumParts = (Load (Key TotalParts) of IT_TYPE_KEY from YourHashtable)
      • For each (Integer TempInt) from 1 to NumParts, do (Actions)
        • Loop - Actions
          • Set FAKE_IT = (Load (Key (Parts + (String(TempInt)))) of IT_TYPE_KEY from YourHashtable)
          • Custom script: set udg_IT_TYPE = udg_FAKE_IT
          • For each (Integer TempInt2) from 1 to 6, do (Actions)
            • Loop - Actions
              • Set TempItem = (Item carried by (Triggering unit) in slot TempInt2)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of TempItem) Equal to IT_TYPE
                • Then - Actions
                  • Set RecipeItems[TempInt] = TempItem
                  • Custom script: exitwhen true
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RecipeItems[NumParts] Not equal to No item
        • Then - Actions
          • For each (Integer TempInt) from 1 to 6, do (Actions)
            • Loop - Actions
              • Item - Remove RecipeItems[TempInt]
          • Item - Remove (Item being manipulated)
          • Set FAKE_IT = (Load (Key MadeItem) of IT_TYPE_KEY from YourHashtable)
          • Custom script: set udg_IT_TYPE = udg_FAKE_IT
          • Hero - Create IT_TYPE and give it to (Triggering unit)
        • Else - Actions
      • For each (Integer TempInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set RecipeItems[TempInt] = No item
Anywhere it says "Key <some words>" I'm using a string key.
 
Level 3
Joined
Nov 21, 2016
Messages
30
I am not a fan of the way you're combining items based on checking "ItemValue[A] + ItemValue[B] + ItemValue[d] = ItemValue[Recipe]" because it doesn't look like your ItemValue values are each unique prime numbers, which you would have to use for a system like that to be foolproof. If you're not using unique primes, then A+B+d = R might be true for multiple different combations of A, B, and d... so different component items could get you the same end result!

but that's the idea that one final product can be made im a lot of diferent ways so that way you can customize the item bonus

the only thing i cannot make work its the combine trigger
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
So if A[1]+B[1]+d[1] = Item_A and A[2]+B[2]+d[2] also = Item_A, then should both the resulting item A's have the same stats? Or because they have different components they have slightly different stats? The former is easy, the latter is difficult.
 
Level 3
Joined
Nov 21, 2016
Messages
30
So if A[1]+B[1]+d[1] = Item_A and A[2]+B[2]+d[2] also = Item_A, then should both the resulting item A's have the same stats? Or because they have different components they have slightly different stats? The former is easy, the latter is difficult.
they will have different stats the trigger to add the stats is ready the problem is the shop

all the materials itens have a value and the final item has a material cost
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
My honest opinion is that without a well-defined method this is far too complicated to try to finagle GUI into doing. It would be stupid easy with structs, but the hoops you're having to jump through to save/recall/compare all this item data is getting you to the op limit. To test this, try adding one debug message line like so:
  • Game - Display to (All Players) the text (String(Integer A) + "," + String(Integer B) + "," + String(d))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Item-class of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Permanent
      • (Item-class of (Item carried by (Triggering unit) in slot (Integer B))) Equal to Permanent
      • (Item-class of (Item carried by (Triggering unit) in slot d)) Equal to Permanent
    • Then - Actions
    • Else - Actions
Does it print up to 6,6,6? Or if it stops before then is it creating an item properly?
 
Level 3
Joined
Nov 21, 2016
Messages
30
My honest opinion is that without a well-defined method this is far too complicated to try to finagle GUI into doing. It would be stupid easy with structs, but the hoops you're having to jump through to save/recall/compare all this item data is getting you to the op limit. To test this, try adding one debug message line like so:
  • Game - Display to (All Players) the text (String(Integer A) + "," + String(Integer B) + "," + String(d))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Item-class of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Permanent
      • (Item-class of (Item carried by (Triggering unit) in slot (Integer B))) Equal to Permanent
      • (Item-class of (Item carried by (Triggering unit) in slot d)) Equal to Permanent
    • Then - Actions
    • Else - Actions
Does it print up to 6,6,6? Or if it stops before then is it creating an item properly?

it does using the 3 layers of loop it printed all the values
when using a event to trigger a unit buyng a item whats the difference between acquires and sell a item ??
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
After our conversation, I think this (with a little debugging-- I surely made an error somewhere) will properly switch out the items and avoid any thread crashes. Top trigger for setting the CV of basic items, bottom trigger for creating advanced items when the recipe is bought.

  • BasicItems
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Permanent
    • Actions
      • Set Recipe_It = (Item being manipulated)
      • For each (Integer Counter_A) from 1 to (ItemArray-1), do (Actions)
        • Loop - Actions
          • If (All conditions are true) then do (then actions) else do (else actions
            • If - Conditions
              • (Item-type of Recipe_It) Equal to ItemType[Counter_A]
            • Then - Actions
              • Item - Set Custom Value of Recipe_It to Counter_A
              • Custom script: exitwhen true
            • Else - Actions
  • RecipeItems
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Campaign
    • Actions
      • Set Recipe_It = (Item being manipulated)
      • Set Player_Hero = (Triggering Unit)
      • For each (Integer Counter_A) from 1 to (ItemArray-1), do (Actions)
        • Loop - Actions
          • If (All conditions are true) then do (then actions) else do (else actions
            • If - Conditions
              • (Item-type of Recipe_It) Equal to ItemRecipe[Counter_A]
            • Then - Actions
              • Set Item_Index = Counter_A
              • Custom script: exitwhen true
            • Else - Actions
      • Set Basic_Count = 0
      • For each (Integer Counter_A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set TempItem = Item carried by (Player_Hero) in slot Counter_A
          • If (All conditions are true) then do (then actions) else do (else actions
            • If - Conditions
              • (Item-class of TempItem) Equal to Permanent
            • Then - Actions
              • Set Basic_Count = Basic_Count+1
              • Set Item_Values[Basic_Count] = ItemValue[Custom value of TempItem]
              • Set Item_Actual[Basic_Count] = TempItem
            • Else - Actions
      • Set ItemsToRemove[1] = No item
      • Set ItemsToRemove[2] = No item
      • Set ItemsToRemove[3] = No item
      • Set FoundItem = false
      • For each (Integer Counter_A) from 1 to Basic_Count, do (Actions)
        • Loop - Actions
          • If (All conditions are true) then do (Then actions) else do (Else actions)
            • If - Conditions
              • FoundItem equal to true
            • Then - Actions
              • Custom script: exitwhen true
            • Else - Actions
          • Set ItemsToRemove[1] = Item_Actual[Counter_A]
          • Set ItemsToRemove[2] = No item
          • Set ItemsToRemove[3] = No item
          • Set Total_Value[1] = Item_Values[Counter_A]
          • If (All conditions are true) then do (Then actions) else do (Else actions)
            • If - Conditions
              • Total_Value[1] equal to ItemValue[Item_Index]
            • Then - Actions
              • Set FoundItem = True
              • Custom script: exitwhen true
            • Else - Actions
          • For each (Integer Counter_B) from (Counter_A+1) to Basic_Count, do (Actions)
            • Loop - Actions
              • If (All conditions are true) then do (Then actions) else do (Else actions)
                • If - Conditions
                  • FoundItem equal to true
                • Then - Actions
                  • Custom script: exitwhen true
                • Else - Actions
              • Set ItemsToRemove[2] = Item_Actual[Counter_B]
              • Set Total_Value[2] = Item_Values[Counter_B]
              • Set ItemsToRemove[3] = No item
              • If (All conditions are true) then do (Then actions) else do (Else actions)
                • If - Conditions
                  • (Total_Value[1] + Total_Value[2]) equal to ItemValue[Item_Index]
                • Then - Actions
                  • Set FoundItem = True
                  • Custom script: exitwhen true
                • Else - Actions
              • For each (Integer Counter_C) from (Counter_B+1) to Basic_Count, do (Actions)
                • Loop - Actions
                  • If (All conditions are true) then do (Then actions) else do (Else actions)
                    • If - Conditions
                      • FoundItem equal to true
                    • Then - Actions
                      • Custom script: exitwhen true
                    • Else - Actions
                  • Set ItemsToRemove[3] = Item_Actual[Counter_C]
                  • Set Total_Value[3] = Item_Values[Counter_C]
                  • If (All conditions are true) then do (Then actions) else do (Else actions)
                    • If - Conditions
                      • (Total_Value[1] + Total_Value[2] + Total_Value[3]) equal to ItemValue[Item_Index]
                    • Then - Actions
                      • Set FoundItem = True
                      • Custom script: exitwhen true
                    • Else - Actions
      • If (All conditions are true) then do (Then actions) else do (Else actions)
        • If - Conditions
          • FoundItem equal to true
        • Then - Actions
          • Item - Remove ItemsToRemove[1]
          • Item - Remove ItemsToRemove[2]
          • Item - Remove ItemsToRemove[3]
          • Item - Create 1 ItemType[Item_Index] and give it to Player_Hero
        • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top