local pieces = {} --center pieces & aiming pieces local base = piece "base" local arm_r = piece "arm_r" local arm_l = piece "arm_l" local flare = piece "flare1" --other pieces local head = piece "head" local leg_r = piece "leg_r" local leg_l = piece "leg_l" local belly1 = piece "belly1" table.insert (pieces, belly1) local belly2 = piece "belly2" table.insert (pieces, belly2) local belly3 = piece "belly3" table.insert (pieces, belly3) local belly4 = piece "belly4" table.insert (pieces, belly4) local belly5 = piece "belly5" table.insert (pieces, belly5) local belly6 = piece "belly6" table.insert (pieces, belly6) local belly7 = piece "belly7" table.insert (pieces, belly7) local belly8 = piece "belly8" table.insert (pieces, belly8) local unblownpieces = pieces local unitDef = UnitDefs[Spring.GetUnitDefID(unitID)] local maxhealth = unitDef.health local maxpieces = table.getn (pieces) local blowstepdamage = 10--maxhealth / maxpieces local blowdamage = 0 local blownpieces = {} --signals local SIG_AIM = 2 local SIG_WALK = 1 local walking = false --local orc_machinegun_flash = SFX.CEG --local orc_machinegun_muzzle = SFX.CEG + 1 local walkspeed = 30 ------react to enemy fire----- function script.HitByWeapon (x, z, weaponDefID, damage) blowdamage = blowdamage + damage if (blowdamage < blowstepdamage) then return end blowdamage = 0 if (table.getn(unblownpieces) > 0) then local exploID = math.random(table.getn(unblownpieces)) local explo = unblownpieces [exploID] if (explo) then --Spring.UnitScript.Explode (explo, SFX.SHATTER) Spring.UnitScript.Explode (explo, SFX.EXPLODE) Spring.UnitScript.Hide (explo) table.remove (unblownpieces, exploID) table.insert (blownpieces, explo) end end end ------------------------------ --AllowUnitBuildStep() --> "builderID, builderTeam, unitID, unitDefID, part" --end -------WALKING----- local function walk() Signal(SIG_WALK) SetSignalMask(SIG_WALK) while (walking) do Move (leg_r, z_axis, -5, walkspeed) Move (leg_l, z_axis, 5, walkspeed) Turn(arm_l, x_axis, math.rad(40), math.rad(80)) Turn(arm_r, x_axis, -math.rad(25), math.rad(40)) WaitForMove (leg_r, z_axis) WaitForMove (leg_l, z_axis) Sleep (20) Move (leg_r, z_axis, 5, walkspeed) Move (leg_l, z_axis, -5, walkspeed) Turn(arm_l, x_axis, -math.rad(40), math.rad(80)) Turn(arm_r, x_axis, math.rad(25), math.rad(40)) WaitForMove (leg_r, z_axis) WaitForMove (leg_l, z_axis) Sleep (20) end end local function stopwalk () end function script.StartMoving() walking = true StartThread(walk) end function script.StopMoving() walking = false Signal(SIG_WALK) end ------------------------- function script.Create() --Spin(head, y_axis, 5) --Spin(arm_r, x_axis, 5) end local function RestoreAfterDelay(unitID) Sleep(1500) Turn(arm_r, x_axis, 0, math.rad(50)) Turn(arm_l, x_axis, 0, math.rad(100)) Turn(base, y_axis, 0, math.rad(180)) Move (leg_r, z_axis, 0, walkspeed) Move (leg_l, z_axis, 0, walkspeed) end function script.QueryWeapon1() return flare end function script.AimFromWeapon1() return base end function script.AimWeapon1( heading, pitch ) Signal(SIG_AIM) SetSignalMask(SIG_AIM) Turn(base, y_axis, heading, math.rad(360)) --if (math.deg(pitch) < 0) then pitch = 0 end Turn(arm_r, x_axis, -pitch-math.rad(90), math.rad(180)) WaitForTurn(base, y_axis) WaitForTurn(arm_r, x_axis) StartThread(RestoreAfterDelay) return true end function script.FireWeapon1() -- EmitSfx(flare, orc_machinegun_flash) -- EmitSfx(flare, orc_machinegun_muzzle) Sleep(30) end function script.EndBurst1 ( ) --Turn(arm_l, x_axis, 360, math.rad(720)) end function script.Killed(recentDamage, maxHealth) Sleep(30) end