1 /* Recharge callback in clonk if ammo has been used up */
2 
3 #appendto GrenadeLauncher
4 
Ejection()5 func Ejection()
6 {
7 	var cont = Contained();
8 	if (cont)
9 	{
10 		if (!Contents() && cont->GetAlive()) RechargeIronBomb();
11 	}
12 	return _inherited(...);
13 }
14 
ContentsDestruction()15 func ContentsDestruction()
16 {
17 	var cont = Contained();
18 	if (cont)
19 	{
20 		if (ContentsCount()<=1 && cont->GetAlive()) RechargeIronBomb();
21 	}
22 	return _inherited(...);
23 }
24 
25 // Recreate ammo - but max one per frame (also to ensure we don't run into endless loops when destructing)
RechargeIronBomb()26 func RechargeIronBomb()
27 {
28 	if (!g_homebases)
29 		return;
30 	var t = FrameCounter();
31 	if (this.last_iron_bomb_recharge == t) return nil;
32 	this.last_iron_bomb_recharge = t;
33 	return CreateContents(IronBomb);
34 }
35