ai to shoot players carrying sniper rifles before other play

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
small_sumo
Lieutenant General
Posts: 953
Joined: Mon Jul 01, 2002 4:17 pm
Contact:

ai to shoot players carrying sniper rifles before other play

Post 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
Image

www.smallsumo.tk

Yeah Truth above Honor Man ;)
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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 .
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Post Reply