View Full Version : Stealing Items?
Hotshot
07-11-2006, 7:06 AM
I know it's a long shot, but would it be possible to create an item/ability that could steal an item off a hero?
Markpyro
07-11-2006, 1:37 PM
Hmm. An ability, that when activated by a certain unit, starts a trigger that deletes an item from targeted hero's inventory and creates a copy in the caster's? Doesnt sound too far fetched for me, but I must warn you that I havent touched World Edit in nearly two years :/. Go for it.
Dayoh
07-12-2006, 12:19 AM
That would be very simple to make, if u did it as a hero spell it would be way easier, u will have to trigger it thats the clue :D
(it will only take like 4 lines of code to do a basic one)
Hotshot
07-12-2006, 7:51 AM
What about stealing a random item, say from a random item slot from 1 - 6 every time the ability is used? So if there isn't an item in that particular slot, nothing is stolen that time round; makes things interesting and fair. I gotta try this out! Might need some help though.
gamer102
07-16-2006, 9:06 PM
Use the "For each integer A" and A being the hero spell's level
and how many items to steal.
I saw it trying out a map that created fire spirals depending on what the level was
Hotshot
07-17-2006, 12:11 AM
Use the "For each integer A" and A being the hero spell's level
and how many items to steal.
I saw it trying out a map that created fire spirals depending on what the level was
Actually I was talking about stealing an item from a random item slot of the 6 you can carry, and if there isn't an item there that time nothing would be stolen, not multiple item stealing.
Zipsco
07-26-2006, 6:17 PM
Since it loots like nobody really answered with anything but yes, and maybe i thought i would come with an example. You got complete control over items in the world editor through triggers, an example in making what you are talking about would be;
Make an item (not type/not class) variable, then use: Set variable = item carried by hero in slot (math - random number from X(1) to X(6))
Hero - give ITEM to UNIT
then set item to item_variable, and unit to the unit using the spell.
Now since i haven't tested this i can't be sure it will work to actually give away items in someones inventory but i should guess it would. Anyway i have made sure all the triggers exist and the options i gave them is possible. Try it out. Otherwise just do this:
set variable_INTEGER(name = SLOT_ID) = (math - random number from X(1) to X(6))
set variable_item_type = item-type of item carried by hero in slot SLOT_ID
Item - create an item of item-type (variable_item_type) for unit (stealer)
Item - remove item from hero inventory slot SLOT_ID
done and done :) hope it helps. (this is ofc made thinking that you know about how to trigger triggers with spells, otherwise write a new post about not knowing)
Hotshot
07-27-2006, 12:55 AM
Thanks for the concept Zipsco, and while attempting your method I found a simpler way to do it. Problem solved.
Zipsco
07-27-2006, 6:56 AM
A simpler method, by all means show, so ill know it, if ill have to make something similar sometime :D
Hotshot
07-27-2006, 7:11 AM
The following is the easier way.
ItemSteal
- Events
... Unit - A unit Begins casting an ability
- Conditions
... (Ability being cast) Equal to 'Steal Item Ability'
- Actions
... Hero - Give (Item carried by (Target unit of ability being cast) in slot (Random integer number between 1 and 6)) to (Triggering unit)
Unfortunately, because I am casting the ability from an item (even though the 'Steal' item is a charged item with only 1 charge) when I steal an item from the enemy using this method it will take a different inventory slot to the 'Steal' item - this means that if you already have 6 items (inc. the 'Steal' item) it won't steal anything because it wont fit in the inventory at the time it is used. This method will work great as a unit ability though.
Here is a better way for it as a charged item ability. (The way I wanted)
Variables: RandItem (as Integer), StealItem (as Item)
Abilities: Steal Item (I used modified Unholy Frenzy base because you can target units)
ItemSteal
-Events
...Unit - A unit Begins casting an ability
-Conditions
...(Ability being cast) Equal to 'Steal Item Ability'
-Actions
...Set RandItem = (Random integer number between 1 and 6)
...Set StealItem = (Item carried by (Target unit of ability being cast) in slot RandItem)
...Hero - Drop the item from slot RandItem of (Target unit of ability being cast)
...Item - Hide StealItem
...Wait 0.01 seconds
...Hero - Give StealItem to (Triggering unit)
The Steal Item Ability should only be able to target enemy heroes; units that carry items.
The hide item action will make the item invisible when it is on the ground for the 0.01 seconds.
The wait 0.01 seconds will allow the stolen item to take the place of the 'Steal' item in the inventory if there are no charges left.
If you want to use this ability as a unit ability I would suggest you just use the 1st version as there is no 'Steal' item involved to overwrite. This means if the ability is used as a unit ability when holding 6 items already nothing will happen when the ability is used.
Zipsco
07-27-2006, 7:15 AM
cool cool, a refined method :) also nice of you to sum up with everything nicely put up. then people migth understand the concept :D i kno iam babling every once in a while.
Hotshot
07-27-2006, 7:19 AM
Keep an eye out for my 'Gloves of Theft' item in the map I'm submitting for Gamer102's mapping contest. ;)
Zipsco
07-27-2006, 7:30 AM
Sounds cool, ill do that. Anyway if i don't get my map finished at time i might consider asking gamer102 to help him out "judging" you all!!
Please have check that the Random Slot chosen by the Trigger has an Item! If it hasn't, Choose different slot.
Or you can scan target's inventory, record the slots that have items on an array with Boolean check. Then count the elements with flag on the array, choose a random of what you got as "Flagged Elements"
Hotshot
07-30-2006, 7:36 AM
Please have check that the Random Slot chosen by the Trigger has an Item! If it hasn't, Choose different slot.
Or you can scan target's inventory, record the slots that have items on an array with Boolean check. Then count the elements with flag on the array, choose a random of what you got as "Flagged Elements"
For what I was doing I wanted it to not steal items sometimes as well, so it would be a 1/(number of items being carried) chance to steal an item. So if your enemy had 1 item it would be a 1/6 chance to steal where as if your enemy had a full inventory (6/6 chance) you are guarenteed an item.
What about stealing a random item, say from a random item slot from 1 - 6 every time the ability is used? So if there isn't an item in that particular slot, nothing is stolen that time round; makes things interesting and fair.
If you want to add extra conditions yourself so that it will steal an item regardless of how many items the enemy is holding, go for it. :)
I'm sure it wouldn't be hard.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.