Page 1 of 1
Very still and quiet tank!
Posted: Mon Aug 18, 2003 4:10 pm
by bluelamb
Well I've searched and I can't find what I've done wrong
I followed a Tank tut but my tank just sits there...
Also after adding the tank code to the script the objectives dont work...
If someone could take a look that would be awesome, I want to kill this tank!
The errors in the console after loading are:
Script error: binary '<=' applied to incompatible types 'string' and 'int'
BAD FAILSAFE: -2417.10 4498.55 -27.14
(entum 195, radnum -1) blocked, ddoing failsafe)
entum 195, radnum -1) failsafe finished.
Here is the script:
//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
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
//
thread player_prep
end
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 350
$player ammo grenade 3
$player ammo heavy 92
$player useweaponclass smg
$player.has_disguise = 1
iprintlnbold "God forgive them, for they know not what they do!"
end
StartTank:
// Initialisation of the tank parameters.
$TankPanzer1 waitthread InitTank
// Put the tank health on the player screen.
$TankPanzer1 thread TankHealthLoop
// Make the tank move along the chosen path.
$TankPanzer1 thread MoveTank
// Destruction of the tank.
$TankPanzer1 thread TankDeath
end
InitTank:
self.health = 800 // Set the initial health of the tank.
self removeondeath 0 // Make sure the tank doesn't desappear when it is destroy.
self lock // Make sure the player can't use the tank.
self setcollisionentity self.target // Set the tank collision mask
// 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
Posted: Mon Aug 18, 2003 5:57 pm
by Alcoholic
hmm, above the script error part, it shows the line that has the problem.. can you check what it is again?
lines above
Posted: Tue Aug 19, 2003 1:15 am
by bluelamb
The lines above the error were:
if(self.spawn_left ==NIL || self.spawn_left <= 0) (global/mg42_active.scr, 151)
if(self.spawn_left=NIL self.spawn_left^
is this refering to something in the mg42 script?
Thanks
Posted: Tue Aug 19, 2003 1:23 am
by Alcoholic
Yeah it does. Usually, these scripts work, and if they don't, it's usually because the LD (level designer) did something wrong... look over the directions at the top of the mg42active script again and make sure you did everything right.
er...
Posted: Tue Aug 19, 2003 2:54 am
by bluelamb
where do I find that?
n00b
Posted: Tue Aug 19, 2003 3:07 am
by Alcoholic
don't want to put you through all that agony, ill post the script here. make sure you followed the header directions correctly.
hmm thats wierd, they didnt include the directions

.
Code: Select all
////////////////////////////////////////////////////////////////////////////////////////
//
// MoH: Allied Assault Script File
// Global function: MG42 routine for mounted machine guns with spotters
// Script Written By: Benson 'elmagoo' Russell, Robert Field
//
////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
// self is the mg42 gun
//*****************************************************************************************************************
mg42 local.range:
//*** check to see if the gun exists
if (self == NULL)
{
println "^~^~^ MG42 turret does not exist!"
end
}
//println self " set in gun range: " self.max_range
if (local.range != NIL)
self.max_range = local.range
else if (self.max_range == NIL)
self.max_range = 2400
//println self " range: " local.range
//println self " in-set spawn value: " self.spawn
if (self.setplayerusable == NIL)
self.setplayerusable = 1
if (self.turnspeed == NIL)
self.turnspeed = 45
if (self.pitchcaps == NIL)
self.pitchcaps = ( -15 15 0)
if (self.maxyawoffset == NIL)
self.maxyawoffset = 45
self.firedelay = .1
if (self.bulletdamage == NIL)
self.bulletdamage = 70
if (self.tracerfrequency == NIL)
self.tracerfrequency = 3
/*
println self " setplayerusable(1): " self.setplayerusable
println self " turnspeed(45): " self.turnspeed
println self " pitchcaps(-15 15 0): " self.pitchcaps
println self " maxyawoffset(45): " self.maxyawoffset
println self " firedelay(.06): " self.firedelay
println self " bulletdamage(70): " self.bulletdamage
println self " tracerfrequency(4): " self.tracerfrequency
*/
self setplayerusable self.setplayerusable
self turnspeed self.turnspeed
self pitchcaps self.pitchcaps
self maxyawoffset self.maxyawoffset
self firedelay self.firedelay
self bulletdamage self.bulletdamage
self tracerfrequency self.tracerfrequency
self.gunner = $(self.targetname + "_gunner")
if (self.gunner != NULL)
thread mg42_gunner_death
self.spotter = $(self.targetname + "_spotter")
if (self.spotter != NULL)
thread mg42_spotter_death
//*** create the center aim target script_origin for reloading
//println self " spawning a center aim target"
self.center = spawn script_origin
self.temp_origin = (self.forwardvector * 128) + self.origin
self.temp_origin[2] = self.origin[2]
self.center.origin = self.temp_origin
//*** create a temp target for this gun for accuracy
self.temp_target = spawn script_origin
//println "MG42: spawned temp target: " self.temp_target
self.reload_counter = 0
self.cover_time = 0
self.spawner_gunner = $(self.targetname + "_spawner_gunner")
if (self.spawner_gunner != NULL)
{
if (self.spawner_gunner.path == NIL || self.spawner_gunner.path == "")
{
self.path_gunner = $(self.targetname + "_gunner_path")
}
else
{
self.path_gunner = $(self.spawner_gunner.path)
}
if (self.spawner_gunner.ai_model == NIL || self.spawner_gunner.ai_model == "")
{
self.model_gunner = "models/human/german_wehrmact_grenadier"
}
else
{
self.model_gunner = ("models/human/" + self.spawner_gunner.ai_model)
}
}
self.spawner_spotter = $(self.targetname + "_spawner_spotter")
if (self.spawner_spotter != NULL)
{
if (self.spawner_spotter.path == NIL || self.spawner_spotter.path == "")
{
self.path_spotter = $(self.targetname + "_spotter_path")
}
else
{
self.path_spotter = $(self.spawner_spotter.path)
}
if (self.spawner_spotter.ai_model == NIL || self.spawner_spotter.ai_model == "")
{
self.model_spotter = "models/human/german_wehrmact_grenadier"
}
else
{
self.model_spotter = ("models/human/" + self.spawner_spotter.ai_model)
}
}
self.spawn_left = self.spawn
thread mg42_gunner_start
thread mg42_spotter_start
wait 1
if (self.gunner == NULL && self.spotter == NULL)
thread mg42_spawn
end
//*****************************************************************************************************************
mg42_spawn:
if (self.spawn_left == NIL || self.spawn_left <= 0)
end
self.gunner = spawn self.model_gunner gun "mg42" ammo_grenade "5" origin self.spawner_gunner.origin
thread mg42_gunner_death
if (self.spawner_spotter != NULL)
{
self.spotter = spawn self.model_spotter gun "mauser kar 98k" ammo_grenade "5" origin self.spawner_spotter.origin
self.spotter exec global/disable_ai.scr
thread mg42_spotter_death
}
self.spawn_left--
thread mg42_gunner_run
if (isalive self.spotter)
thread mg42_spotter_run
end
//*****************************************************************************************************************
mg42_gunner_run:
//println "gunner: " self.gunner " running on path: " self.path_gunner
self.gunner exec global/disable_ai.scr
self.gunner exec global/runto.scr self.path_gunner
self.gunner waittill movedone
self.gunner exec global/enable_ai.scr
thread mg42_gunner_start
end
//*****************************************************************************************************************
mg42_spotter_run:
//println "spotter: " self.spotter " running on path: " self.path_spotter
self.spotter exec global/runto.scr self.path_spotter
self.spotter waittill movedone
thread mg42_spotter_start
end
//*****************************************************************************************************************
mg42_gunner_start:
if !(isalive self.gunner)
end
//*** turn the gunner into a machinegunner
self.gunner type_idle machinegunner
self.gunner type_attack machinegunner
self.gunner type_disguise machinegunner
self.gunner type_grenade machinegunner
self.gunner turret self
self.gunner health 5
self.gunner exec global/setdeathanim.scr "death_fall_back"
goto enable
//*****************************************************************************************************************
enable:
if !(isalive self.gunner)
end
if (self.gunner_thread)
end
self.gunner_thread = local
self.target_changed = 1
mg42_main_fireloop:
if (!self.gunner.turret)
{
if (IsAlive self.spotter)
{
self.spotter weapon_internal models/weapons/kar98.tik
self.spotter exec global/enable_ai.scr
}
end
}
//*** check to see if the gun needs to reload
if (self.reload_counter >= 13)
{
// println self " reloading"
self stopfiring
self.isfiring = 0
self setaimtarget self.center
wait .5
self.gunner reload_mg42
self.gunner waittill animdone
self.target_changed = 1
self.reload_counter = 0
// println self " done reloading"
}
//println self " setaimtarget: " self.setaimtarget
//println self " current_target: " self.current_target
//*** if there is currently no target, make it the player
if (self.setaimtarget == NIL || self.current_target == NIL || !(isalive self.setaimtarget) || !(isalive self.current_target))
{
// println self " target was NIL, setting to player"
self.setaimtarget = $player
self stopfiring
self.isfiring = 0
self.target_changed = 1
}
else if (self.setaimtarget != self.current_target)
{
self.target_changed = 1
}
//*** If the target changed, have the spotter tap gunner on the head
if (self.target_changed == 1)
{
// println self " target was changed, stopping to switch to new target"
if (isalive self.spotter)
thread mg42_spotter_tap
// Set target_changed to 2 so the gunner knows to respond next loop.
self.target_changed = 2
}
//*** When you get tapped on the head, fire at the new target
else if (self.target_changed == 2)
{
self startfiring
self.isfiring = 1
// Reset the target_changed variable now we're done with it.
self.target_changed = 0
}
self.current_target = self.setaimtarget
//*** check distance and line of sight to target, if outside distance or not visible, stop firing
if !(self.gunner cansee self.current_target (self.maxyawoffset * 2) self.max_range)
{
// println self " can't see it's current target: " self.current_target
wait self.cover_time
self stopfiring
self setaimtarget NULL
self.isfiring = 2 // 2 to represent "wants to fire"
wait .5
goto mg42_main_fireloop
}
else
{
if (!self.player_enemy && (self.current_target == $player))
{
//*** check to see if the player is disguised
if ($player.is_disguised == 1)
{
self stopfiring
self setaimtarget NULL
wait .5
goto mg42_main_fireloop
}
self.player_enemy = 1
}
if (self.isfiring == 2)
{
// println "MG42: wait time to start firing again: " self.cover_time
wait self.cover_time
self startfiring
self.isfiring = 1
}
}
//println self " has target: " self.current_target
//*** do a range check and set the accuracy accordingly
local.distance = vector_length (self.origin - self.current_target.origin)
//println "MG42: range to target: " self.current_target " : is: " local.distance
if (local.distance >= 2401)
{
//*** calculate a point that's offset from the current target
local.xoffset = (randomint 321 - 160)
local.yoffset = (randomint 321 - 160)
local.zoffset = (randomint 185 - 92)
self.temp_origin = ( (self.current_target.origin[0] + local.xoffset) (self.current_target.origin[1] + local.yoffset) ((self.current_target.origin[2] + local.zoffset) + 48) )
//*** set the temp targets origin to the offset origin
self.temp_target.origin = self.temp_origin
//*** set the wait time for if the player goes behind cover
self.cover_time = 1.5
//*** make the gun shoot at that
self setaimtarget self.temp_target
}
else if (local.distance >= 1801)
{
//*** calculate a point that's offset from the current target
local.xoffset = (randomint 297 - 148)
local.yoffset = (randomint 297 - 148)
local.zoffset = (randomint 145 - 72)
self.temp_origin = ( (self.current_target.origin[0] + local.xoffset) (self.current_target.origin[1] + local.yoffset) ((self.current_target.origin[2] + local.zoffset) + 48) )
//*** set the temp targets origin to the offset origin
self.temp_target.origin = self.temp_origin
//*** set the wait time for if the player goes behind cover
self.cover_time = 1
//*** make the gun shoot at that
self setaimtarget self.temp_target
}
else if (local.distance >= 1201)
{
//*** calculate a point that's offset from the current target
local.xoffset = (randomint 185 - 92)
local.yoffset = (randomint 185 - 92)
local.zoffset = (randomint 65 - 32)
self.temp_origin = ( (self.current_target.origin[0] + local.xoffset) (self.current_target.origin[1] + local.yoffset) ((self.current_target.origin[2] + local.zoffset) + 48) )
//*** set the temp targets origin to the offset origin
self.temp_target.origin = self.temp_origin
//*** set the wait time for if the player goes behind cover
self.cover_time = .5
//*** make the gun shoot at that
self setaimtarget self.temp_target
}
else if (local.distance >= 501)
{
//*** calculate a point that's offset from the current target
local.xoffset = (randomint 65 - 32)
local.yoffset = (randomint 65 - 32)
local.zoffset = (randomint 33 - 16)
self.temp_origin = ( (self.current_target.origin[0] + local.xoffset) (self.current_target.origin[1] + local.yoffset) ((self.current_target.origin[2] + local.zoffset) + 48) )
//*** set the wait time for if the player goes behind cover
self.cover_time = .25
//*** set the temp targets origin to the offset origin
self.temp_target.origin = self.temp_origin
//*** make the gun shoot at that
self setaimtarget self.temp_target
}
else if (local.distance < 500)
{
//*** set the wait time for if the player goes behind cover
self.cover_time = .25
self setaimtarget self.current_target
}
if (self.isfiring == 1)
{
self.reload_counter++
}
/*
println "MG42: xoffset: " local.xoffset
println "MG42: yoffset: " local.yoffset
println "MG42: zoffset: " local.zoffset
println "MG42: temp_targets origin: " self.temp_target.origin
println "MG42: current_targets origin: " self.current_target.origin
*/
wait .5
goto mg42_main_fireloop
//*****************************************************************************************************************
mg42_spotter_tap:
//println "MG42 SPOTTER TAP: executing tap"
if (self.current_target != NIL)
{
if (((self.current_target.origin - self.origin) * self.leftvector) >= 0)
{
//*** point left and tap
// println "MG42 SPOTTER TAP: " self.spotter " spotter pointing left"
self.spotter anim MG42_spotter_stand_left
}
else
{
//*** point right and tap
// println "MG42 SPOTTER TAP: " self.spotter " spotter pointing right"
self.spotter anim MG42_spotter_stand_right
}
}
end
//*****************************************************************************************************************
mg42_spotter_start:
//println "MG42 SPOTTER SETUP: spotter at the weapon"
//println "MG42 SPOTTER SETUP: spotter: " self.spotter " has reached the weapon"
if !(isalive self.spotter)
end
// println "MG42 SPOTTER SETUP: " self.spotter " is alive, disabling and telling the weapon"
self.spotter exec global/disable_ai.scr
self.spotter holster
end
//*****************************************************************************************************************
mg42_gunner_death:
self.gunner waittill death
if (self.gunner_thread)
self.gunner_thread delete
if !(isalive self.spotter)
{
wait 2
thread mg42_spawn
}
else
{
// println self.gunner " waking up the spotter"
self.spotter type_idle idle
self.spotter type_attack cover
self.spotter exec global/enable_ai.scr
self.spotter unholster
self.spotter attackplayer
}
end
//*****************************************************************************************************************
mg42_spotter_death:
self.spotter waittill death
if !(isalive self.gunner)
{
wait 2
thread mg42_spawn
}
end
//*****************************************************************************************************************
disable:
if (self.gunner_thread)
self.gunner_thread delete
self stopfiring
self setaimtarget NULL
end
how did you set up your first mg42? tell me everything related to it.
Posted: Tue Aug 19, 2003 3:08 am
by Alcoholic
don't want to put you through all that agony, ill post the script here. make sure you followed the header directions correctly.
hmm thats wierd, they didnt include the directions

.
Code: Select all
////////////////////////////////////////////////////////////////////////////////////////
//
// MoH: Allied Assault Script File
// Global function: MG42 routine for mounted machine guns with spotters
// Script Written By: Benson 'elmagoo' Russell, Robert Field
//
////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
// self is the mg42 gun
//*****************************************************************************************************************
mg42 local.range:
//*** check to see if the gun exists
if (self == NULL)
{
println "^~^~^ MG42 turret does not exist!"
end
}
//println self " set in gun range: " self.max_range
if (local.range != NIL)
self.max_range = local.range
else if (self.max_range == NIL)
self.max_range = 2400
//println self " range: " local.range
//println self " in-set spawn value: " self.spawn
if (self.setplayerusable == NIL)
self.setplayerusable = 1
if (self.turnspeed == NIL)
self.turnspeed = 45
if (self.pitchcaps == NIL)
self.pitchcaps = ( -15 15 0)
if (self.maxyawoffset == NIL)
self.maxyawoffset = 45
self.firedelay = .1
if (self.bulletdamage == NIL)
self.bulletdamage = 70
if (self.tracerfrequency == NIL)
self.tracerfrequency = 3
/*
println self " setplayerusable(1): " self.setplayerusable
println self " turnspeed(45): " self.turnspeed
println self " pitchcaps(-15 15 0): " self.pitchcaps
println self " maxyawoffset(45): " self.maxyawoffset
println self " firedelay(.06): " self.firedelay
println self " bulletdamage(70): " self.bulletdamage
println self " tracerfrequency(4): " self.tracerfrequency
*/
self setplayerusable self.setplayerusable
self turnspeed self.turnspeed
self pitchcaps self.pitchcaps
self maxyawoffset self.maxyawoffset
self firedelay self.firedelay
self bulletdamage self.bulletdamage
self tracerfrequency self.tracerfrequency
self.gunner = $(self.targetname + "_gunner")
if (self.gunner != NULL)
thread mg42_gunner_death
self.spotter = $(self.targetname + "_spotter")
if (self.spotter != NULL)
thread mg42_spotter_death
//*** create the center aim target script_origin for reloading
//println self " spawning a center aim target"
self.center = spawn script_origin
self.temp_origin = (self.forwardvector * 128) + self.origin
self.temp_origin[2] = self.origin[2]
self.center.origin = self.temp_origin
//*** create a temp target for this gun for accuracy
self.temp_target = spawn script_origin
//println "MG42: spawned temp target: " self.temp_target
self.reload_counter = 0
self.cover_time = 0
self.spawner_gunner = $(self.targetname + "_spawner_gunner")
if (self.spawner_gunner != NULL)
{
if (self.spawner_gunner.path == NIL || self.spawner_gunner.path == "")
{
self.path_gunner = $(self.targetname + "_gunner_path")
}
else
{
self.path_gunner = $(self.spawner_gunner.path)
}
if (self.spawner_gunner.ai_model == NIL || self.spawner_gunner.ai_model == "")
{
self.model_gunner = "models/human/german_wehrmact_grenadier"
}
else
{
self.model_gunner = ("models/human/" + self.spawner_gunner.ai_model)
}
}
self.spawner_spotter = $(self.targetname + "_spawner_spotter")
if (self.spawner_spotter != NULL)
{
if (self.spawner_spotter.path == NIL || self.spawner_spotter.path == "")
{
self.path_spotter = $(self.targetname + "_spotter_path")
}
else
{
self.path_spotter = $(self.spawner_spotter.path)
}
if (self.spawner_spotter.ai_model == NIL || self.spawner_spotter.ai_model == "")
{
self.model_spotter = "models/human/german_wehrmact_grenadier"
}
else
{
self.model_spotter = ("models/human/" + self.spawner_spotter.ai_model)
}
}
self.spawn_left = self.spawn
thread mg42_gunner_start
thread mg42_spotter_start
wait 1
if (self.gunner == NULL && self.spotter == NULL)
thread mg42_spawn
end
//*****************************************************************************************************************
mg42_spawn:
if (self.spawn_left == NIL || self.spawn_left <= 0)
end
self.gunner = spawn self.model_gunner gun "mg42" ammo_grenade "5" origin self.spawner_gunner.origin
thread mg42_gunner_death
if (self.spawner_spotter != NULL)
{
self.spotter = spawn self.model_spotter gun "mauser kar 98k" ammo_grenade "5" origin self.spawner_spotter.origin
self.spotter exec global/disable_ai.scr
thread mg42_spotter_death
}
self.spawn_left--
thread mg42_gunner_run
if (isalive self.spotter)
thread mg42_spotter_run
end
//*****************************************************************************************************************
mg42_gunner_run:
//println "gunner: " self.gunner " running on path: " self.path_gunner
self.gunner exec global/disable_ai.scr
self.gunner exec global/runto.scr self.path_gunner
self.gunner waittill movedone
self.gunner exec global/enable_ai.scr
thread mg42_gunner_start
end
//*****************************************************************************************************************
mg42_spotter_run:
//println "spotter: " self.spotter " running on path: " self.path_spotter
self.spotter exec global/runto.scr self.path_spotter
self.spotter waittill movedone
thread mg42_spotter_start
end
//*****************************************************************************************************************
mg42_gunner_start:
if !(isalive self.gunner)
end
//*** turn the gunner into a machinegunner
self.gunner type_idle machinegunner
self.gunner type_attack machinegunner
self.gunner type_disguise machinegunner
self.gunner type_grenade machinegunner
self.gunner turret self
self.gunner health 5
self.gunner exec global/setdeathanim.scr "death_fall_back"
goto enable
//*****************************************************************************************************************
enable:
if !(isalive self.gunner)
end
if (self.gunner_thread)
end
self.gunner_thread = local
self.target_changed = 1
mg42_main_fireloop:
if (!self.gunner.turret)
{
if (IsAlive self.spotter)
{
self.spotter weapon_internal models/weapons/kar98.tik
self.spotter exec global/enable_ai.scr
}
end
}
//*** check to see if the gun needs to reload
if (self.reload_counter >= 13)
{
// println self " reloading"
self stopfiring
self.isfiring = 0
self setaimtarget self.center
wait .5
self.gunner reload_mg42
self.gunner waittill animdone
self.target_changed = 1
self.reload_counter = 0
// println self " done reloading"
}
//println self " setaimtarget: " self.setaimtarget
//println self " current_target: " self.current_target
//*** if there is currently no target, make it the player
if (self.setaimtarget == NIL || self.current_target == NIL || !(isalive self.setaimtarget) || !(isalive self.current_target))
{
// println self " target was NIL, setting to player"
self.setaimtarget = $player
self stopfiring
self.isfiring = 0
self.target_changed = 1
}
else if (self.setaimtarget != self.current_target)
{
self.target_changed = 1
}
//*** If the target changed, have the spotter tap gunner on the head
if (self.target_changed == 1)
{
// println self " target was changed, stopping to switch to new target"
if (isalive self.spotter)
thread mg42_spotter_tap
// Set target_changed to 2 so the gunner knows to respond next loop.
self.target_changed = 2
}
//*** When you get tapped on the head, fire at the new target
else if (self.target_changed == 2)
{
self startfiring
self.isfiring = 1
// Reset the target_changed variable now we're done with it.
self.target_changed = 0
}
self.current_target = self.setaimtarget
//*** check distance and line of sight to target, if outside distance or not visible, stop firing
if !(self.gunner cansee self.current_target (self.maxyawoffset * 2) self.max_range)
{
// println self " can't see it's current target: " self.current_target
wait self.cover_time
self stopfiring
self setaimtarget NULL
self.isfiring = 2 // 2 to represent "wants to fire"
wait .5
goto mg42_main_fireloop
}
else
{
if (!self.player_enemy && (self.current_target == $player))
{
//*** check to see if the player is disguised
if ($player.is_disguised == 1)
{
self stopfiring
self setaimtarget NULL
wait .5
goto mg42_main_fireloop
}
self.player_enemy = 1
}
if (self.isfiring == 2)
{
// println "MG42: wait time to start firing again: " self.cover_time
wait self.cover_time
self startfiring
self.isfiring = 1
}
}
//println self " has target: " self.current_target
//*** do a range check and set the accuracy accordingly
local.distance = vector_length (self.origin - self.current_target.origin)
//println "MG42: range to target: " self.current_target " : is: " local.distance
if (local.distance >= 2401)
{
//*** calculate a point that's offset from the current target
local.xoffset = (randomint 321 - 160)
local.yoffset = (randomint 321 - 160)
local.zoffset = (randomint 185 - 92)
self.temp_origin = ( (self.current_target.origin[0] + local.xoffset) (self.current_target.origin[1] + local.yoffset) ((self.current_target.origin[2] + local.zoffset) + 48) )
//*** set the temp targets origin to the offset origin
self.temp_target.origin = self.temp_origin
//*** set the wait time for if the player goes behind cover
self.cover_time = 1.5
//*** make the gun shoot at that
self setaimtarget self.temp_target
}
else if (local.distance >= 1801)
{
//*** calculate a point that's offset from the current target
local.xoffset = (randomint 297 - 148)
local.yoffset = (randomint 297 - 148)
local.zoffset = (randomint 145 - 72)
self.temp_origin = ( (self.current_target.origin[0] + local.xoffset) (self.current_target.origin[1] + local.yoffset) ((self.current_target.origin[2] + local.zoffset) + 48) )
//*** set the temp targets origin to the offset origin
self.temp_target.origin = self.temp_origin
//*** set the wait time for if the player goes behind cover
self.cover_time = 1
//*** make the gun shoot at that
self setaimtarget self.temp_target
}
else if (local.distance >= 1201)
{
//*** calculate a point that's offset from the current target
local.xoffset = (randomint 185 - 92)
local.yoffset = (randomint 185 - 92)
local.zoffset = (randomint 65 - 32)
self.temp_origin = ( (self.current_target.origin[0] + local.xoffset) (self.current_target.origin[1] + local.yoffset) ((self.current_target.origin[2] + local.zoffset) + 48) )
//*** set the temp targets origin to the offset origin
self.temp_target.origin = self.temp_origin
//*** set the wait time for if the player goes behind cover
self.cover_time = .5
//*** make the gun shoot at that
self setaimtarget self.temp_target
}
else if (local.distance >= 501)
{
//*** calculate a point that's offset from the current target
local.xoffset = (randomint 65 - 32)
local.yoffset = (randomint 65 - 32)
local.zoffset = (randomint 33 - 16)
self.temp_origin = ( (self.current_target.origin[0] + local.xoffset) (self.current_target.origin[1] + local.yoffset) ((self.current_target.origin[2] + local.zoffset) + 48) )
//*** set the wait time for if the player goes behind cover
self.cover_time = .25
//*** set the temp targets origin to the offset origin
self.temp_target.origin = self.temp_origin
//*** make the gun shoot at that
self setaimtarget self.temp_target
}
else if (local.distance < 500)
{
//*** set the wait time for if the player goes behind cover
self.cover_time = .25
self setaimtarget self.current_target
}
if (self.isfiring == 1)
{
self.reload_counter++
}
/*
println "MG42: xoffset: " local.xoffset
println "MG42: yoffset: " local.yoffset
println "MG42: zoffset: " local.zoffset
println "MG42: temp_targets origin: " self.temp_target.origin
println "MG42: current_targets origin: " self.current_target.origin
*/
wait .5
goto mg42_main_fireloop
//*****************************************************************************************************************
mg42_spotter_tap:
//println "MG42 SPOTTER TAP: executing tap"
if (self.current_target != NIL)
{
if (((self.current_target.origin - self.origin) * self.leftvector) >= 0)
{
//*** point left and tap
// println "MG42 SPOTTER TAP: " self.spotter " spotter pointing left"
self.spotter anim MG42_spotter_stand_left
}
else
{
//*** point right and tap
// println "MG42 SPOTTER TAP: " self.spotter " spotter pointing right"
self.spotter anim MG42_spotter_stand_right
}
}
end
//*****************************************************************************************************************
mg42_spotter_start:
//println "MG42 SPOTTER SETUP: spotter at the weapon"
//println "MG42 SPOTTER SETUP: spotter: " self.spotter " has reached the weapon"
if !(isalive self.spotter)
end
// println "MG42 SPOTTER SETUP: " self.spotter " is alive, disabling and telling the weapon"
self.spotter exec global/disable_ai.scr
self.spotter holster
end
//*****************************************************************************************************************
mg42_gunner_death:
self.gunner waittill death
if (self.gunner_thread)
self.gunner_thread delete
if !(isalive self.spotter)
{
wait 2
thread mg42_spawn
}
else
{
// println self.gunner " waking up the spotter"
self.spotter type_idle idle
self.spotter type_attack cover
self.spotter exec global/enable_ai.scr
self.spotter unholster
self.spotter attackplayer
}
end
//*****************************************************************************************************************
mg42_spotter_death:
self.spotter waittill death
if !(isalive self.gunner)
{
wait 2
thread mg42_spawn
}
end
//*****************************************************************************************************************
disable:
if (self.gunner_thread)
self.gunner_thread delete
self stopfiring
self setaimtarget NULL
end
how did you set up your first mg42? tell me everything related to it.
Posted: Tue Aug 19, 2003 3:08 am
by Alcoholic
don't want to put you through all that agony, ill post the script here. make sure you followed the header directions correctly.
hmm thats wierd, they didnt include the directions

. might as well not post it.
how did you set up your first mg42? tell me everything related to it.
mg42s
Posted: Tue Aug 19, 2003 5:20 am
by bluelamb
Ok, I followed the tuts on .map for making an mg42 with spotter and in the map they are working just fine, although the gunner tends to jump up onto the sandbags that the gun is on before getting into the firing position.
The problem is now that I have inserted the script for the tank, the tank doesn't work and neither do the objectives.
having said all that...
I have three mg42s, targetnames mg42, mg42b and mg42c.
they all have spotters and gunners that spawn...
What else can I tell you that would help?
Thx
Posted: Tue Aug 19, 2003 4:26 pm
by Alcoholic
i mean whats the technical data like whats EVERYTHING you did to them ever since you placed them in radiant.
mgs
Posted: Wed Aug 20, 2003 1:35 am
by bluelamb
ok first one:
$spawn 2
$targetname mg42
angles 0.00 135.00 0.00
classname turretweapon_german_mg42
model statweapons/mg42_gun.tik
origin -2435.00 4538.00 27.00
pitchcap -90 90 0
scale 1.0
spawn
testanim idle
second one:
$spawn 2
$targetname mg42b
angles 0.00 135.00 0.00
classname turretweapon_german_mg42
model statweapons/mg42_gun.tik
origin 415.00 5023.00 32.00
pitchcap -45 45 0
scale 1.0
spawn
testanim idle
third one:
$spawn 2
$targetname mg42c
angles 0.00 135.00 0.00
classname turretweapon_german_mg42
model statweapons/mg42_gun.ti
origin 2507.00 1968.00 23.00
pitchcap -45 45 0
scale 1.0
spawn
testanim idle
Well thats it. the plain spawn value isn't doing anything...
At first I copied the first mg42 and then changed the values but then I had problems so i rebuilt each from scratch so they should be fine...
Any suggestions?
Thanks