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.

Dynamic character script?

simply put, I wanna create a new character IN-GAME,
then add it to the party.
*when you start the game, the actor does not exist in the data base.

I have a game where enemies can join your party. when this happens, I create a new actor with the enemy's states, and add it as party member. I can't create an actor for each enemy, cause there are 100+ enemies.
I made a script which duplicates Aluxes, give it new states & add it to the party. and.. somehow it works XD. so my Q:
1.what's the difference between $data_actors and $game_actors ?
2. about ID's: the new character will use ID bigger than the maximum value
- will this cause bugs?
-can I increase the maximum in-game?
3.why must I be so damn original? T.T

and.. last one:
4. if I had a method that receives enemy-ID, and creates an actor,
it'll be inside Game_Actor. so, how can I use it without a Game_Actor object?
can I have 2 initialize methods in ruby?
 

poccil

Sponsor

The variable $data_actors stores actors as they appear in the database.  They are instances of the class RPG::Actor.  The variable $game_actors stores the current state of actors in the game.  They are instances of the class Game_Actor and are included in save files.  The class RPG::Actor (see the help file) contains the data necessary to create a starting actor.  The following code shows how a new kind of actor can be created:

Code:
actor=RPG::Actor.new
actor.id=$data_actors.length
actor.name="Aluxes"
$data_actors.push(actor)
game_actor=Game_Actor.new(actor.id)
 
thanks, poccil. that's what I thought.
that was very helpful. :)
let me see if I get it right- provided that i have a method to turn any enemy into an actual character, I don't need it inside $data_actors, cause I'll never need to initialize my actor?
any idea how I change the maximum value?
 

khmp

Sponsor

Array.length equates to the same method functionality as Array.size. The only reason you would get an error for using it is that the invoking object is nil or undefined.
 

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