Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function drehMatrix (x, y, zx, zy, degree)
- x= x-zx
- y=y-zy
- x=(math.cos(degree)+ (-1*math.sin(degree)))*x
- y=(math.cos(degree)+ (math.sin(degree)))*y
- IntCastX=x%1
- x=x-IntCastX
- IntCastY=y%1
- y=y-IntCastY
- x=x+zx
- y=y+zy
- return x,y
- end
- --My BASE the unit does nothing
- local boolAllReadySpawnedNotYetKilled=false
- local nanoemit = piece "nanoemit"
- local sentrynelshield = piece "sentrynelshield"
- local sentrynelshield2 = piece "sentrynelshield2"
- local sentrynell = piece "sentrynell"
- local sentrynel0 = piece "sentrynel0"
- local sentrynel1 = piece "sentrynel1"
- local sentrynel2 = piece "sentrynel2"
- local sentrynel3 = piece "sentrynel3"
- local sentrynel4 = piece "sentrynel4"
- local sentrynel5 = piece "sentrynel5"
- local snfoot = piece "snfoot"
- local pivot = piece "Pivot"
- local pivot01 = piece "Pivot01"
- local boolStoped
- local boolIsItDeadYet=false
- local SIG_UNFOLD=8
- local SIG_FOLD=4
- local SIG_SPAM=16
- local SIG_TRACK=2
- local SIG_WALK=32
- local spamfilterSTART=true
- local spamfilterSTOP=false
- local boolFilterActive=false
- local spotOnTarget=false
- local boolActive
- local boolSTOP=false
- local boolLongSTOP=false
- local boolMoveStateStart=true
- local boolAllreadyMovin=false
- function vectorBetrag(xv,yv,x2,y2)
- -- determiniere höheren Wert
- xv=xv-x2
- yv=yv-y2
- local xv=xv*xv
- local yv=yv*yv
- local xyv=xv+yv
- local Betrag=math.sqrt(xyv)
- return Betrag
- end
- local function headingToDegree(heading)
- local degree=0
- local oneDegree=177.7
- if heading==0 then
- return degree
- end
- if heading < 0 then
- degree= (heading/oneDegree)
- degree=degree+360
- return degree
- end
- if heading >0 then
- degree=(heading/oneDegree)
- return degree
- end
- end
- function motionTrack()
- Spring.Echo("MotionTrack Started")
- SetSignalMask(SIG_TRACK)
- local x,y,z=Spring.GetUnitPosition(unitID)
- while (true) do
- Sleep(50)
- nearEnemyID=Spring.GetUnitNearestEnemy(unitID, 3000, false)
- if nearEnemyID == nil then
- Distance =9000
- else
- local xe,ye,ze=Spring.GetUnitPosition(nearEnemyID)
- Distance = vectorBetrag(x,y,xe,ye)
- end
- Spring.Echo(Distance)
- if boolIsItDeadYet==false then
- for beep=0, 2, 1 do
- sleePer=666
- if Distance >1000 then
- Spring.PlaySoundFile("sounds/mt/mtnocontact.wav")
- -- Spring.Echo("da")
- --Play Sound Plock
- Sleep(sleePer)
- end
- if Distance <=1000 and Distance>745 then
- Spring.PlaySoundFile("sounds/mt/mtfarawaycontact.wav")
- --Play (DetectedNonHecticBeep)
- Spring.Echo("do")
- sleePer=303+ ((Distance/2.5)-100)
- Sleep(sleePer)
- end
- if Distance <=745 and Distance >500 then
- Spring.PlaySoundFile("sounds/mt/mtcloser.wav")
- --Play (DetectedGettingHecticBeep)
- --Spring.Echo("de")
- sleePer=303 +((Distance/2.5)-100)
- Sleep(sleePer)
- end
- if Distance <=500 then
- Spring.PlaySoundFile("sounds/mt/mtclosecomb.wav")
- --play shrill panicy sound
- --Spring.Echo("di")
- sleePer=303+((Distance/2.5)-100)
- if sleePer < 303 then
- sleePer=303
- end
- Sleep(sleePer)
- end
- end
- if boolIsItDeadYet==true then
- Spring.PlaySoundFile("sounds/mt/suddendeath2.wav")
- --play Soundfile beeping heartdead...
- Sleep(LenghtOfSoundfile)
- Signal(SIG_TRACK)
- end
- end
- end
- end
- function faceConvert(degree)
- local aNumber=0
- if degree>=315 and degree<45 then
- aNumber=0
- return aNumber
- end
- if degree>=45 and degree<135 then
- aNumber=1
- return aNumber
- end
- if degree>=135 and degree<225 then
- aNumber=2
- return aNumber
- end
- if degree>=225 and degree<315 then
- aNumber=3
- return aNumber
- end
- end
- function sentry_Spawn()
- if boolAllReadySpawnedNotYetKilled==false then
- boolAllReadySpawnedNotYetKilled=true
- local xDistance=1500
- local zx,zy,z=Spring.GetUnitPosition (unitID)
- local teamID = Spring.GetUnitTeam (unitID)
- local heading= Spring.GetUnitHeading(unitID)
- local sentryDegree=headingToDegree(heading)
- local face=faceOff(sentryDegree)
- z1=z
- Spring.Echo(z1)
- x1,y1=drehMatrix (1500, 0, zx, zy, sentryDegree)
- sentryID1 = Spring.CreateUnit("sentry", x1, y1, z1, face, teamID)
- Spring.Echo(x1)
- Spring.Echo(y1)
- x2,y2=drehMatrix (1250, -450, zx, zy, sentryDegree)
- sentryID2 = Spring.CreateUnit("sentry", x2, y2, z1, face, teamID)
- x3,y3=drehMatrix (1250, 450, zx, zy, sentryDegree)
- sentryID3 = Spring.CreateUnit("sentry", x3, y3, z1, face, teamID)
- x4,y4=drehMatrix (850, 950, zx, zy, sentryDegree)
- sentryID4 = Spring.CreateUnit("sentry", x4, y4, z1, face, teamID)
- x5,y5=drehMatrix (850, -950, zx, zy, sentryDegree)
- sentryID5 = Spring.CreateUnit("sentry", x5, y5, z1, face, teamID)
- --
- --calculate Position
- --delivers x1,y1,z1
- --getViewingVectory
- --flatten ground has to go for this
- end
- end
- function sentry_Kill()
- if (Spring.ValidUnitID (sentryID2)) then
- Spring.DestroyUnit (sentryID2, false,true) --leave no wreck
- end
- if (Spring.ValidUnitID (sentryID1)) then
- Spring.DestroyUnit (sentryID1, false,true) --leave no wreck
- end
- if (Spring.ValidUnitID (sentryID3)) then
- Spring.DestroyUnit (sentryID3, false,true) --leave no wreck
- end
- if (Spring.ValidUnitID (sentryID4)) then
- Spring.DestroyUnit (sentryID4, false,true) --leave no wreck
- end
- if (Spring.ValidUnitID (sentryID5)) then
- Spring.DestroyUnit (sentryID5, false,true) --leave no wreck
- end
- boolAllReadySpawnedNotYetKilled=false
- end
- local function walk()
- SetSignalMask(SIG_WALK)
- StopSpin(sentrynel3,y_axis)
- while(true) do
- --vorn rechts
- Move(sentrynel0,z_axis,2,2.5)
- Turn(sentrynel0,x_axis,math.rad(-7),3)
- --hinten schub
- Turn(sentrynell,x_axis,math.rad(4),0.5)
- Turn(sentrynel1,x_axis,math.rad(-6),3)
- Turn(sentrynel2,x_axis,math.rad(12),4)
- Move(sentrynel1,z_axis,-1,1.5)
- Turn(snfoot,x_axis,math.rad(9),3)
- Move(snfoot,x_axis,0,2)
- --Various Waits
- WaitForMove(sentrynel0,z_axis)
- WaitForTurn(sentrynel0,x_axis)
- WaitForTurn(sentrynel1,x_axis)
- WaitForTurn(sentrynel2,x_axis)
- WaitForMove(sentrynel1,z_axis)
- WaitForTurn(snfoot,x_axis)
- WaitForTurn(snfoot,x_axis)
- Sleep(20)
- --vorne links
- Move(snfoot,z_axis,2,1.5)
- Turn(snfoot,x_axis,math.rad(-7),2)
- Turn(sentrynel0,x_axis,math.rad(9),3)
- Move(sentrynel0,x_axis,0,2)
- --hinten zug
- Turn(sentrynell,x_axis,math.rad(-4),0.5)
- Move(sentrynel1,z_axis,1,1.5)
- Turn(sentrynel1,x_axis,math.rad(8),2)
- Turn(sentrynel2,x_axis,math.rad(-28),6)
- WaitForMove(sentrynel0,z_axis)
- WaitForTurn(sentrynel0,x_axis)
- WaitForTurn(sentrynel1,x_axis)
- WaitForTurn(sentrynel2,x_axis)
- WaitForMove(sentrynel1,z_axis)
- WaitForTurn(snfoot,x_axis)
- WaitForTurn(snfoot,x_axis)
- Sleep(20)
- end
- end
- ---------------------------------------------------------------------------------------------------------------------------------------------
- local function spamFilter()
- SetSignalMask(SIG_SPAM)
- while (true) do
- if spamfilterSTART==true and spamfilterSTOP==false then
- for it=0,3,1 do
- Sleep(1024)
- if spamfilterSTOP==true then
- spamfilterSTART=false
- break
- end
- end
- if spamfilterSTART==true then
- --if spamfilterSTART is still ==true then
- Signal(SIG_FOLD)
- StartThread (fold)
- end
- end
- if spamfilterSTOP==true and spamfilterSTART==false then
- for at=0,3,1 do
- Sleep(1024)
- if spamfilterSTART==true then
- spamfilterSTOP=false
- break
- end
- end
- if spamfilterSTOP==true then
- --if spamfilterSTOP is still ==true then
- Signal(SIG_FOLD)
- Signal(SIG_UNFOLD)
- StartThread(unfold)
- if boolActive==true then
- sentry_Spawn()
- end
- end
- end
- if spamfilterSTOP==false and spamfilterSTART==false then
- Spring.Echo("No idea what you did, but you broke it. You gonna pay!")
- end
- end
- end
- function fold()
- Signal(SIG_UNFOLD)
- SetSignalMask(SIG_FOLD)
- StopSpin(sentrynel3,y_axis)
- Move(sentrynell,y_axis,0,1.4)
- Turn(sentrynel5,x_axis,math.rad(0),5)
- Turn(sentrynel5,y_axis,math.rad(0),5)
- Turn(sentrynel5,z_axis,math.rad(0),5)
- WaitForTurn(sentrynel5,z_axis)
- WaitForTurn(sentrynel5,y_axis)
- WaitForTurn(sentrynel5,x_axis)
- Turn(sentrynel4,x_axis,math.rad(0),5)
- Turn(sentrynel4,y_axis,math.rad(0),5)
- Turn(sentrynel4,z_axis,math.rad(0),5)
- WaitForTurn(sentrynel4,z_axis)
- WaitForTurn(sentrynel4,y_axis)
- WaitForTurn(sentrynel4,x_axis)
- Turn(sentrynel3,x_axis,math.rad(0),5)
- Turn(sentrynel3,y_axis,math.rad(0),5)
- Turn(sentrynel3,z_axis,math.rad(0),5)
- WaitForTurn(sentrynel3,z_axis)
- WaitForTurn(sentrynel3,y_axis)
- WaitForTurn(sentrynel3,x_axis)
- Turn(sentrynelshield2,z_axis,math.rad(-65),3)
- Turn(sentrynelshield,z_axis,math.rad(65),3)
- WaitForTurn(sentrynelshield2,z_axis)
- WaitForTurn(sentrynelshield,z_axis)
- while(true) do
- walk()
- end
- end
- function unfold()
- Signal(SIG_FOLD)
- SetSignalMask(SIG_UNFOLD)
- Turn(sentrynelshield2,z_axis,math.rad(0),1)
- Turn(sentrynelshield,z_axis,math.rad(0),1)
- WaitForTurn(sentrynelshield2,z_axis)
- WaitForTurn(sentrynelshield,z_axis)
- Move(sentrynell,y_axis,-2,0.4)
- Turn(sentrynel0,x_axis,math.rad(28),7)
- Turn(snfoot,x_axis,math.rad(28),7)
- Turn(sentrynel1,x_axis,math.rad(-20),7)
- Sleep(890)
- Turn(sentrynel3,y_axis,math.rad(160),1.25)
- Turn(sentrynel5,x_axis,math.rad(-61),3)
- WaitForTurn(sentrynel3,y_axis)
- Turn(sentrynel4,x_axis,math.rad(-13),1)
- Turn(sentrynel3,y_axis,math.rad(270),1.25)
- WaitForTurn(sentrynel3,y_axis)
- Turn(sentrynel4,x_axis,math.rad(59),0.5)
- Turn(sentrynel3,y_axis,math.rad(360),1.25)
- Turn(sentrynel5,x_axis,math.rad(-83),1)
- WaitForTurn(sentrynel3,y_axis)
- triforce=1
- while(true) do
- triforce=triforce+1
- Sleep(4024)
- Spring.Echo("Idle")
- if triforce%3==0 then
- --idle
- IwantRandy=math.random(0,1)
- if IwantRandy==1 then
- giveMeFive=5*math.random(-1,1)
- Spin(sentrynel3,y_axis,math.rad(giveMeFive),1.5)
- Sleep(19192)
- StopSpin(sentrynel3,y_axis)
- end
- end
- triforce=triforce%4
- end
- end
- function script.AimWeapon1(heading ,pitch)
- Signal(SIG_AIM)
- SetSignalMask(SIG_AIM)
- Turn(sentrynel4,x_axis,math.rad(64),8)
- Turn(sentrynel3,y_axis,-heading,4)
- WaitForTurn(sentrynel3,y_axis)
- WaitForTurn(sentrynel4,x_axis)
- Turn(sentrynel5,x_axis,pitch,3)
- WaitForTurn(sentrynel5,x_axis)
- return true
- end
- function script.AimFromWeapon1()
- return nanoemit
- end
- function script.QueryWeapon1()
- return nanoemit
- end
- function script.FireWeapon1()
- return true
- end
- function script.Killed()
- boolIsItDeadYet=true
- Sleep(420)
- Signal(SIG_SPAM)
- Signal(SIG_FOLD)
- Signal(SIG_UNFOLD)
- Explode(nanoemit, SFX.FIRE)
- Explode(sentrynelshield2,SFX.FIRE)
- Explode(sentrynelshield,SFX.FIRE)
- end
- function script.StartMoving()
- if boolFilterActive==false then
- boolFilterActive=true
- Signal(SIG_SPAM)
- StartThread(spamFilter)
- end
- sentry_Kill()
- spamfilterSTOP=false
- spamfilterSTART=true
- end
- function script.StopMoving()
- -- Spring.Echo ("stopped walking!")
- spamfilterSTART=false
- spamfilterSTOP=true
- Turn(sentrynell,x_axis,math.rad(0),3)
- boolSTOP=true
- Signal(SIG_TRACK)
- Signal(SIG_UNDEPLOY)
- Signal(SIG_WALK)
- StartThread(motionTrack)
- end
- ---------------------------------------------------------------------------------------------------------------------------------------------
- function script.StartBuilding(heading, pitch)
- SetUnitValue(COB.INBUILDSTANCE, 1)
- end
- function script.QueryNanoPiece()
- return nanoemit
- end
- function script.StopBuilding()
- SetUnitValue(COB.INBUILDSTANCE, 0)
- end
- function script.Activate()
- boolActive=true
- return 1
- end
- function script.Deactivate()
- boolActive=false
- return 0
- end
- function script.Create()
- Hide(pivot01)
- Hide(pivot)
- Signal(SIG_SPAM)
- end
Add Comment
Please, Sign In to add comment