| 09-23-2005, 11:02 PM | #1 |
I was wondering if there was any way to get a certain number of units to drop random items from a list...does anyone know how? Any help would be appreciated. |
| 09-25-2005, 11:59 PM | #2 |
Yes, there are ways to do so. In fact there are many ways and your question is not exactly the most specific question ever. Could you please be more specific? If you want any kind of list you can always use an item type array and random numbers for indexes |
| 09-27-2005, 01:37 AM | #3 |
what i want to happen is to set certain types of units to variables. (footman variable 1, rifleman variable 2, etc.) and then have them drop a random item from a list (potion of healing, potion of mana, etc.) |
| 09-27-2005, 09:33 PM | #4 |
This isn't really a problem that would require JASS. Simple GUI triggering can get the job done. All you would need to do would be to initialize an item-type variable array, as Lord Vexorian suggested. Let's call it itemDropTypes[] (create it in the variable editor). In these examples, for ease of understanding, I also use an integer variable called tempInteger. If you want to clear your memory leaks, you also need a location (point) variable, I called it tempPoint. Code:
Events:
Map Initialization
Conditions:
Actions:
Set itemDropTypes[1] = Potion of Healing
Set itemDropTypes[2] = Potion of Mana
Set itemDropTypes[3] = Healing Salve
...
Set itemDropTypes[59] = Grand Mithril Runeblade of Carnage +50Code:
Events:
A unit dies
Conditions:
//check if the unit is the one that drops an item - there are more possibilities, depending on what you want
Unit-type comparison //if you want only units of a certain type to drop items
Unit comparison //if you want a specific unit to drop an item, like one set to a variable
Integer comparison - Random number between 0 and 100 less than 20 //if you want a percent chance for a drop, in this case it is 20%
Actions:
Set tempInteger = random number between 1 and 3 //in this example trigger, the unit can drop only one of the first three items
item - create itemDropTypes[tempInteger] at position of (Dying unit)Code:
...
Actions:
Set tempInteger = random number between 55 and 59 //the mighty dragon can drop only the most stylish items
Set tempPoint = position of (Dying unit)
item - create itemDropTypes[tempInteger] at tempPoint
Custom script: call RemoveLocation( udg_tempPoint )Edit: Yay, we got the code tags back. GJ Vex. Although... it's a bit hard to read, as small as it is... and that bold Code: each time is a bit annoying, it disturbs the layout. |
| 09-28-2005, 11:29 PM | #5 |
ok i get all that but ive got one question... when you say units of a certain type, do u mean like undead or units in a certain section? because i want to have a number of units that i have selected to randomly drop items. |
| 09-29-2005, 10:19 PM | #6 |
It's up to you. I don't know what you want, you must decide that and tailor the trigger's condition(s) accordingly. You want it to work for some "selected" units? Add them to a unit group when you select which ones you want and use the "unit in unit group" boolean for the trigger's condition. |
| 09-29-2005, 11:17 PM | #7 |
got it, thanks a lot. |
