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

[Trigger] Problems with equipment system

Status
Not open for further replies.
Level 1
Joined
Nov 24, 2011
Messages
4
Hello there.
Im making an rpg map for my friends and i to play, but i've run into some problems with my shitty equip items triggers

I want the paladin to equip the paladin wep, but to only be able to have one equipped at a time. But because of my lack of knowledge in triggers he can hold as many as them as he wants.
Im hoping someone can help me

http://imgur.com/a/8g6du
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
Of course it's not going to work. This is your trigger in simple form:
Code:
Set x = 1
If
   (x != 1)
Then
   (do some actions)
Else
   (do something else)

So of course you won't get to the "Then" block, because just an action above the If/Then/Else you set x to be equal to 1.

The way these "item-types" are handled is usually through item level. For example all items with item-level 1 will be weapons. All items with item-level 2 will be Armor, etc.
So in your trigger, when unit acquires an item, you loop through each item slot and:
1) check if level of item in that slot is not equal to the level of the picked item, and
2) also if the item in a slot is not the acquired item itself.
If this passes, the unit does not carry any other item of same item-type (e.g. weapon).

The problem is that items can have only item levels from 0 to 8. What you can do though is to also use item classification (classification is Artifact, campaign, etc.) - there is a total of 7 classifications (well, in truth it can have 8, more on this below), so you can have a total of 63 different item-types. This way you can have items for a class/hero only - e.g. Paladin-only weapon. Such item could for example have item-level 5 and item-classification 'Power Up'.

So your trigger should look something like this:

Code:
V A R I A B L E S
acquiring_unit = unit variable
acquired_item = item variable
acquired_item_level = integer variable
item_slot = integer variable

  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Paladin
    • Actions
      • -------- Set triggering unit, acquired item and item level in variables for efficiency and easier-to-read code --------
      • Set acquiring_unit = (Triggering unit)
      • Set acquired_item = (Item being manipulated)
      • Set acquired_item_level = (Item level of acquired_item)
      • -------- ------------------------------------------------------------------------------------------ --------
      • -------- Loop through each item slot of acquiring_unit --------
      • For each (Integer item_slot) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by acquiring_unit in slot item_slot) Not equal to acquired_item
              • (Item level of (Item carried by acquiring_unit in slot item_slot)) Equal to acquired_item_level
            • Then - Actions
              • -------- Acquiring_unit already carries a different item which is of same type as the acquired-item --------
              • -------- e.g. alredy carrying a weapon, so we force the unit to drop acquired item and end the loop --------
              • Hero - Drop acquired_item from acquiring_unit
              • Set item_slot = 7
            • Else - Actions
If you want to also use the "classification" idea I wrote above earlier, you could nest another ITE inside the first ITE like this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Item carried by acquiring_unit in slot item_slot) Not equal to acquired_item
      • (Item level of (Item carried by acquiring_unit in slot item_slot)) Equal to acquired_item_level
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-class of acquired_item) Equal to Powerup
          • Or - Any (Conditions) are true
            • Conditions
              • acquired_item_level Equal to 5
              • acquired_item_level Equal to 6
              • acquired_item_level Equal to 7
              • acquired_item_level Equal to 8
        • Then - Actions
          • -------- This is one of paladin-only item-types --------
        • Else - Actions
    • Else - Actions
As for the 8th classification - there is a classification called "Unknown". Basically when the classification of an item is not one of the standard 7 ones, then it is of classification "unknown". You can check if item-classification is "unknown" in triggers.

In object editor it's a bit harder to set unknown classification, because it only offers you the standard 7 classifications. To bypass this, select the item you want, hold down left SHIFT key and open the item-classification field. Now instead of list it will open as text box. Write in it anything you want - be it empty space " ", or "Custom", etc. - triggers will evaluate this item's classification as "unknown".
So theoretically you have 9 levels and 8 classifications, so 72 possible options. Do note though that I didn't do any extensive testing of this, so while it shouldn't break anything, one can never be sure it won't bug something.
 
Last edited:
Status
Not open for further replies.
Top