Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local base = piece "base"
- local pelvis = piece "pelvis"
- local body = piece "body"
- local head = piece "head"
- local L_upper = piece "L_upper"
- local L_lower = piece "L_lower"
- local L_hand = piece "L_hand"
- local R_upper = piece "R_upper"
- local R_lower = piece "R_lower"
- local R_hand = piece "R_hand"
- local L_legupper = piece "L_legupper"
- local L_leglower = piece "L_leglower"
- local L_foot = piece "L_foot"
- local R_legupper = piece "R_legupper"
- local R_leglower = piece "R_leglower"
- local R_foot = piece "R_foot"
- local hammer = piece "hammer"
- local flare = piece "flare"
- local SIG_REST = 1
- local SIG_WALK = 2 --signal for the walk animation thread
- local SIG_AIM = 4 --signal for the weapon aiming thread
- local SIG_SWING = 8
- local leg_movespeed = 6
- local RESTORE_DELAY = 1 * 1000 * Spring.GetUnitWeaponState(unitID, 0, 'reloadTime')
- ---REST---
- local function rest()
- Signal(SIG_REST)
- SetSignalMask(SIG_REST)
- while (true) do
- Move (body, 2, 0.5, 0.25)
- Turn (body, 1 , math.rad(-2), math.rad(2))
- Turn (head, 1 , math.rad(4), math.rad(4))
- Turn (L_upper, 1, math.rad(4), math.rad(4))
- Turn (R_upper, 1, math.rad(2), math.rad(2))
- Sleep (1010)
- Move (body, 2, 0, 0.25)
- Turn (body, 1 , math.rad(0), math.rad(2))
- Turn (head, 1 , math.rad(0), math.rad(4))
- Turn (L_upper, 1, math.rad(0), math.rad(4))
- Turn (R_upper, 1, math.rad(0), math.rad(2))
- Sleep (1010)
- end
- end
- function script.Create()
- --rest arms
- Turn(R_upper, 3, math.rad(-80))
- Turn(L_upper, 3, math.rad(80))
- Turn(R_lower, 3, math.rad(-10))
- Turn(L_lower, 3, math.rad(10))
- Turn(R_upper, 1, math.rad(10))
- Turn(L_upper, 1, math.rad(10))
- Turn(R_lower, 1, math.rad(-20))
- Turn(L_lower, 1, math.rad(-20))
- Turn(R_hand, 3, math.rad(-10))
- Turn(hammer, 3, math.rad(90))
- Turn(hammer, 2, math.rad(30))
- --rest legs
- Turn(R_legupper, 1, math.rad(-5))
- Turn(L_legupper, 1, math.rad(-10))
- Turn(R_legupper, 3, math.rad(3))
- Turn(L_legupper, 3, math.rad(-3))
- Turn(R_leglower, 1, math.rad(15))
- Turn(L_leglower, 1, math.rad(10))
- Turn(R_foot, 1, math.rad(-10))
- StartThread (rest)
- end
- local function RestoreAfterDelay()
- Sleep(RESTORE_DELAY)
- Turn(body, 2, 0 ,math.rad(125))
- Turn(L_upper, 2, 0, math.rad(75))
- Turn(L_lower, 2, 0, math.rad(75))
- Turn(head, 2, 0, math.rad(100))
- Turn(L_upper, 1, 0, math.rad(50))
- Turn(L_lower, 1, 0, math.rad(50))
- Turn(L_hand, 1, 0, math.rad(200))
- Turn(L_hand, 3, 0, math.rad(200))
- end
- ---WALKING---
- local function walk()
- Sleep (math.random(100))
- Signal(SIG_WALK)
- SetSignalMask(SIG_WALK)
- while (true) do
- --left leg up, right leg down
- Turn (R_legupper, 1, math.rad(-3), math.rad(19)*leg_movespeed)
- Turn (R_legupper, 3, math.rad(1), math.rad(1))
- Turn (R_leglower, 1, math.rad(10), math.rad(0)*leg_movespeed)
- Turn (R_foot, 1, math.rad(-8), math.rad(4)*leg_movespeed)
- Turn (L_legupper, 1, math.rad(-16), math.rad(29)*leg_movespeed)
- Turn (L_legupper, 3, math.rad(-1), math.rad(2))
- Turn (L_leglower, 1, math.rad(58), math.rad(46)*leg_movespeed)
- Turn (L_foot, 1, math.rad(12), math.rad(15)*leg_movespeed)
- Turn (pelvis, 3, math.rad(0), math.rad(10))
- Turn (body, 3, math.rad(0), math.rad(10))
- Turn (R_upper, 1, math.rad(0), math.rad(10)*leg_movespeed)
- Move (pelvis, 2, 0, 10)
- Sleep (1010/leg_movespeed)
- Turn (R_legupper, 1, math.rad(13), math.rad(16)*leg_movespeed)
- Turn (R_legupper, 3, math.rad(3), math.rad(2))
- Turn (R_leglower, 1, math.rad(12), math.rad(2)*leg_movespeed)
- Turn (R_foot, 1, math.rad(-3), math.rad(5)*leg_movespeed)
- Turn (L_legupper, 1, math.rad(-22), math.rad(6)*leg_movespeed)
- Turn (L_legupper, 3, math.rad(0), math.rad(1))
- Turn (L_leglower, 1, math.rad(10), math.rad(48)*leg_movespeed)
- Turn (L_foot, 1, math.rad(-12), math.rad(24)*leg_movespeed)
- Turn (pelvis, 3, math.rad(-4), math.rad(10))
- Turn (body, 3, math.rad(4), math.rad(10))
- Turn (R_upper, 1, math.rad(-10), math.rad(10)*leg_movespeed)
- Move (pelvis, 2, -0.3, 10)
- Sleep (1010/leg_movespeed)
- Turn (R_legupper, 1, math.rad(-16), math.rad(29)*leg_movespeed)
- Turn (R_legupper, 3, math.rad(1), math.rad(2))
- Turn (R_leglower, 1, math.rad(58), math.rad(46)*leg_movespeed)
- Turn (R_foot, 1, math.rad(12), math.rad(15)*leg_movespeed)
- Turn (L_legupper, 1, math.rad(-3), math.rad(19)*leg_movespeed)
- Turn (L_legupper, 3, math.rad(-1), math.rad(1))
- Turn (L_leglower, 1, math.rad(10), math.rad(0)*leg_movespeed)
- Turn (L_foot, 1, math.rad(-8), math.rad(4)*leg_movespeed)
- Turn (pelvis, 3, math.rad(0), math.rad(10))
- Turn (body, 3, math.rad(0), math.rad(10))
- Turn (R_upper, 1, math.rad(0), math.rad(10)*leg_movespeed)
- Move (pelvis, 2, 0, 10)
- Sleep (1010/leg_movespeed)
- Turn (R_legupper, 1, math.rad(-22), math.rad(6)*leg_movespeed)
- Turn (R_legupper, 3, math.rad(0), math.rad(1))
- Turn (R_leglower, 1, math.rad(10), math.rad(48)*leg_movespeed)
- Turn (R_foot, 1, math.rad(-12), math.rad(24)*leg_movespeed)
- Turn (L_legupper, 1, math.rad(13), math.rad(16)*leg_movespeed)
- Turn (L_legupper, 3, math.rad(-3), math.rad(2))
- Turn (L_leglower, 1, math.rad(12), math.rad(2)*leg_movespeed)
- Turn (L_foot, 1, math.rad(-3), math.rad(5)*leg_movespeed)
- Turn (pelvis, 3, math.rad(-4), math.rad(10))
- Turn (body, 3, math.rad(4), math.rad(10))
- Turn (R_upper, 1, math.rad(10), math.rad(10)*leg_movespeed)
- Move (pelvis, 2, -0.3, 10)
- Sleep (1010/leg_movespeed)
- end
- end
- local function armswing()
- Signal(SIG_SWING)
- SetSignalMask(SIG_SWING)
- while (true) do
- Turn (L_upper, 1, math.rad(0), math.rad(20)*leg_movespeed)
- Turn (L_lower, 1, math.rad(0), math.rad(10)*leg_movespeed)
- Sleep (1010/leg_movespeed)
- Turn (L_upper, 1, math.rad(20), math.rad(20)*leg_movespeed)
- Turn (L_lower, 1, math.rad(10), math.rad(10)*leg_movespeed)
- Sleep (1010/leg_movespeed)
- Turn (L_upper, 1, math.rad(0), math.rad(20)*leg_movespeed)
- Sleep (1010/leg_movespeed)
- Turn (L_upper, 1, math.rad(-20), math.rad(20)*leg_movespeed)
- Sleep (1010/leg_movespeed)
- end
- end
- local function legs_down ()
- Turn (R_upper, 1, math.rad(0), math.rad(10)*leg_movespeed)
- Turn (L_upper, 1, math.rad(0), math.rad(20)*leg_movespeed)
- Turn (L_lower, 1, math.rad(0), math.rad(10)*leg_movespeed)
- Turn(R_legupper, 1, math.rad(-5), math.rad(90)*leg_movespeed)
- Turn(L_legupper, 1, math.rad(-10), math.rad(90)*leg_movespeed)
- Turn(R_leglower, 1, math.rad(15), math.rad(90)*leg_movespeed)
- Turn(L_leglower, 1, math.rad(10), math.rad(90)*leg_movespeed)
- Turn(R_foot, 1, math.rad(-10), math.rad(90)*leg_movespeed)
- Turn(L_foot, 1, math.rad(0), math.rad(90)*leg_movespeed)
- Turn (pelvis, 3, math.rad(0), math.rad(10))
- Turn (body, 3, math.rad(0), math.rad(10))
- end
- function script.StartMoving()
- -- Spring.Echo ("starting to walk!")
- StartThread (walk)
- StartThread (armswing)
- Signal(SIG_REST)
- end
- function script.StopMoving()
- -- Spring.Echo ("stopped walking!")
- StartThread (rest)
- Signal(SIG_WALK)
- Signal(SIG_SWING)
- legs_down ()
- end
- ---AIMING & SHOOTING---
- function script.AimFromWeapon1()
- return body
- end
- function script.QueryWeapon1()
- return flare
- end
- --must return true to allow the weapon to shot. return false denies the weapon from shooting
- --can be used delay the shooting until a "turn turret" animation is completed
- function script.AimWeapon1( heading, pitch )
- --make sure the aiming animation is only run once
- Signal(SIG_AIM)
- Signal(SIG_SWING)
- SetSignalMask(SIG_AIM)
- if heading < math.rad(180) then
- Turn(body, 2, heading/2, math.rad(150))
- Turn(L_upper, 2, heading/4, math.rad(200))
- Turn(L_lower, 2, heading/4, math.rad(200))
- Turn(head, 2, heading/2, math.rad(200))
- Turn(head, 1, -pitch, math.rad(200))
- Turn(L_upper, 1, math.rad(280)-pitch, math.rad(200))
- Turn(L_lower, 1, math.rad(350), math.rad(200))
- Turn(L_hand, 1, math.rad(50), math.rad(200))
- Turn(L_hand, 3, math.rad(-80), math.rad(200))
- --wait until the weapon is pointed in the right direction
- WaitForTurn (body, y_axis)
- WaitForTurn (L_upper, x_axis)
- StartThread(RestoreAfterDelay)
- return true
- else
- headingdif = 2*math.pi-heading
- Turn(body, 2, heading+headingdif/2, math.rad(150))
- Turn(L_upper, 2, -headingdif/2, math.rad(200))
- Turn(L_lower, 2, 0, math.rad(200))
- Turn(head, 2, -headingdif/2, math.rad(200))
- Turn(head, 1, -pitch, math.rad(200))
- Turn(L_upper, 1, math.rad(280)-pitch, math.rad(200))
- Turn(L_lower, 1, math.rad(350), math.rad(200))
- Turn(L_hand, 1, math.rad(50), math.rad(200))
- Turn(L_hand, 3, math.rad(-80), math.rad(200))
- --wait until the weapon is pointed in the right direction
- WaitForTurn (body, y_axis)
- WaitForTurn (L_upper, x_axis)
- StartThread(RestoreAfterDelay)
- return true
- end
- end
- --called after the weapon has fired
- function script.FireWeapon1()
- Move(L_hand, 1, 0.5)
- Move(L_upper, 3, -0.5)
- Sleep(150)
- Move(L_hand, 1, 0, 2)
- Move(L_upper, 3, 0, 2)
- end
- ----death animation: fall over & explode
- function script.Killed(recentDamage, maxHealth)
- Turn (base, x_axis, math.rad(90),math.rad(150))
- WaitForTurn (base, x_axis)
- Explode (body, SFX.SHATTER)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement