Jump to content
kal

Ruby/RGSS3 questions that don't deserve their own thread

Recommended Posts

So, I thought I'd train my scriptfu by trying my hand on a script request and decided on one that wanted a sort of pop up window that shows exparameters of equipment. I tinkered with Scene_Item first and figured that I should make equips enabled in the item menu and did so. Then I copied and tweaked the status window to use as a stepping for the actual window. I commented almost everything to make it blank and cut the width in half. After that I made the necessary adjustment so that the window appeared whenever a weapon or armor is chosen and close if x is hit. Then I figured I'd see if there's a stored vocab list for the names of the exparameters when I noticed that the window's color was different for the other menu windows. After tweaking it some, I just couldn't change it to be the same as the rest unless I called it as a scene by itself. What do you guys think I did wrong? I printed out most of the properties and compared it to those of other windows and they were the same. My first guess is that it has something to do with create_background in Scene_MenuBase but I can't seem to replicate its effect on the experimental window. I tried commenting create_background out and the window was still different.

Share this post


Link to post
Share on other sites

What to I need to set an event's priority_type to in order for it to be displayed above the map? (Or: What is the priority of a picture?)

Share this post


Link to post
Share on other sites

What to I need to set an event's priority_type to in order for it to be displayed above the map? (Or: What is the priority of a picture?)

 

.z value.

Share this post


Link to post
Share on other sites

Double checking

(a.atk+a.mat) - (b.def+b.mdf)/2

This will cause your Attack+Mind to be reduced by the average of enemies Defense and Resist?

 

Share this post


Link to post
Share on other sites

How do I make that work, exactly? It isn't set like an x or y value is it?

 

If you want to set the priority of the picture, you need to set the z value up. Example:

@image.z = 100

Share this post


Link to post
Share on other sites

Question:

 

I want it where you have to have a certain item equipped to use certain weapons and/or armor.

 

For example Actor One cannot use swords with a certain ring equipped.

 

Is there a way to do this?

Share this post


Link to post
Share on other sites

You'll need to check for that condition before changing equip. Your options are to either check that in the scene you can change equip in (e.g. in your inventory) or directly in the method that changes equip (in Game_Interpreter, you should use an alias here). The second one might break compability with some scripts but is an easier solution if you have multiple scenes in which you can change your equipment. Both will not actually make it impossible for your actor to wear both a sword and that ring - they will just make it impossible to equip the sword when you wear the ring and vice-versa. If for some reason your character ends up wearing both, they will continue to do so until they unequip one of these.

Share this post


Link to post
Share on other sites

It should be the same concept.
In the method that would equip an item, do something like the following pseudocode:

if ( (actor == that actor you want to restrict)
   && (item == that item you want to restrict)) do
      if (actor has item xyz equipped) do // you could also check a variable or switch, or check if something is in the inventory
        equip it
      else
        popup window with error message // alternatively, play a buzzer sound or just don't do anything
        return
      end
else
  equip it // this is the default case if you don't restrict that item-actor combination
end

I can't actually code this for you right now because I don't have Ace installed atm and do not have a local copy of these scripts but it shouldn't be too difficult to do so yourself.
Since you seem to have a lot of different cases of this, using switch-case constructs would probably make the code easier to read. Something like

case actor
when $game_actors[0]
  case item
  when $game_items[1]
     // ...
  when $game_items[54]
    // ...
  end
when $game_actors[1]
  case item
  when $game_items[42]
    // ...
  when $game_items[123]
    // ...
  end
end

Edit: If you want to restrict whole categories of weapons (all swords, all greataxes, etc) I believe there is an event command for that.

Edited by regendo

Share this post


Link to post
Share on other sites

Huh... is that case statement valid? I never saw a when statement using do and break in ruby before.

Edited by KilloZapit

Share this post


Link to post
Share on other sites

You're right. I haven't used ruby in a while and tried to do it from memory, I should have looked it up on google in the first place. I'll edit the post above.

Share this post


Link to post
Share on other sites

Wait, does apply_guard condition ALWAYS applied in the battle? I was wondering about this since my Guard Break script seems to be adding values even without guarding myself.

Share this post


Link to post
Share on other sites

yes apply_guard always runs.

 

 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)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end
 
 
  def apply_guard(damage)
    damage / (damage > 0 && guard? ? 2 * grd : 1)
  end

Share this post


Link to post
Share on other sites

 

yes apply_guard always runs.

 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)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end
 
 
  def apply_guard(damage)
    damage / (damage > 0 && guard? ? 2 * grd : 1)
  end

 

In my guard break script, I am adding a variable count to an attribute accessor on the game system. How would I exactly know who's guarding and when they're guarding? using self = user in the apply_guard somehow seems not to work properly since it applies still. Any ideas?

Share this post


Link to post
Share on other sites

you could

 

@user = user

and then use that to check the user in apply_guard

  • Like 1

Share this post


Link to post
Share on other sites

you could

@user = user

and then use that to check the user in apply_guard

 

Yes, normally, this works:

  #--------------------------------------------------------------------------
  # * Applying Guard Adjustment
  #--------------------------------------------------------------------------
  def apply_guard(user, damage)
    puts "I am a user" if user.is_a?(Game_Actor)
    damage / (damage > 0 && guard? ? 2 * grd : 1)
  end

however, the values would still be applied (on my script) since the values pass to apply_guard. I tried to use the following but failed.

user.guard?
user.guarding?

since I only wanted to add the values when my actor is really guarding during his turn. Adding the values on the apply guard seems to be passing the value even if I'm not actually warding from any attacks.

Share this post


Link to post
Share on other sites

I'm a little confused.

Game_Battler runs as self = target, why do you need to check if the user is guarding?

Share this post


Link to post
Share on other sites

For a shake of god and compatibility, do not change the argument number of apply_guard. It should stay with one argument.

That's why I agree to put the user to instance variable

 

@user = user

Share this post


Link to post
Share on other sites

I changed the argument so did I change the value argument on make_damage_value. But I'll go with you and remove that.

 

 

I'm a little confused.

Game_Battler runs as self = target, why do you need to check if the user is guarding?

 

This is the issue I am trying to resolve since even when I don't exactly guard, my Guard Meter (a script that adds a value to a gauge when I guard) applies even when I don't exactly used the guard command. It applies when the enemy attacks me (without using the guard).

 

Here's the entire code I am trying tor resolve. Please ignore the stuff I put here at some point :D

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Calculate Damage
  #--------------------------------------------------------------------------
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    
    if item.physical?
      if user.is_a?(Game_Actor)
        if $game_system.one_soul_burst_mode >= 100
          $game_system.reburst = true
        else
          $game_system.reburst = false if $game_system.reburst
          $game_system.one_soul_burst_mode += pdr / 2
        end
        if $game_system.reburst
          value *= pdr  * $game_system.burst_mode / 2
          $game_system.one_soul_burst_mode = 0
        else
          value *= pdr 
        end
      end
    end
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(user, value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(user = self, value)
    @result.make_damage(value.to_i, item)
  end  
  
  #--------------------------------------------------------------------------
  # * Apply Critical
  #--------------------------------------------------------------------------
  def apply_critical(user, damage)
    if user.is_a?(Game_Actor)
      if $game_system.critical_overdrive >= 3
        $game_system.overdrive_ok = true
      else
        $game_system.critical_overdrive += 1
      end
      if $game_system.overdrive_ok
        damage *= (3 * $game_system.critical_overdrive)
      else
        damage *= 3
      end
    else
      damage *= 3
    end
  end  
  #--------------------------------------------------------------------------
  # * Applying Guard Adjustment
  #--------------------------------------------------------------------------
  def apply_guard(user, damage)
    $game_system.one_soul_guard_break_bonus += 1 if user.is_a?(Game_Actor)
    damage / (damage > 0 && guard? ? 2 * grd : 1)
  end
  
end

this is the guard meter I am talking about (shortcut)

class Window_BattleStatus < Window_Selectable
  
  #--------------------------------------------------------------------------
  # * Draw Gauge Area (with TP)
  #--------------------------------------------------------------------------
  def draw_gauge_area_with_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 0, rect.y, 72)
    draw_actor_mp(actor, rect.x + 82, rect.y, 64)
    draw_actor_tp(actor, rect.x + 156, rect.y, 64)
    draw_actor_gb(actor, rect.x, rect.y + 20, 224)
  end
  #--------------------------------------------------------------------------
  # * Draw Gauge Area (without TP)
  #--------------------------------------------------------------------------
  def draw_gauge_area_without_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 0, rect.y, 134)
    draw_actor_mp(actor, rect.x + 144,  rect.y, 76)
    draw_actor_gb(actor, rect.x, rect.y + 20, 224)
  end  
    
  #--------------------------------------------------------------------------
  # * Draw HP
  #--------------------------------------------------------------------------
  def draw_actor_gb(actor, x, y, width = 124)
    draw_gauge(x, y, width, $game_system.one_soul_guard_break_bonus/Soulpour::OSBS::MAX_GUARD_BREAK.to_f, hp_gauge_color1, hp_gauge_color2)
    change_color(system_color)
    draw_text(x, y, 100, line_height, Soulpour::OSBS::Guard_Break_Name)
    draw_current_and_max_values(x, y, width, $game_system.one_soul_guard_break_bonus, Soulpour::OSBS::MAX_GUARD_BREAK,
      hp_color(actor), normal_color)
  end
end

Share this post


Link to post
Share on other sites

this should work?

def apply_guard(damage)
$game_system.one_soul_guard_break_bonus += 1 if actor?
damage / (damage > 0 && guard? ? 2 * grd : 1)
end

edit: also theres no reason to pass user = self as self will always be self in Game_Battler

Edited by Xypher

Share this post


Link to post
Share on other sites

It seems to be working when I attack, but when the enemy attacks, the guard meter stills adds something. Is it because every damage is passed throughout the value variable? I just want the guard meter's value to be added when:

 

  • I guard

Current problems:

 

  1. The Meter adds when the enemy attacks.

is there another way to do this rather than doing it on apply_guard?

Share this post


Link to post
Share on other sites

oh I see, it would add the value everytime the actor is attacks when he's guarding.

you could add it to the guard damage formula through something like

$game_system.one_soul_guard_break_bonus += 1 if a.actor?;0
Edited by Xypher
  • Like 1

Share this post


Link to post
Share on other sites

You mean something like:

  #--------------------------------------------------------------------------
  # * Applying Guard Adjustment
  #--------------------------------------------------------------------------
  def apply_guard(damage)
    $game_system.one_soul_guard_break_bonus += 1 if actor?;0
    damage / (damage > 0 && guard? ? 2 * grd : 1)
  end

the value still adds :o

Share this post


Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted