Only one type of item trigger help

tonton302

Member
Reaction score
0
I have this trigger that works in a new map, but when I try to put it into my rpg it doesn't. I copy pasted the exact code and it just doesn't work. I looked through all of my other triggers and I don't see any contradictory triggers. If you want to see the map I will let you. Or if you have another trigger I can try.

Trigger 1
Code:
Time - Every 0.10 seconds of game time

Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
    Loop - Actions
        Set ItemThing[1] = (Item carried by (Picked unit) in slot 1)
        Set ItemThing[2] = (Item carried by (Picked unit) in slot 2)
        Set ItemThing[3] = (Item carried by (Picked unit) in slot 3)
        Set ItemThing[4] = (Item carried by (Picked unit) in slot 4)
        Set ItemThing[5] = (Item carried by (Picked unit) in slot 5)
        Set ItemThing[6] = (Item carried by (Picked unit) in slot 6)
Trigger 2
Code:
Unit - A unit Acquires an item

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Item-type of (Item being manipulated)) Equal to (Item-type of ItemThing[1])
    Then - Actions
        Hero - Drop (Item being manipulated) from (Triggering unit)
    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-type of (Item being manipulated)) Equal to (Item-type of ItemThing[2])
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to (Item-type of ItemThing[3])
                    Then - Actions
                        Hero - Drop (Item being manipulated) from (Triggering unit)
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Item-type of (Item being manipulated)) Equal to (Item-type of ItemThing[4])
                            Then - Actions
                                Hero - Drop (Item being manipulated) from (Triggering unit)
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Item-type of (Item being manipulated)) Equal to (Item-type of ItemThing[5])
                                    Then - Actions
                                        Hero - Drop (Item being manipulated) from (Triggering unit)
                                    Else - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                (Item-type of (Item being manipulated)) Equal to (Item-type of ItemThing[6])
                                            Then - Actions
                                                Hero - Drop (Item being manipulated) from (Triggering unit)
                                            Else - Actions
                                                Do nothing

Thanks
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
You should place the actions of the first trigger into the second, since Player 1 (Red) most likely has more than one unit in your RPG.

Also you should try a For Each Integer loop:
Trigger:
  • Item AntiStacking
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))
            • Then - Actions
              • Hero - Drop (Item being manipulated) from (Triggering unit)
            • Else - Actions

A word of advice - never use Do Nothing actions. They literally do nothing and still take up a function call, using more space.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
the only problem with that trigger pkmn is that it drops the item that was acquired automatically, just add another condition in the if then else:
Trigger:
  • (Item carried by (Triggering unit) in slot (Integer A)) is not equal to (Item being manipulated)
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Right. Forgot about that part. In fact, this would be faster if the unit doesn't pick up the item when ordered if it already has one.

Trigger:
  • Item AntiStacking
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Target item of issued order) Not equal to No item
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Target item of issued order)) Equal to (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))
            • Then - Actions
              • Unit - Order (Triggering unit) to Stop
              • Custom script: call SimError ("You already have one of those!")
              • Skip Remaining Actions
            • Else - Actions
 

tonton302

Member
Reaction score
0
I tried those triggers, but neither of them worked it still allows you to pick up more than one of an item. :mad:
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Add a 0.00 second wait in place of the SimError call, and it works. I don't think you have that function anyway,
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
if you call a function that you do not have it will cause a syntax error
and i believe the call u wanted was: [ljass]call BJDebugMsg("You already have one of those!")[/ljass]
 

tonton302

Member
Reaction score
0
with this trigger it lets me pick up both items and gives me the message but when I change the order triggering unit to stop to a drop the item being manipulated by triggering hero it wont let me pick the item up.

Code:
Unit - A unit Acquires an item

For each (Integer A) from 1 to 6, do (Actions)
    Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))
            Then - Actions
                Unit - Order (Triggering unit) to Stop
                Wait 0.00 seconds
                Custom script:   call BJDebugMsg ("You already have one of those")
                Skip remaining actions
            Else - Actions
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
@GFreak: I actually meant SimError.
Use SimError to display the message. Source (copy in map custom script header) :

JASS:
//Needs a udg_SimError global sound variable
function SimError takes player ForPlayer, string msg returns nothing
    if udg_SimError==null then
        set udg_SimError=CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
    endif
    if (GetLocalPlayer() == ForPlayer) then
        call ClearTextMessages()
        call DisplayTimedTextToPlayer( ForPlayer, 0.52, -1.00, 2.00, "|cffffcc00"+msg+"|r" )
        call StartSound( udg_SimError )
    endif
endfunction


You need a sound-type variable declared using CTRL+B and name it SimError. Then, to display the error message, do :

Trigger:
  • //...
    • Set MyPlayerVariable = (Owner of (Triggering unit))
    • call SimError(udg_MyPlayerVariable,"You cannot cast that on mechanical units !")

@tonton32: Your condition will always be true because the item has been acquired, and therefore exists in the inventory. Add this condition:
Trigger:
  • (Item carried by (Triggering unit) in slot (Integer A)) Not equal to (Item being manipulated)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top