HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Limiting item types

05-12-2005, 12:18 AM#1
High Loremaster
I am attempting to make triggers that limit the number of a kind of item a hero can carry. For example, I want to make sure a hero cannot carry two or more swords at one time (same thing applies to shields and other armor).

I have tried numerous triggers and combinations, but no luck... any help?
05-12-2005, 12:42 AM#2
Guest
Code:
Events
    Unit - A unit Acquires an item
Conditions
    (Item-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Min(2, 6))))
Actions
    Item - Move (Item being manipulated) to (Position of (Hero manipulating item))
This is a little buggy but it should work.

Peace
Destruction
05-12-2005, 01:30 PM#3
Anitarf
Quote:
Originally Posted by Hunter_Destruction
Code:
Events
    Unit - A unit Acquires an item
Conditions
    (Item-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Min(2, 6))))
Actions
    Item - Move (Item being manipulated) to (Position of (Hero manipulating item))
This is a little buggy but it should work.
Actually, it's a lot buggy, it only compares the item type (so you can have two swords, if they are different) of the acquired item with the item type of item in slot 2. If the acquired item gets put in that slot, it will be dropped no matter if the hro has another such item or not. If a hero already has an item of that type but in any slot other than 2, it won't be dropped even though it should be.

This trigger should work properly, it uses item classes (for example permanent, artifact, purchaseable,...), so you should put all swords in one category, all shields in another... if you have more types of items than there are class categories, use life of items or something like that instead:

Code:
Events:
    a unit acquires an item
Conditions:
actions:
    for each Integer A from 1 to 6 do actions
        loop - actions:
            if - then - else multiple functions
                if - conditions:
                    item class of (item being manipulated) equal to item class of (item carried by hero in slot (Integer A))
                    (item being manipulated) not equal to item carried by hero in slot (Integer A)
                then - actions:
                    hero - drop (item being manipulated) from (hero manipulating item)
                    skip remaining actions
                else - actions:
                    do nothing
05-12-2005, 08:07 PM#4
High Loremaster
*praises Anitarf*

Thanks a ton! This trigger's been bugging me for the past couple of weeks (again).