mg42 by it's own

Post your scripting questions / solutions here

Moderator: Moderators

Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

mg42 by it's own

Post by Krane »

Is there any possible way to make the spotlight/gunner without a gunner? I mean, the mg42 shots at you by itself, w/o the AI there?
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Definately...
Image
User avatar
Mj
Map Reviewer
Posts: 1394
Joined: Sun Apr 25, 2004 3:36 pm
Location: England

Post by Mj »

check out the scripting for ohama beach, i think thereis something in there, since the mg42s in the bunkers shoot at you with no AI

Mj
ImageImage
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

Post by Krane »

jv_map wrote:Definately...
Any tips?

Oh, btw, this is for MP...I'm havin a hard time trying to put the mg42/gunner/spotlight in MP, he don't shot at me at all...I'm using a jvbot, since regular AI don't work in MP (nope, the global/ai.scr don't produce any fx...)
Mj wrote:check out the scripting for ohama beach
Ok, I will. I had never realized the mg's at omaha shoot by themselfs...

txs
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Well just use general commands like $mygun setaimtarget $someent and $mygun startFiring / $mygun stopFiring. You'll have to write targeting threads yourself (but you'd have to do that anyway).
Image
Bilko
Colour Sergeant
Posts: 91
Joined: Sat May 24, 2003 3:06 pm
Location: UK
Contact:

Post by Bilko »

I've made that for my map but without the spotlight, here it is:

Code: Select all

fire_mg:
	
	local.gun_name = $mg1
	local.target = parm.other
	while(local.target istouching self) 
	{ 
		//Set target
		local.gun_name setaimtarget local.target 
		local.gun_name waittill ontarget
		wait 0.2
	
		//Set Accuracy
		local.range = 96 + randomint(128)
		local.offset = 96 + randomint(128) 
		
		//Apply Random Aiming
	
		if((randomint(100)) < 50)
			local.gun_name rotateXup local.range
		else
			local.gun_name rotateXdown local.range
	
		if((randomint(100)) < 50)
			local.gun_name rotateYup local.offset
		else
			local.gun_name rotateYdown local.offset
	
		//Gun Fire
			if(local.gun_name cansee local.target) {
				if(isAlive local.target) {
					local.gun_name burstFireSettings 0.25 0.5 1 .25
					local.gun_name maxYawOffset 55
					local.gun_name bulletdamage 20
					local.gun_name setaimtarget local.target
					local.gun_name startfiring
					$mg1 setaimtarget NULL
					wait 1
				} else {
					local.gun_name stopfiring
					$mg1 setaimtarget NULL
				}
			} else {
				local.gun_name stopfiring
				$mg1 setaimtarget NULL
			}
	}

$mg1 setaimtarget NULL

end
and fire_mg is called by a number of trigger_multiple's across the map. That script also stops the mg firing once the person is dead and if it cannot see the target. I am currently try to work out how to get a spotlight to follow a player, not sure how at the moment. :? What you be able to do however is spawn a dynamic light at the position of the player with something like:

Code: Select all

local.light = spawn "fx/dummy.tik"
local.light.origin = local.target.origin
local.light light 1 1 1 200

then of course:

Code: Select all

local.light light 1 1 1 0
when you want to turn the light off. I am however, stuck on how to get a searchlight to follow a player (any help on that would be great :D).
I hope this helps Krane,

Bilko.

ps some of this code was made by other people - credit to them :)
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

Post by Krane »

Sorry guys, not a single shot...

I placed a mg42 in my map, targetname turret. In my script:

main:

level waittill prespawn


thread setup_turret


level waittill spawn

end

setup_turret:

$turret setaimtarget $player
$turret startfiring

end

0...The weapon does not respond to anything...Well, I can use it...

What's wrong?
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

hey, Bilko, it's working perfectly! tvm 8-)

Krane u'll get an email :wink:
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

Post by Krane »

Sorry, Biko, I didn't mean your method don't work. It's just not exactly what I want. I don't want trigger_targets, I want the mg to recognize a player and shoot at him!

So I started w/ Biko's modified script. I was simplifing the script until it was a simple script...nothing...

Then I tryed what jv said, simple commands...nothing...

A simple gun and a simple command...0

Edit: Wacko sended me a map w/ Biko's script...cool, but the trigger is activating the shooting.

Triggers can use commands like "istouching" etc...Can a mg do this by itself?

Or maybe I'll have to put a enormous trigger all over the map...
Image
User avatar
Mj
Map Reviewer
Posts: 1394
Joined: Sun Apr 25, 2004 3:36 pm
Location: England

Post by Mj »

Try putting a trigger where the player starts, so he starts in it...
ImageImage
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

thread it straight away and use

while (1)
{
for (local.i=1; local.i<=$player.size; local.i++)
{
if ($mg42 cansee $player[local.i] 140 768)
$mg42 setaimtarget $player[local.i]
$mg42 startfiring
wait 2
if (!($mg42 cansee $player[local.i] 140 768) || !(isAlive $player[local.i]))
{
$mg42 stopfiring
$mg42 setaimtarget NULL
}
}
wait 1
}
end
hope this helps, prob not cos it's all foreign 2 me :-/
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

hey, great, tvm! :D
I did:

Code: Select all

fire_mg:
while (1) 
	{ 
	for (local.i=1; local.i<=$player.size; local.i++) 
		{ 
		if (($mg1 cansee $player[local.i] 140 768) && (isAlive $player[local.i]))
			{
			$mg1 burstFireSettings 0.25 0.5 1 .25
			$mg1 bulletdamage 1
			$mg1 setaimtarget $player[local.i] 
			$mg1 startfiring 
			wait 2
			} 
		else 
			{ 
			$mg1 stopfiring 
			$mg1 setaimtarget NULL 
			} 
		} 
	wait 1 
	} 
end
It seems that the mg did no stop firing when I was dead with ur script, now it does.
But there are still some questions:
What is this '140 768'? Is 140 fov in degrees? 768 max distance to player?
Is there anything where I can find information about 'bulletdamage' and 'burstfiresettings'? They're in the 'game modul classes', I know, but they seem to do nothing at the moment...
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

Post by Krane »

Ok, me and Wacko (more Wacko than me...) have this thing working. The problem is that the mg doesn't turn to the player properly. It keeps shooting "sideways"...

Actual script:
main:
level waittill prespawn


level waittill spawn
thread prep_mg
thread activate_mg
end
//***************************************************************
prep_mg:
$mg_origin bind $mg_housing
$mg1 glue $mg_origin

$mg1 setPlayerUsable 0

$mg1 maxYawOffset 10
$mg1 pitchCaps -10 10 0
$mg1 turnspeed 50
$mg1 bulletdamage 1
$mg1 burstFireSettings 0.25 0.5 1 .25

level.mg_enemy="axis"
end

activate_mg:
while (1)
{
for (local.i=1; local.i<=$player.size; local.i++)
{
if (($mg1 cansee $player[local.i] 140 768) && (isAlive $player[local.i]) && $player[local.i].dmteam==level.mg_enemy)
{
$mg_housing rotatey 0
local.origin=$mg1.origin
$mg1 unglue $mg_origin
$mg1.origin=local.origin
$mg1 setaimtarget $player[local.i]
$mg1 startfiring
wait 2
}
else
{
$mg1 stopfiring
$mg1 glue $mg_origin
$mg1 setaimtarget NULL
$mg_housing rotatey 50
}
}
wait 1
}
end

mg_enemy:
$mg_trigger nottriggerable
if (level.mg_enemy=="allies")
{
$mg_switch anim turnon
level.mg_enemy="axis"
$mg playsound click
}
else
{
$mg_switch anim turnoff
level.mg_enemy="allies"
$mg playsound click
}
iprintln level.mg_enemy " is to be killed"
wait .5
$mg_trigger triggerable
end
Is there a way to make the mg stick on the player 100%?
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yes do not glue or bind the mg to anything :)

btw, what is $mg_housing?
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

hehehe, the housing is my bad english and it's a case around the mg that ought to rotate together with the mg, stop when the mg sees an enemy and starts rotating again when the 'target' is dead or not to be seen anymore.

But, Krane will do a new model instead, so we won't need a 'housing' and, errrm the topic is solved so far...

thanks m8
Post Reply