Spawning Paths, and Standing Still
Moderator: Moderators
Spawning Paths, and Standing Still
I've got two questions, again. About Allied Assault, of course.
THE BRIEF QUESTION 1 - Spawning Paths
I'd like to make allies follow along a path. You know, friendtype 0. Through some quick, easy study, I think that first a path must exist, then the allies must simply be told to runto the path in order to follow along it. I've also looked at paths, and what seems to happen is the bot is told to runto the first node in a path, then that node targets another node, and each node just targets the next node on the path.
How do I spawn a pathnode (through scripting) to make a path for friendly AI? I've used the search feature, but all of the things I found seemed to be for JV bots.
THE LONG QUESTION 2 - Standing Still
I used to think I had this question figured out, but I don't.
All of my AI keep standing still and aiming at enemies they can't see. It's not so bad when enemies do it, because the player usually moves around the corner and they're ready to fight. However, friendly AI do it, too. One friendly AI will spot a target (even though they won't be able to shoot at them most of the time) and all of the friendly AI across the map will apparently spot the same target, because every single friendly AI will be aiming at the same thing, standing perfectly still and not doing anything. After quite a while (sometimes it seems as much as a minute), they'll decide that they can't see the target and begin moving again, but they'll usually just begin the same behavior again when they "see" another target.
How do I get the AI to not stand perfectly still when they think they see something, even if they can't see it? Or, how do I get the AI to not share targets like I described above? As in, to prevent every single AI of a certain team from aiming at the same unseeable target?
Sometimes, they'll all aim at one unseeable target, then aim at another and switch back and forth. These enemies they're aiming at are really where they're looking, but they can't possibly hit the enemy, so there's no point in them aiming like they do.
THE BRIEF QUESTION 1 - Spawning Paths
I'd like to make allies follow along a path. You know, friendtype 0. Through some quick, easy study, I think that first a path must exist, then the allies must simply be told to runto the path in order to follow along it. I've also looked at paths, and what seems to happen is the bot is told to runto the first node in a path, then that node targets another node, and each node just targets the next node on the path.
How do I spawn a pathnode (through scripting) to make a path for friendly AI? I've used the search feature, but all of the things I found seemed to be for JV bots.
THE LONG QUESTION 2 - Standing Still
I used to think I had this question figured out, but I don't.
All of my AI keep standing still and aiming at enemies they can't see. It's not so bad when enemies do it, because the player usually moves around the corner and they're ready to fight. However, friendly AI do it, too. One friendly AI will spot a target (even though they won't be able to shoot at them most of the time) and all of the friendly AI across the map will apparently spot the same target, because every single friendly AI will be aiming at the same thing, standing perfectly still and not doing anything. After quite a while (sometimes it seems as much as a minute), they'll decide that they can't see the target and begin moving again, but they'll usually just begin the same behavior again when they "see" another target.
How do I get the AI to not stand perfectly still when they think they see something, even if they can't see it? Or, how do I get the AI to not share targets like I described above? As in, to prevent every single AI of a certain team from aiming at the same unseeable target?
Sometimes, they'll all aim at one unseeable target, then aim at another and switch back and forth. These enemies they're aiming at are really where they're looking, but they can't possibly hit the enemy, so there's no point in them aiming like they do.
i'll start with question 2.
it's hardcoded, and the only way to change it would to ultimately write your own AI for them, however i think there's a solution with setting sight and hearing to 0, and checking an enemy's thinkstate (in a radius) and turning on their senses by checking what the enemy knows. it's clumsy, since your guys will never get the drop on an enemy, but i know i saw it somewhere.
as for #1, it's fairly simple. just go around the points of your map you wish to put your path, get the coordinates, and out of that do something like this.
the array holds all the coordinates, fill in the "x y z"'s with the actual coordinates.
i'm not ENTIRELY sure that that will work because i dont know it'll spawn a node every time the local.lastPath is referenced, or if that variable holds the actual reference to the object. rookie or jv will know.
regardless, try it out.
it's hardcoded, and the only way to change it would to ultimately write your own AI for them, however i think there's a solution with setting sight and hearing to 0, and checking an enemy's thinkstate (in a radius) and turning on their senses by checking what the enemy knows. it's clumsy, since your guys will never get the drop on an enemy, but i know i saw it somewhere.
as for #1, it's fairly simple. just go around the points of your map you wish to put your path, get the coordinates, and out of that do something like this.
the array holds all the coordinates, fill in the "x y z"'s with the actual coordinates.
Code: Select all
makePath:
local.coords = {"x y z", "x y z", "x y z"}
local.lastPath = spawn info_pathnode "origin" "local.coords[0]"
for(local.i = 1; local.i < local.coords.length; local.i++)
{
local.newPath = spawn info_pathnode "origin" "local.coords[local.i]"
local.lastPath.target = local.newPath.targetname
local.lastPath = local.newPath
}
endregardless, try it out.
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
You can download .pth file for some of the mp map or make your own . My site has a script called bodger_nodes . It is a script that when run spawns coronas where ever you run in the map . By typeing writescript 1 into the console when you are done it will print a script out to qconsole.log . You must of course have logging turned on . You then copy the writeout to the top of your level script . That will create a .pth file and when that happens ai can run and shoot but not the stock ai because a file called new_generic_human.tik that defines the what animations the ai use would have to be modded for ai to work in mp . Another way is to use JVbots and spawn a bot . they will work in mp . Bots are modded ai modded to work in mp . The best thing to do would be to learn how to make a bot map but even if you don't the ai can be used the same way normal ai are used . Clients must have JVbot for the mod to work .
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
Lizard and Bodger pretty much answered the questions. 
@Lizard: it's pretty much OK.
Only little changes are needed:
Class (entities, listeners) script variables actually contain the pointer to the class instance, so you only modify the reference, not the actual object.
@Lizard: it's pretty much OK.
Code: Select all
makePath:
local.coords = "x y z"::"x y z"::"x y z" // C style arrays don't work in MoHAA
local.lastPath = spawn info_pathnode "origin" local.coords[1] "targetname" "pathnode1" // they need an explicit targetname; array indexing starts at 1
for(local.i = 2; local.i <= local.coords.length; local.i++)
{
local.newPath = spawn info_pathnode "origin" local.coords[local.i] "targetname" ("pathnode" + local.i)
local.lastPath.target = local.newPath.targetname
local.lastPath = local.newPath
}
end... Wow. I'm really sorry, but you guys lost me. I'm not very big on real scripting.
I don't like to be annoying about everything. It's really awesome how there's always someone willing to be helpful, here. I've only been able to be helpful to one dude, and I'm not sure if my help was fully appreciated. I feel like a mooch.
Anyway, I guess I could keep playing around with the AI so that they don't stand still like idiots. How could I check the enemy's thinkstate like that?
bdbodger, were you talking about making stock AI follow a path? Because I don't want to make a path for JV bots, just the normal AI in single player.
And, uh...
All righty, I have a false scenario I think would help. Let's say I have these four coordinates making up the path:
1.00 2.00 0.00
2.00 3.00 0.00
3.00 4.00 0.00
4.00 5.00 0.00
Then I have
$jerk
that needs to follow the path.
How would I make a path using those coordinates, then get $jerk to follow it?
I don't like to be annoying about everything. It's really awesome how there's always someone willing to be helpful, here. I've only been able to be helpful to one dude, and I'm not sure if my help was fully appreciated. I feel like a mooch.
Anyway, I guess I could keep playing around with the AI so that they don't stand still like idiots. How could I check the enemy's thinkstate like that?
bdbodger, were you talking about making stock AI follow a path? Because I don't want to make a path for JV bots, just the normal AI in single player.
And, uh...
Wow. I think I know where you guys are going, but I'm not sure how to, uh... Make that.makePath:
local.coords = "x y z"::"x y z"::"x y z" // C style arrays don't work in MoHAA
local.lastPath = spawn info_pathnode "origin" local.coords[1] "targetname" "pathnode1" // they need an explicit targetname; array indexing starts at 1
for(local.i = 2; local.i <= local.coords.length; local.i++)
{
local.newPath = spawn info_pathnode "origin" local.coords[local.i] "targetname" ("pathnode" + local.i)
local.lastPath.target = local.newPath.targetname
local.lastPath = local.newPath
}
end
All righty, I have a false scenario I think would help. Let's say I have these four coordinates making up the path:
1.00 2.00 0.00
2.00 3.00 0.00
3.00 4.00 0.00
4.00 5.00 0.00
Then I have
$jerk
that needs to follow the path.
How would I make a path using those coordinates, then get $jerk to follow it?
ah, my MOH scripting isnt as good as it used to be, too used to Java and C i guess, ty rook. 
in any case, for your example, your script would look like this.
just modify that as much as you need for each pathnode, you'll probably have more coords than 4, so after that just put ::"x y z" and continue. not sure if that made sense but i think you'll get it 
aaah you're not annoying, nor a mooch. you can't really be a leech in an open-handed community
thinkstate is just another field, such as targetname or gun, but it'll be useless without the whole algorthm... i'll try and dig it up, i KNOW i saw something that did that.
the AI follow nodes in a "linked list" style, so anything with a field "target" that points to another node is linked together. think of it like a chain, first node, second gets welded on, third welded to that, and so on. thus why you can make a continual, everlasting path out of any number of nodes.
in any case, for your example, your script would look like this.
Code: Select all
main:
// everything normal before end. precache, spawn, and prespawn.
thread makePath
$jerk runto $pathnode1
end
makePath:
local.coords = "1.00 2.00 0.00"::"2.00 3.00 0.00"::"3.00 4.00 0.00"::" 4.00 5.00 0.00"
local.lastPath = spawn info_pathnode "origin" local.coords[1] "targetname" "pathnode1" for(local.i = 2; local.i <= local.coords.length; local.i++)
{
local.newPath = spawn info_pathnode "origin" local.coords[local.i] "targetname" ("pathnode" + local.i)
local.lastPath.target = local.newPath.targetname
local.lastPath = local.newPath
}
endaaah you're not annoying, nor a mooch. you can't really be a leech in an open-handed community
thinkstate is just another field, such as targetname or gun, but it'll be useless without the whole algorthm... i'll try and dig it up, i KNOW i saw something that did that.
the AI follow nodes in a "linked list" style, so anything with a field "target" that points to another node is linked together. think of it like a chain, first node, second gets welded on, third welded to that, and so on. thus why you can make a continual, everlasting path out of any number of nodes.
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
I see most of the questions have already been answered, and you might be the only one that doesn't like to be annoying about everything
Anyway, just wanted to add this: If you just want your AI to move from A to B, you don't have to make a path sequence with targets etc. Instead, if your map is covered with info_pathnodes (each singleplayer map is), you can just use the runto B or walkto B commands and the game will automatically find the shortest path from the AI's current position to B, and make it follow it.
Anyway, just wanted to add this: If you just want your AI to move from A to B, you don't have to make a path sequence with targets etc. Instead, if your map is covered with info_pathnodes (each singleplayer map is), you can just use the runto B or walkto B commands and the game will automatically find the shortest path from the AI's current position to B, and make it follow it.
Well, thanks, dudes! I'll try out the pathnode spawn thing and get back to you.
JV, if I make the friendly AI runto or walkto a place, will they still lead (or follow) the player like normal friendtype 0s, or will they literally just take off?
JV, if I make the friendly AI runto or walkto a place, will they still lead (or follow) the player like normal friendtype 0s, or will they literally just take off?
Last edited by Broadus on Tue May 02, 2006 6:04 pm, edited 1 time in total.
It'd be nice if, just once, a plan would come together on the first try.
I didn't say anything in this topic for a while, because I put the use for paths on hold. Now that I've tried to make a path, it breaks the script for the map I try to use it on.
I put this at the end of the script of m5l2a to test out if the path would work (which it doesn't):
makePath:
local.coords = "1615.70 196.08 174.36"::"-10.97 868.78 238.13"
local.lastPath = spawn info_pathnode "origin" local.coords[1] "targetname" "gotomeplz" for(local.i = 2; local.i <= local.coords.length; local.i++)
{
local.newPath = spawn info_pathnode "origin" local.coords[local.i] "targetname" ("pathnode" + local.i)
local.lastPath.target = local.newPath.targetname
local.lastPath = local.newPath
}
end
I'm unable to make a path without messing up the map!
I didn't say anything in this topic for a while, because I put the use for paths on hold. Now that I've tried to make a path, it breaks the script for the map I try to use it on.
I put this at the end of the script of m5l2a to test out if the path would work (which it doesn't):
makePath:
local.coords = "1615.70 196.08 174.36"::"-10.97 868.78 238.13"
local.lastPath = spawn info_pathnode "origin" local.coords[1] "targetname" "gotomeplz" for(local.i = 2; local.i <= local.coords.length; local.i++)
{
local.newPath = spawn info_pathnode "origin" local.coords[local.i] "targetname" ("pathnode" + local.i)
local.lastPath.target = local.newPath.targetname
local.lastPath = local.newPath
}
end
I'm unable to make a path without messing up the map!

MOHAA ends statements at the end of a line in Notepad, in other words if you have two statements on one line you'll get either an error or strange stuff.
something like
will generate an error, MOH wasn't expecting two statements on one line.
which... it looks like the problem here is... everything looks completely right except for...
being all on the same line.
not sure if that's just a thing with the forums or if thats actually whats in script, if its in script there's your problem.
otherwise what's the console saying?
something like
Code: Select all
iprintln "hi" iprintln "bye"which... it looks like the problem here is... everything looks completely right except for...
Code: Select all
local.lastPath = spawn info_pathnode "origin" local.coords[1] "targetname" "gotomeplz" for(local.i = 2; local.i <= local.coords.length; local.i++)not sure if that's just a thing with the forums or if thats actually whats in script, if its in script there's your problem.
otherwise what's the console saying?
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
Well, I put those on different lines, and that just flat-out crashed the game.local.lastPath = spawn info_pathnode "origin" local.coords[1] "targetname" "gotomeplz" for(local.i = 2; local.i <= local.coords.length; local.i++)
When the map loads (but the script is broken), there aren't any console errors at all. The script simply doesn't work.




