When I re-arranged the script I must have messed things up and no I didn't back it up...
I have started all the tuts on scripting and although they seem to be very comprehensive as I don't know much about programming I am having a little trouble picking it up!
I have not yet added all the objectives... or all the stuff i'm only just realising I ahve to add!
Anyway here is my "code"!
//STOWAWAY SCRIPT
//Coded by Bluelamb
//
main:
level waittill prespawn
exec global/exploder.scr
exec global/weather.scr
exec global/ambient.scr m5l1b
exec global/cabinet.scr
exec global/bomber.scr
exec global/ai.scr
level waittill spawn
level.flyplane = 1
wait 2
$player stufftext "tmstartloop sound/music/mus_02f_suspense.mp3"
//
//mg42s
//
$mg42 thread global/mg42_active.scr::mg42
$mg42b thread global/mg42_active.scr::mg42
$mg42c thread global/mg42_active.scr::mg42
//
//player stuff
//
$player ammo smg 300
$player useweaponclass smg
$player useweaponclass sniper
$player useweaponclass heavy
player_prep:
$player item weapons/silencedpistol.tik
$player item weapons/KAR98sniper.tik
$player item weapons/mp40.tik
$player item weapons/steilhandgranate.tik
$player ammo pistol 20
$player ammo rifle 50
$player ammo smg 50
$player ammo grenade 3
$player ammo heavy 92
$player.has_disguise = 1
iprintlnbold "God forgive them, for they know not what they do!"
//
//Tank bits
//
Start Tank:
// Initialisation of the tank parameters
$Tank1 waitthread initTank
// Put the tank health on the player screen.
$Tank1 thread TankHealthLoop
// Make the tank move along the chosen path.
$Tank1 thread MoveTank
// Destruction of the tank.
$Tank1 thread TankDeath
End
InitTank:
self.health = 1000
self removeondeath 0
self lock
self setcollisionentity self.target
// Set the tank's immunities.
self immune bullet
self immune fast_bullet
self immune grenade
self immune bash
end
TankHealthLoop:
local.StartHealth = self.health // Set the starting health of the tank.
local.LastHealth = self.health // Set the last known health of the tank.
// While the tank health is greater than zero.
while (isAlive self)
{
waitframe // Wait one frame.
// If the tank health is still greater than zero.
if !(isAlive self)
end
// If the tank health has changed since the last frame.
if (self.health < local.LastHealth)
{
local.HealthFraction = (self.health / local.StartHealth) * 100
local.HealthFractionInt = int local.HealthFraction
iprintlnbold_noloc (loc_convert_string "PANZER TANK: ") local.HealthFractionInt (loc_convert_string " percent")
local.LastHealth = self.health
}
}
end
MoveTank:
local.Path = $TankPanzer1_Path1 // Set the tank path.
local.TankSpeed = 7 // Set the tank speed value.
local.Acceleration = 30 // Set the tank acceleration value.
local.ReachDistance = 200 // Set the tank reaching distance value.
local.LookAhead = 64 // Set the tank look ahead value
// Move the tank along the path.
self drive local.Path local.TankSpeed local.Acceleration local.ReachDistance local.LookAhead
self waitTill drive // Wait until the tank is at end of path.
self stop // Stop the tank.
self thread TankFire // Call the firing thread.
end
TankFire:
// While the tank is still alive.
while(isAlive self)
{
// Get out of the thread if the player is dead.
if !(isAlive $player)
end
// Initialisation of the main gun.
local.gun1 = self QueryTurretSlotEntity 0
// Set the main gun turn speed
local.gun1 TurnSpeed 15
// Aim the main gun at the player and wait until it is on the target.
local.gun1 setAimTarget $player
local.gun1 waittill ontarget
// Get out of the thread if the tank is destroy.
if !(isAlive self)
end
// Check if the line of sight is clear.
local.trace = trace (self.origin + (0 0 120)) ($player.origin + (0 0 48)) 1
if ((local.trace[0] != $player.origin[0]) || (local.trace[1] != $player.origin[1]) || (local.trace[2] != $player.origin[2] + 48))
wait(1)
// Check if the player is not to close to the tank.
else if (vector_within $player.origin self.origin 384)
wait(1)
// Check if the player is not to far from the tank.
else if (!(vector_within $player.origin self.origin 2500))
wait(1)
// If the tank can fire at the player
else
{
// Make the main gun fire a shot at the target.
local.gun1 startfiring
wait(1)
local.gun1 stopFiring
wait(5)
}
}
end
TankDeath:
// Wait until the tank is dead.
self waittill death
// Make sure the tank is visible and not moving.
self show
self stop
// Initialisation of the 2 guns (main gun and mg).
local.gun1 = self QueryTurretSlotEntity 0
local.gun2 = self QueryTurretSlotEntity 1
// Make sure the main gun isn't firing.
local.gun1 stopfiring
// Delete the main gun.
if (local.gun1)
{
self DetachTurretSlot 0
local.gun1 remove
}
// Delete the mg.
if (local.gun2)
{
self DetachTurretSlot 1
local.gun2 remove
}
// Play the sound for the explosion.
self playsound explode_tank
// Spawn the tank explosion.
local.Exp = spawn "fx/fx_tank_explosion.tik"
local.Exp.origin = self.origin
local.Exp anim start
// Shake the ground hard and make a damage zone for the tank destruction blast.
exec global/earthquake.scr .23 4 0 0
radiusdamage self.origin 200 200
// Set the dead thank collision mask.
local.brushmodel = self.target.brushmodel
local.collision = spawn script_object model local.brushmodel
local.collision.angles = self.angles
local.collision.origin = self.origin
local.collision disconnect_paths
// Spawn the destroy tank model.
local.damaged = spawn script_model model models/vehicles/tigertank_d.tik
local.damaged.origin = self.origin
local.damaged.angles = self.angles
// Remove the non-destroy tank model and the explosion.
self remove
local.Exp remove
end
/////////////OBJECTIVES
objectives:
waitthread global/objectives.scr::add_objectives 1 2 "Kill the badass officer." $obj1.origin
//this makes the compass point to the officer
set_objective_pos $badmofo // this makes the officer to be killed an objective
thread objective1
end
//////////
objective1:
waitthread global/objectives.scr::current_objectives 1
if (IsAlive $badmofo) // the "if" must be a lower case, MOHAA is case sensitive
$badmofo waittill death // if the officer is killed, then the mission will complete
thread mission_complete
end
///////////
mission_complete:
waitthread global/objectives.scr::add_objectives 1 3 "Kill the officer." $obj1.origin
waitthread global/objectives.scr::current_objectives 0 // clears objectives
iprintln_noloc "The officer has been killed. Mission complete!"
wait 1
exec global/missioncomplete.scr test_assassination 1 // loads the mission complete screen
end
end