Giving Battler's New Parameters

Status
Not open for further replies.

Maximus32

Absolute Genius
Veteran
Joined
Feb 20, 2014
Messages
81
Reaction score
27
First Language
English
Primarily Uses
N/A
I would like to define a new parameter for a battler, called Imagination (IMG).

Observing the param and feature methods of the BattlerBase class, however, shortly leads me to confusion. Such as this snippet of code:

feature_objects.inject([]) {|r, obj| r + obj.features }defined under the all_features method. I imagine it has something to do with the RVDATA2 files, but I'm not sure. If anyone has some knowledge of how this works or the proper way of defining a new parameter, their help would be greatly appreciated.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That line of code is the bane of my life!

feature_objects is the group of objects that can have features.  So for an actor, it would be states, equipment (weapons and armors), class, and the actor itself.  For an enemy, it's just states and the enemy itself.

What the whole line of code is doing is creating a new array, by taking the features from each of those objects.

If you want to add a NEW feature, you won't be able to do it via the database.  And unfortunately most (?) features are linked with the $data classes, not the $game classes, so making a change via script will not guarantee that it's still there if you save your game and resume it later.

You might be able to use and maybe modify my Dynamic Features script to add new features, but then you'd still need to modify the other scripts to actually use it, because just having it there won't make it actually do anything.
 

Maximus32

Absolute Genius
Veteran
Joined
Feb 20, 2014
Messages
81
Reaction score
27
First Language
English
Primarily Uses
N/A
Ha ha! I feel your pain...

So I did some more research on features and parameters and what not, and I think I understand them quite a bit better. Using your awesome Dynamic Features engine seems to do the trick, and it's astounding that the code isn't that complicated for such a useful script   :)

I defined a new feature that is a parameter for enemies and actors (which I call IMG) and initialized it at the beginning of the game. I have one problem, however: although I can reference it from the RPG maker event scripter fine, how would you reference the get_feature method from within the script editor itself? It appears to stem from the object class... or something... But when I call it from Game_Enemy, it throws an error.
 

Mouser

Veteran
Veteran
Joined
Aug 19, 2012
Messages
1,245
Reaction score
264
First Language
English
Primarily Uses
The far simpler, if less elegant, solution is to pick one of the already existing features that you aren't using (or don't feel you need) and 'repurpose' it to do what you want it to do.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Check the script again - see if Game_Enemy is included in there. For some reason when I initially wrote it, I didn't include enemies at all. In the script comments you can see that someone indicated it was really easy to make it apply to enemies, so maybe that's all you need to do.


Enemies are a bit funny - you can't link directly back to the Data_Enemies object from a Game_Enemy. You've got to do it through $game_troop.members[index].enemy.features - that might get you a little further.


If it doesn't, let us know the exact error message you're getting (post a screenshot, if possible) as well as the command you're using to try and get to it.
 

Maximus32

Absolute Genius
Veteran
Joined
Feb 20, 2014
Messages
81
Reaction score
27
First Language
English
Primarily Uses
N/A
Yeah, I saw that handling for enemies was missing in the comments, but added it according to Tsukihime's instructions easily enough.

Unfortunately, the error still occurs even when I try to reference the enemy from the $game_troop.

Here are my attempts:

#1

class Sprite_Battler < Sprite_Base ... def set_imagination if @battler.is_a?(Game_Enemy) @img = @battler.get_feature:)param, 8) @iml = @battler.get_feature:)param, 9) else @img = @battler.get_feature:)param, 8) @iml = @battler.get_feature:)param, 9) end end ...end#2

class Sprite_Battler < Sprite_Base ... def set_imagination if @battler.is_a?(Game_Enemy) index = $game_troop.members.index(@battler) @img = $game_troop.members[index].get_feature:)param, 8) @iml = $game_troop.members[index].get_feature:)param, 9) else @img = @battler.get_feature:)param, 8) @iml = @battler.get_feature:)param, 9) end end...endAs you can see, I am trying to change the appearance of the battler based on this parameter. Actually, there are two parameters, but that shouldn't make a difference. Also, I know that the 1st block of code is a little redundant, but I'm just keeping that way for now, until I can be sure that I don't need to discriminate between actors and enemies when getting features.

This is the error either of these throw:



Also, thanks for the suggestion Mouser, but I would like to have my own defined parameters. Plus, it's not hard at all adding the features with Shaz's Manager, just referencing them :p
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
@battler.enemy.get_feature(...)


As I said, Game_Enemy is not the same as Data_Enemy. You have to use Game_Enemy's enemy method to take that next step back.
 

Maximus32

Absolute Genius
Veteran
Joined
Feb 20, 2014
Messages
81
Reaction score
27
First Language
English
Primarily Uses
N/A
Aha! Yes! It works fine now. The method is called without error and the graphics are adjusted as necessary. Thank you so much. I did not even know such a method existed!

And thus, my problem has been solved!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
lol - I didn't know such a method existed either, for a long time, which led to many hours of hair-pulling :)


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
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.

Forum statistics

Threads
105,868
Messages
1,017,081
Members
137,582
Latest member
Spartacraft
Top