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

Preventing ppl from using more than one of the same itemtype

Status
Not open for further replies.
Level 5
Joined
Mar 12, 2005
Messages
117
ok to start off lets make our types
things in brackets are titles of where you gotta look or drop down menu titles)

for this example i will use campaign item type (in we)
so sword will be under campaign items when you search for it in WE

Event: Unit Acuires Item

Condition: (Item class comparrison) Item Class of(item being manipulated) = Campaign

Action: (Set Variable) [this is general menu and is not filed into a category] setweapon=weapon+1.

do the same trigger but change the unit acuires item to unit losses item, and change the variable to setweapon=weapon-1

that sets up the variable youll need to run the trigger (if you dont know anything about variables there are tutorials on the site.)

then make a new trigger

event: unit acuires item

condition: Item Class of(item being manipulated) = Campaign


action: (If/Then/Else Action)

if [integer value comparrison] weapon is greater than 0. then [actions] drop item being manipulated. else [actions] do nothing.
 
Level 6
Joined
Feb 18, 2005
Messages
263
I would write i a little different.

Event: Unit aquires Item
Condition: [boolean] Unit has item of class(Itemclass of (Item beeing manipulated)) == true
Action:
drop item beeing manipulated
DisplayTextToPlayer(OwnerOfUnit(UnitManipulatingItem), "you already have an ietm of that class")

in addition to this you should group all items into different catgories
e.g.
weapons = campaign
armor = permanent
shields = rechargable
...

therefore you can simply check if the unit already has an item of this is that category and if it has, order it to drop the item it wanted to get.

PS:
I know, this is quite the same as written above, but i hope it's easier to undertand ^^
 
Level 2
Joined
Feb 23, 2006
Messages
11
Lord Raszul said:
I would write i a little different.

Event: Unit aquires Item
Condition: [boolean] Unit has item of class(Itemclass of (Item beeing manipulated)) == true
Action:
drop item beeing manipulated
DisplayTextToPlayer(OwnerOfUnit(UnitManipulatingItem), "you already have an ietm of that class")

in addition to this you should group all items into different catgories
e.g.
weapons = campaign
armor = permanent
shields = rechargable
...

therefore you can simply check if the unit already has an item of this is that category and if it has, order it to drop the item it wanted to get.

PS:
I know, this is quite the same as written above, but i hope it's easier to undertand ^^

where do i find "unit has item"
 
Level 2
Joined
Feb 23, 2006
Messages
11
Eziekiel_Rage said:
ok to start off lets make our types
things in brackets are titles of where you gotta look or drop down menu titles)

for this example i will use campaign item type (in we)
so sword will be under campaign items when you search for it in WE

Event: Unit Acuires Item

Condition: (Item class comparrison) Item Class of(item being manipulated) = Campaign

Action: (Set Variable) [this is general menu and is not filed into a category] setweapon=weapon+1.

do the same trigger but change the unit acuires item to unit losses item, and change the variable to setweapon=weapon-1

that sets up the variable youll need to run the trigger (if you dont know anything about variables there are tutorials on the site.)

then make a new trigger

event: unit acuires item

condition: Item Class of(item being manipulated) = Campaign


action: (If/Then/Else Action)

if [integer value comparrison] weapon is greater than 0. then [actions] drop item being manipulated. else [actions] do nothing.

this doesnt work i cant buy any item of that type at all it automatically drops them
 
Level 3
Joined
Oct 14, 2005
Messages
37
That is because the trigger event is gaining the item; thus, you have at least one item matching those criteria (the one you picked up) when the actions start running. Therefore it drops the item automatically, since the condition is always true. One solution is to drop the item before checking the condition (using an If/Then/Else statement for the condition) and then remove the item if they still don't have a matching item and giving a new item to the Hero via the Create Item For Hero action. Even though the item itself doesn't propagate, the net effect works out correctly.
 
Level 6
Joined
Feb 18, 2005
Messages
263
Ok, i had written it jsut out of my midn without checking of the functions i mention exist.

here is the code as i put it in the editor. Haven't tested whether it works, but it should.

Code:
LetItDrop
    Ereignisse
        Einheit - A unit Erwirbt einen Gegenstand
    Bedingungen
        tmp_boolean_IsCheckingItems Gleich False
    Aktionen
        Set tmp_boolean_IsCheckingItems = True
        Set tmp_boolean = False
        Held - Drop (Item being manipulated) from (Hero manipulating item)
        For each (Integer A) from 1 to (Size of inventory for (Hero manipulating item)), do (Actions)
            Schleifen - Aktionen
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    'IF'-Bedingungen
                        (Item-class of (Item being manipulated)) Gleich (Item-class of (Item carried by (Hero manipulating item) in slot (Integer A)))
                    'THEN'-Aktionen
                        Set tmp_boolean = True
                    'ELSE'-Aktionen
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            'IF'-Bedingungen
                tmp_boolean Gleich False
            'THEN'-Aktionen
                Held - Give (Item being manipulated) to (Hero manipulating item)
            'ELSE'-Aktionen
        Set tmp_boolean_IsCheckingItems = False
 
Status
Not open for further replies.
Top