[Ace] How do enemies choose targets - custom pet scripting

Hi, got RPG Maker VX ACE about a week ago and just been messing around trying to script hack interesting battle options so far. No prior experience of Ruby so not completely up on how it works.

I'm a bit over my head on this one, so need a few pointers.

I've been trying to script a pets system - characters in my game will have abilities like "Summon Angel" or "Summon Zombie." But I don't want the pets added to the main party or the enemy troops - I don't want them buffable, and I don't want them to take up troop slots.

What I've done is make (mostly unchanged so far) clones of Game_Enemy and Game_Troop and called them Game_Pet and Game_Pets. Game_pets loads a default troop that contains one of each kind of pet, who will remain hidden until the summon skill is used. I've made the appropriate edits in Battlemanager and Scene_Battle to enable this.

So I've got three "groups" going - $game_party, $game_troop and $game_pets. It seems to be working.

TaYhKR8.jpg


Note that the angel and zombie cannot be targeted by the player. Perfectly WAI. They can take actions just fine as well. Except...

Problem the First: Pets attack the players

I figured making the pets friendly would be a matter of setting the following in game_pet...

Code:
#--------------------------------------------------------------------------  # * Get Allied Units  #--------------------------------------------------------------------------  def friends_unit    $game_party  end  #--------------------------------------------------------------------------  # * Get Enemy Units  #--------------------------------------------------------------------------  def opponents_unit    $game_troop  end
 

But it doesn't work. The pets attack the players regardless. I CAN set it so that pets use special skills that target allies (the enemies) but it seems like it might be more trouble in the long run.

 

Problem the Second: Enemies do not attack pets

 

I want enemies to target both actors and pets. I guess this means something like this in game_enemy...

 


Code:
#--------------------------------------------------------------------------  # * Get Enemy Units  #--------------------------------------------------------------------------  def opponents_unit    $game_party + $game_pets  end

 

but this crashes the game and not sure how to proceed from here. (I am a hack)

 

 

Thanks for any help you can give  🙂

 

 

 

EDIT: Boy do I feel stupid. I really should have thought of changing this line in game_pets

 

enemy = Game_Enemy.new(@enemies.size, member.enemy_id)

 

No wonder they were acting like enemies, they were enemies!

 

 

That said I'm still working on the second problem, so any tips that could be useful would be nice.

 

 

EDIT: And I got it figured out. Problem solved.

Original thread: https://forums.rpgmakerweb.com/threads/ace-how-do-enemies-choose-targets-custom-pet-scripting.17012/