Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Actor Enemies, Please Assist
Philip
post Mar 8 2012, 08:40 PM
Post #1


Nura (The Jade Ring)
Group Icon

Group: Revolutionary
Posts: 325
Type: Developer
RM Skill: Masterful




Ok guys, for those inevitable and totally unexpected parts in EVERY RPG game EVER made where one of your party members all of a sudden for no apparent reason turns around and says, "Mwa ha ha, I'm an evil spy for XYZ bad guy and you'll go no further" thus obviously spawning a battle with one of your actors I need a bit of help.

I'd like to NOT have to create an enemy that I'm guessing on the HP, MP and skills to be correct. I'd like to clone the actor stats and skills in all and create an enemy out of it. How could I do this? I'm a very good scripter and I THINK I've figured out everything but the skills. So if anyone has any suggestions please share them. You can write a scriptlet and show it to me.

Thanks for any help.


__________________________
"If your mind goes blank don't forget to turn off the sound." Unknown Author

Phil


Go to the top of the page
 
+Quote Post
   
Pacman
post Mar 9 2012, 04:43 AM
Post #2


Level 3
Group Icon

Group: Member
Posts: 34
Type: Scripter
RM Skill: Advanced




I would just take the parameters of the actor and transfer them to the enemy. If you give me a moment I can whip up a snippet that would do that. You would, of course, have to make a dummy enemy with the required graphic.

This post has been edited by Pacman: Mar 9 2012, 04:56 AM


__________________________
Go to the top of the page
 
+Quote Post
   
Philip
post Mar 9 2012, 12:16 PM
Post #3


Nura (The Jade Ring)
Group Icon

Group: Revolutionary
Posts: 325
Type: Developer
RM Skill: Masterful




QUOTE (Pacman @ Mar 9 2012, 06:43 AM) *
I would just take the parameters of the actor and transfer them to the enemy. If you give me a moment I can whip up a snippet that would do that. You would, of course, have to make a dummy enemy with the required graphic.

That'd be cool! Just remember I need the actor skills as well. And yes I do have a dummy enemy and I'm using Yggdrasil so the graphic doesn't actually matter. Thank ya thank ya.


__________________________
"If your mind goes blank don't forget to turn off the sound." Unknown Author

Phil


Go to the top of the page
 
+Quote Post
   
Pacman
post Mar 9 2012, 05:46 PM
Post #4


Level 3
Group Icon

Group: Member
Posts: 34
Type: Scripter
RM Skill: Advanced




Script
CODE
#===============================================================================
#
# Actor-based Enemies
# Version 1.0
# By Pacman (rmrk.net), for Phillip
# Description: This script allows you to base enemies' stats off of actors'
# stats. With a simple notetag, you can designate an enemy's name, skills,
# element efficiency, status efficiency and battle stats from a specific actor.
# You will need a place-holder enemy in which to place the notetag, and with
# it a necessary graphic, gold amount and drops, which can't be taken from the
# actor because they don't have those things.
# Use the notetag:
# \actor[x]
# in an enemy's notebox to base the enemy's stats from the actor with ID x.
#
#===============================================================================

#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#  This class handles enemy characters. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # Alias listing
  #--------------------------------------------------------------------------
  alias actor_enemy_initialize initialize
  alias actor_enemy_base_maxhp base_maxhp
  alias actor_enemy_base_maxmp base_maxmp
  alias actor_enemy_base_atk base_atk
  alias actor_enemy_base_def base_def
  alias actor_enemy_base_spi base_spi
  alias actor_enemy_base_agi base_agi
  alias actor_enemy_hit hit
  alias actor_enemy_eva eva
  alias actor_enemy_cri cri
  alias actor_enemy_odds odds
  alias actor_enemy_element_rate element_rate
  alias actor_enemy_state_probability state_probability
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(index, enemy_id, *args)
    actor_enemy_initialize(index, enemy_id, *args)
    @from_actor = false
    if !self.enemy.note[/\\actor\[(\d+)\]/].nil?
      @actor = $game_actors[$1.to_i]
      @original_name = @actor.name
      @hp = @actor.maxhp
      @mp = @actor.maxmp
      @from_actor = true
    end
  end
  #--------------------------------------------------------------------------
  # * Aliased Stat Methods
  #--------------------------------------------------------------------------
  def base_maxhp(*a)
    if @from_actor
      return @actor.base_maxhp
    else
      actor_enemy_base_maxhp(*a)
    end
  end
  def base_maxmp(*a)
    if @from_actor
      return @actor.base_maxmp
    else
      actor_enemy_base_maxmp(*a)
    end
  end
  def base_atk(*a)
    if @from_actor
      return @actor.base_atk
    else
      actor_enemy_base_atk(*a)
    end
  end
  def base_def(*a)
    if @from_actor
      return @actor.base_def
    else
      actor_enemy_base_def(*a)
    end
  end
  def base_spi(*a)
    if @from_actor
      return @actor.base_spi
    else
      actor_enemy_base_spi(*a)
    end
  end
  def base_agi(*a)
    if @from_actor
      return @actor.base_agi
    else
      actor_enemy_base_agi(*a)
    end
  end
  def hit(*a)
    if @from_actor
      return @actor.hit
    else
      actor_enemy_hit(*a)
    end
  end
  def eva(*a)
    if @from_actor
      return @actor.eva
    else
      actor_enemy_eva(*a)
    end
  end
  def cri(*a)
    if @from_actor
      return @actor.cri
    else
      actor_enemy_cri(*a)
    end
  end
  def odds(*a)
    if @from_actor
      return @actor.odds
    else
      actor_enemy_odds(*a)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Element Rate
  #--------------------------------------------------------------------------
  def element_rate(element_id, *args)
    if @from_actor
      return @actor.element_rate(element_id, *args)
    else
      actor_enemy_element_rate(element_id, *args)
    end
  end
  #--------------------------------------------------------------------------
  # * Get State probability
  #--------------------------------------------------------------------------
  def state_probability(state_id, *args)
    if @from_actor
      return @actor.state_probability(state_id, *args)
    else
      actor_enemy_state_probability(state_id, *args)
    end
  end
  #--------------------------------------------------------------------------
  # * Collect Skills
  #--------------------------------------------------------------------------
  def skills
    skills = []
    for action in enemy.actions
      skills.push if action.kind == 1
    end
    if @from_actor
      for skill in @actor.skills
        skills.push(skill) unless skills.include?(skill)
      end
    end
    return skills.compact
  end
  #--------------------------------------------------------------------------
  # * Make Battle Action
  #--------------------------------------------------------------------------
  def make_action
    @action.clear
    return unless movable?
    available_actions = []
    rating_max = 0
    for action in enemy.actions
      next unless conditions_met?(action)
      if action.kind == 1
        next unless skill_can_use?($data_skills[action.skill_id])
      end
      available_actions.push(action)
      rating_max = [rating_max, action.rating].max
    end
    for skill in skills
      available_actions.push(skill) unless available_actions.include?(skill)
    end
    ratings_total = 0
    rating_zero = rating_max - 3
    for action in available_actions
      next if action.rating <= rating_zero
      ratings_total += action.rating - rating_zero
    end
    return if ratings_total == 0
    value = rand(ratings_total)
    for action in available_actions
      next if action.rating <= rating_zero
      if value < action.rating - rating_zero
        @action.kind = action.kind
        @action.basic = action.basic
        @action.skill_id = action.skill_id
        @action.decide_random_target
        return
      else
        value -= action.rating - rating_zero
      end
    end
  end
end

#===============================================================================
#
# END OF SCRIPT
#
#===============================================================================

I hope this works for you.

This post has been edited by Pacman: Mar 9 2012, 05:49 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Philip
post Mar 9 2012, 11:20 PM
Post #5


Nura (The Jade Ring)
Group Icon

Group: Revolutionary
Posts: 325
Type: Developer
RM Skill: Masterful




QUOTE (Pacman @ Mar 9 2012, 07:46 PM) *
Script
CODE
#===============================================================================
#
# Actor-based Enemies
# Version 1.0
# By Pacman (rmrk.net), for Phillip
# Description: This script allows you to base enemies' stats off of actors'
# stats. With a simple notetag, you can designate an enemy's name, skills,
# element efficiency, status efficiency and battle stats from a specific actor.
# You will need a place-holder enemy in which to place the notetag, and with
# it a necessary graphic, gold amount and drops, which can't be taken from the
# actor because they don't have those things.
# Use the notetag:
# \actor[x]
# in an enemy's notebox to base the enemy's stats from the actor with ID x.
#
#===============================================================================

#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#  This class handles enemy characters. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # Alias listing
  #--------------------------------------------------------------------------
  alias actor_enemy_initialize initialize
  alias actor_enemy_base_maxhp base_maxhp
  alias actor_enemy_base_maxmp base_maxmp
  alias actor_enemy_base_atk base_atk
  alias actor_enemy_base_def base_def
  alias actor_enemy_base_spi base_spi
  alias actor_enemy_base_agi base_agi
  alias actor_enemy_hit hit
  alias actor_enemy_eva eva
  alias actor_enemy_cri cri
  alias actor_enemy_odds odds
  alias actor_enemy_element_rate element_rate
  alias actor_enemy_state_probability state_probability
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(index, enemy_id, *args)
    actor_enemy_initialize(index, enemy_id, *args)
    @from_actor = false
    if !self.enemy.note[/\\actor\[(\d+)\]/].nil?
      @actor = $game_actors[$1.to_i]
      @original_name = @actor.name
      @hp = @actor.maxhp
      @mp = @actor.maxmp
      @from_actor = true
    end
  end
  #--------------------------------------------------------------------------
  # * Aliased Stat Methods
  #--------------------------------------------------------------------------
  def base_maxhp(*a)
    if @from_actor
      return @actor.base_maxhp
    else
      actor_enemy_base_maxhp(*a)
    end
  end
  def base_maxmp(*a)
    if @from_actor
      return @actor.base_maxmp
    else
      actor_enemy_base_maxmp(*a)
    end
  end
  def base_atk(*a)
    if @from_actor
      return @actor.base_atk
    else
      actor_enemy_base_atk(*a)
    end
  end
  def base_def(*a)
    if @from_actor
      return @actor.base_def
    else
      actor_enemy_base_def(*a)
    end
  end
  def base_spi(*a)
    if @from_actor
      return @actor.base_spi
    else
      actor_enemy_base_spi(*a)
    end
  end
  def base_agi(*a)
    if @from_actor
      return @actor.base_agi
    else
      actor_enemy_base_agi(*a)
    end
  end
  def hit(*a)
    if @from_actor
      return @actor.hit
    else
      actor_enemy_hit(*a)
    end
  end
  def eva(*a)
    if @from_actor
      return @actor.eva
    else
      actor_enemy_eva(*a)
    end
  end
  def cri(*a)
    if @from_actor
      return @actor.cri
    else
      actor_enemy_cri(*a)
    end
  end
  def odds(*a)
    if @from_actor
      return @actor.odds
    else
      actor_enemy_odds(*a)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Element Rate
  #--------------------------------------------------------------------------
  def element_rate(element_id, *args)
    if @from_actor
      return @actor.element_rate(element_id, *args)
    else
      actor_enemy_element_rate(element_id, *args)
    end
  end
  #--------------------------------------------------------------------------
  # * Get State probability
  #--------------------------------------------------------------------------
  def state_probability(state_id, *args)
    if @from_actor
      return @actor.state_probability(state_id, *args)
    else
      actor_enemy_state_probability(state_id, *args)
    end
  end
  #--------------------------------------------------------------------------
  # * Collect Skills
  #--------------------------------------------------------------------------
  def skills
    skills = []
    for action in enemy.actions
      skills.push if action.kind == 1
    end
    if @from_actor
      for skill in @actor.skills
        skills.push(skill) unless skills.include?(skill)
      end
    end
    return skills.compact
  end
  #--------------------------------------------------------------------------
  # * Make Battle Action
  #--------------------------------------------------------------------------
  def make_action
    @action.clear
    return unless movable?
    available_actions = []
    rating_max = 0
    for action in enemy.actions
      next unless conditions_met?(action)
      if action.kind == 1
        next unless skill_can_use?($data_skills[action.skill_id])
      end
      available_actions.push(action)
      rating_max = [rating_max, action.rating].max
    end
    for skill in skills
      available_actions.push(skill) unless available_actions.include?(skill)
    end
    ratings_total = 0
    rating_zero = rating_max - 3
    for action in available_actions
      next if action.rating <= rating_zero
      ratings_total += action.rating - rating_zero
    end
    return if ratings_total == 0
    value = rand(ratings_total)
    for action in available_actions
      next if action.rating <= rating_zero
      if value < action.rating - rating_zero
        @action.kind = action.kind
        @action.basic = action.basic
        @action.skill_id = action.skill_id
        @action.decide_random_target
        return
      else
        value -= action.rating - rating_zero
      end
    end
  end
end

#===============================================================================
#
# END OF SCRIPT
#
#===============================================================================

I hope this works for you.


Wow, I'm impressed actually! Very well written script with a note tag and everything! Thank you very much for the help.


__________________________
"If your mind goes blank don't forget to turn off the sound." Unknown Author

Phil


Go to the top of the page
 
+Quote Post
   
Pacman
post Mar 10 2012, 01:53 AM
Post #6


Level 3
Group Icon

Group: Member
Posts: 34
Type: Scripter
RM Skill: Advanced




Note tags are very simple once you get the hang of them. I'd be happy to whip up a tutorial if you'd like wink.gif


__________________________
Go to the top of the page
 
+Quote Post
   
Philip
post Mar 10 2012, 10:38 AM
Post #7


Nura (The Jade Ring)
Group Icon

Group: Revolutionary
Posts: 325
Type: Developer
RM Skill: Masterful




QUOTE (Pacman @ Mar 10 2012, 03:53 AM) *
Note tags are very simple once you get the hang of them. I'd be happy to whip up a tutorial if you'd like wink.gif

Oh I know how to use notes I just was having trouble with passing the actor skills to the enemy. I don't know why and I was having a problem with the evade and hit parameters too cz I'd try to get those properties and it kept saying they weren't found for RPG::Enemy and I looked and both eva and hit were there. I still don't know why they weren't found. I'll show you what I was using for my script. I'll post it later cz I'm at work.


__________________________
"If your mind goes blank don't forget to turn off the sound." Unknown Author

Phil


Go to the top of the page
 
+Quote Post
   
Philip
post Mar 10 2012, 04:41 PM
Post #8


Nura (The Jade Ring)
Group Icon

Group: Revolutionary
Posts: 325
Type: Developer
RM Skill: Masterful




@Pacman

Ok, so one thing that you could teach me is what the make action or make battle action def is all about. I know it's suppose to be used for auto battle actors and then enemies but it's fairly difficult to understand.


__________________________
"If your mind goes blank don't forget to turn off the sound." Unknown Author

Phil


Go to the top of the page
 
+Quote Post
   
Pacman
post Mar 10 2012, 10:00 PM
Post #9


Level 3
Group Icon

Group: Member
Posts: 34
Type: Scripter
RM Skill: Advanced




I hardly understand that myself.


__________________________
Go to the top of the page
 
+Quote Post
   
Philip
post Mar 11 2012, 08:17 PM
Post #10


Nura (The Jade Ring)
Group Icon

Group: Revolutionary
Posts: 325
Type: Developer
RM Skill: Masterful




QUOTE (Pacman @ Mar 11 2012, 01:00 AM) *
I hardly understand that myself.

Yeah it's a strange def.


__________________________
"If your mind goes blank don't forget to turn off the sound." Unknown Author

Phil


Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th May 2013 - 03:39 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker