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.

[RMVX] [Request Filled] Betrayal - Battle a Party Member

I'm sorry for asking for so many scripts recently.  I really want to use all of the ones I requested.  Anyway, I'm creating another game for now where a character from the party betrays the main character and you have to battle him.  However, I want him with all the stats, skills, equipment, etc. as when he was in the party.  This should be pretty easy . . . I think.  Anyway, I hope someone will help.
 
I like this idea...

This will transfer all the data you see here. (name, stats, battler graphic, and weapon animations)

Enemies don't have weapons, just an ATK value. (actors get their ATK from their weapon)
This will transfer the animations from the current equipped weapon to the enemy.

[ EDIT ] I'm an idiot, this is for RMXP.  I'll port it over to VX and post it here as well.

Code:
#  transfer the stats of an actor in the party to an enemy
#  used to do battle with a party member

module Actor2Enemy
  def self.transfer_stats(enemy_num = 33, actor_num = 1)
    $data_enemies[enemy_num].name = $game_party.actors[actor_num].name
    $data_enemies[enemy_num].maxhp = $game_party.actors[actor_num].maxhp
    $data_enemies[enemy_num].maxsp = $game_party.actors[actor_num].maxsp
    $data_enemies[enemy_num].str = $game_party.actors[actor_num].base_str
    $data_enemies[enemy_num].dex = $game_party.actors[actor_num].base_dex
    $data_enemies[enemy_num].agi = $game_party.actors[actor_num].base_agi
    $data_enemies[enemy_num].int = $game_party.actors[actor_num].base_int
    $data_enemies[enemy_num].atk = $game_party.actors[actor_num].base_atk
    $data_enemies[enemy_num].pdef = $game_party.actors[actor_num].base_pdef
    $data_enemies[enemy_num].mdef = $game_party.actors[actor_num].base_mdef
    $data_enemies[enemy_num].eva = $game_party.actors[actor_num].base_eva
    $data_enemies[enemy_num].battler_name = $game_party.actors[actor_num].battler_name
    weapon = $game_party.actors[actor_num].weapon_id
    $data_enemies[enemy_num].animation1_id = $data_weapons[weapon].animation1_id
    $data_enemies[enemy_num].animation2_id = $data_weapons[weapon].animation2_id
  end
end

Where we run into confusion is the skills. Actors have Skills, Enemies have Actions.
Actions consist of "Conditions", an Action (Attack, Defend, Escape, Do Nothing, or a Skill),
and Ratings for each Action.
Essentially, it replaces the player deciding the action for an actor, with a very rudimentary AI for the enemy.

You'll have to help me with how you want to map the skills to actions.
Or, just define the actions in the "Betrayer" Enemy

To set it up, create an enemy called, "Betrayer"
You shouldn't have to set anything but the EXP, Gold, Treasuer if you want to reward the player.
Create a Troop called "Betrayer*1"  (the names are arbitrary, you can set them to what you want.)

Then, in your event that starts the battle...
Code:
Script: Actor2Enemy.transfer_stats(enemy_id, actor_num)  
Battle Processing: Betrayer

enemy_id is the enemies number from the database
actor_num is the actors order in the party (starting with 0)

you can also call without the arguments... Script: Actor2Enemy.transfer_stats
and the defaults are enemy[33], and actor[1]  (the second actor in the party)

And, if you want to change the defaults, look at line 5 in the script.

  def self.transfer_stats(enemy_num = 33, actor_num = 2)

and change the 33 & 2 to whatever you want. I used 33 because it was the next available Enemy slot in the default game.

GIve it a shot.

Be Well
 
Sorry, I did it, I just hadn't finished testing it.
Since there are no Actor battler's in VX by default, I just used the actor's name to define the enemy's battler.  So, if your actor is 'Ulrika', you'll need to put a Ulrika.png file in the Battlers folder.

Code:
#  transfer the stats of an actor in the party to an enemy
#  used to do battle with a party member

module Actor2Enemy
  def self.transfer_stats(enemy_num = 31, actor_num = 1)
    $data_enemies[enemy_num].name = $game_party.members[actor_num].name
    $data_enemies[enemy_num].maxhp = $game_party.members[actor_num].maxhp
    $data_enemies[enemy_num].maxmp = $game_party.members[actor_num].maxmp
    $data_enemies[enemy_num].atk = $game_party.members[actor_num].base_atk
    $data_enemies[enemy_num].def = $game_party.members[actor_num].base_def
    $data_enemies[enemy_num].agi = $game_party.members[actor_num].base_agi
    $data_enemies[enemy_num].spi = $game_party.members[actor_num].base_spi
    $data_enemies[enemy_num].atk = $game_party.members[actor_num].base_atk
    $data_enemies[enemy_num].hit = $game_party.members[actor_num].hit
    $data_enemies[enemy_num].has_critical = $game_party.members[actor_num].cri
    $data_enemies[enemy_num].eva = $game_party.members[actor_num].eva
    $data_enemies[enemy_num].battler_name = $game_party.members[actor_num].name
  end
end
 
I'm having some issues with it, but I know it's because I'm doing something wrong, so I'll explain what I did.

1. I put the VX script in a new slot above (Insert Here) in Materials.  I'm using default actor #6, Oscar, so I changed it to (enemy_num = 31, actor_num = 6).  I named it Battle Party Member.
2. The character I was using actually had a battler already, but I still exported and imported it with the name Oscar.
3. I created enemy #31 and named it Betrayer, but didn't change anything else.
4. I created troop #31 and named it Betrayer, also, and again didn't change anything else.
5. Created an event.  The event commands are as follows (I was just testing the script first):
@>Text: 'Evil', 3, Normal, Bottom
:    : Ready?
@>Show Choices: Yes, No
:  When [Yes]
    @>Script: Actor2Enemy.transfer_stats
    @>Battle Processing: Betrayer
    @>
:  When [No]
    @>
:  Branch End
@>
6. I walk down to the event, click yes, and . . .
Script 'Battle Party Member' line 6: NoMethodError occured.
undefined method 'name' for nil:NilClass.

I'm sorry for my lack of script knowledge as I've only used a couple so far.  Since you tested it, I just messed up somewhere, but I have no idea where.  Thanks for your help, by the way.  I feel bad asking for a script and then asking how to use it.
 
Nope, only one small mistake, and that could just be a communication error on my part.

YOu said you wanted to transfer the 'current' stats, so I assumed the actor was in the party.
If it's just an idle actor in the database, you could create the enemy to match without needing the script.

The actor_num is the actors order in the party, not the actor number from the database.

So, if Oscar is the 3rd actor in the party, you use actor_num = 2  in the script, or
Actor2Enemy.transfer_stats(31, 2)  in the event command.

If you want to remove Oscar from the party, since he is now an enemy, do it after transfering the stats.

Hope that helps.
 
Ah, that makes sense.  OK, it's working now.  Just a quick question: does it transfer the name?  By the look of this line:

$data_enemies[enemy_num].name = $game_party.members[actor_num].name

I'm assuming it does, but I just want to make sure.  I used the name input function for the character to increase the player's attachment when they have to fight him.  That sounds unusually evil for some reason.

A couple of other questions:
1. About scripts - if you put the # symbol in front of a line, it appears to be a description or something.  If I just put a # sign followed by a couple of notes about how to work it, will it affect the script in any way?

2. About the game - I've gotten to a point in the game where I've decided to stop and have a couple people test it for errors.  Are you interested in playing what I've got?
 
Yes, it will transfer the name. And it should transfer the 'changed' name as well.

1) Yes, anything in a line after a # sign gets ignored by the interpreter.

2) Sure, I'll check it out.

Be Well
 

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