Page 1 of 1

Help with Halftrack

Posted: Thu Feb 13, 2003 2:48 am
by matt_moh
:?: I need help with putting a halftrack in one of my maps for Spearhead.
My halftrack moves, shoots, and has a gunner manning the mg42, but there is one problem. The mg42 does not stay in one spot on the halftrack. Sometimes it is where it is supposed be, on top of the Halftrack, but most of the time while its fireing it is either in the halftrack or on top of its left track.


Here is the script. I am a begginer in mapping/scripting so any help or fixes to this would be appreciated.

halftrack_fight:
$player stufftext "tmstop sound/music/mus_Stat_t1.mp3"
$player stufftext "tmstartloop sound/music/Thuringer.mp3"
$halftrack thread global/vehicles_thinkers.scr::enemy_halftrak_think
$halftrack waitthread initHalftrack
$halftrack thread HalftrackHealthLoop
$halftrack thread MoveHalftrack
$halftrack thread HalftrackDeath
$halftrack thread HalftrackFire // Call the firing thread.
$halftrack attachmodel "vehicles/sdkfz_shield.tik" "shield" 1.5 "halftrack_gunnershield"

$halftrack_gunnershield.angles = (0 270 0)

// $halftrack.shield = spawn script_model model "vehicles/sdkfz_shield.tik"
// $halftrack.shield notsolid
// $halftrack.shield nodamage

// $halftrack.mg42 = $halftrack queryTurretSlotEntity 0
// $halftrack.shield glue $halftrack.mg42
$halftrack_gunner lookAt $player

end

initHalftrack:

self.health = 500
self removeondeath 0
self lock
self setcollisionentity self.target
self immune bullet
self immune fast_bullet
self immune bash
// Initialisation of the main gun.
$halftrack.mg42 = self QueryTurretSlotEntity 0
$halftrack.mg42 bulletdamage 50
$halftrack.mg42 bulletspread 2 2

end

MoveHalftrack:

local.Path = $halftrack_path // Set the halftrack path.
local.HalftrackSpeed = 70 // Set the halftrack speed value.
local.Acceleration = 80 // Set the halftrack acceleration value.
local.ReachDistance = 200 // Set the halftrack reaching distance value.
local.LookAhead = 100 // Set the halftrack look ahead value

// Move the halftrack along the path.
self drive local.Path local.HalftrackSpeed local.Acceleration local.ReachDistance local.LookAhead

self waitTill drive // Wait until the halftrack is at end of path.
self stop // Stop the halftrack.

end

HalftrackFire:

// While the halftrack is still alive.
while(isAlive self)
{

// Get out of the thread if the player is dead.
if !(isAlive $player)
end
// Aim the main gun at the player.
$halftrack.mg42 setAimTarget $player

// Get out of the thread if the halftrack is destroyed.
if !(isAlive self)
end
while !($halftrack_gunner cansee $player 0 3050)
{
wait .25
if !(isAlive $halftrack)
end
}

// Make the main gun fire at the target.
$halftrack.mg42 startfiring
wait(5)
$halftrack.mg42 stopFiring
wait(2.5)


}

end

HalftrackDeath:

// Wait until the halftrack is dead.
self waittill death

// Make sure the halftrack is visible and not moving.
self show
self stop

// Initialisation of the 2 guns (main gun and mg).
$halftrack.mg42 = self QueryTurretSlotEntity 0

// Make sure the main gun isn't firing.
$halftrack.mg42 stopfiring

// Delete the main gun.
if ($halftrack.mg42)
{
self DetachTurretSlot 0
$halftrack.mg42 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 haltrack destruction blast.
exec global/earthquake.scr .23 4 0 0
radiusdamage self.origin 200 200

// Set the dead halftrack 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 halftrack model.
local.damaged = spawn script_model model models/vehicles/sdkfz_green_d.tik
local.damaged.origin = self.origin
local.damaged.angles = self.angles

// Remove the non-destroy halftrack model and the explosion.
self remove
local.Exp remove

end






I tried to base the script partly on Kalahad's tank tutorial and the script from m3l3 in MOHAA.

Posted: Thu Feb 13, 2003 7:09 am
by jv_map
Maybe the gunner shield is a problem. All looks pretty good :?.

Anyway, I have a script like yours for multiplayer halftracks with a mg-42. If I can find it and fix the bugs I might send you ;).

Posted: Mon Feb 17, 2003 2:55 am
by small_sumo
Me too captain.