• 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.

Switching Guns(items)?

Status
Not open for further replies.
Level 6
Joined
Feb 16, 2014
Messages
193
How to do this:
when a player uses an ability then the item in that player's unit will be dropped and given to a dummy unit,and an item in the dummy unit's inventory will be dropped and given to the player's unit.
how do i do that help please.
 
Level 6
Joined
Feb 16, 2014
Messages
193
Um is this a correct approach to what i want to do?(ill fix leaks later)
  • Next Weapon
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Next Weapon(Q)
    • Actions
      • Set Loc = (Units in (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 6) Equal to 1
        • Then - Actions
          • Unit Group - Pick every unit in Loc and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Unit-type of (Picked unit)) Equal to Inventory Handler
                      • (Owner of (Picked unit)) Equal to (Owner of (Casting unit))
                • Then - Actions
                  • Hero - Drop the item from slot 1 of (Picked unit)
                  • Hero - Give (Last dropped item) to (Casting unit)
                • Else - Actions
        • Else - Actions
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
make 2 variables "Dummy_Item" and "Unit_Item" and set those variables before you switch both items.

do it in this order:
Set Unit_Item = item in slot 1 of unit
Set Dummy_Item = item in slot 1 of caster
Drop Unit_Item
Drop Dummy_Item
Give Unit_Item to caster
Give Dummy_Item to unit.

If you do not do that, items will be given in the 2nd slot and the next switch weapon will not work.
Next to that, it should work fine... i guess
 
Level 6
Joined
Feb 16, 2014
Messages
193
  • Next Weapon
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Next Weapon(Q)
    • Actions
      • Set Loc = (Units in (Playable map area))
      • Set UnitItem1 = (Item carried by (Casting unit) in slot 1)
      • Set DummyItem1 = (Item carried by (Picked unit) in slot 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 6) Equal to 1
        • Then - Actions
          • Unit Group - Pick every unit in Loc and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Unit-type of (Picked unit)) Equal to Inventory Handler
                      • (Owner of (Picked unit)) Equal to (Owner of (Casting unit))
                • Then - Actions
                  • Hero - Drop UnitItem1 from (Casting unit)
                  • Hero - Drop DummyItem1 from (Picked unit)
                  • Hero - Give DummyItem1 to (Casting unit)
                  • Hero - Give UnitItem1 to (Picked unit)
                • Else - Actions
        • Else - Actions
Is this OK now? :)
 
Level 6
Joined
Feb 16, 2014
Messages
193
It worked thx Maker and Wietlol well +rep for both of you :ogre_haosis:
EDIT: i want to make sure there are no leaks so is there any leaks?
  • Next Weapon
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Next Weapon(Q)
    • Actions
      • Set Loc = (Units in (Playable map area))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Owner of (Casting unit)) of type Inventory Handler) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
            • Then - Actions
              • Set UnitItem1 = (Item carried by (Casting unit) in slot 1)
              • Set DummyItem1 = (Item carried by (Picked unit) in slot (Random integer number between 1 and 6))
              • Hero - Drop UnitItem1 from (Casting unit)
              • Hero - Drop DummyItem1 from (Picked unit)
              • Hero - Give DummyItem1 to (Casting unit)
              • Hero - Give UnitItem1 to (Picked unit)
            • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top