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

Inventory System help!

Status
Not open for further replies.
Level 18
Joined
Dec 17, 2009
Messages
1,114
I'm making a system that allows every player to own only 1 Mainhand weapon!

The problem is, when i test the map with it, it didn't work
i bought a sword, then it successfully says, Equipped Sword!
i bought a copper ore + sword = copper sword

then it dropped ( i triggered that, but it supposed to not drop! )

in the recipe trigger, it removed the sword and copper ore, then adds a copper sword!

by removing it, i think it dropped it somehow...


i want people reading this to try ^^ if the want to help me.. i sure give rep..


so here's the trig for the main hand

Level 1 item = Weapons(Mainhand)


  • Mainhand
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item level of (Item being manipulated)) Equal to 1
    • Actions
      • Set PlayerNumber = (Player number of (Owner of (Hero manipulating item)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Mainhand_Checker[PlayerNumber] Equal to False
        • Then - Actions
          • Set Mainhand_Checker[PlayerNumber] = True
          • Set Mainhand_count[PlayerNumber] = (Mainhand_count[PlayerNumber] + 1)
          • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: (Equipped + (Name of (Item being manipulated)))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Mainhand_Checker[PlayerNumber] Equal to True
            • Then - Actions
              • Hero - Drop (Item being manipulated) from (Hero manipulating item)
              • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: You already equippe...
            • Else - Actions
okay, that should work perfectly right?? (It's MPI too!)

  • Reduce Mainhand
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item level of (Item being manipulated)) Equal to 1
    • Actions
      • Set Mainhand_count[(Player number of (Owner of (Hero manipulating item)))] = (Mainhand_count[(Player number of (Owner of (Hero manipulating item)))] - 1)
THis trigger will reduce the count of it! (up there!)

WHile this one below..

  • Reset Mainhand
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item level of (Item being manipulated)) Equal to 1
      • Mainhand_Checker[(Player number of (Owner of (Hero manipulating item)))] Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Mainhand_count[(Player number of (Owner of (Hero manipulating item)))] Equal to 0
        • Then - Actions
          • Set Mainhand_Checker[(Player number of (Owner of (Hero manipulating item)))] = False
          • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: (Unequipped the + (Name of (Item being manipulated)))
        • Else - Actions
          • Floating Text - Create floating text that reads Insufficient materi... above (Hero manipulating item) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 0.01 seconds
now what should i do with this...


Please help..
 
Level 8
Joined
Jun 26, 2010
Messages
530
Can you explain better? Wich item dropped? The Sword? Ore? Both?
The only action that drop itens on your triggers is on the first, so, the level of copper ore can't be 1, otherwise that drop action will cause the problem. Let's say you have a sword. You pickup Copper Ore and the "Mainhand" trigger will run and copper ore will be droped. Probably even if used on the recipe. If Copper Ore level is not 1, then the problem probably is in another trigger. Can you post the recipe (in that case)?

Your If-Then-Else is a bit redundant. Shouldn't it be like this? I mean, a boolean can only be true or false.

[TRIGGER=]
Mainhand
Events
Unit - A unit Acquires an item
Conditions
(Item level of (Item being manipulated)) Equal to 1
Actions
Set PlayerNumber = (Player number of (Owner of (Hero manipulating item)))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Mainhand_Checker[PlayerNumber] Equal to False
Then - Actions
Set Mainhand_Checker[PlayerNumber] = True
Set Mainhand_count[PlayerNumber] = (Mainhand_count[PlayerNumber] + 1)
Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: (Equipped + (Name of (Item being manipulated)))
Else - Actions
Hero - Drop (Item being manipulated) from (Hero manipulating item)
Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: You already equippe...
[/TRIGGER]

Also, you should unite the 2 last triggers. That's not a good thing to have more than 1 trigger running with the same event.

  • Reset Mainhand
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item level of (Item being manipulated)) Equal to 1
      • Mainhand_Checker[(Player number of (Owner of (Hero manipulating item)))] Equal to True
    • Actions
      • Set Mainhand_count[(Player number of (Owner of (Hero manipulating item)))] = (Mainhand_count[(Player number of (Owner of (Hero manipulating item)))] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Mainhand_count[(Player number of (Owner of (Hero manipulating item)))] Equal to 0
        • Then - Actions
          • Set Mainhand_Checker[(Player number of (Owner of (Hero manipulating item)))] = False
          • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: (Unequipped the + (Name of (Item being manipulated)))
        • Else - Actions
          • Floating Text - Create floating text that reads Insufficient materi... above (Hero manipulating item) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 0.01 seconds
 
Level 9
Joined
Oct 17, 2009
Messages
370
you dont need the If Then Else in the last trigger, since it will set Mainhand_Checker to 0 and the If is "Mainhand_Checker = 0". And you can REMOVE the floating text triggers, they cant trigger at any way (if the mainhand checker stays between 1 or 0, if it is 2 they will)
 
Status
Not open for further replies.
Top