Page 1 of 1

ai to shoot players carrying sniper rifles before other play

Posted: Thu Apr 08, 2004 8:31 am
by small_sumo
I need some code that tells my ai to shoot players (its for mp) who are carrying sniper rifles before shooting others. Its for a mp version of omaha I am doing.

Thanks

Posted: Thu Apr 08, 2004 12:53 pm
by bdbodger
Well JV posted this bit of code that lets you see what weapon the players are useing as thier primary weapon

local.randnum = randomint 1000
self weaponcommand dual targetname ("weap" + local.randnum)
local.weap = $("weap" + local.randnum)
local.weap.targetname = ""

So if you use that something like this

for(local.i=1;local.i <= $player.size;local.i++)
{
local.gun = $player[local.i] waitthread getmygun
if( local.gun == "models/weapons/Kar98sniper.tik" || local.gun == "models/weapons/sprinfield.tik")
{
$myai runto $player[local.i]
end
}
}
end

getmygun:

local.randnum = randomint 1000
self weaponcommand dual targetname ("weap" + local.randnum)
local.weap = $("weap" + local.randnum)
local.weap.targetname = ""

end local.weap.model


but if he finds someone else along the way he will stop and fight unless you disable him until he gets close or something and you need to find a way to keep running those threads when the ai needs a new target to runto .

Posted: Thu Apr 08, 2004 3:28 pm
by lizardkid
if there's a set number of players passing by him before he decides to shoot, then try using a sequence like bdbodger suggested and have him count the players. as so

Code: Select all

level.playersee = 0

for(local.i=1;local.i <= $player.size;local.i++) 
{ 
local.gun = $player[local.i] waitthread getmygun 
if( local.gun == "models/weapons/Kar98sniper.tik" || local.gun == "models/weapons/springfield.tik") 
{ 
$myai runto $player[local.i] 
end 
} 
} 
end 

getmygun: 

local.randnum = randomint 1000 
self weaponcommand dual targetname ("weap" + local.randnum) 
local.weap = $("weap" + local.randnum) 
local.weap.targetname = "" 



level.playersee ++
if (level.playersee == 5)
{
"sight" "8000"
}
end local.weap.model 
so that he counts five players going by, if none of them have a sniper rifle, he fires at the code-determined one. (i believe they use flags for this)

another thing you might be able to do is open up ai.scr and find where it talks about flags, and how the ai determines which one to shoot at and make that one's flags or whatever much higher than the rest.