This requires a few triggers. First, your cannon needs a spell like Orc Burrow's Load, and it can load only peasants. Then you need a spell based off of either Storm Bolt or Shockwave, depending on what kind of damage you want. Change them to how you find it fitting, then change the Art - Missle to either the peasant model, or, since the meatwagon missle is a peasant, that. Make it cost 1 mana. Here are your two trigs:
Events - Every .05 seconds
Conditions
Actions
Set AntiLeakUnitGroup = Units of type CannonUnit
Pick every unit in AntiLeakUnitGroup and do actions
Unit - Set mana of (Picked unit) to (Real((Number of units in (Units owned by (Owner of (Picked unit)) matching (((Matching unit) is loaded into (Picked unit)) Equal to True)))))
Custom Script: call DestroyGroup (udg_AntiLeakUnitGroup)
Trig 2:
Actions
A Unit begins casting an ability
Conditions
Ability is equal to CannonFireAbility
Actions
Kill Unit - (Random unit from (Units owned by Player 1 (Red) matching (((Triggering unit) is loaded into (Last created unit)) Equal to True)))
thanks purplepoot 4 ideas ( wich are veery cool ! ) , Thank donut 4 the triggers , but i am using a dummy spell , because using paesant as a missile doesn't look good . Also the trigger shouldnt be like that :
Actions A Unit begins casting an ability Conditions Ability is equal to CannonFireAbility Actions Kill Unit - (Random unit from (Units owned by Player 1 (Red) matching (((Triggering unit) is loaded into (Last created unit)) Equal to True)))
but :
Actions A Unit begins casting an ability Conditions Ability is equal to CannonFireAbility Actions If/Then/Else =Conditions: (Units owned by (Owner of (casting unit) loaded into (casting unit ) is more than (0) Then: Kill Unit - (Random unit from (Units owned by Player 1 (Red) matching (((Triggering unit) is loaded into (Last created unit)) Equal to True))) Else: Game - display to ( owner of (casting unit) : (Got no ammo !)
thanks purplepoot 4 ideas ( wich are veery cool ! ) , Thank donut 4 the triggers , but i am using a dummy spell , because using paesant as a missile doesn't look good . Also the trigger shouldnt be like that :
Actions A Unit begins casting an ability Conditions Ability is equal to CannonFireAbility Actions Kill Unit - (Random unit from (Units owned by Player 1 (Red) matching (((Triggering unit) is loaded into (Last created unit)) Equal to True)))
but :
Actions A Unit begins casting an ability Conditions Ability is equal to CannonFireAbility Actions If/Then/Else =Conditions: (Units owned by (Owner of (casting unit) loaded into (casting unit ) is more than (0) Then: Kill Unit - (Random unit from (Units owned by Player 1 (Red) matching (((Triggering unit) is loaded into (Last created unit)) Equal to True))) Else: Game - display to ( owner of (casting unit) : (Got no ammo !)