Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local torso = piece "torso"
- local rFoot = piece "rFoot"
- local lFoot = piece "lFoot"
- local turret = piece "lHand"
- local rHand = piece "rHand"
- local head = piece "head"
- local flare = piece "flare"
- local SIG_WALK = 1
- local SIG_AIM = 2
- local SIG_AIM_2 = 4
- local SIG_AIM_3 = 8
- local RESTORE_DELAY = Spring.UnitScript.GetLongestReloadTime(unitID)*2
- local leg_movespeed = 20
- local leg_movedistance = 10
- local waterGunE = false
- local hulaHoopP = false
- local magicWandP = false
- local waterGunP = false
- local bbGloveP = false
- local capeP = false
- local swimTrunksP = false
- local runningShoesP = false
- local waterGunAllowed = false
- local waterGunVal = 0
- local activeWeapon = 1
- local AP = 12
- local ename1
- local eid1
- local wID
- local unitName
- local unitDefID
- --FLARE POSITIONING --
- local fguny = 8
- local fgunz = 39
- function script.Create()
- Sleep(50)
- Spring.SetUnitRulesParam(unitID, "bbGlove", 0, {public = true})
- Spring.SetUnitRulesParam(unitID, "cape", 0, {public = true})
- Spring.SetUnitRulesParam(unitID, "hulaHoop", 0, {public = true})
- Spring.SetUnitRulesParam(unitID, "magicWand", 0, {public = true})
- Spring.SetUnitRulesParam(unitID, "swimTrunks", 0, {public = true})
- Spring.SetUnitRulesParam(unitID, "waterGun", 0, {public = true})
- Spring.SetUnitRulesParam(unitID, "runningShoes", 0, {public = true})
- local ux, uy, uz = Spring.GetUnitPosition(unitID)
- local idleTransports = Spring.GetUnitsInCylinder(ux, uy, 2000)
- local enemyID = Spring.ENEMY_UNITS
- local enemyunits = Spring.GetUnitsInCylinder(ux, uy, 2000, enemyID)
- eid1 = idleTransports[2]
- unitDefID = Spring.GetUnitDefID(unitID)
- unitName = UnitDefs[unitDefID].name
- if(eid1 ~= nil) then
- local enemyID1 = Spring.GetUnitDefID(eid1)
- ename1 = UnitDefs[enemyID1].name
- if(ename1 == "Jenny") then
- AP = AP-2
- end
- end
- Spring.SetUnitRulesParam(unitID, "maxAP", AP, {public = true})
- end
- local function Equip()
- if waterGunAllowed == true then
- Spring.UnitScript.Move( flare, y_axis, fguny, 999)
- Spring.UnitScript.Move( flare, z_axis, fgunz, 999)
- end
- end
- local function walk()
- Signal(SIG_WALK)
- SetSignalMask(SIG_WALK)
- while (true) do
- Move(lFoot, y_axis, leg_movedistance, leg_movespeed)
- Move(rFoot, y_axis, 0, leg_movespeed)
- WaitForMove(lFoot, y_axis)
- WaitForMove(rFoot, y_axis)
- Sleep(50)
- Move(lFoot, y_axis, 0, leg_movespeed)
- Move(rFoot, y_axis, leg_movedistance, leg_movespeed)
- WaitForMove(lFoot, y_axis)
- WaitForMove(rFoot, y_axis)
- local ucx, ucy, ucz = Spring.GetUnitPosition(unitID)
- if(ename1 == "dana") then
- local dcx, dcy, dcz = Spring.GetUnitPosition(eid1)
- local distance = math.sqrt((dcx-ucx)^2 + (dcz-ucz)^2)
- --Spring.Echo(distance)
- if(distance < 200) then
- --Spring.Echo("STOPPPPP!!!")
- Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, {})
- script.StopMoving()
- end
- end
- if(ename1 == "timmy") then
- local ecx, ecy, ecz = Spring.GetUnitPosition(eid1)
- local distance = math.sqrt((ecx-ucx)^2 + (ecz-ucz)^2)
- if(distance < 200) then
- Spring.SetUnitCloak(eid1, false)
- end
- end
- Sleep(50)
- end
- end
- local function legs_down()
- Move(lFoot, y_axis, 0, leg_movespeed)
- Move(rFoot, y_axis, 0, leg_movespeed)
- end
- local function RestoreAfterDelay(unitID)
- Sleep(RESTORE_DELAY)
- if(waterGunAllowed == true) then
- Turn(turret, y_axis, 0, math.rad(90))
- Turn(torso, y_axis, 0, math.rad(90))
- Turn(head, y_axis, 0, math.rad(90))
- Turn(rHand, y_axis, 0, math.rad(90))
- Turn(rFoot, y_axis, 0, math.rad(90))
- Turn(lFoot, y_axis, 0, math.rad(90))
- else
- Move(lHand, z_axis, 0, 20)
- end
- end
- function script.QueryWeapon3()
- return rHand
- end
- function script.AimFromWeapon3()
- return rHand
- end
- function script.AimWeapon3(heading, pitch)
- Spring.Echo("aim weapon 2!")
- Signal(SIG_AIM_3)
- SetSignalMask(SIG_AIM_3)
- Move(rHand, z_axis, 15, 20)
- StartThread(RestoreAfterDelay)
- return true
- end
- function script.FireWeapon3()
- Spring.Echo("fire2!")
- end
- function script.QueryWeapon1()
- return flare
- end
- function script.AimFromWeapon1()
- return flare
- end
- function SwitchWeapon()
- if (waterGunP == true) then
- weaponChosen = 0
- elseif (magicWandP == true) then
- weaponChosen = 1
- end
- end
- function script.AimWeapon1(heading, pitch)--(weaponID, heading, pitch)
- Spring.Echo("heyyyyy")
- Signal(SIG_AIM_2)
- SetSignalMask(SIG_AIM_2)
- while(weaponChosen) do
- Sleep(100)
- end
- Spring.Echo("aiming when I shouldn't")
- Turn(turret, y_axis, heading, math.rad(90))
- --Turn(gun, x_axis, -pitch, math.rad(90))
- --Turn(waterGunVal, x_axis, -pitch, math.rad(90))
- Turn(torso, y_axis, heading, math.rad(90))
- Turn(head, y_axis, heading, math.rad(90))
- Turn(rHand, y_axis, heading, math.rad(90))
- Turn(rFoot, y_axis, heading, math.rad(90))
- Turn(lFoot, y_axis, heading, math.rad(90))
- WaitForTurn(turret, y_axis)
- --WaitForTurn(waterGunVal, x_axis)
- --WaitForTurn(gun, x_axis)
- WaitForTurn(head, y_axis)
- WaitForTurn(rHand, y_axis)
- WaitForTurn(rFoot, y_axis)
- WaitForTurn(lFoot, y_axis)
- StartThread(RestoreAfterDelay)
- StartThread(RestoreAfterDelay)
- return true
- end
- function script.FireWeapon1()
- Spring.Echo("fire!")
- end
- function script.HitByWeapon(x, z, weaponDefID, damage)
- wname = WeaponDefs[weaponDefID].name
- i, j = string.find(wname, "fist")
- if(hulaHoopP == true) then
- newDamage = damage - (0.75*damage)
- return newDamage
- end
- end
- function script.StartMoving()
- StartThread(walk)
- end
- function script.StopMoving()
- Signal(SIG_WALK)
- legs_down()
- end
- function script.TransportDrop(passengerID)
- end
- function script.TransportPickup (passengerID)
- Spring.UnitScript.AttachUnit(turret, passengerID)
- local unitDefID = Spring.GetUnitDefID(passengerID)
- wID = passengerID
- local name = UnitDefs[unitDefID].name
- if (name == "wwatergun") then
- waterGunAllowed = true
- Equip()
- waterGunP = true
- Spring.SetUnitRulesParam(unitID, "waterGun", 1, {public = true})
- end
- if(name == "whulahoop") then
- hulaHoopP = true
- -- CHANGE THE UNIT'S HEALTH --
- local _, currentMaxHealth, _, _, _= Spring.GetUnitHealth(unitID)
- currentMaxHealth = currentMaxHealth+20
- Spring.SetUnitMaxHealth(unitID, currentMaxHealth)
- Spring.SetUnitHealth(unitID, currentMaxHealth)
- Spring.SetUnitRulesParam(unitID, "hulaHoop", 1, {public = true})
- end
- if(name == "wbbglove") then
- bbGloveP = true
- Spring.SetUnitRulesParam(unitID, "bbGlove", 1, {public = true})
- Spring.UnitScript.SetPieceVisibility(rHand, false)
- end
- if(name == "wmagicwand") then
- magicWandP = true
- Spring.SetUnitRulesParam(unitID, "magicWand", 1, {public = true})
- end
- if(name == "wcape") then
- capeP = true
- Spring.SetUnitRulesParam(unitID, "cape", 1, {public = true})
- UnitDefs[unitName].cruisealt = 4.0
- end
- if(name == "wswimTrunks") then
- swimTrunksP = true
- Spring.SetUnitRulesParam(unitID, "swimTrunks", 1, {public = true})
- end
- if(name == "wrunningShoes") then
- runningShoesP = true
- Spring.SetUnitRulesParam(unitID, "runningShoes", 1, {public = true})
- end
- SwitchWeapon()
- end
- function script.Killed(recentDamage, maxHealth)
- --return 0
- end
Advertisement
Add Comment
Please, Sign In to add comment