Jump to content
Rpg²S Forum
  • 0

Aiuto RGSS3 su Simple Row Script


Riccardo
 Share

Question

Salve ragazzi,

sono tornato con altri dubbi esistenziali sull'uso dell'RGSS3.
Premetto, non so se questo vada più in Supporto o Richieste scripts, immagino che lo lascerò decidere a voi e poi un moderatore potrebbe eventualmente spostare di conseguenza.
I miei dubbi/problemi sono questi.

Ho questo script realizzato da Mr. Trivel:

 

 

# )----------------------------------------------------------------------------(
# )--     AUTHOR:     Mr Trivel                                              --(
# )--     NAME:       Simple Battle Rows                                     --(
# )--     CREATED:    2014-06-15 (2014-07-10)                                --(
# )--     VERSION:    1.2                                                    --(
# )----------------------------------------------------------------------------(
# )--                         VERSION HISTORY                                --(
# )--  1.2  - Some skills can ignore battle row positions and deal full dmg. --(
# )--  1.1b - Displayed damage is fixed.                                     --(
# )--  1.1a - Enemies have rows, too.                                        --(
# )--  1.1  - Attacks while attacking from back row will deal less  damage   --(
# )--  than from front row. User can set up exceptions like ranged weapons   --(
# )--  or long reaching melee weapons.                                       --(
# )--  1.0  - Initial Script                                                 --(
# )----------------------------------------------------------------------------(
# )--                          DESCRIPTION                                   --(
# )--  This scripts adds basic Battle Row functionality. You can switch rows --(
# )--  in menu Formation command by selecting same Actor twice.              --(
# )--  Battlers in backrow will receive less damage than the ones in the front.(
# )--  Battlers in backrow will receive same damage if front row is wiped.   --(
# )--  Battlers attacking from back row will have damage penalty, unless     --(
# )--  stated in exceptions.                                                 --(
# )----------------------------------------------------------------------------(
# )--                          INSTRUCTIONS                                  --(
# )--   Use <backrow> note tag for enemies to set them in Back Row.          --(
# )--                     Plug, Custmomize, Play.                            --(
# )----------------------------------------------------------------------------(
# )--                          LICENSE INFO                                  --(
# )--  [url]http://mrtrivelvx.wordpress.com/terms-of-use/[/url]                         --(
# )----------------------------------------------------------------------------(

module MrTS
  module Formation
    # )------------------------------------------------------------------------(
    # )--  0.6 - means backrow takes 60% of the damage                       --(
    # )--  0.7 - 70%, 0.3 - only 30%, etc...                                 --(
    # )------------------------------------------------------------------------(
    DAMAGE_BACKROW_TAKEN = 0.5
    
    # )------------------------------------------------------------------------(
    # )--  0.4 - means Backrow only deals 40% of the damage, unless the      --(
    # )--  weapon type is in no_penalty_backrow_weapon_ids list.             --(
    # )------------------------------------------------------------------------(
    DAMAGE_BACKROW_DEALT = 0.4
    
    # )------------------------------------------------------------------------(
    # )--  Weapon settings. Back row: You can only attack with them in       --(
    # )--  backrow.( Front row: You can only attack with them in front row.  --(
    # )------------------------------------------------------------------------(
    BACKROW_WEAPON_IDS = [3]
    FRONTROW_WEAPON_IDS = []
    
    # )------------------------------------------------------------------------(
    # )--  Weapon type with these IDs won't receive a damage penalty while   --(
    # )--  attacking with them in the backrow. (For ranged weapons/polearms) --(
    # )------------------------------------------------------------------------(
    NO_PENALTY_BACKROW_WEAPON_IDS = [3, 4]
    
    # )------------------------------------------------------------------------(
    # )--  Skills with IDs listed in the array won't have it's damage        --(
    # )--  penalized when using from back row or on a back row battler.      --(
    # )------------------------------------------------------------------------(
    NO_PENALTY_SKILL_IDS = [12]
  end
end

$imported ||= {} ; $imported["MrTS_Simple_Battle_Rows"] = true

# )---------------------------(
# )--  Class: Game_Battler  --(
# )---------------------------(
class Game_Battler < Game_BattlerBase  
  # )---------------------------------(
  # )--  Public Instance Variables  --(
  # )---------------------------------(
  attr_reader :battle_row
  
  # )--------------------------(
  # )--  Method: initialize  --(
  # )--------------------------(
  alias mrts_initialize_b initialize
  def initialize
    mrts_initialize_b
    @battle_row = 0
  end
  
  # )------------------------------(
  # )--  New Method: switch_row  --(
  # )------------------------------(
  def switch_row
    if @battle_row == 0
      @battle_row = 1
    else
      @battle_row = 0
    end
  end
  
  # )-------------------------------------------(
  # )--  Overwrite Method: make_damage_value  --(
  # )-------------------------------------------(
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    if item.is_a?(RPG::Skill) && !MrTS::Formation::NO_PENALTY_SKILL_IDS.include?(item.id)
      value *= MrTS::Formation::DAMAGE_BACKROW_TAKEN if self.battle_row == 1 && self.is_front_row?
      if user.is_a?(Game_Actor)
        value *= MrTS::Formation::DAMAGE_BACKROW_DEALT if user.penalty_damage?
      end
    end
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end
  
  # )---------------------------------(
  # )--  New Method: is_front_row?  --(
  # )---------------------------------(
  def is_front_row?
    return $game_party.get_frontrow_size > 0 if self.is_a?(Game_Actor)
    return $game_troop.get_frontrow_size > 0 if self.is_a?(Game_Enemy)
  end
end

# )--------------------------------(
# )--  Class: Window_MenuStatus  --(
# )--------------------------------(
class Window_MenuStatus < Window_Selectable
  # )-----------------------------------(
  # )--  Overwrite Method: draw_item  --(
  # )-----------------------------------(
  def draw_item(index)
    actor = $game_party.members[index]
    enabled = $game_party.battle_members.include?(actor)
    rect = item_rect(index)
    draw_item_background(index)
    draw_actor_face(actor, rect.x + 1 + 10*actor.battle_row, rect.y + 1, enabled)
    draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
  end
end

# )-------------------------(
# )--  Class: Scene_Menu  --(
# )-------------------------(
class Scene_Menu < Scene_MenuBase
  # )-------------------------------=---------(
  # )--  Overwrite Method: on_formation_ok  --(
  # )----------------------------------=------(
  def on_formation_ok
    if @status_window.pending_index >= 0
      $game_party.swap_order(@status_window.index,
                             @status_window.pending_index)
      if @status_window.pending_index == @status_window.index
        $game_party.members[@status_window.index].switch_row
        @status_window.redraw_item(@status_window.index)
      end
      @status_window.pending_index = -1
      @status_window.redraw_item(@status_window.index)
    else
      @status_window.pending_index = @status_window.index
    end
    
    @status_window.activate
  end
end

# )-------------------------(
# )--  Class: Game_Party  --(
# )-------------------------(
class Game_Unit
  # )------------------------------------(
  # )--  New Method: get_backrow_size  --(
  # )------------------------------------(
  def get_backrow_size
    size = 0
    battle_members.each do |memb|
      size += 1 if memb.alive? && memb.battle_row == 1
    end
    
    return size
  end
  
  # )-------------------------------------(
  # )--  New Method: get_frontrow_size  --(
  # )-------------------------------------(
  def get_frontrow_size
    size = 0
    alive_members.each do |memb|
      size += 1 if memb.battle_row == 0
    end
    
    return size
  end
end

# )-------------------------(
# )--  Class: Game_Actor  --(
# )----------------0--------(
class Game_Actor < Game_Battler
  # )----------------------------------------(
  # )--  New Method: get_weapon_row        --(
  # )----------------------------------------(
  def get_weapon_row
    weapons.each do |w| 
      if MrTS::Formation::BACKROW_WEAPON_IDS.include?(w.wtype_id)
        return 1
      elsif MrTS::Formation::FRONTROW_WEAPON_IDS.include?(w.wtype_id)
        return 0
      end
    end
    return 2 # both rows
  end
  
  # )----------------------------------------(
  # )--  New Method: penalty_damage?       --(
  # )----------------------------------------(
  def penalty_damage?
    weapons.each do |w| 
      if (MrTS::Formation::NO_PENALTY_BACKROW_WEAPON_IDS.include?(w.wtype_id) && @battle_row == 1) || @battle_row == 0
        return false
      end
    end
    return true
  end
end

# )-------------------------(
# )--  Class: Game_Enemy  --(
# )-------------------------(
class Game_Enemy < Game_Battler
  
  # )---------------------------------(
  # )--  Alias To: initialize       --(
  # )---------------------------------(
  alias mrts_initialize initialize
  def initialize(*args)
    mrts_initialize(*args)
    @battle_row = enemy.note =~ /<backrow>/i ? 1 : 0
  end
end

# )----------------------------------(
# )--  Class: Window_ActorCommand  --(
# )----------------------------------(
class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Add Attack Command to List
  #--------------------------------------------------------------------------
  def add_attack_command
    add_command(Vocab::attack, :attack, @actor.attack_usable? && [@actor.battle_row, 2].include?(@actor.get_weapon_row))
  end
end 

 



E' un semplice ed essenziale script che inserisce le Linee nel party stile final fantasy. Insomma se sei in Prima Linea prendi e infliggi la normale quantità di danno, se sei in seconda linea il danno inflitto e ricevuto viene opportunamente ridimensionato, funzionalità tra l'altro già presente in RMXP tant'è vero che mi chiedo cosa li abbia spinti a rimuoverla.

Tornano on topic.
Quello che mi serve è che all'inizializzazione e ad eventuali cambi, vengano assegnati a quel personaggio degli stati, rispettivamente Prima e Seconda Linea che hanno valenza puramente visiva. Non fanno nient'altro che quello che fa già lo script, ma dato che non è presente in battaglia una qualche dimostrazione della linea effettivamente usata, almeno con questa indicazione sarebbe più facile comprendersi.
Ora so che dovrebbero essere utilizzati i comandi add_state e remove_state il problema è che non ho affatto compreso su che classe invocare i due metodi o comunque anche se l'ho compreso non riesco ad invocarli senza errori. Quindi avrei bisogno di qualche aiuto a riguardo.

L'altro quesito è se fosse possibile, apportando giusto qualche minima modifica al codice(su vostro consiglio magari), fare in modo che all'inizializzazione anziché essere tutti i personaggi inizializzati sulla Prima Linea si possa, attraverso opportune indicazioni, settare la posizione di partenza.

Ad es. Settando tra le note del personaggio <row: 1> vorrei che il personaggio venisse inizializzato in Seconda Linea.

Terza ed ultima nota. Dispongo dello script di Yanfly "Battle Command" che permette di aggiungere nuovi comandi nella schermata di combattimento.
Nulla di strano con questo, infatti, tra le opzioni dello script c'è quello di poter settare un comando che attivi un determinato evento comune, nell'evento comune poi c'è la chiamata o l'operazione che necessito di fare.
Bene, ho creato il comando "Cambia Linea", ho creato l'evento comune e la chiamata si attiva effettivamente, ma non capisco qual è la giusta invocazione del metodo switch.row
Ho provato "Game_Battler.switch_row" visto che la funzione sembra invocata nella classe Game_Battler, ma non funziona. Ne ho provati in realtà molti altri, che non sto neanche qui ad elencarvi.
Quindi niente avrei bisogno che qualcuno mi desse una dritta anche su questa chiamata che probabilmente è di una banalità assurda.

Eccoci qui ragazzi fine del post!
Vi ringrazio intanto per essere arrivati fin qui!
Spero di essere stato abbastanza chiaro, ovviamente non fatevi problemi a chiedermi eventuali altre spiegazioni. Farò in modo di essere più chiaro.
Sono abbastanza convinto che agli occhi di un esperto programmatore RGSS3 questi quesiti saranno delle vere inezie, ma io mi sto da poco affacciando al lato script di RPG Maker e ho ancora molte cose da comprendere.

Ringrazio anticipatamente tutti coloro che avranno la gentilezza di rispondere e aiutarmi!
Saluti :smile:

Edited by Riccardo
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...