Changing features in-game

Status
Not open for further replies.

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I have a character whose equipment I want fixed the first time she joins the party, but not fixed when she joins again later. So I set her up with fixed equipment via features in the Actors tab. But I'm not sure what to do when I add her to the party the second time. I have to remove or void that feature via script and I can't see an easy way to do it.


Is there a way to do this via events? I couldn't see one. Even if there is, I'd still like to know how to do this via script, as I've come across a couple of other cases where I might need to change features on the fly.
 

VegaKotes

Veteran
Veteran
Joined
Jun 25, 2013
Messages
96
Reaction score
3
First Language
English
Primarily Uses
Could you create two versions of her and just set the second one to the same specs as the first?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Use class features maybe, assuming you're not using class changing scripts on your game... Create two classes... One has the Fixed equip feature, the other does not... then just change class in-game...
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Well, according to my great deal of poking at the way the data files are stored, features are a huh-uuuuuge pain. From what I understand it, features are stored in an array, but each feature itself is an array. Now, conveniently, we can't store things with string names, noooooo that'd be easy! Features are stored like this:

[[@code=23,@data_id=1,@value=0], [@code=3,@data_id=0,@value=0], [@code=40,@data_id=5,@value=2]]Rinse, repeat, done. I haven't made a list of what each code is for yet, so I can't help you there for now (I'll get around to it at some point), but that's how they look in the save file.

Good luck editing it with a script.

Edit: Just to clarify, Code is the feature (Seal Skill, Seal Equip, etc), Data_id is the specific type (i.e. Affect which parameter of an actor?), and Value I assume would be something you put in a text box, like how much an item should heal you.
 
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
Yeah, Game_Battler_Base has the list, and there are methods to GRAB the features depending on the code. But I suspect it returns a smaller array and not the entire features list, so you couldn't use the same scripts to tell it what to modify.

I don't want to create two versions or two classes, because when she joins the second time, I want her to have all the same stats that she had when she left the first time. I know at least EXP belongs to the class, so if I give her 2 classes, she'll start off at level 1 again.

I COULD work around that, but I'd REALLY like to just figure out how to change features, because, as I said, I have other situations where being able to change features will come in handy too.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You can always save the exp/level into a variable so that you can load it up later... Though of course, being able to change features in game is a really nice capability...
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
So are the features on the class or the actor?

Edit: So after poking around some, here's an idea! I have absolutely NO idea if this will work or not:

actor = $game_actors[1].actor.features.reject! {|feature| feature.code == 53 }#save_data($data_actors, "Data/Actors.rvdata2")That will wipe the feature out of the array (reject will remove any items that will somehow return true in the block. In this case, if the code is 53 (Equipment lock). The save_data part I had originally had in, and then realized that if you included that, any new games would not have the equipment locked. the reject! statement already removed the lock from the actor, so saving the game and reloading should have it work entirely fine, the actors aren't re-loaded from Actors.rvdata2 each time, because they change during the game.

This should be fine for what you're doing, just change the actor ID.
 
Last edited by a moderator:

VegaKotes

Veteran
Veteran
Joined
Jun 25, 2013
Messages
96
Reaction score
3
First Language
English
Primarily Uses
Yeah, Game_Battler_Base has the list, and there are methods to GRAB the features depending on the code. But I suspect it returns a smaller array and not the entire features list, so you couldn't use the same scripts to tell it what to modify.

I don't want to create two versions or two classes, because when she joins the second time, I want her to have all the same stats that she had when she left the first time. I know at least EXP belongs to the class, so if I give her 2 classes, she'll start off at level 1 again.

I COULD work around that, but I'd REALLY like to just figure out how to change features, because, as I said, I have other situations where being able to change features will come in handy too.
Correct me if I'm wrong but can't you set a variable to an actor's Level (possibly their exp points specifically) and then set another's level to that exp?

edit: Err Variable not exp.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Levels you can via event commands and variables... for exp I believe it can be via scripts...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
But folks, did you miss this bit?

I'd still like to know how to do this via script, as I've come across a couple of other cases where I might need to change features on the fly.
and

I COULD work around that, but I'd REALLY like to just figure out how to change features, because, as I said, I have other situations where being able to change features will come in handy too.
So let's forget the fixed/non-fixed equipment for a minute, because it's not the ONLY reason you could want to change features.

I DON'T want to do a workaround with duplicate actors or classes. I WANT to figure out how to change features on the fly.

Whether the features are on the class or the actor don't really matter. In my case, it's on the actor, because that's saved with the player's save data. But it could be on ANYTHING that has features, if you made sure it was saved too.
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
But folks, did you miss this bit?

and

So let's forget the fixed/non-fixed equipment for a minute, because it's not the ONLY reason you could want to change features.

I DON'T want to do a workaround with duplicate actors or classes. I WANT to figure out how to change features on the fly.

Whether the features are on the class or the actor don't really matter. In my case, it's on the actor, because that's saved with the player's save data. But it could be on ANYTHING that has features, if you made sure it was saved too.
I was editing my post D:

So after poking around some, here's an idea! I have absolutely NO idea if this will work or not:

actor = $game_actors[1].actor.features.reject! {|feature| feature.code == 53 }#save_data($data_actors, "Data/Actors.rvdata2") That will wipe the feature out of the array (reject will remove any items that will somehow return true in the block. In this case, if the code is 53 (Equipment lock). The save_data part I had originally had in, and then realized that if you included that, any new games would not have the equipment locked. the reject! statement already removed the lock from the actor, so saving the game and reloading should have it work entirely fine, the actors aren't re-loaded from Actors.rvdata2 each time, because they change during the game.

This should be fine for what you're doing, just change the actor ID.

Edit again! Also, if you want to change features as a whole, just add or remove them by doing the whole $game_actors[*id*].actor.features *insert your magical stuff here*, and you can do whatever you want with them. Add some (Don't forget they have to be RPG::BaseItem::Feature objects! RPG::BaseItem::Feature.new(code, data_id, value)!!), remove some, change some, whatever you want. Changing features on the fly, all via scripting. Yay!
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
It doesn't work, really? RPG::BaseItem (RPG::Actor's superclass, which holds the features array) sets the features array with an attribute accessor, so you *should* be able to alter it directly, no?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
(sorry - I didn't type it exactly as you had it, and I got errors - I deleted my post before doing a few more experiments, but obviously not before you saw it :D )

Ooh, that seems to work (now that I've looked into the syntax more).

No need to save $data_actors - I'm doing it to $game_actors, not $data_actors. And I wouldn't WANT to do it to $data_actors, as that would change it for future games too, prior to that point (so when the actor joins the party the first time in a subsequent game, the equipment would no longer be fixed).

Thanks for that - should give me enough information to be dangerous :)

Edit. I dunno ... it didn't save it after all. But I DEFINITELY don't want to be replacing Actors.rvdata2. So it removes it, but it comes back again when I load the saved data. Something to do with using $game_actors.actor instead of just $game_actors[1] maybe?
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
oooo nooooo, now I'm a double poster! Whatever shall I dooooo?

Anyway, glad you got it working. I realized half way through typing the description that you wouldn't want to save the actors file again, so I then commented it out. Otherwise, the features array was given an attr_accessor, so you can change it directly.

Good luck, and don't be *too* dangerous.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
save it to the save file for it to retain the values... 

Dekita's elemental script does something like saving the elemental variations of the actors... so that it will be updated when you change it in-game...
 
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
Yeah, sorry about that. My fault.

It's not quite working. Data isn't saved. When I save and load the save file, the equipment is still fixed.

But if it's part of $game_actors, then it IS being saved to the save file. Or, by saying $game_actors[1].actor am I now adjusting $data_actors[1]?
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I think the game loads the features from the Actors.rvdata2 file and not from the save file...

maybe you can edit the save/load scripts so that you can save the feature changes and load it correctly
 

Fomar0153

Arkz
Restaff
Joined
Mar 13, 2012
Messages
1,327
Reaction score
473
First Language
English
Primarily Uses
RMMZ
I just wrote a quick snippet that might help you.

Code:
class Game_Battler  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_accessor :add_features  attr_accessor :del_features  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  alias features_initialize initialize  def initialize    @add_features = []    @del_features = []    features_initialize  end  #--------------------------------------------------------------------------  # * Get Array of All Feature Objects  #--------------------------------------------------------------------------  def all_features    super + @add_features - @del_features  endend
And then in a script event:
Code:
f = $game_actors[1].features(51)[0]$game_actors[1].del_features.push(f)f = RPG::BaseItem::Feature.new(51,2)$game_actors[1].add_features.push(f)
Which would be removing his ability to equip axes in the default rtp heroes and add the ability to use claws. I would also need to refresh him or change his equipment via event.
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Yea, I saw your edit. I think that's because actors are partially loaded from the Actors file when you load a saved game. the regular $game_actors.features isn't the same as $game_actors.actor.features. The .actor way goes to the actor as defined in Actors.rvdata2, so you'll have to add a simple little script in with your loading code, something similar to this:

module DataManager class << self # This is how you alias methods in a module that begin with self. alias load_yer_game load_game_without_rescue end def self.load_game_without_rescue(index) load_yer_game(index) if $game_switches == true # ON $game_actors.actor.feature.reject! {|feat| feat.code == 53 } end endendThat's how I would do it. $game_switches is loaded when we run the new 'load_yer_game' method.

 

 

 

Edit: Or go the Fomar way. The Fomar way usually works well.

 

@Fomar: it's code 53 for locked equipment, by the way :p
 
Last edited by a moderator:

Fomar0153

Arkz
Restaff
Joined
Mar 13, 2012
Messages
1,327
Reaction score
473
First Language
English
Primarily Uses
RMMZ
I know, I just gave the example I tested the script with.

So assuming you wanted to remove all of a certain feature:

Code:
f = $game_actors[1].features(53)$game_actors[1].del_features += f
 
Status
Not open for further replies.

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,862
Messages
1,017,049
Members
137,570
Latest member
fgfhdfg
Top