Giving Battler's New Parameters

● ARCHIVED · READ-ONLY
Started by Maximus32 9 posts View original ↗
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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:

    error.png

    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
  7. @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.
  8. 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!
  9. 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.