--flares local flares = {} flares [1] = piece "flare_lol" flares [2] = piece "flare_lor" flares [3] = piece "flare_hil" flares [4] = piece "flare_hir" local flare_lol = piece "flare_lol" local flare_lor = piece "flare_lor" local flare_hil = piece "flare_hil" local flare_hir = piece "flare_hir" --aiming pieces local turret = piece "turret2" local pivot_low = piece "pivot_low" local barrelsn = 2 --2 für normal, 4 für upgradet. used for QueryWeapon local shotfrom = 1 --which barrel will be shot from. [1,2] für normal, [1,4] für upgradet local muzzleflash = SFX.CEG+1 --signals local SIG_SHOT = 1 local SIG_AIM = 2 ----Shooting--- function script.QueryWeapon1() shotfrom = math.random (barrelsn) return flares [shotfrom] --if (b==1) then return flare_lol end --if (shotfrom==2) then return flare_lor end --if (shotfrom==3) then return flare_hil end --if (shotfrom==4) then return flare_hir end end function script.AimFromWeapon1() return turret end function script.AimWeapon1( heading, pitch ) Signal(SIG_AIM) SetSignalMask(SIG_AIM) Turn(turret, y_axis, heading, math.rad(270)) if (math.deg(pitch) < 0) then pitch = 0 end --do not aim turret lower than horizontal to ground Turn(pivot_low, x_axis, -pitch, math.rad(360)) WaitForTurn(turret, y_axis) WaitForTurn(pivot_low, x_axis) StartThread(RestoreAfterDelay) return true end function script.FireWeapon1() Spin (barrel_lol,z_axis, 12) Spin (barrel_lor,z_axis, -12) Spin (barrel_hil,z_axis, -12) Spin (barrel_hir,z_axis, 12) EmitSfx(flares [shotfrom], muzzleflash) end ------ function upgradegun () Spring.Echo ("unlocking extra barrels!") local newgun = {} newgun["reloadTime"] = 0.17 --newgun["maxRange"] = 100 Spring.SetUnitWeaponState(unitID, 0, newgun) barrelsn = 4 Spring.UnitScript.Show (pivot_high) Spring.UnitScript.Show (barrel_hil) Spring.UnitScript.Show (barrel_hir) end function script.Killed(recentDamage, maxHealth) for id,piece in pairs(unblownpieces) do Spring.UnitScript.Explode (piece, SFX.FALL) end end