When I script my ai eg, $mysoldier runto spot
Can I write something so he will randomly choose from a small list of possible spots liek spot1 spot2 spot3, so it would be $mysoldier runto and he picks one of the spots or even patrol one of 2 or 3 patrol paths?
Thanks for any help.
Random goto point for ai
Moderator: Moderators
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
Make several pathnodes connected to other pathnodes to make several paths to follow that end near where they started but don't form a closed circle I mean the last node does not target the first node . Give the first pathnode of all the paths the same targetname such as $ai1_path then try this
while ( isalive $mysoldier)
{
local.path = randomint( $ai1_path.size)+1
$mysoldier exec global/walkto.scr $ai1_path[local.path]
$mysoldier waitill movedone
}
take out the while statements if you don't want it to keep repeating this would be for a patrol path
while ( isalive $mysoldier)
{
local.path = randomint( $ai1_path.size)+1
$mysoldier exec global/walkto.scr $ai1_path[local.path]
$mysoldier waitill movedone
}
take out the while statements if you don't want it to keep repeating this would be for a patrol path
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
If I have 3 paths all with the same name then wouldnt the last node for each point to 3 nodes, seams kinda wierd.
I am sure I have it wrong. Maybe if I explane what I plan to do, its part of my less load bots I want to add to mp maps. I want to have regular bots probably 2 or 4 just to load bombs and the rest will be set up useing the scritps I am working on now. I just want them to run to a destination but to have several alternatives so the guy doesnt run to exactly the same spot each time.
Thanks.
I am most of the way there with this script. I just want to add some variety. Maybe even where I have $mysoldier runto spot I could have $mysoldier thread random thread1 thread2 or thread3 and in those threads I can get him to walk run crawl to whateevr spot. I just need to know how to call in a radom selection, if that makes any sence.
/forum/viewtopic.php?t=5902
I am sure I have it wrong. Maybe if I explane what I plan to do, its part of my less load bots I want to add to mp maps. I want to have regular bots probably 2 or 4 just to load bombs and the rest will be set up useing the scritps I am working on now. I just want them to run to a destination but to have several alternatives so the guy doesnt run to exactly the same spot each time.
Thanks.
I am most of the way there with this script. I just want to add some variety. Maybe even where I have $mysoldier runto spot I could have $mysoldier thread random thread1 thread2 or thread3 and in those threads I can get him to walk run crawl to whateevr spot. I just need to know how to call in a radom selection, if that makes any sence.
/forum/viewtopic.php?t=5902
Like I said in my post the end node does "not" target anything . The waittill movedone will wait untill the ai reaches the last node then the script picks another path to patrol . If you don't loop the thread then each time you play the map you won't know what path he will choose . If the last node does target all the first nodes one of two things will happen you will get an error because it looks for $ai1_path and finds $ai1_path[1] so it can't find the start node or it works in which case that is good isn't it ? but I'dd just do the first method . Another way to make it work is to have different targetname for the end nodes and have them target one of the startnodes from script .
$myend_node1 target $ai1_path[1]
$myend_node2 target $ai1_path[2]
etc
or
while ( isalive $mysoldier)
{
local.i = randomint (3)+1
switch(local.i)
{
case 1:
$mysoldier exec global/walkto.scr $node1
break
case 2:
$mysoldier exec global/walkto.scr $node2
break
case 3:
$mysoldier exec global/walkto.scr $node3
break
}
$mysoldier waitill movedone
}
$myend_node1 target $ai1_path[1]
$myend_node2 target $ai1_path[2]
etc
or
while ( isalive $mysoldier)
{
local.i = randomint (3)+1
switch(local.i)
{
case 1:
$mysoldier exec global/walkto.scr $node1
break
case 2:
$mysoldier exec global/walkto.scr $node2
break
case 3:
$mysoldier exec global/walkto.scr $node3
break
}
$mysoldier waitill movedone
}
