Author Topic: AI, spells and skills  (Read 2353 times)

Offline detah

  • BFF
  • ***
  • Posts: 190
  • Ruler of 2D
    • View Profile
AI, spells and skills
« on: February 05, 2009, 11:25:53 am »
AI/spells/skills combat design question:

Suppose you want to make an npc which always casts faerie fire on rd 2 of combat. Where/how would you implement that?

Suppose you want your npc to always attack the player who has the lowest MaxHP first. Would you build this in combat.c and make it a function AttackLowestLevelFirst() in npc.c?
 
How about just plain old spellcasting and skills? Do you build a giant switch like ds has? Forget about whether spellcasting or skills should be in addition to or instead of a melee attack for a moment. The question here is how would you implement the ability to cast spells or use skills during combat. I can think of several ways to implement these abilities. But surely there are advantages, disadvantages and pitfalls witrh each design. I am curious if you have discovered a way to make AI flexible, to using spells and skills in combat. What are the pros and cons of doing it that way?

Design 1 (independence)
Each skill & spell is coded in its own skill file as a command. Obvious disadvantages are that one could cast a huge number of spells and execute a large number of skills per round, governed only by command entering speed and processor time. Also, there is no ability to set or control npc AIs.

Design 2 (categorical)
Each attack type (skill, spell, melee) have their own 'slot' in the combat code. When the player casts fireball, they are just setting the switch to fireball during that round. Fireball specs are taken from the caster's traits, like magic skill and intelligence. Again, disadvantage is that no AI can be built into this. Adding a controlling front end to the switch seems like the equivalent putting second car engine into your car just to move the steering wheel.

Both design ideas clearly fail at adding AI in any kind of easy way.

I am trying to make a system which allows for modular additions of AI actions. I know how to code this stuff. I do not need technical advice. Right now I am just trying to work out a good design to allow the most flexibility for adding spells and skills.

Suggestions, comments?

Offline daelaskai

  • BFF
  • ***
  • Posts: 174
    • View Profile
Re: AI, spells and skills
« Reply #1 on: February 05, 2009, 12:11:13 pm »
Personally, I would probably think having separate skills/spells as individual commands
in the game.  The control of how many spells can be done would/should be done
by either a SPELL_D or COMBAT_D daemon.  For instance, player A is fighting a
Stone Troll.  Player casts fireball.  The command sends a request to the daemon
adding the spell to a 'stack'.  The normal combat system would then check the
daemon for 'waiting spells'.  There could be a 'last casting time' to determine
how long ago a spell was cast also to prevent casting spells each time.

I guess my thinking is, coding skills/spells separately would allow easier expansion
by area coders rather than having anything hard-coded into the combat system.
Adding/removing spells would be as easy as making a command and 'registering'
the spell with the daemon.

Daelas