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
ai to shoot players carrying sniper rifles before other play
Moderator: Moderators
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
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 .
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 .
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
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.
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
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.
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006

