Page 1 of 1

Target The Right Team

Posted: Sun Apr 13, 2003 2:02 am
by Desert Eagle
I can get my "ai" tanks running and firing in mulitplayer map. Only problem is they target all players. I have been pulling my hair out.

I just want the tanks to fire at the allies. Any suggestions?


Desert Eagle

Posted: Sun Apr 13, 2003 2:20 am
by MPowell1944
Ask JV. This could be a similar setup that he used with his bots recognizing which team the player was on.

Posted: Sun Apr 13, 2003 7:42 am
by jv_map
Actually I have also a multiplayer tank & halftrack & flak script that attacks the right players ;).

Just do a $player[number].dmteam check.

dmteam can be:
allies
axis
spectator
freeforall

Example:

Code: Select all

if(local.player.dmteam == allies)
{
    local.dummy = spawn script_origin
    local.dummy attach local.player "Bip01 Head"
    $tiger.turret setaimtarget local.dummy
    $tiger.turret waittill ontarget
    $tiger.turret anim fire // blow his head off
    wait 0.5
    $tiger.turret setaimtarget NULL
    local.dummy remove
}
:)

Posted: Sun Apr 13, 2003 7:56 am
by mohaa_rox
Cool, you're da man! But too bad MoH has no gore, other wise byebye to his head.

Posted: Sun Apr 13, 2003 11:39 am
by Parts
The script below I wrote to only target players fairly near by that the tank can actually see. Otherwise you'll find the tank firing at walls because it knows there is a player behind it:

Code: Select all

//************************************** 
//*** this will:
//***    find an player near by to shoot at!
// if local.team = 1 then shoot at axis
// if local.team = 2 then shoot at allies

start local.team:


if (local.team == 1)
{
	println ("looking for Axis target")
	
	//look for first player in range and shoot at them!
	
	for (self.i = 1; self.i <= 32; self.i++)
	{
		if ($player[self.i])
		{
			if ($player[self.i].dmteam == axis)
			{
				if (vector_length (self.origin - $player[self.i].origin) > 200)
				{
					if (vector_length (self.origin - $player[self.i].origin) < 3000)
					{
						if (self cansee $player[self.i])
						{
							println ("targeting player #" + self.i)
							self.gun setAimTarget $player[self.i]
							self.gun waittill ontarget
							self.gun anim fire
							goto breakloop
						}
						else
						{
							println "can't see him!"
						}
					}
				}
			}		
		}
	}
	println "no target found" 
}
else
{
	println ("looking for Allied target")
	
	//look for first player in range and shoot at them!
	
	for (self.i = 1; self.i <= 32; self.i++)
	{
		if ($player[self.i])
		{
			if ($player[self.i].dmteam == allies)
			{
				if (vector_length (self.origin - $player[self.i].origin) > 200)
				{
					if (vector_length (self.origin - $player[self.i].origin) < 3000)
					{
						if (self cansee $player[self.i])
						{
							println ("targeting player #" + self.i)
							self.gun setAimTarget $player[self.i]
							self.gun waittill ontarget
							self.gun anim fire
							goto breakloop
						}
						else
						{
							println "can't see him!"
						}
					}
				}
			}		
		}
	}
	println "no target found" 
}


	
breakloop:

end

Posted: Sun Apr 13, 2003 12:20 pm
by mohaa_rox
Awesome! Does it work?

Posted: Sun Apr 13, 2003 12:38 pm
by jv_map
I'm afraid you'll have to use sighttrace instead of cansee :?

Also a little tip: use $player.size instead of 32.

Posted: Sun Apr 13, 2003 4:26 pm
by Parts
ahh ok will change. Certainly works as is however the changes jv-map suggest will make it better

Posted: Sun Apr 13, 2003 4:49 pm
by jv_map
cansee is only supposed to work for AI actors :shock:

Posted: Sun Apr 13, 2003 6:03 pm
by Parts
it is definitly working at present to good effect on the vs-uk server. You should see the players running for cover as the tank cannon turns to shoot them! :twisted:

However looping through an array of 32 players is not hte best way, .size is a much better idea.

NOTE all these mods I have done are for spearhead.

Posted: Sun Apr 13, 2003 7:40 pm
by jv_map
Parts wrote:NOTE all these mods I have done are for spearhead.
That could explain it.

Great Thanks

Posted: Sun Apr 13, 2003 11:18 pm
by Desert Eagle
Thanks for the input everyone. It now seems to be working right. The axis can now be the ground support for the tanks without being shot at by the tanks. Also the allies now have a reason for at least one of them to have a bazooka.

Now tanks moving, stopping and firing at allied players. This is great!

I have been trying hard to give my Spearhead, Roundbased/TOW map that feel like your really there, like in the SIngle Player missions.

So Far:

2 axis tanks running their course and firing at allied players
By using Projectile Genators in maps, giving the impression of a large firefight
Walls that explode apart like in Malta
Allied Assault Gliders the allies ride into battle
Allied portable airborne artillery peice that I built that is driven out via a jeep out of Glider.
Smoke, Fire, Ruined Buidlings
Firing Battery of Flak88 for the axis to shoot down allied airstrikes carried out by p-47 Thunderbolts.

Kinda a Destoyred Village, Small City, St Renan and Stalingard all in type of map.

Whats left:
The scripting nightmare
A little more Manvis
TOW objectives and triggers