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 25
Joined
Aug 29, 2012
Messages
1,082
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 23
Joined
Feb 27, 2019
Messages
727
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 22
Joined
Dec 4, 2007
Messages
1,525
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