|
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn),
581
guests, and 0
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
AI/Player Combat Zones, AI guru input needed :)
#317222
03/30/10 04:26
03/30/10 04:26
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
Hey everyone, I have kind of a complicated problem, if you could take a read and see if you can help I'd appreciate it.
My game can technically handle up to 60 of my AIs, however having them all moving and shooting at the same time lowers the frame rate drastically. So I'm going to implement a way for AI's to be created depending on the player's progression in the level. Each "combat zone" would spawn it's enemy units whenever the player entered that zone. This way I could spawn only the relevant enemies, and technically have over 60 units in the progression of the level.
So the first idea is to place pre-defined trigger gateways such as doors. These doors would open when the current zone is cleared, and the next zone would populate with enemies. Ai's would never be able to pathfind to any node that is locked out. This method is fine, up until how my AI's can flank their target.
When an AI chooses to flank a target, it wont necessarily move to the closest node that it's target is next to. It can choose to move to a node that is to the left or right of the target. So this can put the AI's final destination to a node that is on the other side of a wall, and then proceed to move towards the target after reaching the flank node. The flanking behavior works well because it doesnt use line of sight to the target, and it breaks up the combat in areas with alot of cover.
However with this flanking behavior, and the above combat zones, the zone trigger entities can work against the AI. Because no node will know what zone it is in, (unless i go into every node and assign a zone to it), an AI can choose to flank to a node that should be locked out, but will continue to do so. I need a way to broadly assign nodes their designated zones.
I thought about using passable map entities, assigning them a zone number, duplicating them to the shape of the zone I wanted, then letting the nodes do an intial in_passable check to see if its inside a zone, and then assign itself to the zone of the passable map entity.
This is a fine brute force way of assigning multiple nodes a zone right inside wed other than going into every node, however I already have alot of clutter in WED. AIs, scene objects, wed blocks, path nodes, terrain, and then adding another array of map entities could get very annoying to work with inside wed.
My next idea was to use WED's path object to define a faux polygon shape, and then do a "point vs polygon" collision/inside polygon function to assign a node a zone. This is the most elegant way i can think of, however its the most complicated due to polygon math. I can explain this more in depth if youd like.
/exhale
|
|
|
Re: AI/Player Combat Zones, AI guru input needed :)
[Re: jumpman]
#317224
03/30/10 07:34
03/30/10 07:34
|
Joined: Feb 2009
Posts: 2,154
Damocles_
Expert
|
Expert
Joined: Feb 2009
Posts: 2,154
|
The easiest way is to activate and deactivate the AIs depending on a distance value.
With these zones you will have a problem at the boundary of the zone. Where the AI might instantly shut down at the "door".
Just make the AI "activate" (able to act, and visible to other AIs) at like 2000 quants, and deactivate if further than 2500 quants. In deactive mode, the AI just checks the distance to the player every second or so, and is else just a passive model with "idle" animation.
You can also dynamically tune the game by adjusting the Distance values then. More flexible than a zone system, and much less manual work.
To avoid the player to "pull out" single AIs from a group, temporarily increase the activate distance by 300 quants or so, when a AI newly activates. (or let it activate other AIs close by)
-----
If you really want to use the zone approach, you can dynamically determine if a node is in a zone.
Use a "fill" algorythm for that. Block all "door nodes" out, manually assign a zonenumber to one node in the zone, and let it look for all connected nodes. Then assign them the same zone number. (its also less manual work, and more flexible)
|
|
|
Re: AI/Player Combat Zones, AI guru input needed :)
[Re: jumpman]
#317392
03/31/10 09:29
03/31/10 09:29
|
Joined: Nov 2008
Posts: 946
the_clown
User
|
User
Joined: Nov 2008
Posts: 946
|
I'd rather define zones using corner points; let's say, u want a zone of 500*500 quants, u place a point in the upper left corner (from a top view), and one in the lower right corner; Both corner points get an ID, for example in a skill, and then, in code, write their positions in, say, a struct field that can be accessed by all entities to read out the zones corners (given the case u want rectangles as zones). This system would define clear spaces that the AI can access. Dunno if this is a clear explanation though; I tried my best. 
|
|
|
Re: AI/Player Combat Zones, AI guru input needed :)
[Re: jumpman]
#317759
04/02/10 12:35
04/02/10 12:35
|
Joined: Nov 2008
Posts: 946
the_clown
User
|
User
Joined: Nov 2008
Posts: 946
|
hey the_clown
I would love to use the corner point method, but that limits the zones to be square shaped correct?
Well, yes. But it would also allow zones that dont consist of rooms though.
|
|
|
|