Recording changes to Actor Class name in save files.

● ARCHIVED · READ-ONLY
Started by ArcherBanish 3 posts View original ↗
  1. So this is the issue I have currently presented to myself.
     

    The Already Done
    Since I decided to learn RGSS3 I started out trying to make a simple script, that turned out to not be so simple after all.

    Spoiler
    class Class_Upgrade def upgradeAllActors actor_index = 1 while(actor_index < $data_actors.length) upgradeActor(actor_index) actor_index = actor_index + 1 end end def upgradeActor(actor_id) changeName(actor_id) changeSkillTypes(actor_id) changeWeaponTypes(actor_id) changeArmorTypes(actor_id) end def changeName(actor_id) $data_classes[$data_actors[actor_id].class_id].note[/.*<upgrade name:\s*([a-zA-Z\s]*)>.*/im] if $1 != nil && $1 != "" $data_classes[$data_actors[actor_id].class_id].name = $1 end end def changeSkillTypes(actor_id) $data_classes[$data_actors[actor_id].class_id].note[/.*<upgrade skill type:\s*([0-9,\s]*)>.*/im] if $1 != nil && $1 != "" vector = $1.split(',') gi = Game_Interpreter.new for id in vector gi.add_feature:)class, actor_id, :stype_add,id.to_i) end end end def changeWeaponTypes(actor_id) $data_classes[$data_actors[actor_id].class_id].note[/.*<upgrade weapon type:\s*([0-9,\s]*)>.*/im] if $1 != nil && $1 != "" vector = $1.split(',') gi = Game_Interpreter.new for id in vector gi.add_feature:)class, actor_id, :equip_wtype,id.to_i) end end end def changeArmorTypes(actor_id) $data_classes[$data_actors[actor_id].class_id].note[/.*<upgrade armor type:\s*([0-9,\s]*)>.*/im] if $1 != nil && $1 != "" vector = $1.split(',') gi = Game_Interpreter.new for id in vector gi.add_feature:)class, actor_id, :equip_atype,id.to_i) end end endend
    The Side Problem

     I can change the name of the class simply by using the code:

    Spoiler
    def changeName(actor_id) $data_classes[$data_actors[actor_id].class_id].note[/.*<upgrade name:\s*([a-zA-Z\s]*)>.*/im] if $1 != nil && $1 != "" $data_classes[$data_actors[actor_id].class_id].name = $1 endend
    However. There is the slight problem that this change is not recorded. Because "$data_classes" ( or any of the "$data_..." variables as far as I can tell) saved in the savefile so, when I close the game and load the game after I have ran that code, the change never took place.
     
    After some looking arround in the code I realize that all the saved values go in "$game_..." variables that are then put into a "contents" array that is then saved.
     
    My thought is that I need to create a new variable lets say "$game_class_upgrad" and save my changes on that variable. (Which I have a slight idea how to do... not sure I must say) I belive I must so something like this code that was very much based on a script that is (linked on the end of this post)

    Spoiler
    #-------------------------------------------------------------------------- # * Create Game Objects #-------------------------------------------------------------------------- def self.create_game_objects x_dynamic_features_create_game_objects $game_class_upgrade = {} end #-------------------------------------------------------------------------- # * Create Save Contents #-------------------------------------------------------------------------- def self.make_save_contents contents = x_dynamic_features_make_save_contents contents[:cunames] = $game_class_upgrade ? $game_class_upgrade : {} contents end #-------------------------------------------------------------------------- # * Extract Save Contents #-------------------------------------------------------------------------- def self.extract_save_contents(contents) x_dynamic_features_extract_save_contents(contents) $game_class_upgrade = contents[:cunames] ? contents[:cunames] : {} end
    (I'm preaty sure I can work out how to use that variable correctly but any help would be nice)

    The Point

    The biguest issue would be that, as far as I can figure out, the only way I would be able to change the name of the class would change the class name permanently for as long as the game was open.

    So lets say you open the game and upgrade your class, the class name will change. Then you quit to title start the game again and open the menu, your class will still have the altered name.

    So even if I manage to save and load the values correctly, since it doesn't seam like the game saves the Classes at all, I still have the problem that it would alter the default game Database, I would have then to save this data somewhere, somehow and then display it instead of the default text.

    What would be the best way to do this?

    I thank everyone that helps me out already in advance and sorry if I rambled a bit in this post but at least the last few things came to my mind while writing it.

    Note: The "add_feature" function as well as the base for the content saving, loading code, are from the script Dynamic Featureshttp://forums.rpgmakerweb.com/index.php?/topic/19645-dynamic-features/ by Shaz I removed some code that would be in there for I didn't feel it would be right to have it apear. I do however belive that looking deeper into the code of this script might help me figure out what to do.

    Note 2: There might be something very wrong that I am doing on the line "gi = Game_Interpreter.new" this isn't a very big issue I believe but still if someone could point me out if this is what I should be doing or if I am making a mistake I would apreciate it.
  2. Why are you changing the name of the class? Why not change the actor's class instead?
  3. Engr. Adiktuzmiko said:
    Why are you changing the name of the class? Why not change the actor's class instead?
    Honestly I did it mostly to see what I could or could not do regarding Classes.

    Therefor I was experimenting with altering the class itself.

    Well I tought about it and I will probably just scrap the idea with the changing then saving the values of the class, I seem to be over my head so far.

    I will keep this topic open to see if somone can give me a hint of what I should do in that situation.

    Thank you for taking the time Engr. Adiktuzmiko

    Edit: I ended up simply changing the complete thing and doing

    class Game_Interpreter  def command_321    actor = $game_actors[@params[0]]    actor.change_class(@params[1], true) if actor && $data_classes[@params[1]]  endend

    Basicly just changed the parrameters of the call to  the Game_Actor.change_class() function so the Event "Change Class" would mantain the Exp of the character that was being changed. 

    I'm making this as solved thank you again.