Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Enemy Skills

First question:
How do you add a skill to an enemy
I'm trying to make an enemy that has the same stats as the actor (a clone of sorts). I have the stats done, but can't figure out how to add skills to the enemy

Second Question:
How would you later check to see if an enemy has the skill ID 5?
 

poccil

Sponsor

Enemies don't "have" skills, but rather use them during a battle.  In the "Enemies" tab of the database, look at the section named "Action:".
The "Action" column indicates what the enemy should do, and the "Condition" specifies the condition, if any, that the action requires.

To add an action, double click on the blank line just after the end of the list.  A box will appear.  In your case, select Skill, and then select the
name of the skill to carry out.  The "Rating" at the bottom of the dialog box specifies how often the action will be used.

For your second question:  Because enemies don't have skills, there is normally no way to determine this during a battle.  However, you can put this script section before the last one in the script editor:
Code:
def enemyHasSkill?(enemyID,skillID)
 enemy=$data_enemies[enemyID]
 for action in enemy.actions
  if action.kind==1 && action.skill_id==skillID
   return true
  end
 end
 return false
end
Then use a conditional branch to check for the existence of a skill.
Code:
@>Comment: Does enemy ID 4 have skill ID 3?
@>Conditional Branch: Script: enemyHasSkill?(4,33)
  @>Text: Has skill.
  @>
@>Branch End
 

poccil

Sponsor

An enemy's actions (in the Enemies tab of the Database) include the skills that it will use -- I don't believe such skills can be set elsewhere.  When skills are added to an enemy's actions, the enemy may choose to use the skill under certain conditions.  Setting the conditions for each action, which also includes "Attack" and "Do Nothing" allow you to determine whether and how often the enemy will choose to perform an action during its turn.  If you want the enemy to start attacking first, then set the condition for each enemy's skill to, say, "Turn 3" or higher.  Double-click on an action's name or a blank space to set its conditions.

-------------

After further review on what you were trying to do, you're trying to add actions to an enemy dynamically rather than statically through the database.  That can be done only with a script, which I will try to make for you.  Please wait.
 
Here you go.

def copycat()
# put the id of your monster here.
id = 1
# put the id of the actor here.
id2 = 1
actor= $game_actors[id2]
# OR, always use the 1st actor in the party: change the next false to true.
use_first_actor = false
if (use_first_actor)
actor=$game_party.actors[0]
end
#adding skills to enemy..
for i in (0...actor.skills.length)
skill_id=actor.skills
myaction=set_action(skill_id)
$data_enemies[id].actions.push(myaction)
end
end


def set_action(skill_id)
a=RPG::Enemy::Action.new
a.kind = 1
a.skill_id=skill_id
return a
end


*you need to set 'id' to enemy id, and 'id2' to actor id.
*to use, make a script command with: copycat()
*please use before starting the battle.
Edit: oops. sorry, poccil :D
 

poccil

Sponsor

Here, I made one, too.  Put this in a new script section.  See ACTORCLONES to see how to customize this script.

Code:
class Game_Enemy
 ACTORCLONES={
  # EnemyID=>ActorID
  1=>1,
  2=>2
 }
 def createActionArray(actorID)
  array=[]
  action=RPG::Enemy::Action.new
  action.kind=0
  action.basic=0
  array.push(action)
  actor=$game_actors[actorID]
  for skill in actor.skills
   action=RPG::Enemy::Action.new
   action.kind=1
   action.skill_id=skill
   array.push(action)
  end
  return array
 end
 def actions
  actor=ACTORCLONES[@enemy_id]
  return createActionArray(actor) if actor
  return $data_enemies[@enemy_id].actions
 end
  %w[
      maxhp maxsp str dex agi int atk pdef mdef eva
  ].each_with_index do |s, i|
      eval <<-__END__
        def base_#{s}
          actor=ACTORCLONES[@enemy_id]
          return $game_actors[actor].base_#{s} if actor
          return $data_enemies[@enemy_id].#{s}
        end
      __END__
  end
end
 
thanks to both of you. I have a question.

poccil, i'm using your script. Is there any way to include this in it

Code:
a = $data_enemies[5]
b = $game_actors[1]
a.maxhp = b.maxhp
a.maxsp = b.maxsp
a.str = b.str
a.dex = b.dex
a.agi = b.agi
a.int = b.int
a.atk = b.atk
a.pdef = b.pdef
a.mdef = b.mdef
since i'm calling it via common event and it would be easier by script
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top