Page 1 of 1
Can I spawn an ai and ask him to do a certain task?
Posted: Thu Feb 05, 2004 4:16 am
by small_sumo
Can I spawn an ai and ask him to do a certain task? In my level script? And if so can I get him to stick to that task?
Because they are scripted to change tasks from time to time am I right?
Thanks mate.

Posted: Thu Feb 05, 2004 5:20 pm
by jv_map
Well you can set .notask = 1 to prevent a bot from using the taskhandler to evaluate tasks... however if you just spawn an AI it won't be recognized as a bot so it won't perform any tasks anyway.
Probably the easiest way to go is to just spawn your AI and make it exec the required task script directly, like this:
Code: Select all
local.bot = spawn models/fancybot.tik
local.bot.parm[1] = $snipernode
local.bot.task = sniper // prevents the task script from exiting immediately
local.bot waitthread level.jvbot_tasks_script[local.bot.task]::action
Posted: Fri Feb 06, 2004 6:56 am
by small_sumo
I get this error and also he goes prone so I guess he needs to know he is a bot somehow.
local.gun.runners++ (global/jv_bots/task_machinegun.scr, 145)
local.gun^
^~^~^ Script Error: Cannot cast 'array' to listener
self waitthread level.jvbot_main_script::action_go_to_routed local.gun.node (global/jv_bots/task_machinegun.scr, 147)
self waitthread level.jvbot_main_script::action_go_to_routed local.gun^
This is how my code looks, tell me what you think.
startmymger:
while (level.roundstart != 1)
wait 5
thread sumo_mger
thread sumo_mger2
end
sumo_mger:
while (1)
{
wait 2
local.bot = spawn "human/sumo_german_wehrmact_officer.tik" // origin $sumoaxismg_spotter_spawn.origin
local.bot.parm[1] = $mg_nodenode
local.bot.task = machinegun // prevents the task script from exiting immediately
local.bot waitthread level.jvbot_tasks_script[local.bot.task]::action
while (IsAlive local.bot)
wait 1
}
end
sumo_mger2:
while (1)
{
wait 2
local.bot = spawn "human/sumo_german_wehrmact_officer.tik" // origin $sumoaxismg_spotter_spawn.origin
local.bot.parm[1] = $snipernode
local.bot.task = sniper // prevents the task script from exiting immediately
local.bot waitthread level.jvbot_tasks_script[local.bot.task]::action
while (IsAlive local.bot)
wait 1
}
end
Posted: Fri Feb 06, 2004 6:58 am
by small_sumo
Oh and with the sniper code in as well like above I have errors for each. Sorry to be a bother, I know you dont like em any more.
[BoT]Trogdor has joined the Allies
local.gun.runners++ (global/jv_bots/task_machinegun.scr, 145)
local.gun^
^~^~^ Script Error: Field 'runners' applied to NULL listener
local.gun.runners++ (global/jv_bots/task_machinegun.scr, 145)
local.gun^
^~^~^ Script Error: Field 'runners' applied to NULL listener
self waitthread level.jvbot_main_script::action_go_to_routed local.gun.node (global/jv_bots/task_machinegun.scr, 147)
self waitthread level.jvbot_main_script::action_go_to_routed local.gun^
^~^~^ Script Error: Field 'node' applied to NULL listener
ERROR[jv_mp_ai::action_go_to_routed]: Location is NIL, task: machinegun
if(local.sniper_location.sniperenroute != 1) (global/jv_bots/task_sniper.scr, 127)
if(local.sniper_location^
^~^~^ Script Error: Field 'sniperenroute' applied to NULL listener
local.sniper_location.sniperenroute = 1 (global/jv_bots/task_sniper.scr, 129)
local.sniper_location^
^~^~^ Script Error: Field 'sniperenroute' applied to NULL listener
local.sniper_location.sniper = self (global/jv_bots/task_sniper.scr, 130)
local.sniper_location^
^~^~^ Script Error: Field 'sniper' applied to NULL listener
if(local.location.routelist != NIL && level.routelist[local.location.routelist].size > 0) (global/jv_bots/jv_mp_ai.scr, 896)
if(local.location^
^~^~^ Script Error: Field 'routelist' applied to NULL listener
else if(local.location.route != NIL) (global/jv_bots/jv_mp_ai.scr, 901)
else if(local.location^
^~^~^ Script Error: Field 'route' applied to NULL listener
local.playergunner = local.gun waitthread level.jvbot_modscript[libmachinegun]::mgplayercheck (global/jv_bots/task_machinegun.scr, 162)
local.playergunner = local.gun ^
^~^~^ Script Error: command 'waitthread' applied to NULL listener
if(local.gun.hasgunner == 0 && local.playergunner == -1) (global/jv_bots/task_machinegun.scr, 164)
if(local.gun^
^~^~^ Script Error: Field 'hasgunner' applied to NULL listener
else if(local.gun.hasspotter == 0 && local.gun.spotter_allowed == 1 && ((local.playergunner == -1 && local.gun.gunner.dmteam == self.dmteam) || (local.playergunner != -1 && local.playergunner.dmteam == self.dmteam))) (global/jv_bots/task_machinegun.scr, 180)
else if(local.gun^
^~^~^ Script Error: Field 'hasspotter' applied to NULL listener
local.sniper_location.hassniper = 1 (global/jv_bots/task_sniper.scr, 136)
local.sniper_location^
^~^~^ Script Error: Field 'hassniper' applied to NULL listener
if(local.sniper_location.target != "") (global/jv_bots/task_sniper.scr, 137)
if(local.sniper_location^
^~^~^ Script Error: Field 'target' applied to NULL listener
self aimat local.sniper_location.target (global/jv_bots/task_sniper.scr, 138)
self aimat local.sniper_location^
^~^~^ Script Error: Field 'target' applied to NULL listener
self aimat local.sniper_location.target (global/jv_bots/task_sniper.scr, 138)
self ^
^~^~^ Script Error: Cannot cast 'NIL' to listener
LOCALIZATION ERROR: 'Allies: 0 / 5 / 5' does not have a localization entry
local.gun.runners-- (global/jv_bots/task_machinegun.scr, 211)
local.gun^
^~^~^ Script Error: Field 'runners' applied to NULL listener
local.gun.runners-- (global/jv_bots/task_machinegun.scr, 211)
local.gun^
^~^~^ Script Error: Field 'runners' applied to NULL listener
[BoT]---Coublacka--- has joined the Axis
LOCALIZATION ERROR: 'Press Use(e) to follow a player.' does not have a localization entry
if(local.sniper_location.nocrouch == NIL) (global/jv_bots/task_sniper.scr, 141)
if(local.sniper_location^
^~^~^ Script Error: Field 'nocrouch' applied to NULL listener
if(local.sniper_location.target == "" || sighttrace (self.origin + (0 0 48)) local.sniper_location.target.origin) (global/jv_bots/task_sniper.scr, 143)
if(local.sniper_location^
^~^~^ Script Error: Field 'target' applied to NULL listener
if(local.sniper_location.target == "" || sighttrace (self.origin + (0 0 48)) local.sniper_location.target.origin) (global/jv_bots/task_sniper.scr, 143)
if(local.sniper_location.target == "" || sighttrace (self.origin + (0 0 48)) local.sniper_location^
^~^~^ Script Error: Field 'target' applied to NULL listener
if(local.sniper_location.target == "" || sighttrace (self.origin + (0 0 48)) local.sniper_location.target.origin) (global/jv_bots/task_sniper.scr, 143)
if(local.sniper_location.target == "" || sighttrace (self.origin + (0 0 48)) local.sniper_location.target^
^~^~^ Script Error: Cannot cast 'NIL' to listener
if(local.sniper_location.target == "" || sighttrace (self.origin + (0 0 48)) local.sniper_location.target.origin) (global/jv_bots/task_sniper.scr, 143)
if(local.sniper_location.target == "" || ^
^~^~^ Script Error: Cannot cast 'NIL' to vector
Posted: Fri Feb 06, 2004 12:17 pm
by jv_map
Do the $mg_nodenode and $snipernode entities exist? (that is a rhetorical question

)
Posted: Sat Feb 07, 2004 1:58 am
by small_sumo
Yes they do, well as per your instuctions the sniper node exits targetname sniper and the mg node exists but with a targetname of mg_node thats why I called it mg_nodenode so it would be in line with the other peice of code. Anyway this still leaves me hangin in the wind and I am only online once a week now on thursdays. So if between now and then and you have a look at the map I sent you the tutorial one, if you would please add some code to the second one that has bots spawning that have just one task or a shortlist of available tasks for them, eg sniper camper.
This tutorial I am going to put a lot of work into and I hope that lots of guys who have had hard times making simple obj maps will jump at the chance to do it easily with your code your bots. As you know and I will point this out jv_bot01 is exellent for making obj maps without bots.
Anyway thanks for your help and I hope you help me get past this one.
Bye
Posted: Mon Feb 16, 2004 5:49 am
by small_sumo
Are ya there mate? Busy with mw I guess.
Posted: Mon Feb 16, 2004 4:48 pm
by jv_map
Yeah I'm here but still busy figuring out this sentence:
Yes they do, well as per your instuctions the sniper node exits targetname sniper and the mg node exists but with a targetname of mg_node thats why I called it mg_nodenode so it would be in line with the other peice of code.
I've only understood about 20% of it by now

Posted: Wed Feb 18, 2004 5:36 am
by small_sumo
Well ok thats ok I am hard to understand, sorry about that. So anyway I did this code and it didnt work. What do you think?
startmymger:
while (level.roundstart != 1)
wait 5
thread sumo_mger
thread sumo_mger2
end
sumo_mger:
while (1)
{
wait 2
local.bot = spawn "human/sumo_german_wehrmact_officer.tik" // origin $sumoaxismg_spotter_spawn.origin
local.bot.parm[1] = $mg_nodenode
local.bot.task = machinegun // prevents the task script from exiting immediately
local.bot waitthread level.jvbot_tasks_script[local.bot.task]::action
while (IsAlive local.bot)
wait 1
}
end
sumo_mger2:
while (1)
{
wait 2
local.bot = spawn "human/sumo_german_wehrmact_officer.tik" // origin $sumoaxismg_spotter_spawn.origin
local.bot.parm[1] = $snipernode
local.bot.task = sniper // prevents the task script from exiting immediately
local.bot waitthread level.jvbot_tasks_script[local.bot.task]::action
while (IsAlive local.bot)
wait 1
}
end
Posted: Wed Feb 18, 2004 8:23 am
by jv_map
Why did you comment-out the origin part? (for the spawns)
Posted: Wed Feb 18, 2004 2:37 pm
by small_sumo
Oops sorry about that, I commented out the origins on my second try (after it didnt work) to see if cos you called them bots in the thread they might need to use the standard bot spawns, that didnt work either.
Its like the spawned ai has missed some bot setup things and doesnt know he is a bot?
Anyway I would love for this to work, it would make my bot maps much more interesting.
Thanks mate.

Posted: Wed Feb 18, 2004 5:23 pm
by jv_map
Don't either of the bots work? Do you get any error messages?
Posted: Thu Feb 19, 2004 12:33 am
by small_sumo
Errors are in the 4th posting for this thread, youll see some for the sniper and some relating to the mg guy. You should try it on one of your bot maps.
