• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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).
 
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