Actor AI

Discussion in 'JS Plugin Releases (RMMV)' started by Astfgl66, May 16, 2017.

  1. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    641
    Likes Received:
    489
    First Language:
    French
    Astfgl's Programmable Actor AI

    [​IMG]

    Hi everyone!
    This plugin is an addon to Yanfly's Battle AI Core.

    I've always found the autobattle AI to be really bad. So first I created a way to extend yanfly's battle AI core to actors, then took things further and made a custom scene to allow the player to create his own autobattle AI.
    If any of you have played Dragon age: Origins, this is my attempt at creating something similar to the tactics tab.


    Features:

    • Allows the player to define his own battle AI.
    • If you don't want the player to, this plugin extends Yanfly's battle AI core functionality to actors who have an autobattle flag.

    Screenshots:
    [​IMG]

    How to use:
    • Plug and play, just download, save as a .js file and name it "AstfglActorAI", place it below yanfly's battle AI core.
    • If you don't want the player to be able to set his own AI, set the parameter to false.
    • Instructions on how to add it to the main menu using yanfly's main menu manager are in the help file.
    • Use SceneManager.push(Scene_AI) to bring up the scene manually.
    Requirements:
    • As said above, this is an extension to yanfly's battle AI core. It will not function without it.
    • To have the AI take over the actor needs to have an auto battle trait. You can give the traits in any way you want, state, equipment, actor or class. Traits > Other > Special Flag > Auto Battle

    Download

    Known bugs or incompatibilities:

    I didn't have time to do extensive testing, so bugs or incompatibilities may exist. Please leave a message or send me a PM should one arise.
    I need a screenshot of the error and of the console (press f8 on the error screen), and a precise description of what happened and what you wanted to do to be able to do anything. Error reports that don't have at least that will be ignored.



    Terms of use:
    They are in the plugin file for reference, pasted here:
    Code:
    Yanfly's terms of use apply, please credit me with any of the following
    Astfgl66/Pierre MATEO/Pierre MATEO (Astfgl66).
    

    Plans:
    I'll first start by making it compatible with my own extension: buffs.
    Then I'll look at suggestions for improving the UI, or the functionality.

    Credits:
    • Yanfly: Battle AI Core and so many other awesome plugins.
    Have a nice day, and happy making! If you have any question, feel free to ask.
     
    Last edited: May 20, 2017
    #1
    eluukkanen, Kyuukon, Archeia and 6 others like this.
  2. Janusz

    Janusz Veteran Veteran

    Messages:
    26
    Likes Received:
    4
    Fantastic idea. Something similar to Gambit System in FF-12. Maybe shop when player can buy various conditions like: is state affected, is not affected, strongest target, hp is below x etc?
     
    #2
  3. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    641
    Likes Received:
    489
    First Language:
    French
    Thanks for the kind words!

    Right now it's not really something you can put in your game as is. For example it lists all states, even the ones the actor or the party members can't inflict. Same for elements. Similarily, it lists all skills learned by the actor, regardless if castable in battle or not.
    I'll look into making a way to decide what shows in the skill, state and element tabs, per actor.
     
    #3
  4. ramza

    ramza Lunatic Coder Veteran

    Messages:
    501
    Likes Received:
    282
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    It doesn't seem to be mentioned in your help notes, or in this topic, so I have a question about this plugin, and a possible update for it.

    If the menu is disabled, (ie: the developer doesn't want the player to modify the AI of his party members), where does the plugin pull the actual AI script from? Yanfly's battle AI core requires tags on the monsters, does this just pull from tags on the actors? Or the classes?

    Depending on your answer to that, it would be amazing if you could also include the ability to have it check for AI tags on the classes as well as states, and probably have them overwrite each other in the order States > Class > Actor. This would allow for states to change the AI (think confusion), as well as allowing different classes to influence the AI in different ways, a healer wouldn't want to be attacking as much as, say, a fighter would, right?

    That being said, even as is, this plugin looks great, and I know a few people who can get a lot of use out of it.
     
    #4
  5. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    641
    Likes Received:
    489
    First Language:
    French
    @ramza I did put it in the help file: "Use the actor's note box just as you would an enemy's.".
    I'll say it again, for confirmation: it takes the data from the actor note box.

    I didn't touch the way Yanfly gathers his notetags, and IIRC it's not dynamic: they can't be modified in game.
    I'd have to modify that for your suggestion. I'll look into it, but no promises.
     
    #5
  6. ramza

    ramza Lunatic Coder Veteran

    Messages:
    501
    Likes Received:
    282
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Ah, I thought it would be a least a little dynamic, since your plugin allows the user to make up their own AI, I assumed you were doing this using the existing code, somehow.
     
    #6
  7. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    641
    Likes Received:
    489
    First Language:
    French
    @ramza If you care for a technical explanation: the plugin parameter switches what the AI core reads: the static actor note box or what is dynamically generated as output from the AI lines object I made.

    So, if the parameter is true, it's completely dynamic, but you have to use the AI lines.
    If its false its static but you use the notetags.

    If the parameter is true, but you don't give acess to the custom scene, the player can't set his own AI.
    Then you just have to create the AI lines manually via eventing instead of putting them in the notebox.
    You can use Yanfly's buff and state core to add or remove lines as you want when a state is applied or removed.
    So it's already possible in a way, but not easily translatable as is. It's also completely undocumented because I didn't think someone would need to create AI lines manually.
     
    #7
  8. kerykeion

    kerykeion Villager Member

    Messages:
    11
    Likes Received:
    2
    First Language:
    English
    Hi,

    I'd love to use this plugin, but I'm running into the same error as a similar plugin. Any time an actor with <AI Priority> notes is in battle, the game hangs when they go to take their action. The error text reads : "Cannot read property 'isPassive' of undefined". Thanks.
     
    #8
  9. kerykeion

    kerykeion Villager Member

    Messages:
    11
    Likes Received:
    2
    First Language:
    English
    Got it working, was a conflict with a passive skill script.
     
    #9
  10. Internetomancer

    Internetomancer Veteran Veteran

    Messages:
    56
    Likes Received:
    26
    First Language:
    English
    Hey-- there is a big bug here. Well, big in that it broke my plugins, and it took me hours and hours and hours to find out why.

    1. DataManager.isDatabaseLoaded = function() {
    2. if (!Yanfly.CoreAI.DataManager_isDatabaseLoaded.call(this)) return false;
    3. if (!Yanfly._loaded_YEP_BattleAICore) {
    4. this.processCoreAINotetags1($dataActors);
    5. this.processCoreAINotetags1($dataEnemies);
    6. this.processCoreAINotetags2($dataSkills);
    7. this.processCoreAINotetags3($dataStates);
    8. this.processCoreAINotetags4($dataSystem);
    9. Yanfly._loaded_YEP_BattleAICore = true;
    10. }
    11. return true;
    12. };

    You do not want to simply overwrite DataManager.isDatabaseLoaded, because it will prevent numerous plugins from reading note-tags. Instead you want to alias it. And just add your one line to the end.
     
    #10
    Aloe Guvner likes this.
  11. Waterguy

    Waterguy Veteran Veteran

    Messages:
    1,170
    Likes Received:
    251
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Hey there!
    This seems like a great plugin, but last I read here the creator itself said it was incomplete...
    Any chance it is still being worked on?
     
    #11
  12. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    641
    Likes Received:
    489
    First Language:
    French
    I don't have any time to look into it right now, I'm sorry.
    I'll whip up a quick bugfix update to fix what @Internetomancer mentioned, but for functionality updates I can't promise anything.
     
    #12
  13. Internetomancer

    Internetomancer Veteran Veteran

    Messages:
    56
    Likes Received:
    26
    First Language:
    English
    It should just take a minute. I'd give you suggestions but I'm a lousy programmer.
     
    #13
  14. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    641
    Likes Received:
    489
    First Language:
    French
    Okay I've made the necessary alias.
    @Internetomancer Since you haven't provided with the environment you did the tests in I did a quick test using the bare minimum of plugins and it seems to work properly. Let me know if it doesn't.
     
    #14
    Internetomancer likes this.
  15. Internetomancer

    Internetomancer Veteran Veteran

    Messages:
    56
    Likes Received:
    26
    First Language:
    English
    Thank you very much Asfgl66.

    Waterguy, it's a pretty neat script in its current form! Are you still using it? I ended up using my own (not as good!!!) text based version. But there's a decent chance that one day I'll come back to this and try to rework the functionality. If you're using it now, then I will try to make that day sooner rather than later!
     
    #15
  16. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    641
    Likes Received:
    489
    First Language:
    French
    I've had some time to work on this and your message prompted me to finish and release it already.

    What's new then?
    I've added parameters to remove states skills or elements from the AI Line window. Those are global and can't be changed.
    It's useful if you want the player to program his own AI but don't want him to see all your development states only for example, or the dummy skills your hero has.
    I've also added notetags to do the same thing but on a per hero basis and dynamic.
    <AIRS: [1,2]> will prevent skills 1 and 2 from showing in the list even if they are learned.
    <AIRE: [1]> will prevent element 1 from showing.
    <AIRSt: [1,2]> will prevent states 1 and 2 from showing.
    Those are evaled, meaning if you actually input a game variable in there you can manipulate it in game.
    Ex: <AIRSt: $gameVariables.value(1)>
    Lets imagine you don't want the player AI to react to state 4, you'd put [4] in variable 1 at the beginning.
    Due to story events the player cannot react to state 7, put [4,7] in variable 1 and you're done.

    With a bit of javascript array manipulation (which is very easy) you can do all kind of clever things.

    Take care, and happy making.

    For users that want to use it to create and use dynamic AI lines for theirs actors, but don't want to let the player make their own AI, here is how you create AI lines via script call. Be warned that it's not user friendly at all.
    Code:
    let temp = new AILine() //create the AI line
    temp._actor = $gameActors.actor(actorId) //set the actor
    temp.setCondition(conditionId) //set the condition refer to condition ids below
    
    //Then depending on the condition set:
    //Condition 0,
    temp.setSkill($dataSkills[skillId]) //set skill Id
    
    //Condition 1,
    temp.setElement(elementId) //set element id
    temp.setElemCond(condId) //refer to elemental conditions ids below
    temp.setSkill($dataSkills[skillId]) //set skill Id
    
    //Conditions 2, 3, 4, 5, 11,
    temp.setNumCond(condId) //refer to numerical conditions below
    temp.setNum(number) //put your number here
    temp.setSkill($dataSkills[skillId]) //set skill Id
    
    //Conditions 6, 12,
    temp.setParam(paramId) //refer to parameters id below
    temp.setNumCond(condId) //refer to numerical conditions below
    temp.setNum(number) //put your number here
    temp.setSkill($dataSkills[skillId]) //set skill Id
    
    //Condition 7,
    temp.setLvlCond(condId) //refer to level conditions ids below
    temp.setNumCond(condId) //refer to numerical conditions below
    temp.setNum(number) //put your number here
    temp.setSkill($dataSkills[skillId]) //set skill Id
    
    //Condition 8,
    temp.setNum(number) //put your number here
    temp.setSkill($dataSkills[skillId]) //set skill Id
    
    // Conditions 9, 10,
    temp.setState($dataStates[stateId])) //set state Id
    temp.setSkill($dataSkills[skillId]) //set skill Id
    
    //Then for all those you can add a targetting modifier:
    temp.setTargetting(condId) ///seee targetting conditions ids below
    
    Ex: to create an AI line with: param HP% < 50: Heal, lowest Hp%, for actor 1
    let temp = new AILine() //create the AI line
    temp._actor = $gameActors.actor(1) //actor 1
    temp.setCondition(6) //param condition
    temp.setParam(10) // hp%
    temp.setNumCond(1) // <
    temp.setNum(50) // 50
    temp.setSkill($dataSkills[8]) // Heal skill id
    temp.setTargetting(20) // lowest hp%
    $gameActors.actor(1)._AILines.push(temp) // add the line to the actor
    
    /*
    ========================
    Condition Ids
    0 -> Always
    1 -> Element
    2 -> Party alive members
    3 -> Troop alive members
    4 -> Party dead members
    5 -> Troop dead members
    6 -> Param
    7 -> Party level
    8 -> Random
    9 -> State ===
    10 -> State !==
    11 -> Turn
    12 -> User Param
    
    =======================
    Param Ids
    0    atk
    1    def
    2    mat
    3    mdf
    4    agi
    5    luk
    6    maxhp
    7    maxmp
    8    hp
    9    mp
    10    hp%
    11    mp%
    12    level
    13    tp
    14    maxtp
    15    tp%
    
    ==============================
    Numerical conditions Ids
    0    >
    1    <
    2    ===
    3    >=
    4    <=
    5    !==
    
    ============================
    Elemental conditions Ids
    0    Neutral
    1    Weakness
    2    Resistant
    3    Null
    4    Absorb
    
    ============================
    Level conditions ids
    0    Highest
    1    Lowest
    2    Average
    
    ===========================
    Targetting ids
    0    None
    1    First
    2    User
    3    Highest MaxHp
    4    Highest HP
    5    Highest HP%
    6    Highest MP
    7    Highest MP%
    8    Highest MaxMP
    9    Highest MaxTP
    10    Highest TP
    11    Highest TP%
    12    Highest ATK
    13    Highest DEF
    14    Highest MAT
    15    Highest MDF
    16    Highest LUK
    17    Highest Level
    18    Lowest MaxHP
    19    Lowest HP
    20    Lowest HP%
    21    Lowest MP
    22    Lowest MP%
    23    Lowest MaxMP
    24    Lowest MaxTP
    25    Lowest TP
    26    Lowest TP%
    27    Lowest ATK
    28    Lowest DEF
    29    Lowest MAT
    30    Lowest MDF
    31    Lowest LUK
    32    Lowest Level
    */
    
     
    Last edited: May 27, 2018
    #16
    Chaos17 and Archeia like this.
  17. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    641
    Likes Received:
    489
    First Language:
    French
    Just writing this to tell that Yanfly has made his own actor battle AI plugin.
    That means those of you using mine, if any, should probably switch to his version if you don't need any of the specific properties of my plugin (like the programmable part or the AI lines).
    The good part is that the switch would just require you to move your AI tags from an actor note box to a class note box.

    I don't think I'm breaking the news to anyone but I'm posting this in case someone stumbles upon this plugin in the future and doesn't know.
    Cheers, and happy making!
     
    #17

Share This Page