RPG::Enemy full code

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I am aware of the enemy classes such as the enemy actions, battler hue, battler name, drop items, gold and params, but how can I call them? What are the arguments in actions, battler_hue, battler_name, drop_items, gold and params methods? Are they call like this?

Code:
def actions()   # things hereend
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
564
Reaction score
275
First Language
German
Primarily Uses
You can look those classes up in the makers manual. You can find it either in the program folder of the rpg maker or via  Help->Contents (F1)  in the editor itself.

The  Index  tab lists the build in classes as well as some of the standard classes. For a more cmplete documentation of the standard library classes you can also look at  http://ruby-doc.org/core-1.9.2/.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I've seen this a lot of times, but it doesn't show me the full code, which is what I wanted to see, so I maybe able to make a script out of it, or alias the methods that are inside.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Part of the engine's code is closed source, and the EULA specifically forbids reverse-engineering.


You have to limit yourself with the incomplete official documentation - any other information about the internal classes you might find on the internet is illegally obtained and using it will probably void the licence for the scripts where you're using that information.
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
564
Reaction score
275
First Language
German
Primarily Uses
As Andar stated, sourcecode is not provided for all built in classes/modules. RPG::Enemy is provided along with other database item classes. You should find the sourcecode at the bottom of the respective entry.

Don't expect much though, most of these classes only define an initialize method and a bunch of attribute accessors.

If you are planning to alias certain methods you probably won't need knowledge about the exact implementation of the original as long as you can tell its result.
 
Last edited by a moderator:

Balrogic

Veteran
Veteran
Joined
Dec 19, 2014
Messages
40
Reaction score
17
First Language
English
Primarily Uses
It's probably just yet another data structure as an object. I wouldn't be surprised if that *is* the full code. The editor basically takes what you put in it then saves to a bunch of different data classes. In this case, RPG::Enemy appears to save as Enemies.rvdata2. Looking through that, the only surprise I can see is extra features in the enemy and I can't make sense of the codes and data types because I haven't learned all the RPG::BaseItem::Feature codes yet. I guess if you want to change the features array you could add an attr_accessor :features to RPG::Enemy. If you want to access the data, figure out how it's being stored for battles then use the access methods on it.

I went into RM expecting hidden code and all that, what I've found so far is the opposite. Every case I've hit hard enough turned out to be a chain of methods coming from all sorts of weird and seemingly unrelated places with unrelated names. Start sticking this code snippet into methods, it will make it easier to track down what's actually happening with the methods you're investigating.

Code:
puts caller
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Then that's sad. Because I wanted to make something like randomized stats and parameters for my enemies, but since I don't know what to alias and do some objects of, this script is not to be created.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
There you are wrong - you don't need that knowledge to make different stats. In fact, you shouldn't even use alias for this but simply override and replace the existing structure with your own formulae.


Others have done this before, you might for example check Yanfly's Enemy Level script which replaces the existing values with others depending on player level.
 

Galenmereth

Retired
Veteran
Joined
May 15, 2013
Messages
2,248
Reaction score
2,158
First Language
English
Primarily Uses
N/A
Even if you don't know the inner workings of these methods, you know what values they return; you can test that, and thus surmise what they do. If you want to roll your own alternatives, that shouldn't be stopping you :)
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
564
Reaction score
275
First Language
German
Primarily Uses
RPG::Enemy does represent enemy database entries and holds the values of any data field from the respective database tab. That's the entire purpose of this class, there is nothing missing in the manual.

As a consequence, modifying this class might not be the best option to implement random parameters as any modification will affect all enemies that share the same database entry. If you want to implement anything unique to certain enemies you might want to stick with the Game_Enemy class and its superclasses Game_Battler and Game_BattlerBase.
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,203
First Language
Binary
Primarily Uses
RMMZ
Then that's sad. Because I wanted to make something like randomized stats and parameters for my enemies, but since I don't know what to alias and do some objects of, this script is not to be created.
Just thought I should mention, there is not even a need to alter the RPG::Enemy class at all, not for just having random stat values...

Code:
class Game_Enemy   def param(*args)    case args.shift    when 0 then 50 * $game_variables[5] + 10 / 4 # MHP    when 1 then 50 # MMP    when 2 then 50 # ATK    when 3 then 50 # DEF    when 4 then 50 # MAT    when 5 then 50 # MDF    when 6 then 50 # AGI    when 7 then 50 # LUK    else ; 0    end  endend
 
Last edited by a moderator:

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Thank you so much for that answer. I will see and read about this and see what I may come up with. You're really the best :D
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,203
First Language
Binary
Primarily Uses
RMMZ
Course I am ^_^

But since you noticed, here is an example on how to create a 'randomized' stat value.  If you tried to do that in the regular 'param' method, it would cause problems with each refresh generating a new stat value...

Anyway...

Code:
class Game_Enemy   # This creates a cache to store the generated calculation for param @ index.  def param_base(index)    (@newpar ||= [])[index] ||= cool_param_calculation(index)  end    # This does a calculation to determine the value for the param @ index.  # base = A random value whose max is the database stat for the enemy.  def cool_param_calculation(index)    base = rand(enemy.params[index]) + 1    base = base * 10 if [0,1].include?(index)     base * $game_variables[5] + 10 / 4  end  end
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top