HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How do i make it so that when a hero has 2 of the same tiype...

12-19-2003, 02:33 AM#1
Bustaboom
How do i make it so that when a hero has 2 of the same tiype of item in his inventory one of those items drops out of his inventory?
12-19-2003, 02:37 AM#2
Eriond
Easy. Here's the code:

EVENTS:

Unit - Unit Aquires an Item

CONDITIONS:

None

ACTIONS:
For each integer from 1 to 6 do the following
If ItemType of item in slot (Integer A) is equal to ItemType of Item being manipulated then Order Hero to Drop Item Being Manipulated


That's obviosuly not the exact wording, but that's the just of it, you'll have to find the actual commands, but I know they are there.
12-19-2003, 02:48 AM#3
ObsidianTitan
Only problem is that will drop it all the time, you need to check if there are 2 of the same item when the hero picks up the item.

The variable this needs an integer that i named ItemTypeCount for this.
Event
Unit - A unit Acquires an item

Conditions
(none)

Actions
Set ItemTypeCount = 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-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A)))
Then - Actions
Set ItemTypeCount = (ItemTypeCount + 1)
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ItemTypeCount Greater than or equal to 2
Then - Actions
Hero - Drop (Item being manipulated) from (Hero manipulating item)
Else - Actions
Do nothing

Well it seems the latest patch made that easyer to copy than it was.
12-19-2003, 02:51 AM#4
Bustaboom
I did what you said and it didnt seem to work it dropped every item i tried to puck up not just an item of the same type i already had in m inventory
12-19-2003, 03:01 AM#5
Eriond
Wait a min, it would wouldn't it, because it's checking the manipulating item as well, huh? Here are the revisions to the trigger.

EVENTS:

Unit - Unit Aquires an Item

CONDITIONS:

None

ACTIONS:
For each integer from 1 to 6 do the following
If ItemType of item in slot (Integer A) is equal to ItemType of Item being manipulated and Item being manipulated is not equal to item in slot (Integer A) then Order Hero to Drop Item Being Manipulated
12-19-2003, 03:06 AM#6
Bustaboom
OMG ObsidianTitan you rock thanks so much for your help it worked perfectly
12-19-2003, 03:08 AM#7
ObsidianTitan
Now that trigger would work Eriond, better than mine because it uses no variable.

[edit just so i dont clutter] i litteraly never use non array variables. when i first looked at this thread i first thought of labeling every hero and item in arrays and working with it like that. but when giving things to other people it is best to use as little variables as possible so no to confuse and clutter.
12-19-2003, 03:11 AM#8
Eriond
I guess you're right... big maps get cluttered with too many variables, and you have to start giving them prefixes to get any kind of order :ggani: .

I avoid them wherever possible and where it isn't possible, I use arrays.
12-19-2003, 03:49 AM#9
Bustaboom
Hmm how would i add the and pard of that?
12-19-2003, 03:51 AM#10
Eriond
There's actually a condition called AND. It's at the very bottom of the list.
12-19-2003, 04:39 AM#11
Bustaboom
It still isnt working it makes the all items drop to the ground this is what i have.

If ((Item-type of (Item carried by Paladin 0004 <gen> in slot (Integer A))) Equal to (Item-type of (Item being manipulated))) then do (If ((Item-class of (Item being manipulated)) Not equal to (Item-class of (Item carried by Paladin 0004 <gen> in slot (Integer A)))) then do (Hero - Drop (Item being manipulated) from Paladin 0004 <gen>) else do (Do nothing)) else do (Do nothing)
12-19-2003, 05:03 AM#12
Eriond
Here's what it should be:

For each integer from 1 to 6
If ((Item-type of (Item carried by Paladin 0004 <gen> in slot (Integer A))) Equal to (Item-type of (Item being manipulated))) and (Item being manipulated) not equal to (Item carried by Paladin 0004 <gen> in slot (Integer A)))) then do (Hero - Drop (Item being manipulated) from Paladin 0004 <gen> ) else do (Do nothing)

I hope that works, I'm having trouble concentrating, it's 1:00 AM... I need to go to bed.

EDIT: I've changed around the bold not equal to around to equal to like 5 times! Arg! I can't get it right! SO HARD TO CONCENTRATE! It's not equal to now, though I'm pretty sure, and I better leave before I edit agian and change my mind.
12-19-2003, 06:44 AM#13
Bustaboom
Yup eriond that works thanks so much I really didnt want to have to use anymore variables you rock too
12-19-2003, 06:21 PM#14
Scyze
I'm not sure if this works, but I know these triggers are here! If I'm right you guys have waaaaaaaaay over done your triggers, but if I'm wrong...I'm shutting up!

Events
Unit - A Unit Aqquires an Item
Conditon
Boolean - Triggering Unit Has Item Of Type (Item-type of (Item being manipulated))) Equal to True
Actions
Hero - Drop (Item being manipulated) from unit.
Good luck!

Ah, nope. I just tested it, no worky :(
12-19-2003, 06:42 PM#15
ObsidianTitan
that goes all the way back to erionds first trigger, what that does is if the unit picks up the item they drop it. that is not what he wants, he wants it so he cant have 2 of the same item. all your trigger would do is not allow heros to pick up any items.