taking flak need some help

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

taking flak need some help

Post by ViPER »

this is part of the last one of my sh tow to dm conversions where im trying to make everything in tow work in dm. the flak gun in ardennes switches back and forth when controlled by teams.

the Problem - its working ok its just with each switchover the bombing events are increased. that is -

first control switch - 1 bomb every couple seconds (like it suppose to)

second control switch event - 2 bombs every couple seconds. and so on, and so on and on.

the togglegun thread is the switch part of my script and the flak cannon fire thread and down is mainly from the stock script and i dont understand it fully enough to figureout whats happening. any ideas?

Code: Select all

togglegun:

while(1) 
{ 
// wait for trigger event 
while(1) 
{ 
$guntrg waittill trigger 
if(parm.other.dmteam == allies || parm.other.dmteam == axis) 
break 
}

local.gun_trgteam = parm.other.dmteam
if(local.gun_trgteam == allies)
{

	//$obj_flak.ControlledBy = 0

	if( level.flakfire != 1 )
	{
		level.flakfire = 1
		level.abort_shot = 0

		//Fire
		$flak thread flak_attackdm $flak_allied_target

		iprintln "the Allies have control of the Flak 88!"
		wait 1
		iprintln "the Allies have initiated bombardment on Axis target!"

		if(level.nodynahud != 1)
		{
		$axgn disablespawn
		$algn enablespawn

		huddraw_virtualsize 208 1
		huddraw_shader 208 ("textures/hud/allies")
		huddraw_align  208 right top
		huddraw_rect   208 -100 130 14 14
		huddraw_alpha  208 1.0

		huddraw_virtualsize 210 1
		huddraw_align  210 right top
		huddraw_font   210 "verdana-12"
		huddraw_rect   210 -80 130 100 14
		huddraw_color  210 0 1 1
		huddraw_alpha  210 1.0
		huddraw_string 210 ("Flak 88")
		}
	}
	else
	{
		//$obj_flak.ControlledBy = 2
		level.flakfire = 2
		level.abort_shot = 1
		iprintln "the Allies have ceased bombardment!"
	}
}
else
{
	//$obj_flak.ControlledBy = 1

	if( level.flakfire != 0 )
	{
		level.flakfire = 0
		level.abort_shot = 0

		//Fire
		$flak thread flak_attackdm $flak_axis_target

		iprintln "the Axis have control of the Flak 88!"
		wait 1
		iprintln "the Axis have initiated bombardment on Allied target!"

		if(level.nodynahud != 1)
		{
		$algn disablespawn
		$axgn enablespawn

		huddraw_virtualsize 208 1
		huddraw_shader 208 ("textures/hud/axis")
		huddraw_align  208 right top
		huddraw_rect   208 -100 130 14 14
		huddraw_alpha  208 1.0

		huddraw_virtualsize 210 1
		huddraw_align  210 right top
		huddraw_font   210 "verdana-12"
		huddraw_rect   210 -80 130 100 14
		huddraw_color  210 1 0 0
		huddraw_alpha  210 1.0
		huddraw_string 210 ("Flak 88")
		}
	}
	else
	{
		//$obj_flak.ControlledBy = 2
		level.flakfire = 2
		level.abort_shot = 1

		iprintln "the Axis have ceased bombardment!"
	}
}
wait 10
}
end

//-----------------------------------------------
// Flak cannon fire
//-----------------------------------------------
flak_attackdm local.target:
	
	level.flak_target = local.target

		thread flak_attack_loopdm

	end

flak_attack_loopdm:

	level.fire_attack_thread = local

	while ( level.flakfire < 2 ) //1
	{
		local.rand = randomint level.flak_target.size //level.flak_target
		if( local.rand <= 0 )
		{
			local.rand++
		}

		self setaimtarget level.flak_target[local.rand] //level.flak_target
		self waittill ontarget

		if ( level.abort_shot==0 )
		{
			self anim fire
			
			wait 1

			waitthread Do_flak_explosiondm

			local.rand = randomint 1
			local.rand += 1

			wait local.rand
		}
	}

end

//-----------------------------------------------
// Make flak go boom
//-----------------------------------------------
Do_flak_explosiondm:

	//Axis controlled   
	if( level.flakfire == 0 )
	{
		local.index = randomint $flak_axis_boom.size
		if ( local.index==0 )
			local.index++

		local.ent = spawn models/projectiles/artilleryshellDEADLY.tik origin $flak_axis_boom[local.index].origin
		local.ent explode
	}
	//Allied controlled
	else if ( level.flakfire == 1 )
	{
		local.index = randomint $flak_allied_boom.size
		if ( local.index==0 )
			local.index++

		local.ent = spawn models/projectiles/artilleryshellDEADLY.tik origin $flak_allied_boom[local.index].origin
		local.ent explode
	}
	else
	{
	wait 1
	}
end
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

i think i got it - i still not sure whats going on with the flak fire threads but i changed my switch - Rather then switching targets, it ceases fire - then a second press switches the target - and all seems to be reset.
Post Reply