- Joined
- Jan 13, 2012
- Messages
- 2
Is there a trigger to randomly make items drop on death for spawned units? I want random items to drop at random times when these units are killed. Help?
Is there a trigger to randomly make items drop on death for spawned units? I want random items to drop at random times when these units are killed. Help?
leaks a locationThis trigger gives a level 1 creep a 3% chance to drop a level 1 Permanent item. You can change it however you'd like to adapt for creep level or different percentages
[trigger=Is this what you mean]ITEM DROP TRIGGER
Events
Unit - A unit Dies
Conditions
(Owner of (Dying unit)) Equal to (==) Neutral Hostile
(Level of (Dying unit)) Equal to (==) 1
Actions
Set Random_Integer = (Random integer number between 1 and 100)
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Random_Integer Less than or equal to (<=) 3
Then - Actions
Set DisposablePoint = ((Position of (Dying unit)) offset by 50.00 towards (Random angle) degrees)
Item - Create (Random level 1 Permanent item-type) at DisposablePoint
Custom script: call RemoveLocation(udg_DisposablePoint)
Else - Actions
Do nothing[/trigger]
I haven't had a problem with 'Dying Unit' but Triggering Unit might be better
leaks a location
- Set DisposablePoint = ((Position of (Dying unit)) offset by 50.00 towards (Random angle) degrees)
[trigger=What about this?]Custom script: call RemoveLocation(udg_DisposablePoint)[/trigger]
Don't I remove the leak here?
you create the locationA (Position of Picked Unit)
you create another locationB (LocationA moved x up, y across)
you remove locationB
locationA is still there
Oh I see. So how do I remove them both? I guess there is no need to offset it, not sure why I did that in the first place. But to satisfy my curiosity what would you suggest I do?
I suggest using indexes 0 and 1, this way you waste 2 locations but thats just a little note and is not needed
I personally think there is nothing wrong in the GetDyingUnit(GUI Dying Unit), yes it must convert itself to GetTriggerUnit but it does in lower levels than Jass so its imo not problem
other than that, its leakless and should be bugless as you dont use any waits
function DoNothing takes nothing returns nothing
endfunction
Do Nothing literaly does nothing, it justs wastes space, remove it...
JASS:function DoNothing takes nothing returns nothing endfunction
the only purpose for it is a one-line if-then-else statement where it will give u an error if u dont put anything in the Else block
I suggest it only because in Jass arrays are allocated in powers of 2(so you have 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 or 8192 variables allocated at the same time, dont worry, the null ones dont or should not eat up space because they point to 0 memory in ram) so if you use 0, 1 you will not allocate additional array size but if you use 1, 2 you will allocate indexes 2 and 3
in jass u dont allocate arrays...