Target The Right Team
Moderator: Moderators
-
Desert Eagle
- Captain
- Posts: 237
- Joined: Mon Jan 13, 2003 1:05 am
- Location: Mapping Bunker
- Contact:
Target The Right Team
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
I just want the tanks to fire at the allies. Any suggestions?
Desert Eagle
- MPowell1944
- Moderator
- Posts: 287
- Joined: Thu Jan 09, 2003 7:06 am
- Location: Woodstock, GA
- Contact:
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:

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
}
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
Last edited by Parts on Sun Apr 13, 2003 11:41 am, edited 1 time in total.
[VS-UK]Capt.Parts[BnHQ]
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!
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.
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.
[VS-UK]Capt.Parts[BnHQ]
-
Desert Eagle
- Captain
- Posts: 237
- Joined: Mon Jan 13, 2003 1:05 am
- Location: Mapping Bunker
- Contact:
Great Thanks
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
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
