Jump to content
kal

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

Recommended Posts

Having an Auto Event on the map where the Player starts with the duration value being 0-1 will make it immediately dark.

Share this post


Link to post
Share on other sites

this would be the duration value isn't it?

 

# s.change_alpha(time,a)
# Changes the Effect's Surface opacity in a certain time, where:
# time => The change's time (frames);
# a => opacity

Share this post


Link to post
Share on other sites

There's also

s = $game_map.effect_surface
s.change_color(30,-80,0,40,120)

Where the '30' is the duration; the template being:

s.change_color(duration, red, green, blue, opacity)

And to make the change immediate (in your case "to instantly turn dark instead of fading into darkness when starting the game") you would have the duration value at 0. If 0 does not seem to work, you can make it 1, but 0 should work

 


 

Edit:

 

I have a Skill Formula that's not working. The formula is created in the scripts archive of the project:

     #----------------------------------------------------------------------------------------------------
     # Starts at BASE and increases by DAMAGE for every BUFF on the Enemy, final damage is MULTIPLIED and
     # Target's Defense is taken into account    
     #----------------------------------------------------------------------------------------------------
     def Punishment(a,b,base,damage,mult)
      buffs = 0
          for i in 0..7
        buffs += b.buffs[i]
      end
        (base + (damage * buffs)) * mult - (b.mdf / 2)
    end

And then the skill is called in the skillbox by:

b.Punishment(a,b,50,30,1.75)

However, the skill is not working at all and I think it's because of the way I've inserted the Buffs count in the script or the way the skill is called.

Edited by AJNR

Share this post


Link to post
Share on other sites
I have a Skill Formula that's not working. The formula is created in the scripts archive of the project:
     #----------------------------------------------------------------------------------------------------
     # Starts at BASE and increases by DAMAGE for every BUFF on the Enemy, final damage is MULTIPLIED and
     # Target's Defense is taken into account    
     #----------------------------------------------------------------------------------------------------
     def Punishment(a,b,base,damage,mult)
      buffs = 0
          for i in 0..7
        buffs += b.buffs[i]
      end
        (base + (damage * buffs)) * mult - (b.mdf / 2)
    end

And then the skill is called in the skillbox by:

b.Punishment(a,b,50,30,1.75)

However, the skill is not working at all and I think it's because of the way I've inserted the Buffs count in the script or the way the skill is called.

 

http://www.rpgmakervxace.net/topic/18183-custom-damage-formulae-archive/page-2#entry139501

Share this post


Link to post
Share on other sites

Hey guys,

 

Had a small idea today, having a hard time getting it to work lol.

 

I'd like to have an item increase critical hit damage instead of critical hit chance. In this specific example I created a variable and edited the default script to:

 

#--------------------------------------------------------------------------
# * Apply Critical
#--------------------------------------------------------------------------
  def apply_critical(damage)
    bonus = 2 + ($game_variables[4] * 0.01)
    damage * bonus
  end

How can I have a piece of armor increase this variable?

 

Another idea I had was to use the "Luck" stat in place of this variable, but I haven't figured out how to get that parameter in place of the $game_variable spot.

Edited by HellKiteChaoS

Share this post


Link to post
Share on other sites

Change the def apply_critical to

  def apply_critical(damage, user, item)
    damage * 3
  end

And dont forget to change apply_critical in make_damage_value as well

value = apply_critical(value, user, item) if @result.critical

Now if you want to add luck in critical formula, you may use :

 

damage * 3 + user.luk

And if you want to have each item has different critical formula

 

case item.id
when 1
  formula_1
when 2
  formula_2
else
  default
end

You should get the idea by now :)

Share this post


Link to post
Share on other sites

I'm having some issues with a skill formula right now. I have a Skill that deals damage, and inflicts State #8 (Stun). However, if the Target is already Stunned, then it inflicts State #5 (Confuse).

if b.state(8)? b.add_state(5): b.add_state(8) ; end ;((a.atk*2)-b.def)

The above doesn't work for me for some odd reason

Share this post


Link to post
Share on other sites

 

if b.state?(8) ? b.add_state(5): b.add_state(8) ; end ;((a.atk*2)-b.def)

checking state have to be followed by question mark

  • Like 1

Share this post


Link to post
Share on other sites
if b.state?(8) ? b.add_state(5): b.add_state(8) ; end ;((a.atk*2)-b.def)

checking state have to be followed by question mark

 

 

I've been using RM for some several years. And I couldn't recognize the mistake of '?'

My whole life is a lie.

Edited by AJNR

Share this post


Link to post
Share on other sites

Change the def apply_critical to

  def apply_critical(damage, user, item)
    damage * 3
  end

And dont forget to change apply_critical in make_damage_value as well

value = apply_critical(value, user, item) if @result.critical

Now if you want to add luck in critical formula, you may use :

damage * 3 + user.luk

And if you want to have each item has different critical formula

case item.id
when 1
  formula_1
when 2
  formula_2
else
  default
end

You should get the idea by now :)

 

Awesome. I was trying something like this today, but my Ruby is still a little rusty. I'll give this a shot though. Thanks again. =)

Share this post


Link to post
Share on other sites

I can never get these things to work, can someone help me find the problem with this? It always returns Nil

 

 

 

   def Attack(a, b, power, type)
     if attacker.is_a?(Game_Enemy)
  case type
     when "physical"
       c = (a.atk * 0.4.to_f) + 4
       d = (c * power) * a.atk
      (d / b.def.to_f) / 50.to_f + 2
       d.to_i
     when "magical"
       c = (a.mat * 0.4.to_f) + 4
       d = (c * power) * a.mat
      (d / b.mdf.to_f) / 50.to_f + 2
       d.to_i
  end
   else
 case type
    when "physical"
      c = (a.level * 0.8.to_f) + 4
      d = (c * power) * a.atk
      (d / b.def.to_f) / 50.to_f + 2
       d.to_i
    when "magical"
      c = (a.level * 0.8.to_f) + 4
      d = (c * power.to_f) * a.mat
      (d / b.mdf.to_f) / 50.to_f + 2
       d.to_i
  end
 end
end 

 

 

Share this post


Link to post
Share on other sites

if attacker.is_a?(Game_Enemy)

 

is attacker defined? Or did you mean if a.is_a?(Game_Enemy) ?

  • Like 1

Share this post


Link to post
Share on other sites

No, Attacker is not defined in my script. But I tried switching "if attacker.is_a?(Game_Enemy)" for "if a.is_a?(Game_Enemy) ?"

and the "else" with " ", and I'm still getting nil returned as the final damage.

Edited by AJNR

Share this post


Link to post
Share on other sites

 

 

def Attack(a, b, power, type)
  if a.enemy?
  case type
    when "physical"
      c = (a.atk * 0.4.to_f) + 4
      d = (c * power) * a.atk
      e = (d / b.def.to_f) / 50.to_f + 2
      e.to_i
    when "magical"
      c = (a.mat * 0.4.to_f) + 4
      d = (c * power) * a.mat
      e = (d / b.mdf.to_f) / 50.to_f + 2
      e.to_i
  end
  else
  case type
    when "physical"
      c = (a.level * 0.8.to_f) + 4
      d = (c * power) * a.atk
      e = (d / b.def.to_f) / 50.to_f + 2
      e.to_i
    when "magical"
      c = (a.level * 0.8.to_f) + 4
      d = (c * power.to_f) * a.mat
      e = (d / b.mdf.to_f) / 50.to_f + 2
      e.to_i
  end
  end
end

  • Like 1

Share this post


Link to post
Share on other sites

Wow, I'm such a big babby. Infinite thank yous, Xypher and Galv.  :)

Share this post


Link to post
Share on other sites

I had a quick question about ruby in RGSS3 VX/ACE.  It's something that's come up in several things I'd like to do.  Is there a way to manipulate a variable and increment it or decrease it based on turns in battle spent after a state is applied?  If so how would I go about doing this?

 

I've tried this with states and common events, but there was no way to increment the variable based on turns in battle. 

Share this post


Link to post
Share on other sites
$game_troop.turn_count

Share this post


Link to post
Share on other sites

If I wanted to see if the Actor's Attack Element includes the Element 10, would I use the following?

   if a.atk_elements(10)
     damage
   else
     nil
end
Edited by AJNR

Share this post


Link to post
Share on other sites

I haven't seen in this thread where you can script giving an item to someone.

This is for my Shadowrun Random Loot script that I'm trying to get completely working and this is the only component that I'm missing. LOL

 

I have a list of things that could be in a safe, during a run, and the messages (and SFX get played too), but I can't give anything to the player/party at all.

 

Even with this call, it seems that these are throwing errors...

 

 

 

          Game_Party::give_item( the_package, 1, false)

 

 

 

Please help.

Share this post


Link to post
Share on other sites

$game_party.gain_item(item, x)
item = the item being gained. for example $data_items[1]

x = number of items

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Galv!  I'll check it out! ^_^

 

Edit:  Okay-- no more errors, but I'm not getting anything at all.  There's nothing coming up in my inventory for anyone.

I'm also using the items numbers of the items that I located through this assignment...

this_type = $data_items[ 35 ].name

I have the item number assigned a variable that I'm passing into the $game_party.gain_item(item, x) method, but I'm not getting anything.

Any suggestions?

 

Edit:  Also the $game_party.gain_gold( amount ) doesn't work -- gives me an error about the interpreter having a method of nil. Found my problem with this part with the gold... Typo with the class-name. LOL

Edited by WickedVixen

Share this post


Link to post
Share on other sites

'In your inventory for anyone'?

The script call I gave was to add item to the party, sounds like you are asking for a custom script?

Share this post


Link to post
Share on other sites

I'm looking in my party's inventory, under Items, after my "you receive xxx" and there's nothing gained. I don't understand why not.

I found the ".gain_gold" and that works... Just not sure why this isn't.

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