• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Acquire Item Triggering

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hi again

I want to make a realistic inventory use. So that you can only have 1 two-handed weapon on you, or 2 1-handed weapons. Now I have done this so far:

  • Pick up Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • WepCounterPlayer1 Greater than or equal to 2
              • (Item-type of (Item being manipulated)) Equal to Axe (1 handed)
              • (Item-type of (Item being manipulated)) Equal to Mace (1 handed)
              • (Item-type of (Item being manipulated)) Equal to Sword (1 handed)
        • Then - Actions
          • Wait 2.00 seconds
          • Set WepCounterPlayer1 = (WepCounterPlayer1 + 1)
        • Else - Actions
          • Item - Move (Item being manipulated) to (Position of (Item being manipulated))
          • Game - Display to (All players) the text: Fak u gooby
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • WepCounterPlayer1 Equal to 0
              • (Item-type of (Item being manipulated)) Equal to Hammer (2 Handed)
              • (Item-type of (Item being manipulated)) Equal to Swiftbane (2 Handed)
              • (Item-type of (Item being manipulated)) Equal to War Axe (2 Handed)
        • Then - Actions
          • Set WepCounterPlayer1 = (WepCounterPlayer1 + 2)
        • Else - Actions
          • Item - Move (Item being manipulated) to (Position of (Item being manipulated))
          • Game - Display to (All players) the text: Fak u gooby
The wait 2 seconds was only 2 see if it actually would let me pick it up, and it will. But what leaks is that when he has picked up the item, it sends me the error text, "fak u gooby" and sends it back to the ground. It is only supposed to go back, if I already have an integer of WepCounter on 2. But it is set to 0 in another trigger and it just won't work. Even if I pick up the 1 handed, it will return it to the ground, even though Wepcounter (0) = Wepcounter (0) +1... That would be 1? How can that be "Greater than or equal to 2"?

Although I can manage to pick up all 3 2-handed weapons, which would raise it to be 6. It does not return those.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Your problem is that you do not check for the items separately.
You check for both weapons.

Lets imagine you pick up Axe.
The first If/Then/Else will result true and you will gain the item.
However, the second If/Then/Else will result false and you will drop it because your Axe is not Hammer, Swiftbane or War Axe

So what you have to do is make two If/Then/Else functions inside each other.
The first one will ONLY check what item type it is (1h or 2h).
So you have this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
        • (Item-type of (Item being manipulated)) Equal to Axe (1 handed)
        • (Item-type of (Item being manipulated)) Equal to Mace (1 handed)
        • (Item-type of (Item being manipulated)) Equal to Sword (1 handed)
    • Then - Actions
    • Else - Actions
Now in the Then actions, you place the action "Skip Remaining Actions".
This action will just stop the trigger from doing his actions :D
Before that action (still inside the Then block), you add another If/Then/Else to check if "WepCounterPlayer1 Less than or equal to 2" and if that one results true, you increase WepCounterPlayer1.
If that one results false, you move the item to the ground.

Now you do the same for the 2 handed weapons.
Dont forget the Skip Remaining Actions.
 

EdgeOfChaos

E

EdgeOfChaos

It's much easier to use item classifications. Just check whether the user already has an item of class, and assign each item class to a type of weapon/armor/etc. Then you won't have to code every single new item.
 
Level 8
Joined
Jun 13, 2010
Messages
344
It's much easier to use item classifications. Just check whether the user already has an item of class, and assign each item class to a type of weapon/armor/etc. Then you won't have to code every single new item.

But if a weapon is within a classification, which is 1-handed, how will I make it possible to use 2 of it?
 
Status
Not open for further replies.
Top