radio fireing flak88?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

radio fireing flak88?

Post by Elgan »

Hello

i was making a thing for map dm/mohdm5 (snowy park)
it could be used on any map but i was testing it on there.


What it does:

there is 1 radio spawned into the map at the centre bridge. all players can use this radio to fire a flak88 explosion. calling it with his binoculars.

if a has the radio he can shoot else it says he needs the radio.

---------

It all works great with 1 person and some times with more then 1. but sometimes a player without the radio can shoot and so can the radio guy. and some times the guy with the radio is messaged he needs the radio when he does it and sometimes the flak88 just doesnt fire at all:(.


--------

is there any reason why things like that may happen and how could they be fixed?

here is the code. i also include a download pk3 with radio mod on snowy park http://elgan.pwp.blueyonder.co.uk/zz-us ... wypark.pk3

Code: Select all

local.master= spawn ScriptMaster
local.master aliascache flak_snd_fire1 sound/weapons/fire/TankCannonFire1.wav soundparms 1.5 0.0 1.0 0.0 2000 4000 weapon loaded maps "obj dm"
local.master aliascache flak_snd_fire2 sound/weapons/fire/Flak88Fire1.wav soundparms 1.5 0.0 1.0 0.0 2000 4000 weapon loaded maps "obj dm"
local.master aliascache flak_snd_fire3 sound/weapons/fire/Flak88Fire3.wav soundparms 1.5 0.0 1.0 0.0 2000 4000 weapon loaded maps "obj dm"
local.master aliascache flak_snd_fire4 sound/weapons/fire/Flak88Fire4.wav soundparms 1.5 0.0 1.0 0.0 2000 4000 weapon loaded maps "obj dm"
local.master aliascache snd_binoculars sound/mechanics/Mec_RadioNoise_11.wav soundparms 0.5 0.2 0.9 0.1 160 1600 item auto loaded maps "m moh obj dm team " 

local.master aliascache leadinmp1 sound/weapons/explo/Exp_LeadIn_06.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m moh obj dm team " 
local.master aliascache leadinmp2 sound/weapons/explo/Exp_LeadIn_07.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m moh obj dm team " 
local.master aliascache leadinmp3 sound/weapons/explo/Exp_LeadIn_08.wav soundparms 0.8 0.2 0.7 0.5 160 300 auto loaded maps "m moh obj dm team " 
local.master aliascache m3l2_radio_pickup sound/items/Item_ToolBox_01.wav soundparms 1.5 0.0 1.0 0.0 100 2000 item loaded maps "m3l2 dm moh obj train"
level.radio_spot = ( 2103 -4838 167 )
goto spawn_radio
end

spawn_radio:

local.radio = spawn script_model "targetname" "radio"
local.radio model "items/walkietalkie.tik"
local.radio.origin = level.radio_spot
local.radio.angles = ( 0 0 0 )
local.radio.scale = 1.0


local.radio_trigger = spawn trigger_use "targetname" "radio_trigger"
local.radio_trigger.origin = level.radio_spot
local.radio_trigger setsize ( -30 -30 -30 ) ( 30 30 30 ) 
local.radio_trigger setthread radio_trigger
local.radio_trigger message "You Have a Radio"
local.radio_trigger wait 1 // How often the trig acts
local.radio_trigger delay 0 // How long before trig acts 

end 

binocular_fire:

local.player=parm.other

if(local.player.can!=1)
{
	local.player iprint "i need radio"
	end
}

if(level.canshoot==1)
{
	local.player iprint "Please wait..." 
	end
}
thread canshoot
wait 1
self playsound flak_snd_fire1
wait .1
self playsound flak_snd_fire2

self playsound snd_binoculars
if ($world.farplane == NIL ) {
	level.bnok_sight_max = 22000
} else {
	if ($world.farplane < 1) {
		level.bnok_sight_max = 22000
	} else {
		level.bnok_sight_max = $world.farplane
	}
}

local.fwd_vec = angles_toforward self.viewangles
local.start = self gettagposition "Bip01 Head"
local.hit_location = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * level.bnok_sight_max) 0
local.org = spawn script_origin 
local.org.origin = local.hit_location

wait 1
self playsound leadinmp1
wait 1
self playsound leadinmp2
wait 1
self playsound leadinmp3
wait 1

local.Exp1 = spawn "fx/scriptbazookaexplosion.tik"
local.Exp2 = spawn "animate/fx_mortar_dirt.tik"
local.Exp3 = spawn "animate/fx_mortar_higgins.tik"

exec global/earthquake.scr .23 4 0 0
local.Exp1.origin = local.org.origin
local.Exp1 anim start
local.Exp2.origin = local.org.origin
local.Exp2 anim start
local.Exp3.origin = local.org.origin
local.Exp3 anim start
wait 1
local.Exp1 remove
local.Exp2 remove
local.Exp3 remove


end


radio_trigger:
	local.player=parm.other
	level.lighting=0
	$radio playsound m3l2_radio_pickup
	local.player.can = 1
	local.player playsound m3l2_radio_pickup
	local.player iprint "You Have the Radio, You can now Fire the Flak88's"
	//local.player light 1 0 0 300
	local.player stufftext "say Ive got the radio!!!"
	$radio remove
	$radio_trigger nottriggerable
	while (1) 
	{
		if !(isalive local.player) 
	{
		level.lighting = 1
		thread radio_lights
		local.player light 0 0 0 0
		level.radio_spot = local.player.origin
		local.player.can = 0
		$radio_trigger triggerable
		thread spawn_radio
		break	
	}
	wait 1 
	}

end

radio_lights:

	while(level.lighting==1)
	{
	wait 1
		$radio light 0 0 0 0
		$radio light 1 0 0 200
	wait 1
		$radio light 0 0 0 0
		$radio light 0 1 0 200
	}
	$radio light 0 0 0 0
end
	
canshoot:
level.canshoot=1
wait 5
level.canshoot=0
end	
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Cool script Elgan.

But you can steal the rario from the map by going to spectator while having it... so I think you neen to check for more than the player isAlive. You need to check if the player is actually in the game as well. This is takern from the MOH:AA Liberation script:

Code: Select all

detect_player_status local.player:
	// Test if the player has spawned into the map, or are still choosing weapon
	local.trigger = spawn trigger_multiple "targetname" "player_position_trigger" setthread player_exists_setthread
	local.trigger.origin = local.player.origin
	waitframe
	waitframe
	waitframe
	$player_position_trigger delete
	if(local.player.activated && isAlive local.player)
	{
		if(local.player.dmteam == allies)
		{
			level.allies_in_game++
			if(local.player istouching $axis_prison_volume)
			{
				level.allies_in_prison++
			}
		}
		else
		{
			if(local.player.dmteam == axis)
			{
				level.axis_in_game++
				if(local.player istouching $allied_prison_volume)
				{
					level.axis_in_prison++
				}
			}
			else
			{
				if(local.player.dmteam == spectator)
				{
					iprintln "Spectating player detected " local.player.dmteam
					local.player.activated = false
				}
				else
				{
					iprintln "Undefined player detected " local.player.dmteam
					local.player.activated = false
				}
			}
		}
	}
end
Admin .MAP Forums
Image
Head above heels.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

binocular_fire

Post by tltrude »

I can't see how the binocular_fire thread is triggered. You need to rethink your script and orginize it a bit. Putting every thing in the main thread is not a good practice. You could make a seperate (global) script and then call it with one line in the level script. And, you can also set the coordinates of the radio in the same line.


exec global/flakk-eyes.scr::eyes_setup ( 2103 -4838 167 )

Then in the global script.

eyes_setup local.radio_spot:

local.master= spawn ScriptMaster
etc......


That will transfer the coordinates to the global script and assign them that variable name. You can add more variables the same way, just put a space between them in both lines. The closest script to what you are tring to do would probably be the global/minefield.scr script.
Last edited by tltrude on Thu May 27, 2004 9:53 pm, edited 5 times in total.
Tom Trude,

Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

cool

Post by Elgan »

cool thank you Bjarne.

i had totaly forgetten about the spectators :o
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Re: binocular_fire

Post by Elgan »

tltrude wrote:I can't see how the binocular_fire thread is triggered. You need to rethink your script and orginize it a bit. Putting every thing in the main thread is not a good practice. You could make a seperate (global) script and then call it with one line in the level script. And, you can also set the coordinates of the radio in the same line.


exec global/flakk-eyes.scr::main ( 2103 -4838 167 )

Then in the global script.

main level.radio_spot:

local.master= spawn ScriptMaster
etc......


That will transfer the coordiates to the global script and assign them that variable name.

sorry i shold of said:(

if u look in the pk3 i supplyed it has after main in the main map script

Code: Select all

clickitem_fail:
	exec maps/DM/fixes/snowy.scr::binocular_fire
end
thus when the player clicks with the binoculars it runs "exec maps/DM/fixes/snowy.scr::binocular_fire"

i also thank Bjarne for that:D
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Here is what I am useing in one of my maps to fire the flak useing the binoculars . This works for any number of flak guns . In my script the flaks are all targetname $snowflak . The script checks after the clickitem_fail to see what player is holding the fire button and useing the binoculars to shoot a flak if the player is within 128 units of a flak gun .

Code: Select all

//-------------------------------------------------------------------

clickitem_fail:

for(local.p=1;local.p<= $player.size;local.p++)
{
	if($player[local.p].fireheld == 1)
	{

		local.randnum = randomint 1000
		$player[local.p] weaponcommand dual targetname ("weap" + local.randnum)
		local.weap = $("weap" + local.randnum)
		local.weap.targetname = ""
		//iprintln_noloc "Player " $player[local.p].entnum " has weapon " local.weap.model

		if(local.weap.model == models/items/binoculars.tik)
		{

			local.spotorg = $player[local.p] waitthread find_spot

			for(local.i=1;local.i <= $snowcannon.size;local.i++)
			{
				if((vector_length ($player[local.p].origin - $snowcannon[local.i].origin) < 128 ) && !($snowcannon[local.i].shooting==1))
				{
					$snowcannon[local.i] waitthread fire_cannon local.spotorg
					local.spotorg immediateremove
					break
				}
			}
		}
	}
}

end

//-------------------------------------------------------------------

find_spot:

   local.fwd_vec = angles_toforward self.viewangles
   local.start = self gettagposition "Bip01 Head"
   local.range = 5000
   local.hit_location = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0

   local.ent = spawn script_origin origin (local.hit_location - ( 0 0 32 ))

end local.ent

//-------------------------------------------------------------------

fire_cannon local.arty:

	self.shooting = 1

	self setaimtarget local.arty
	self waittill ontarget
	self anim fire
	local.arty immediateremove
	wait 2
	self.shooting = 0

end
Image
Post Reply