Please supervise/review my small edit on a battle script (RPG XP)

Started by koktengri, January 28, 2017, 05:32:43 pm

Previous topic - Next topic

koktengri

Evenin'.
Yes, thanks for reading this.
let me first say, that I am not a scripter. I've made a small edit on atoas acbs battlesystem script. So I want someone else to check if the edits are correct or not because my scripting skills are VERY VERY limited.
What I wanted to make: I wanted to create a state like Lex aeterna from the MMORPG Ragnarok online. When you dont know what it does: When a certain enemy or hero is infected with the Lex aeterna state, the next attack (regardless of whether it is normal attacking or a skill), will do double the damage. After the attack/skill is done, the state will vanish. The state 87 is the LEX Aeterna state I mentioned.
Heres what I did:

The original line from 406-428 untouched
#--------------------------------------------------------------------------
  # * Applying Normal Attack Effects
  #     attacker : battler
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    self.sp_damage = false
    hit_result = set_attack_hit_result(attacker)
    if hit_result
      set_sp_damage(attacker, attacker.actor? ? attacker.weapons[0] : nil)
      set_attack_damage_value(attacker)
      if attacker.target_damage[self] > 0
        attacker.target_damage[self] /= 2 if self.guarding?
        set_critical_damage(attacker, attacker.weapon_critical_damage) if self.critical
        apply_variance(attacker.weapon_variance, attacker)
      end
      set_attack_state_change(attacker)
    else
      attacker.target_damage[self] = Miss_Message
      self.critical = false
    end
    set_attack_damage(attacker)
    return true
  end


Under the line attacker.target_damage[self] /= 2 if self.guarding?
I put the following line:
Quoteattacker.target_damage[self] *= 2 if self.states.include?(87)



The original Line 592-623 reads as:
#--------------------------------------------------------------------------
  # * Set skill result
  #     user      : user
  #     skill     : skill
  #     effective : effective skill
  #--------------------------------------------------------------------------
  def set_skill_result(user, skill, effective)
    set_sp_damage(user, skill)
    set_skill_damage_value(user, skill)
    if user.target_damage[self].abs > 0
      user.target_damage[self] /= 2 if self.guarding?
      if self.critical
        if check_include(skill, 'CRITICALDAMAGE')
          ext = check_extension(skill, 'CRITICALDAMAGE/')
          rate = ext.nil? ? Base_Critical_Damage : Base_Critical_Damage + ext.to_i
        elsif check_include(skill, 'CRITICALWEAPONDAMAGE')
          ext = checkextension(skill, 'CRITICALWEAPONDAMAGE/')
          rate = user.weapon_critical_damage
          rate +=  ext.to_i unless ext.nil?
        end
        set_critical_damage(user, rate)
      end
      apply_variance(skill.variance, user)
      apply_variance(user.weapon_variance, user) if check_include(skill, 'WEAPONVARIANCE')
    end
    effective |= set_skill_state_change(user, skill, effective)
    if effective and not $game_temp.in_battle
      set_damage(user, skill)
      apply_damage(user.target_damage[self], self.sp_damage)
    end
    return effective
  end


under the line
user.target_damage[self] /= 2 if self.guarding?
I created the following line
user.target_damage[self] *= 2 if self.states.include?(87)

Thanks for reading me, I hope for feedback.

KK20


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

koktengri

Yes, it seemed to work, but I didint know if something was missing that could ruin my project. Also I really didint know if the places where I put the things were at the right place. To be honest, it was more luck that I had the right place. Id like to prevent problems before they even appear. I hope that was okay.
And since we're talking about the script, heres what also bothers me which I havent found a solution for.
Atoa has a nice CTBlike script that I use. He has made a thing called CTB_Delay, (skills can do a delay on the CTB Bar when damage is received). It is determinable how strong a skill can delay the ctb bar.

The configuration sections is as following. (im going to quote in parts because the script itself is too big.)
#--------------------------------------------------------------------------
  # Delay on the CTB bar when recive damage
  # This value is used for all actions that don't have individual definition.
  Base_CTB_Delay = 0
   
  # Set here the actions that will cause CTB delay
  # 
  #   Cast_Cancel[Action_Type] = {Action_ID => Delay}
  #     Action_Type = 'Skill' for skills, 'Item' for items, 'Weapon' for weapons
  #     Action_ID = ID of the skill, item or weapon
  #     Delay = CTB delay value, increases with damage caused.
  #
  # Important: if the action is an physical skill, the weapon delay is also calculated
CTB_Delay['Skill'] = {417 => 100},
CTB_Delay['Skill'] = {430 => 200},
CTB_Delay['Skill'] = {431 => 350},
CTB_Delay['Skill'] = {432 => 450},
CTB_Delay['Skill'] = {401 => 250}


end

According to that the skills that are mentioned there should cause some ctb delay on the enemies. But nothing happens. I mean really nothing. The last numbers are the values that should effect the CTB bar. As far as I've understood, the higher the value, the higher the delay on the CTB bar.  Oh, the  max CTB Bar value is 500. Also, my skills do damage.

And here are the parts where things are determined for the whole CTB delay function. Im only quoting parts that are related to CTB delay function, not the whole script.
line 533 - 550

 #--------------------------------------------------------------------------
  # * Set CTB delay action
  #     user   : user
  #     action : action
  #--------------------------------------------------------------------------
  def set_delay_action(user, action)
    if action != nil and CTB_Delay[action.type_name] != nil and
       CTB_Delay[action.type_name][action.id] != nil
      delay_action(user, CTB_Delay[action.type_name][action.id], action)
      if action.type_name == 'Skill' and not action.magic?
        for weapon in weapons
          delay_action(user, CTB_Delay['Weapon'][weapon.id], action)
        end
      end
    else
      delay_action(user, Base_CTB_Delay, action)
    end
  end


from line  576 till 586

#--------------------------------------------------------------------------
  # * Set ATB delay
  #     user   : user
  #     delay  : delay value
  #     action : action
  #--------------------------------------------------------------------------
  def delay_action(user, delay, action)
    return if cant_delay(user, action)
    rate =  delay + (delay * (user.target_damage[self] * 50.0 / self.maxhp) / 100.0)
    self.ctb -= rate.to_i
  end


504-514

#--------------------------------------------------------------------------
  # * Final damage setting
  #     user   : user
  #     action : action
  #--------------------------------------------------------------------------
  alias set_damage_ctb set_damage
  def set_damage(user, action = nil)
    set_damage_ctb(user, action)
    set_cast_cancel(user, action)
    set_delay_action(user, action)
  end


Thats it. Theres a "cast cancel function" (skills can cancel other casting skills) which works, lets say, similar and functions without problems. But, this is somehow doesnt want to work despite being coded similar. I compared both codes over and over again but didint find any bugs that could cause the error

Any ideas?
Thanks.

KK20

The configuration is totally wrong.

CTB_Delay['Skill'] = {417 => 100, 430 => 200, 431 => 350, 432 => 450, 401 => 250}


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

koktengri

You're very fast. :) Thanks.
Worked perfectly. The problem was also, that there was no configuration from the very beginning. It was me who did the configuration. I copied the cast cancel configuration and just renamed it. I remember it now.
Last question: Since, the max CTB bar is 500, do you think I can use a number beyond 500?
Would that work or would that cause trouble? I experiemented with values like 1000 and more and I didint got en error message.

KK20

I would be surprised if it did crash your game (cuz that would be terrible scripting practices). But there's actually a limitation to the script.

  def ctb=(n)
    @ctb = [n.to_i, self.max_ctb].min
  end

It doesn't matter if you do 1000 or a million...anything more than 500 will just be treated as 500. I'm pretty sure you could have confirmed this for yourself in testing.
You could change the Max_Ctb constant to something other than 500 if you wanted, despite the comment saying you shouldn't. But that's why experimenting exists, right?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

koktengri

Thank you for the advice. I think I just keep the 500 limitation, because if I would change that, then I would need to change many other things do. 500 is enough for me :))