Ok this is my code (sdee sumo_mger) and I have been getting errors, well this one in particular.
if(vector_within local.ent.origin local.origin local.radius) (global/jv_mp_players.scr, 503)
if(^
and it only happens when I have the gunners in the battle called in by the below thread. I have a feeling its because the mg is trying to run without the ai, like the ai is spawned away from the mg (not directly on it) and he runs to it, I think the error comes up in the time it takes for him to get to his gun. So I ask how to I turn off the mg? So my ai can get into possition first. Youll see I commented out "$sumoaxismg stop" I took a guess at that one, it was a failed command.
So a long story short is I want a command that will stop my mg or a better thread for getting my ai into possition before the mg executes the custom global script.
Thanks heaps.
sumo_mger:
wait 1
local.dude = spawn "human/sumo_german_wehrmact_soldier_2.tik" origin $sumoaxismg_gunner_spawn.origin targetname "sumoaxismg_gunner"
waitframe
local.dude.weapon = "none"
local.dude.enableEnemy = 0
local.dude exec global/runto.scr $sumoaxismg_gunner_spot
local.dude waittill movedone
waitframe
$sumoaxismg exec global/jv_mp_mg42_active_55.scr::mg42 3000
while (IsAlive local.dude)
// $sumoaxismg stop
wait 5
goto sumo_mger
end
Below is the
// originally written by the master of scripting jv_map, changed by small_sumo with some help from bdbodger..............
mg42 local.range:
if(level.main_player_handler != 1)
exec global/jv_mp_players.scr
local.gunner_location = self.origin - (self.forwardvector * 64)
if(local.range == NIL)
{
if($world.farplane == NIL)
self.range = 4096
else
self.range = $world.farplane * 0.8
}
else
self.range = local.range
self burstfiresettings 1 2.5 0.2 1
self.maxyawoffset = 45 // !!
self.gunner = $(self.targetname + "_gunner")
self.gunner waitthread setup_gunner self
self thread targeting
self.gunner waittill death
end
set_team:
// later to be put in a global AI script
if(self.team == german)
self.dmteam = axis
else
self.dmteam = allies
end
setup_gunner local.mg:
//*** turn the gunner into a machinegunner
self unholster // just to be sure he doesn't try to holster the mg turret
self.enableEnemy = 0
self type_idle machinegunner
self type_attack machinegunner
self type_disguise machinegunner
self type_grenade machinegunner
self turret local.mg
// self health 5
self.deathanim = "death_fall_back"
self waitthread set_team
end
get_targets:
// find player targets
local.players = waitthread global/jv_mp_players.scr::get_active_players $player
local.enemy_players = waitthread global/jv_mp_players.scr::get_team_players local.players allies
local.enemy_players_inrange = waitthread global/jv_mp_players.scr::get_area_entities local.enemy_players self.origin self.maxrange
// find bot targets
local.j = 0
if(level.botlastid != NIL)
{
for(local.i = 1; local.i <= level.botlastid; local.i++)
{
local.bot = level.actualbots[local.i]
if(isAlive local.bot)
{
if(local.bot.dmteam == allies)
{
// if(vector_within local.bot.origin self.origin self.maxrange)
{
local.j++
local.enemy_bots_inrange[local.j] = local.bot
}
}
}
}
}
for(local.i = 1; local.i <= local.enemy_players_inrange.size; local.i++)
local.targets[local.i] = local.enemy_players_inrange[local.i]
for(local.i = local.enemy_players_inrange.size + 1; local.i <= local.enemy_players_inrange.size + local.enemy_bots_inrange.size; local.i++)
local.targets[local.i] = local.enemy_bots_inrange[local.i]
end local.targets
targeting:
// panzer tank barrel targeting
while(self)
{
local.targets = waitthread get_targets
if(local.targets.size > 0)
{
local.unluckynumber = randomint (local.targets.size - 1) + 1
local.target = local.targets[local.unluckynumber]
// if(self.spotter && self.spotter != -1 && local.target != local.previoustarget)
// self waitthread spotter_tap local.target
// local.previoustarget = local.target
self waitthread attack local.target
wait 0.1
}
waitframe
}
end
attack local.target:
local.time = 0
while(isAlive self.gunner && isAlive local.target && local.time < 4)
{
if(self.gunner cansee local.target (2 * self.maxyawoffset) self.range)
{
self setaimtarget local.target
wait 0.3
local.time += 0.3
self startfiring
while(isAlive self.gunner && isAlive local.target && local.time < 4 && self.gunner cansee local.target (2 * self.maxyawoffset) self.range)
{
wait 0.2
local.time += 0.2
}
self stopfiring
}
wait 0.5
local.time += 0.5
}
self setaimtarget NULL
end
Mg trying to exec but gunner not there yet........ I think .
Moderator: Moderators
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
-
vonderbakluft
- Corporal
- Posts: 46
- Joined: Fri Aug 01, 2003 11:15 am
- Location: NL
- Contact:
I suggest:
sumo_mger:
while (1) //or whatever the condition, better than goto at the end
{
wait 1
local.dude = spawn "human/sumo_german_wehrmact_soldier_2.tik" origin $sumoaxismg_gunner_spawn.origin targetname "sumoaxismg_gunner"
waitframe
local.dude.weapon = "none"
local.dude.enableEnemy = 0
local.dude exec global/runto.scr $sumoaxismg_gunner_spot
local.dude waittill movedone
while ( !(vector_within local.dude $sumoaxismg_gunner_spot 16) && (isAlive local.dude) )
waitframe
if (isAlive local.dude) //Only start the mg when dude reached it alive
$sumoaxismg exec global/jv_mp_mg42_active_55.scr::mg42 3000
while (isAlive local.dude) //now let jvs script do the work and wait tiil the gunner is dead before spawning a new one
waitframe
wait 5
}
end
Now you force the guy to go to the gunner with the vector_wthin waitloop. Jv's script will see the gunner close enough so you shouldnt get ther error.
There is no stop command in the sumo_mger, since that part is already covered in jv's script.
btw. The correct way to stop an mg42 is
$mg42 ClearAimtarget //to bring the gun back in idle position
$mg42 stopFiring
Success
Von

sumo_mger:
while (1) //or whatever the condition, better than goto at the end
{
wait 1
local.dude = spawn "human/sumo_german_wehrmact_soldier_2.tik" origin $sumoaxismg_gunner_spawn.origin targetname "sumoaxismg_gunner"
waitframe
local.dude.weapon = "none"
local.dude.enableEnemy = 0
local.dude exec global/runto.scr $sumoaxismg_gunner_spot
local.dude waittill movedone
while ( !(vector_within local.dude $sumoaxismg_gunner_spot 16) && (isAlive local.dude) )
waitframe
if (isAlive local.dude) //Only start the mg when dude reached it alive
$sumoaxismg exec global/jv_mp_mg42_active_55.scr::mg42 3000
while (isAlive local.dude) //now let jvs script do the work and wait tiil the gunner is dead before spawning a new one
waitframe
wait 5
}
end
Now you force the guy to go to the gunner with the vector_wthin waitloop. Jv's script will see the gunner close enough so you shouldnt get ther error.
There is no stop command in the sumo_mger, since that part is already covered in jv's script.
btw. The correct way to stop an mg42 is
$mg42 ClearAimtarget //to bring the gun back in idle position
$mg42 stopFiring
Success
Von
Real mappers map in wordpad 
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:

