Attack from Where?
Attack from Where?
Does anyone know any good articles on determining where an NPC should attach from? I've got a very waypoint-dense system and examining every waypoint for suitablity would be rather expensive. . .
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
dont know of any articles but how about
if (attack from this point good)
{
attack()
}
else
{
if(attack better than from last point)
{
move in same direction as last time()
}
else
{
move in some other direction()
}
}
this would require you to determine the suitability of a point for an attack and then a threshold for when the position is good enough for attack.
this way you can even implement different levels of enemies (lower levels only attack when position is 90% good, the higher the level the lower the needed percentage)
if (attack from this point good)
{
attack()
}
else
{
if(attack better than from last point)
{
move in same direction as last time()
}
else
{
move in some other direction()
}
}
this would require you to determine the suitability of a point for an attack and then a threshold for when the position is good enough for attack.
this way you can even implement different levels of enemies (lower levels only attack when position is 90% good, the higher the level the lower the needed percentage)
Well, assessing waypoints is the only thing you can do, but you could do it all in advance.
Say for every waypoint where the target is, you keep a list of waypoints from where an attack would be possible, with some extra information for the requirements.
E.g. if the player is on top of a cliff, there's no point in throwing a grenade from below, but you could use a gun.
The other way around, the grenade approach would be preferable.
You might also want to add some "intelligence" to the waypoint, such as "good for sniping", or "don't linger around here" - simpler to decide when editing a level than when making calculations.
The "don't linger" stuff would still be useful when assaulting with automatic weapons.
Basically at runtime, the NPC would do the following assessment:
1. Where's my target?
2. What's my preferred weapon at this point? (depending on NPC playing style and ammo)
3. What's the best waypoint for this kind of weapon and the target's position?
4. Repeat 2 and 3 for every weapon.
Say for every waypoint where the target is, you keep a list of waypoints from where an attack would be possible, with some extra information for the requirements.
E.g. if the player is on top of a cliff, there's no point in throwing a grenade from below, but you could use a gun.
The other way around, the grenade approach would be preferable.
You might also want to add some "intelligence" to the waypoint, such as "good for sniping", or "don't linger around here" - simpler to decide when editing a level than when making calculations.
The "don't linger" stuff would still be useful when assaulting with automatic weapons.
Basically at runtime, the NPC would do the following assessment:
1. Where's my target?
2. What's my preferred weapon at this point? (depending on NPC playing style and ammo)
3. What's the best waypoint for this kind of weapon and the target's position?
4. Repeat 2 and 3 for every weapon.
yeah, thanks. I do already have a good bit of imbeded tactical information in the waypoints (like bitsets of vixibility data a la Lars Liden's article in AI Game Programming Wisdom) and plan to put in flags for good sniping spots, good places to shoot out from. I was just wondering if anyone knew of other techniques that could eliminate some waypoint analyzing. I guess I'll just proceed as planned and worry about optimization if the determination of good attach points is a major bottleneck
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
do u mean like diablo2? if ya do, then u could use somekind of area checking. store the monster/player/things level ur npc is attacking (such as an area for each waypoint) in a pointer, and pass that pointer to the npc. then, u could have each area have the waypoints as a subclass, and then use that for checking.
of course, u might mean something totally different
of course, u might mean something totally different
This is an fps. If I follow what your saying, I'm basically doing that. The NPC knows where the target is and has access to data from nearby waypoints. I was looking for some algorithm that could save checking every single waypoint in the vicinity for suitablity in order to determine the best position to attack from, but I'm not sure that there is any good way to do that.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
exactly as i was saying. heiarchy of ur class (monster for who to be attacked, npc for attacking, zone being an ISceneNode subclass of the monster)
if(monsterattacking) { //however u check
npc->node->setPosition(monster->zone->getPosition());
}
not sure about how ur enemies and npcs are set up, but either way it shouldnt be hard
keep in mind that its just setting position and checking position, not using switch or a bunch of if statements.
if(monsterattacking) { //however u check
npc->node->setPosition(monster->zone->getPosition());
}
not sure about how ur enemies and npcs are set up, but either way it shouldnt be hard
keep in mind that its just setting position and checking position, not using switch or a bunch of if statements.
blah. It's probably me being dense, but I still don't totally get what ur saying. There are going to be several possible locations that a given npc could attack its enemy from. The problem is determining which spot is the best spot.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars