Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name ertex GyroPod
- @inputs CenterProp:entity On Eyepod:vector2 Camera:wirelink
- @outputs A:angle V:vector
- @persist E:entity A:angle VD:vector Home:vector O:entity
- @persist MaxTurningSpeed MaxSpeed MaxSpeedU Updaterate
- @trigger
- #All E2ship is of the highest quality
- #The side is encrused with gems
- #Menacing spikes of ertex is along the edges
- if(first()|changed(CenterProp)){
- E= CenterProp
- Home = E:pos()
- A=E:angles()
- O=owner()
- Updaterate=20 #ms
- #speed classification stuff
- ShipClasses = table( #lookup tableS to set the max speed
- "Drone",
- "Fighter",
- "Frigate",
- "Cruiser",
- "Battlecruiser",
- "Battleship",
- "Dreadnaught",
- "Titan",
- "Station"
- )
- ShipSpeeds = table( #in units/s
- 10000,
- 8000,
- 3500,
- 2000,
- 1250,
- 1000,
- 500,
- 250,
- 0
- )
- ShipTurningSpeeds = table( #in degrees/s
- 80,
- 70,
- 40,
- 30,
- 20,
- 12,
- 8,
- 5,
- 0
- )
- Coreclass = E:isWeldedTo():getCoreEnt():getCoreClass()
- if(!E:isWeldedTo():getCoreEnt():isValid()){
- hint("place a core on this ship to make it valid",10)
- MaxSpeed = 100
- MaxSpeedU/0.04261185612
- MaxTurningSpeed = 80
- }
- I=0
- while(I<ShipSpeeds:count()){
- I++
- if(Coreclass == ShipClasses[I,string]){
- MaxSpeed = ShipSpeeds[I,number]*(0.04261185612)#convertion from U/s to mph, also maxspeed set
- MaxSpeedU = ShipSpeeds[I,number] #the max speed in units/s
- MaxTurningSpeed = ShipTurningSpeeds[I,number]
- hint(""+round(MaxSpeed)+"mph was set as maximum speed",5)
- hint(""+MaxTurningSpeed+" Deg/s is the fastest turning speed",5)
- MaxTurningSpeed = MaxTurningSpeed*(Updaterate/1000)
- hint(""+MaxTurningSpeed+" Deg/update is the fastest turning speed",5)
- }
- }
- #classification done
- timer("main",Updaterate)
- }
- runOnTick(1)
- if(clk("main")){
- timer("main",Updaterate)
- #A is the angle of wich E will point
- #V is the vector in wich E will accelerate
- #note V is not set to zero after each itteration, and is transformed to VD that is
- #a clamped vector
- A=A+ang(-clamp(Eyepod:y(),-MaxTurningSpeed,MaxTurningSpeed),-clamp(Eyepod:x(),-MaxTurningSpeed,MaxTurningSpeed),0)
- if(On){
- if(O:keyPressed("W")){
- V = V+E:forward()
- }
- if(O:keyPressed("S")){
- V = V-E:forward()
- }
- if(O:keyPressed("D")){
- V = V+E:right()
- }
- if(O:keyPressed("A")){
- V = V-E:right()
- }
- if(O:keyPressed("space")){
- V = V+E:up()
- }
- if(O:keyPressed("F")){
- V = V*0.95
- }
- E:setAng(A)
- VD=clamp(V,-MaxSpeedU,MaxSpeedU)
- E:setPos(E:pos()+VD)
- Camera["Position",vector] = E:pos()-owner():eye()*1000
- Camera["Angle",angle] = A
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement