The lander script......found it !!
This was created by Digital Workshop and it's on the v2001b disk.
This is an excellent bit of OpusScript
Code:
function StartButton()
{
// set up landing pad position/dimensions
Landing = GetLandingPad();
// Set Up The Thrusters
SetThruster(0, Aft_Thrusters, Thrust_Main_Cur_Pow,Thrust_Main_Cur_Eff);
SetThruster(1, For_Thrusters, Thrust_Retro_Cur_Pow,Thrust_Retro_Cur_Eff);
SetThruster(2, Port_Thruster, Thrust_Side_Cur_Pow,Thrust_Side_Cur_Eff);
SetThruster(3, Stb_Thruster, Thrust_Side_Cur_Pow,Thrust_Side_Cur_Eff);
SpaceShip = GetSpaceShip();
//Build the spaceship.
var x = Clamp.GetXPosition() - SpaceShip.Shell.GetXPosition();
var y = Clamp.GetYPosition()+30 - SpaceShip.Shell.GetYPosition();
//MoveObject(x,y);
Docked = 1;
Money = 1000;
//Build the spaceship.
SpaceShip.Shell.Show();
SpaceShip.Thrust_Retro.Obj.Show(true);
SpaceShip.Thrust_Stb.Obj.Show(true);
SpaceShip.Thrust_Port.Obj.Show(true);
SpaceShip.Thrust_Main.Obj.Show(true);
MenAboard = 0;
Lives = 3;
Reward = 100;
PowerupTime = TimeGetSeconds();
PowerupOn = false;
if(FirstRun)
{
ThrustSound = OpenSound("sfx00004.wav", -1, true);
FirstRun = false;
}
//REMOVE
//Debug.trace("StartButton!!!\n\n")
//var shipPos = SpaceShip.Shell.GetPosition()
//Debug.trace("shipPos.x = " + shipPos.x + " shipPos.y = " + shipPos.y + "\n\n")
//REMOVE
//Run the Game....
main();
}
function GetSpaceShip()
{
var Vessel = new Object;
Vessel.Shell = GetCurrentShip();
Vessel.Height = Vessel.Shell.GetHeight()/2;
Vessel.Width = Vessel.Shell.GetWidth()/2;
Vessel.Thrust_Main = GetCurrentThruster(0); // update the thrusters from the thruster objects....
Vessel.Thrust_Retro = GetCurrentThruster(1);
Vessel.Thrust_Port = GetCurrentThruster(2);
Vessel.Thrust_Stb = GetCurrentThruster(3);
Vessel.Fuel = FuelTank;
return Vessel;
}
function GetLandingPad()
{
var LandPad = new Object;
LandPad.Pad = LandingPad;
LandPad.Height = LandPad.Pad.GetHeight()/2;
LandPad.Width = LandPad.Pad.GetWidth()/2;
LandPad.x = LandPad.Pad.GetXPosition();
LandPad.y= LandPad.Pad.GetYPosition();
return LandPad;
}
function GetCurrentShip()
{
return Ship;
}
function GetCurrentThruster(T) // set up the current thruster characteristics....
{
if (T==0) return Thrust_Main;
if (T==1) return Thrust_Retro;
if (T==2) return Thrust_Port;
if (T==3) return Thrust_Stb;
}
function SetThruster(ID,Obj,Pow,Eff) // write the current thruster characteristics - i.e. in the ship
{
var THRUSTER = new Object;
THRUSTER.Obj = Obj; // the object to use...
THRUSTER.pow = Pow; // the power...
THRUSTER.eff = Eff; // the Effect...
if (ID==0) Thrust_Main = THRUSTER;
if (ID==1) Thrust_Retro = THRUSTER;
if (ID==2) Thrust_Port = THRUSTER;
if (ID==3) Thrust_Stb = THRUSTER;
}
function ApplyForces(Vel){
Vel+=Gravity;
return Vel;
}
function Thrusters()
{
var Vector = new Object;
Vector.x = 0;
Vector.y = 0;
Vector.Rate = 0.0;
if (SpaceShip.Fuel >0)
{
if(IsKeyPressed("Up"))
{
Vector.y = -SpaceShip.Thrust_Main.pow;
Vector.Rate += SpaceShip.Thrust_Main.pow / SpaceShip.Thrust_Main.eff;
}
else if(IsKeyPressed("Down"))
{
Vector.y = SpaceShip.Thrust_Retro.pow;
Vector.Rate += SpaceShip.Thrust_Retro.pow / SpaceShip.Thrust_Retro.eff;
}
if(IsKeyPressed("Left"))
{
Vector.x = -SpaceShip.Thrust_Stb.pow; // right engine to go left...
Vector.Rate += SpaceShip.Thrust_Stb.pow / SpaceShip.Thrust_Stb.eff;
}
else if(IsKeyPressed("Right"))
{
Vector.x = SpaceShip.Thrust_Port.pow;
Vector.Rate += SpaceShip.Thrust_Port.pow / SpaceShip.Thrust_Port.eff;
}
}
return Vector;
}
function Move(time)
{
var ychange = Velocity*time;
var xchange = XVelocity*time;
//REMOVE
//Debug.trace("Entering Move!!!\n")
//Debug.trace("Velocity = " + Velocity + "\n")
//Debug.trace("XVelocity = " + XVelocity + "\n")
//Debug.trace("time = " + time + "\n\n")
//REMOVE
MoveObject(xchange,ychange);
}
function Draw()
{
if (IsKeyPressed("Up")&&SpaceShip.Fuel)
{
SpaceShip.Thrust_Main.Obj.Show(false);
if(ThrustSound.GetPosition() == 0.0)
{ThrustSound.Play();}
}
else SpaceShip.Thrust_Main.Obj.Hide();
if (IsKeyPressed("Down")&&SpaceShip.Fuel)
{
SpaceShip.Thrust_Retro.Obj.Show(false);
if(ThrustSound.GetPosition() == 0.0)
{ThrustSound.Play();}
}
else SpaceShip.Thrust_Retro.Obj.Hide();
if (IsKeyPressed("Left")&&SpaceShip.Fuel)
{
SpaceShip.Thrust_Stb.Obj.Show(false);
if(ThrustSound.GetPosition() == 0.0)
{ThrustSound.Play();}
}
else SpaceShip.Thrust_Stb.Obj.Hide();
if (IsKeyPressed("Right")&&SpaceShip.Fuel)
{
SpaceShip.Thrust_Port.Obj.Show(false);
if(ThrustSound.GetPosition() == 0.0)
{ThrustSound.Play();}
}
else SpaceShip.Thrust_Port.Obj.Hide();
// code to display smoke if we are near a surface.....
// collision detect the thruster effect frame with the surface or something
}
function Land()
{
// get the landing pad details....
var x = SpaceShip.Shell.GetXPosition();
var s = SpaceShip.Width-Landing.Width;
var left=Landing.x+s;
var right=Landing.x-s;
if ( (x>left)&&(x<right) )
{
if (SpaceShip.Shell.IsObjectIntersecting(LandingPad))
{
if (Velocity < 50)
{
var y = SpaceShip.Shell.GetYPosition()-(Landing.y-Landing.Height-SpaceShip.Height+15);
if (y<2) y=0;
if (y>-2) y=0;
MoveObject(0,y);
if (Velocity>0) Velocity = 0;
return 2; // landed safely
}
else return 1; // crashed
}
}
return 0; // carry on
}
function MoveObject(x,y)
{
SpaceShip.Shell.Move(x,y);
SpaceShip.Thrust_Main.Obj.Move(x,y);
SpaceShip.Thrust_Retro.Obj.Move(x,y);
SpaceShip.Thrust_Port.Obj.Move(x,y);
SpaceShip.Thrust_Stb.Obj.Move(x,y);
}
function Objects()
{
if (SpaceShip.Shell.IsObjectIntersecting(Asteroid))
{
return 1;
}
if (SpaceShip.Shell.IsObjectIntersecting(Shuttle))
{
return 1;
}
if (SpaceShip.Shell.IsObjectIntersecting(Plane))
{
return 1;
}
if (SpaceShip.Shell.IsObjectIntersecting(Console))
{
return 1;
}
if (SpaceShip.Shell.IsObjectIntersecting(Ground))
{
return 1;
}
if (SpaceShip.Shell.IsObjectIntersecting(Shield))
{
return 1;
}
return 0;
}
function Bonus()
{
// bonus to equiment - retros, thrusters, fuel.
}
function LoadShip()
{
// trigger a man added to ship
}
function UnloadShip()
{
// trigger a man left the ship.
}
function BurnFuel(Rate,Time)
{
// fuel burning depends upon thruster power and efficiency.
SpaceShip.Fuel -= (Rate*Time)*2;
if (SpaceShip.Fuel<0) SpaceShip.Fuel=0;
// Debug.trace("Fuel = "+SpaceShip.Fuel+"\n");
}
function Refuel(Time)
{
// fuel cost from money......
// fills up at rate but costs money for rate.....
var totalfuel = FuelTank*Time/5;
var d = SpaceShip.Fuel+totalfuel;
if (d>=FuelTank)
{
totalfuel = FuelTank - SpaceShip.Fuel;
Time = (totalfuel*5)/FuelTank;
}
var totalcost = FuelPrice*Time*5;
if (totalcost > Money){
totalfuel = totalfuel*(Money/totalcost);
totalcost = Money;
}
SpaceShip.Fuel += totalfuel;
var roundcost = Math.round(totalcost);
if (roundcost < totalcost) roundcost++;
Money -= roundcost;
// Debug.trace("Fuel = "+SpaceShip.Fuel);
// Debug.trace("Money = "+Money+"\n");
}
function main()
{
while(true)
{
var Time = TimeGetSeconds();
var TimeStep = Time - CurrentTime;
CurrentTime = Time;
Velocity = ApplyForces(Velocity);
var Thrust = Thrusters();
Velocity += Thrust.y;
XVelocity += Thrust.x;
BurnFuel(Thrust.Rate,TimeStep);
SetFuelGauge();
if (Objects())
{
ShipStatus = "***Crashed***";
Crash=1;
var soundPath = "bexpl2.wav";
PlaySound(soundPath);
break;
}
var n=0;
var m = DockSpaceStation();
if (m)
{
if (IsKeyPressed(" ")) Docked = 0;
ShipStatus = "Docked!";
LandTime+=TimeStep;
n=1;
if(MenAboard > 0)
{
UnloadShip()
}
}
var l = Land();
if (l==2)
{
ShipStatus = "Landed!";
if (IsKeyPressed(" ")) Refuel(TimeStep);
XVelocity = 0;
Berth();
LandTime+=TimeStep;
n=1;
if(MenAboard < 4)
{
BoardShip();
}
}
else if (l==1)
{
ShipStatus = "***Crashed***";
Crash=1;
var soundPath = "bexpl2.wav";
PlaySound(soundPath);
break;
}
if (!n)
{
ShipStatus = "Okay";
LandTime=0;
}
if(!PowerupOn)
{
if(Time - PowerupTime >= 5)
{
var rand = Math.random();
if(rand > 0 && rand <= 0.25)
{
Item_Upg_2.Show();
PlaySound("sfx00582.wav");
}
else if(rand > 0.25 && rand <= 0.5)
{
Item_Upg_3.Show();
PlaySound("sfx00582.wav");
}
else if(rand > 0.5 && rand <= 0.75)
{
Item_Upg_4.Show();
PlaySound("sfx00582.wav");
}
else if(rand > 0.75 && rand <= 1.0 && Lives < 3)
{
Item_Upg_1.Show();
PlaySound( "sfx00582.wav");
}
rand = Math.random()
PowerupOn = true
PowerupLast = 5 + (10 * rand);
PowerupTime = Time;
}
}
else
{
TestPowerups();
}
Move(TimeStep);
Draw();
//REMOVE
//var shipPos = SpaceShip.Shell.GetPosition()
//Debug.trace("ShipPosition after main!!!\n")
//Debug.trace("shipPos.x = " + shipPos.x + " shipPos.y = " + shipPos.y + "\n\n")
//REMOVE
wait(0);
}
}
function SetFuelGauge()
{
// slider nneds to position self as percentage of fuel left...
// i.e. position determined by SpaceShip.Fuel/FuelTank;
var Percentage = (SpaceShip.Fuel/FuelTank);
var yh = Fuel.GetHeight()*Percentage; // if no fuel this is zero - if full this is yh!
var y = Fuel.GetYPosition();
Empty_Fuel.SetPosition(Empty_Fuel.GetXPosition(),y-yh);
}
var last_time_fraction=0.1
function Berth()
{
// for every second you are landed there is a charge of landing fee.
var y = LandTime/3;
var x = Math.round(y-0.5); // should always give integer part of LandTime
var time_fraction = y-x;
if (time_fraction < last_time_fraction)
{
Money -= SpacePortFee;
BerthingCharge.SetPosition(SpaceShip.Shell.GetXPosition()+20,SpaceShip.Shell.GetYPosition(),0);
BerthingCharge.Show();
}
last_time_fraction = time_fraction;
}
function DockSpaceStation()
{
// if the object is not docked and can dock then dock and set docked......
//if we are intersectng and docked =1 then kill velocity.
if (SpaceShip.Shell.IsObjectIntersecting(Clamp))
{
if (Docked)
{
Velocity = 0;
XVelocity=0;
return 1; // we are officially docked!
}
else
{
return 0; // docking clamps released
}
}
else
{
Docked = 1;
return 0;
}
}
function Reset()
{
// move the ship back to the start.....
Crashed=0;
Boom.Hide();
XVelocity=0;
Velocity=0;
//Debug.trace("Lives = " + Lives + "\n")
if(Lives == 3)
{
Life_1.Hide();
}
else if(Lives == 2)
{
Life_2.Hide();
}
else if(Lives == 1)
{
Life_3.Hide();
}
Lives--;
if (Lives <=0){
ShipStatus = "GameOver";
return;
}
CurrentTime = TimeGetSeconds();
// need to set te position of the objects to the start position.
// set up landing pad position/dimensions
Landing = GetLandingPad();
// Set Up The Thrusters
SetThruster(0, Aft_Thrusters, Thrust_Main_Cur_Pow,Thrust_Main_Cur_Eff);
SetThruster(1, For_Thrusters, Thrust_Retro_Cur_Pow,Thrust_Retro_Cur_Eff);
SetThruster(2, Port_Thruster, Thrust_Side_Cur_Pow,Thrust_Side_Cur_Eff);
SetThruster(3, Stb_Thruster, Thrust_Side_Cur_Pow,Thrust_Side_Cur_Eff);
//Build the spaceship.
SpaceShip = GetSpaceShip();
var x = Clamp.GetXPosition() - SpaceShip.Shell.GetXPosition();
var y = Clamp.GetYPosition()+30 - SpaceShip.Shell.GetYPosition();
Docked = 1;
SpaceShip.Shell.Show(true);
Thrust_Main.Obj.Show(true);
SpaceShip.Thrust_Retro.Obj.Show(true);
SpaceShip.Thrust_Stb.Obj.Show(true);
SpaceShip.Thrust_Port.Obj.Show(true);
SpaceShip.Thrust_Main.Obj.Show(true);
MenAboard = 0;
ManAboard1.Hide();
ManAboard2.Hide();
ManAboard3.Hide();
ManAboard4.Hide();
PowerupTime = TimeGetSeconds();
PowerupOn = false;
//Run the Game....
main();
}
function BoardShip()
{
//Debug.trace("BoardShip!!!\n");
Passenger.SetPosition(Passenger.GetXPosition() + 2, Passenger.GetYPosition());
if(Passenger.IsObjectIntersecting(SpaceShip.Shell))
{
//Debug.trace("CollisionDetected!!!\n");
Passenger.Hide();
Passenger.Show(true);
MenAboard++;
if(MenAboard == 1)
{
ManAboard1.Show()
}
else if(MenAboard == 2)
{
ManAboard2.Show()
}
else if(MenAboard == 3)
{
ManAboard3.Show()
}
else if(MenAboard == 4)
{
ManAboard4.Show()
}
}
}
function UnloadShip()
{
var y = LandTime/3;
var x = Math.round(y-0.5); // should always give integer part of LandTime
var time_fraction = y-x;
if (time_fraction < last_time_fraction)
{
if(MenAboard == 1)
{
ManAboard1.Hide();
}
else if(MenAboard == 2)
{
ManAboard2.Hide();
}
else if(MenAboard == 3)
{
ManAboard3.Hide();
}
else if(MenAboard == 4)
{
ManAboard4.Hide();
}
Money += Reward;
PassengerReward.Show();
MenAboard--;
}
last_time_fraction = time_fraction;
}
function TestPowerups()
{
var Time = TimeGetSeconds()
if(Item_Upg_1.IsShowing())
{
if(SpaceShip.Shell.IsObjectIntersecting(Item_Upg_1))
{
Lives++;
if(Lives == 3)
{
Life_1.Show();
}
else if(Lives == 2)
{
Life_2.Show();
}
else if(Lives == 1)
{
Life_3.Show();
}
Item_Upg_1.Hide();
PowerupTime = Time;
PowerupOn = false;
PlaySound( "sfx00099.wav");
}
else if(Time - PowerupTime >= PowerupLast)
{
Item_Upg_1.Hide();
PowerupTime = Time;
PowerupOn = false;
}
}
if(Item_Upg_2.IsShowing())
{
if(SpaceShip.Shell.IsObjectIntersecting(Item_Upg_2))
{
SpaceShip.Fuel = 1000;
Item_Upg_2.Hide();
PowerupTime = Time;
PowerupOn = false;
PlaySound( "sfx00099.wav");
}
else if(Time - PowerupTime >= PowerupLast)
{
Item_Upg_2.Hide();
PowerupTime = Time;
PowerupOn = false;
}
}
if(Item_Upg_3.IsShowing())
{
if(SpaceShip.Shell.IsObjectIntersecting(Item_Upg_3))
{
//Thruster Bonus
Item_Upg_3.Hide();
PowerupTime = Time;
PowerupOn = false;
PlaySound( "sfx00099.wav");
}
else if(Time - PowerupTime >= PowerupLast)
{
Item_Upg_3.Hide();
PowerupTime = Time;
PowerupOn = false;
}
}
if(Item_Upg_4.IsShowing())
{
if(SpaceShip.Shell.IsObjectIntersecting(Item_Upg_4))
{
Money += MoneyBonus;
Item_Upg_4.Hide();
PowerupTime = Time;
PowerupOn = false;
PlaySound("sfx00099.wav");
}
else if(Time - PowerupTime >= PowerupLast)
{
Item_Upg_4.Hide();
PowerupTime = Time;
PowerupOn = false;
}
}