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

Unit Give Item To Unit

Status
Not open for further replies.
Level 4
Joined
Feb 17, 2007
Messages
121
So what i was thinking was if someone can help me make a trigger where a unit cast a ability called "Search" on a invulnerable unit. The invulnerable unit will automatically give the casting unit the item in the invulnerable unit's inventory. If cast again on the same invulnerable unit, there will be a message saying "You find nothing special in here"

Any help on making this trigger?? :vw_wtf:
 
Level 4
Joined
Feb 17, 2007
Messages
121
Okay. How many inventory slots will the invulnerable unit have? 6?

The invulnerable unit will have a six slot inventory so when the ability is used on the invulnerable unit, it will make the invulnerable unit give what ever he has in all the slot. If its only one item in the inventory then only that item will be given to the unit casting the ability.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Okay, here is the trigger:

  • Give Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to [your ability]
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item carried by (Target unit of ability being cast) in slot 1) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 2) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 3) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 4) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 5) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 6) Equal to No item
        • Then - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You find nothing special in here.
          • Skip remaining actions
        • Else - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Drop the item from slot (Integer A) of (Target unit of ability being cast)
          • Hero - Give (Last dropped item) to (Triggering unit)
Also, make sure your ability can only target enemy invulnerable units.
 
^Why do you skip 'Else'? It's made for this like situation. 'Skip remaining actions' isn't needed at all. By the way, I guess you can ignore checking whole unit's inventory. Just use the loop, thats all.

  • Give Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to [your ability]
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Drop the item from slot (Integer A) of (Target unit of ability being cast)
          • Hero - Give (Last dropped item) to (Triggering unit)
 
Level 4
Joined
Feb 17, 2007
Messages
121
Bro man you are such a great help!
+Rep!
Hmm i forgot one part. When the unit starts the ability on the invulnerable unit, have a 1 second wait then have a game text where it says "You found "The Item". (can you help me on that?)

Thanks for helping me so much mr.bean
just made my night now i can sleep now haha. whenever i got other triggers that i need help ill ask you to see if you can help.
 
Level 4
Joined
Feb 17, 2007
Messages
121
What if the Casting Unit has full-slot items ?
Did the items fall to the ground ?

This is a matter of logic, you gotta think advance than that fellow triggerers.

Good point. If the casting unit have full item and starts to cast the ability on a different invulnerable unit, I want a text msg where it says your inventory is full.


Make a check if the caster's inventory is full, to prevent items from lying on the ground.

Good point^idk how to do that
 
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
You can use both local and global variable to keep track of the count of the item(s) (Integer-variable)
Use that Condition, and when it found an item, do like this:

  • Set ItemCount = (ItemCount + 1)
Then, if the ItemCount of the Casting Unit achieve to 6, get the error message running.

Use IF/THEN/ELSE Function to execute this.
 
Level 4
Joined
Feb 17, 2007
Messages
121
defskull: i still dont get how to start up that trigger that your explaining to me. im getting confused.
 
  • Actions
    • Custom script: local integer i = 0
    • 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 carried by (Triggering unit) in slot (Integer A)) Not equal to No item
          • Then - Actions
            • Custom script: set i = i + 1
          • Else - Actions
    • Custom script: if i == 6 then
    • -------- The inventory of the unit is full, do actions here. --------
    • Custom script: endif
 
Level 4
Joined
Feb 17, 2007
Messages
121
Pharaoh: sorry to be slow but i got stuck at this part, where do you get "not equal to no item"

(Item carried by (Triggering unit) in slot (Integer A)) 'Not equal to No item"
 
Level 4
Joined
Feb 17, 2007
Messages
121
pharaoh: when i saved the map this trigger gives me an script error

local integer i = 0
set i = i + 1
if i == 6 then
endif
 
Level 4
Joined
Feb 17, 2007
Messages
121
  • Item Search
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Search
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item carried by (Target unit of ability being cast) in slot 1) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 2) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 3) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 4) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 5) Equal to No item
          • (Item carried by (Target unit of ability being cast) in slot 6) Equal to No item
        • Then - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You find nothing sp...
          • Skip remaining actions
        • Else - Actions
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hero - Drop the item from slot (Integer A) of (Target unit of ability being cast)
              • Hero - Give (Last dropped item) to (Triggering unit)
              • Custom script: local integer i = 0
              • 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 carried by (Triggering unit) in slot (Integer A)) Not equal to No item
                    • Then - Actions
                      • Custom script: set i = i + 1
                    • Else - Actions
                      • Custom script: if i == 6 then
                      • Game - Display to (Player group((Triggering player))) the text: The inventory of th...
                      • Custom script: endif
 
  • Item Search
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Item Search
  • Actions
    • Custom script: local integer i = 0
    • For each (Integer A) from 1 to 6, do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Item carried by (Triggering unit) in slot (Integer A)) Equal to No item
          • Then - Action
            • Custom script: set i = i + 1
          • Else - Actions
    • Custom script: if i == 6 then
    • Set TempForce = (PlayerGroup(Triggering player))
    • Game - Display to TempForce the text: "The inventory is full."
    • Custom script: call DestroyForce (udg_TempForce)
    • Custom script: else
    • ----- Create items -----
    • Custom script: endif
 
Last edited:
Level 4
Joined
Feb 17, 2007
Messages
121
So is that a whole new trigger? Or the same because on yours I dont see where it says "gAme display text, you find nothi special in here."


[Edit]When i copy that trigger and save it, it still says line error. or something about that custom scripts..
 
Last edited:
Level 4
Joined
Feb 17, 2007
Messages
121
look at the attachment
before save and after save
 

Attachments

  • Error.png
    Error.png
    273.2 KB · Views: 62
Level 4
Joined
Feb 17, 2007
Messages
121
so is this how you want it?

  • Item Inventory
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Search
    • Actions
      • Custom script: local integer i = 0
      • 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 carried by (Triggering unit) in slot (Integer A)) Equal to No item
            • Then - Actions
              • Custom script: set i = i + 1
            • Else - Actions
              • Set TempForce = (Player group((Triggering player)))
              • Game - Display to TempForce the text: Your inventory is f...
              • Custom script: call DestroyForce (udg_TempForce)
              • -------- Create items --------
              • Custom script: endif
          • Custom script: if i == 6 then
 
Status
Not open for further replies.
Top