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

[Solved] Item Forging System Help

Status
Not open for further replies.
Level 11
Joined
Sep 14, 2009
Messages
284
Hello. I am making an item forging system similar to the one in The Legend of Magnador.
For those who haven't played this map you basically put X number of items in a forge and it creates a forged item.
But in my case the the "forge" unit sells a dummy unit which "triggers" the forging, and number of items is 2. The items that can be forged are called material items and there must be 2 different of them in order to forge a forged item.
Here are the triggers:

  • ForgeSabertoothNecklace
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to (==) Forge Item
      • ((Selling unit) has an item of type |cffEEDD82Beast Hide|r) Equal to (==) True
      • ((Selling unit) has an item of type |cffEEDD82Monster Claw|r) Equal to (==) True
    • Actions
      • Unit - Remove (Sold unit) from the game
      • If ((Charges remaining in (Item carried by (Selling unit) of type |cffEEDD82Beast Hide|r)) Greater than (>) 1) then do (Item - Set charges remaining in (Item carried by (Selling unit) of type |cffEEDD82Beast Hide|r) to ((Charges remaining in (Item carried by (Selling unit) of type |cffEEDD82Beast Hide|r)) - 1)) else do (Item - Remove (Item carried by (Selling unit) of type |cffEEDD82Beast Hide|r))
      • If ((Charges remaining in (Item carried by (Selling unit) of type |cffEEDD82Monster Claw|r)) Greater than (>) 1) then do (Item - Set charges remaining in (Item carried by (Selling unit) of type |cffEEDD82Monster Claw|r) to ((Charges remaining in (Item carried by (Selling unit) of type |cffEEDD82Monster Claw|r)) - 1)) else do (Item - Remove (Item carried by (Selling unit) of type |cffEEDD82Monster Claw|r))
      • Set TempPointA = (Position of (Buying unit))
      • Special Effect - Create a special effect at TempPointA using Abilities\Spells\Items\AIem\AIemTarget.mdl
      • Custom script: call RemoveLocation(udg_TempPointA)
      • Special Effect - Destroy (Last created special effect)
      • Set TempPointA = (Center of PMMagicForge <gen>)
      • Item - Create Sabertooth Necklace at TempPointA
      • Custom script: call RemoveLocation(udg_TempPointA)
  • ForgeInvalid
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to (==) Forge Item
        • Multiple ConditionsOr - Any (Conditions) are true
          • Conditions
            • (Item carried by (Selling unit) in slot 1) Equal to (==) No item
            • (Item carried by (Selling unit) in slot 2) Equal to (==) No item
            • (Item-class of (Item carried by (Selling unit) in slot 1)) Not equal to (!=) Miscellaneous
            • (Item-class of (Item carried by (Selling unit) in slot 2)) Not equal to (!=) Miscellaneous
            • (Item-type of (Item carried by (Selling unit) in slot 1)) Equal to (==) (Item-type of (Item carried by (Selling unit) in slot 2))
    • Actions
      • Unit - Remove (Sold unit) from the game
      • Set ErrorPlayer = Player 9 (Gray)
      • Set ErrorMessage = Unable to forge these items.
      • Custom script: call ErrorMessage(udg_ErrorMessage, udg_ErrorPlayer)
      • Player - Add 2 to Player 9 (Gray) Current lumber
The problem is, that if we have more triggers like "ForgeSabertoothNecklace", the ForgeInvalid will run twice and thus add 4 lumber but should only run once and return 2 lumber.
I can't think of a way around to fix this problem.
 
Level 11
Joined
Sep 14, 2009
Messages
284
Hi, the "ForgeInvalid" trigger is independent from the rest, and will be global to the system - you don't need to write another ForgeInvalid for each ForgeValid - make sense?

Try it out and you will see that it behaves properly.

I'm not sure what you mean but I don't have "ForgeInvalid" for each "Forge<Item>" trigger, there is only 1 "ForgeInvalid" trigger.
EDIT: The problem is that when Sabertooth Necklace is created it still gives me the error function and returns 2 lumber to the player (from Invalid trigger).
 

Cokemonkey11

Spell Reviewer
Level 29
Joined
May 9, 2006
Messages
3,534
Ah okay I understand the problem now. In that case, you could put all items (including ForgeInvalid) in a big if/then/else logic structure in 1 trigger.

Like this:
->unit sells an item
->sell type is "forge item"
->if (invalid) then (fail)
-->elseif (sabernecklace) then (win1)
-->elseif (bonesawblade) then (win2)
-->elseif (xyz) then (win3)

Obviously that's just some pseudocode, but the logic can be adapted to work in GUI.
 
Status
Not open for further replies.
Top