Back to the Korax Forum Archives


Forum

KRPG monster AI

Fri, 10 Jul 2009 19:41:05

Crimson Wizard

There was AI thread one time here but it is already 2 years old (my, my, how fast time goes <!-- s:roll: --><img src="{SMILIES_PATH}/orcpascompris.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: --> ), and used to discuss both KA bots and KRPG monsters. I am going to work more intensively on SE AI now, and I think I mention what things are already there and what I will try to implement; so if anyone has extra ideas, questions or maybe disagreements, please speak out. At the moment advanced monster AI is based on two "whales": better navigation and tasks. Navigation's backbone is a classic node graph: a collection of nodes, invisible things similar to Map Spots, and links between them. Earlier I had problem with this mainly because building route for monster took too long; but now vavoom executes progs much faster, plus I made some optimization, and that is not a problem anymore (at least on test maps <!-- s;) --><img src="{SMILIES_PATH}/orc9.gif" alt=";)" title="Wink" /><!-- s;) --> ). I am going to enhance this even more by using Priority Paths, which are constructed on level start and connect special "checkpoints" not by simple links but by paths of many nodes; they will help monster buid the correct way much faster. Another optimization here which was already implemented is choosing a "task leader". This allows monster quickly scan around and check if some other monster have same target and already have determined the route; thus any number of monsters may follow this "leader" until they have their target in reach. Tasks, basically speaking, allow to give monster orders, either from other parts of code, or from map script. There were such tasks implemented as Attack, Move To, Stand Still, etc. Each task have a priority, multiple tasks can be stored at once in the sorted queue, which makes it possible to create sequence of orders (like goto somewhere then do something else). I was also planning to add Task Packages feature; a sequence of orders that is predefined and can be applied to any monster at any (or maybe rather some particular) time. (Silly example: every X minutes a ettin goes to chapel and rings the bell <!-- s:P --><img src="{SMILIES_PATH}/orc4.gif" alt=":P" title="Razz" /><!-- s:P --> ) Aside from Tasks, there is now such thing as Threat Reaction, which as well can be set in map script. Threat reaction makes monster react on any threat differently from standart behavior and do not switch from current action/task. It may be "None" (do not react at all), "When health is low", "If damaged by threat source", "If seeing threat" or "If detected threat" (last case implies that monster can not only see, but also hear possible target). For two last ones a Threat Vicinity can be set up to make monster ignore enemy which is beyond some distance; this may come handy if you want monster not switch to attacking unless player is really near. Apart from optimizing the code, which is what I am currently doing, I want to add various techniques, like intrinsic abilities to strafe, backpedal, dodge, make other evasive actions (flyers may drop-down quickly to evade a player shot), an ability to aim better, etc. An anticipation capability: monsters are allowed (or sometimes allowed) to predict some or all of the player's actions (shooting, at first hand) and make evasive action not randomly or as a reaction to hit, but at right time; imagine Centaurs hide under shield BEFORE player strikes. Monster jumping: this may be an interesting thing, but needs to be thought out. Certain monsters may have special "Jump" state added with corresponding animation, or we may just use common walk/stand animation for this; or there could be "standart" jump capability and special different movement only for certain monsters. I was also thinking about tactical ability. Making a special move is one thing, but knowing when and which one is another. Perhaps I will be able to make monsters walk around player to attack from different directions. Next thing which is planned by me is Group Tactics. Assuming there's a group of creatures of similar kind (or of the kinds that may have tactical relationship), they may act more as a team when attacking player, like trying to attack him from different directions, or making tougher monsters cover weaker ones during approach.
Sat, 11 Jul 2009 01:00:52

Firebrand

This all sounds very interesting and might add some interesting things for monsters and NPCs (which are basically neutral monsters <!-- s:P --><img src="{SMILIES_PATH}/orc4.gif" alt=":P" title="Razz" /><!-- s:P -->) for scripts and other things <!-- s:) --><img src="{SMILIES_PATH}/orc2.gif" alt=":)" title="Smile" /><!-- s:) -->. I've been basing my features designs in Nevewinter Nights game (which I played some time ago and I like a lot <!-- s:D --><img src="{SMILIES_PATH}/orc6.gif" alt=":D" title="Very Happy" /><!-- s:D -->), the inventory for monsters and players alike comes from there, I would like to make monsters able to interact in almost every way the player can with the world (like to make monsters able to use switches or activate scripts if they want to) and with other actors/monsters in game. I know that we are limited by the engine, but I also think that we can overcome certain limits and create some really interesting interaction between actors in the game <!-- s8) --><img src="{SMILIES_PATH}/orccool.gif" alt="8)" title="Cool" /><!-- s8) --> .
Sat, 11 Jul 2009 02:01:07

Crimson Wizard

[quote="Firebrand":3ru4ocdm]like to make monsters able to use switches It should be already possible in latest internal build, although I never tested this myself. There's action special ACTSPEC_PW_TryUse (special id is 1000, 1 argument : thing's TID). Unfortunately I forgot to add such special into krpg.acs, but that's easy to do, all you need (if you want to test it) is to invent a name for this special. This should 'use' both lines and things (I've also planned 2 extra ones to use only lines or things separately). You have to be sure monster stands right before switch when this action special is called; I will add a kind of Actor Task which makes monsters 'use' too, so it will be possible to order monster first walk to the switch, then use it. [quote="Firebrand":3ru4ocdm]or activate scripts if they want to) Not sure what you mean here... [quote="Firebrand":3ru4ocdm]I know that we are limited by the engine, but I also think that we can overcome certain limits and create some really interesting interaction between actors in the game <!-- s8) --><img src="{SMILIES_PATH}/orccool.gif" alt="8)" title="Cool" /><!-- s8) --> . Actually I cannot agree we are limited by engine in this kind of actor behavior much <!-- s:wink: --><img src="{SMILIES_PATH}/orc9.gif" alt=":wink:" title="Wink" /><!-- s:wink: --> Making monsters using items and spells should be very easy from the progs, and very possible by script command, only need tdetermining how to pass inventory item ID as an argument could be problematic (we may define item index table, or use mobj id, or script id).
Sat, 11 Jul 2009 15:42:11

Firebrand

Actually monsters can use inventory stuff already without the need of adding anything to the code <!-- s;) --><img src="{SMILIES_PATH}/orc9.gif" alt=";)" title="Wink" /><!-- s;) -->, with the additions done to Inventory class, the only thing monsters might need is to adapt some spell effects for them in a generic way. As for scripts, I meant that they would do special things with them (like the attacks korax does by using scripts), but maybe a bit more dynamically, so we wouldn't be limited to certain script numbers, but we could define them somehow so that only certain monsters (defined by TID or by class maybe) are able to do this. Another thing I've always wanted to do (but that it's no too easy to do) is to make a boss that would alter the world architecture, so that for example we could make a face using 3d floors and make the walls to become hands that would trap the player somehow... I know it might sound like a crazy idea, but I've always wanted to do something like that, hehehe! <!-- s:evil: --><img src="{SMILIES_PATH}/orcevil.gif" alt=":evil:" title="Evil or Very Mad" /><!-- s:evil: -->

Back to the Korax Forum Archives