0 reviews
  • Review
  • Subscribe
  • Nominate
  • Submit Media
  • RSS

How I use YEM to make unstoppable AI bent on world domination.

Okay so the title is a bit of a misnomer. I thought it might be helpful if I explain how I handle enemy AI in DS, because it's the kind of thing that might benefit other people who read it. Alternatively, someone will comment pointing out how stupid x, y, and z are, and I can be all "tee-hee LET ME ABSORB YOUR KNOWLEDGE AND PUT IT TO FURTHER USE."

Enemy AI relies on two things: YEM's ability to run common events at various points during a battle, and a small bit of script written by Icedragon. This scriptlet tracks which skills the player uses, then assigns those skill IDs to variables. The rest is eventing!

A common event runs at the beginning of the enemy round.


This event gets player-used skills into variables, keeps track of the enemy's turn count, and the rest of the code is just conditional branches that call the appropriate troop's common event. In taking a peek at the one for the first boss...


I begin by clearing any reaction switches leftover from the previous round. Simple enough! The #1/#2 refers to enemy troop index.


Next I handle RAGE, which is essentially a limit-break sort of state.
var = 49

for member in $game_troop.members
$game_variables[var] = member.rage
var += 1
end

This cycles through each member of an enemy troop and puts their current rage into a variable. The first boss has two enemies in the troop, so variable #49 has index 1's rage, and #50 has index 2's rage. The rest of THAT is just conditional branches that determine whether or not to apply the rage state.


And now things are more interesting! After basic shenanigans have been handled, the event goes through various conditions and determines whether or not they've been met; if they have, this turns on a switch that affects which skills an enemy can use. Occasionally some Ruby is involved with this:

skil = []
# The above line creates an array...
skil[0] = $game_variables[27]
skil[1] = $game_variables[28]
skil[2] = $game_variables[29]
skil[3] = $game_variables[30]
# which then has the variables containing last-used skills added to it.
c = [20, 38, 61, 65, 95, 102, 119, 139,
140, 141, 143]
# this is a separate array that holds a static list of skill IDs to check for.
skil.each do |ID|
if c.include?(ID); $game_variables[16] += 1
end
end
#The last bits cycle through each ID in the "skil" array and see if it includes any of the IDs from the "checking" array.
If there's a match, then a separate variable is increased by 1.


That's the general idea. Each enemy in the troop has their own section, which contains patterns that determine how they respond to STUFF going on during the battle. For example, the first boss is accompanied by his slavishly devoted servant. The very first thing that dude checks for is whether or not he should be all over his master.


The results of all this tomfoolery for turning on switches can be seen in enemy action patterns:


The various switches add to their "pool" of available actions and make them more likely to use certain skills depending on what conditions are met. So far, this has been working quite nicely! I've only done the eventing for about 3 battles so far, but I'm optimistic about future potential. I wrote this as a blog rather than an article or anything because really, it's tailored very speficially for Demon Slayer. In any game with a large amount of skills/enemies, like that 60+ hour epic jrpg lurking in everyone's hearts, this would get hard to manage. But if reading this gave you any ideas, then good for you! I hope it can be helpful.

Posts

Pages: 1
Ronove
More like Misao Stealing Prince
977
Ooh I should take notes. I've been wanting to make my enemies smarter. Then again, I'm a bit lazy! XD Do you ever worry about running out of switches to use?
author=Ronove
Ooh I should take notes. I've been wanting to make my enemies smarter. Then again, I'm a bit lazy! XD Do you ever worry about running out of switches to use?


Nah! Each "response" switch can be reused for other battles, and they're all turned off by a common event at the end of every fight.
Ronove
More like Misao Stealing Prince
977
Ooh that is a nifty idea and a bit common sense haha. But yeah, totally nifty idea. I am still getting the hang of doing that stuff for enemies in my own game so hopefully when I go back to balancing later in the week I can get some ideas on how to make enemies smarter from this.
Pages: 1