Search Unity

WIP Making a RPG AI

Discussion in 'Works In Progress - Archive' started by Edumntg, Jul 28, 2016.

  1. Edumntg

    Edumntg

    Joined:
    Dec 26, 2013
    Posts:
    4
    Creating Artificial Intelligence for RPG Games
    Introduction
    First of all, welcome to my thread. I started this project a week ago as a hobbie and I decided to go full with this. I've played a lot of RPG games through the years and my favorite one is Tibia.

    If you have played this game, you can imagine how my AI will work. I decided to recreate an AI not exactly as the one from this game, but i'm basing my project on this one.

    Features
    My plans are to add a lot of features to this. These are some of them:

    • Idle Behaviour: Creature/Monster will do something while not attacking/chasing a player.
    • Chasing: Creature/Monster will chase player when it's on it's alert range.
    • Attack: Creature/Monster will attack player when it's on it's attack range. (Melee and distance attacks)
    • Path finding: Creature/Monster will find shorter and fatest path to a position.
    • Events: A lot of configurable events for Creature/Monster behaviour (OnMove, OnAttack, OnAppear, OnDeath, OnKill, OnThink, OnCastSpell, etc)
    Media
    For now, I've only developed the Idle and Chasing behaviours. You can see it in the next video:


    There's still a lot of work to be done. Feel free to ask questions and I'll be happy to answer them!
    Feedback is also appreciated as long as it's constructive.

     
  2. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Ah Tibia. I used to play that a lot. Just clicked your link and wow they have really updated it since I last played it. At least the updated the graphics. I kind of prefer the cleaner look of the old. Seems like a lot of "stuff" in the landscape now. But probably fine once you get your mind into the game and all of that disappears anyway.

    Just watching your video reminds me of the monster behavior. At least some of them. Rats were quite different IIRC.
     
  3. Vanidash-Studios

    Vanidash-Studios

    Joined:
    Mar 9, 2016
    Posts:
    71
    it looks good, i guess with that extra polishing on the script, it will be perfect.
    Would you mind sharing your code? or explain how does it work?
    Thanks
     
  4. Marrt

    Marrt

    Joined:
    Feb 7, 2012
    Posts:
    613
    I am curious, when does "OnThink" happen?

    I made something similar compared to your features. But one difference worth mentioning is this: Traits
    Monsters have a list of traits. Traits alter some behaviors in certain cases. E.g. one trait is called "CounterFocus". When a Monster with this trait is created it adds a listener that subscribes to the player-event "focusing" (=player starts to channel a bigger spell). The monster gets a speed buff and charges the player in order to interrupt the spell.

    So i have a rigid base Behavior for all foes, but i can wildly add traits to make it more dynamic.
    Traits can also be passives like "aimLeading", a trait that enables the foe to anticipate your movement and lead their projectiles accordingly. Needless to say, facing foes that try to counter your spells and have good aim is really a challenge.
     
  5. Edumntg

    Edumntg

    Joined:
    Dec 26, 2013
    Posts:
    4
    UPDATE: 07/01/2017

    Hello, after all this time I returned to work on this project and here are all the updates I've added to it.

    • Idle Behaviour: The creatures remain in an inactive state until there is a target nearby or they are not hostile.
    • Chasing: Once the creature finds a target, it'll start chasing it until it's near enough to attack it (It will approach the target until the distance between them is equal to the required attack distance)
    • States: This is the basis feature present in almost all AI Systems. Creatures has states like Idle, Attacking, Escaping, etc.
    • Run On Health: If this parameter is declared on a creature, once the creature reach this amount of health, it'll escape from target, finding the farthest position.
    • A* Algorithm: The creatures uses the A* Algorithm to find the shortest way to the destination. It can be configured to prioritize diagonal or parallel movement (If you have played Tibia, you should know that in that game diagonal movement has longer delay than parallel movement and creatures prioritize parallel movement). This also detects unwalkable tiles and obstacles.
    • Map: The project uses a map system to place creatures, detects it's position, get creatures in certain position, etc. This system creates a grid of XxY numbers of tiles.
    • Attack: Hostile creatures now attack their targets. You can configure attack speed, damage formula, etc.
    • Spells: Creatures cast spells. You can declare spells for each creature individual. Spells can have area declared, if it needs targets, min damage, max damage, cooldown, etc.
    • Events: The events is an interface made to make it easier to configure/script essential functions on creatures. There are events like OnAttack, OnMove, OnSelectTarget, OnCastSpell, OnDeath and much more. There events are triggered just before the main function executes. This can be helpful to add new features.
    So these are the main features I've recently added to this project. I would like to know if you guys think this is an interesting project and if it's worth working on. I would love to read your recommendations and possible ideas to be added to this.

    If you want to see some videos of the features I've mentioned, say it here and I'll record them.