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

trigger for item creation

Status
Not open for further replies.
Level 3
Joined
Feb 18, 2017
Messages
31
Hello everyone,

i can't figure out this trigger.


- A hero kills a special creep.
- The hero gets an item when he has space in his inventory.
- The item gets deleted from the game when there is no space in his inventory.

I know how i can give the item but i can't figure out how to check if he has inventory space and then delete the item.

Appreciate any help!
 
Level 20
Joined
Aug 29, 2012
Messages
832
You could try with something like this:

  • 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 YourHero in slot (Integer A)) Not equal to No item
        • Then - Actions
          • Set Int_SpaceFilled = (Int_SpaceFilled + 1)
        • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Int_SpaceFilled Equal to 6
    • Then - Actions
      • Item - Remove YourItem
    • Else - Actions
Theoretically, the integer should return 6 (aka the number of occupied inventory slots in your hero), and if so, the item is deleted. That seems a bit convoluted but I can't think of anything more simple :grin:
 
Level 20
Joined
Feb 27, 2019
Messages
593
Pretty much the same as what Chaosium posted but inverted and added exitwhen true.
  • For each (ItemL) 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 Hero in slot (ItemL)) Equal to No item
        • Then - Actions
          • Hero - Give Item to Hero
          • Custom script: exitwhen true
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ItemL Equal to 6
            • Then - Actions
              • Item - Remove Item
            • Else - Actions
 
Level 21
Joined
Dec 4, 2007
Messages
1,480
You can do it even simpler:

  • itemsFull
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Storm Wyrm
    • Actions
      • Hero - Create Crown of Kings +5 and give it to (Killing unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Killing unit) has (Last created item)) Equal to True
        • Then - Actions
        • Else - Actions
          • Item - Remove (Last created item)
 
Status
Not open for further replies.
Top