How i make, like, when i kill an unit, have a chance to drop one item
3 Likes
- Create a global variable named “randd”
- Make sure you already have a unittype “YourUnit” and an itemtype “YourItem”
Then, add this script
Trigger: when a unit’s attribute becomes 0 or less
Actions:
if (unit type of (last triggering unit)) == (YourUnit):
randd = random number from 1 to 10
if (randd <= 2): # 2 means two times out of ten trials
create (LootItem) at position (coordinates of (last triggering unit))
2 Likes
the randd variable is not needed, you can just
if random number from 1 to 10 <= 2
and entity scripts are more beneficial as you dont need the “if unit type of last triggering unit == unit”
so, as a entity script:
Trigger: when this entity attribute is 0 or less
if attribute type of last triggering attribute == health
then do:
if random number from 1 to 2(50% chance theoritically) == 1
then do:
create item at position of this entity
2 Likes