Jump to content
kal

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

Recommended Posts

Draw the fixed text inside the window padding

 

Does that still properly display the cursor highlight over each item?

I remember messing around with trying to add a "title" to my list and the cursor was just off.

Share this post


Link to post
Share on other sites

I used a separate label window to hold & draw the text inside the window_selectable. You shouldn't get any cut-off if you make sure the text gets drawn before the cursor.

Share this post


Link to post
Share on other sites

So, tried $game_party.tranparent = true and it did not work...what would work (in script form) to make the part transparent and back again? And also...where can I find the answers like you guys do without coming here everytime, lol

 

Ok, tried .opacity and .visible, to no avail. How do I write up the party turning invisible?

Edited by Juan Alvarado

Share this post


Link to post
Share on other sites

 #--------------------------------------------------------------------------
 # * Get Rate of Change Due to Parameter Buff/Debuff
 #--------------------------------------------------------------------------
 def param_buff_rate(param_id)
   @buffs[param_id] * 0.25 + 1.0
 end

 

What would I change the numbers above to, if I wanted a one-stage buff to raise a parameter by 1.5x (so 100 Atk would become 150), a two-stage buff to raise a parameter by 2x (so 100 Atk would become 200), a one-stage debuff to reduce a parameter by 0.5x (so 100 Atk would become 50), and a two-stage debuff to reduce a parameter by 0.25x (so 100 Atk would become 25)?

Share this post


Link to post
Share on other sites

I'm not too familar with the ways buffs work; From above code, I assume @buffs[param_id] is the amount of buffs for that param.

In that case, change 0.25 to 0.5.

Share this post


Link to post
Share on other sites

I'm not too familar with the ways buffs work; From above code, I assume @buffs[param_id] is the amount of buffs for that param.

In that case, change 0.25 to 0.5.

 

It worked just fine for buffs, but a two-stage debuff reduces the unit's Attack to 1 (the limit).

Share this post


Link to post
Share on other sites

How do you change the game's font in-game (Script... Command)

 

I've tried:

$game_system.Font.default_name = Arial

$game_system.Font.default_name = "Arial"

$game_system.Font.default_name = ["Arial"]

 

I have Yanfly's Core Engine and it didn't give any help on changing the font, so I assume that it won't conflict with this

Share this post


Link to post
Share on other sites

Here's one: I want critical hits to ignore the target's Defense, as opposed to doing a flat multiplication of the damage.

 

  #--------------------------------------------------------------------------
 # * Apply Critical
 #--------------------------------------------------------------------------
 def apply_critical(damage)
damage * 3
 end

 

I'm pretty sure that this is where I'd modify VX Ace's base scripts to accomplish that. My problem is...I have no idea how to do that. What would I change this part of the script to, so that all critical hits ignore the foe's Defense/treat it as zero? (Note that I have no intentions of letting non-physical attacks/skills crit).

The issue is that the formula you write is evaluated directly.

 

class RPG::UsableItem::Damage
 def eval(a, b, v)
[Kernel.eval(@formula), 0].max * sign rescue 0
 end
end

 

You would basically have to define a custom "damage eval" formula that will take in a critical flag indicating whether the critical went through or not (through @result.critical), and then modify the formula to ignore b.def or b.mdef, whichever is used.

 

It is not a very clean change to do.

 

Not that hard at all.

 

class Game_Battler < Game_BattlerBase

 def apply_critical(value)
   value
 end

 alias ninjamida_crit_ignore_def_def def
 def def
   return ninjamida_crit_ignore_def_def unless @ninjamida_disable_defence
   return 1
 end

 alias ninjamida_crit_ignore_def_mdf mdf
 def mdf
   return ninjamida_crit_ignore_def_mdf unless @ninjamida_disable_defence
   return 1
 end

 alias ninjamida_crit_ignore_def_make_damage_value make_damage_value
 def make_damage_value(user, item)
   @ninjamida_disable_defence = true if @result.critical
   value = ninjamida_crit_ignore_def_make_damage_value(user, item)
   @ninjamida_disable_defence = false
 end

end

 

Add as a new script.

Share this post


Link to post
Share on other sites

Hey everyone, where can I find the line that defines the height for the menu window (not the one that displays the commands, but shows the actors, etc.)? I'd like to make it shorter, because I have only 1 character in my game. I've already edited the menu so the scene skill, equip and status don't let the player choose an actor, but goes immediately to the first actor.

Share this post


Link to post
Share on other sites

Okay, I've got the weirdest problem. It's only been happening recently in my project, but sometimes, I can't finish battles because of an error message that occurs here:

 #--------------------------------------------------------------------------
 # â— HP ã®æ–‡å­—色をå–å¾—
 #--------------------------------------------------------------------------
 def hp_color(actor)
return knockout_color if actor.hp == 0
return crisis_color if actor.hp < actor.mhp / 4
return normal_color
 end
 #--------

 

I think it's due to a script I have having compatibility problems, but I'm not sure. Should I list the scripts I'm currently using?

 

EDIT: It seems that my entire Window_Base script is glitched. Every time it's used, I'm given an error message/

Edited by MachRiderZ

Share this post


Link to post
Share on other sites

Do any of your scripts change how Window_Base works?

Also, which line exactly does the error point to and what does the error message say? (If you don't remember, try to recreate the error and paste it here)

Share this post


Link to post
Share on other sites

The error will normally appear when trying to fight a troop that only has one enemy left and the rest have been defeated.

return knockout_color if actor.hp == 0

^That's the line it says the error comes from. I've looked through all of my scripts and I couldn't seem to find which one would be causing it, so I'll post the battle-related scripts I'm using ATM:

Victor Engine Basic Module

Ace Core Engine

Battle Pop-Ups

Jet's Simple Side View

Individual Equipment

Level-Up Equipment

Yanfly's Combat Log

Yanfly's Enemy Levels

Yanfly's Victory Aftermath

Mitchi's Auto Battle When Idle

Battle Start Phrase

Victor's Target Arrow

Unsigned Zero's Custom Battle Status

Share this post


Link to post
Share on other sites

Is it possible to add custom text into the battle log through a battle event? And if so, how would you reference a game variable?

Share this post


Link to post
Share on other sites

Is there any reason why I should write

 

class Game_Actor < Game_Battler

 

over just

 

class Game_Actor

 

I don't know, I thought it would be nice to indicate that actor inherits battler, but ruby probably doesn't care either way since custom scripts will crash cause the definitions don't match (since they should be placed after the default anyways)

Share this post


Link to post
Share on other sites

I think as long as your script is placed below Game_Actor is first defined in a script, it doesn't matter.

For example, in my GameOver_with_choices script, I have an option that will make the window shown in the game over scene either a child of Window_Command or Window_HorizontalCommand (own class from another script).

if Regendo::GameOver_Window.multiple_cols?
 class Window_GameOver < Window_HorizontalCommand #more than one column possible
 end
else
 class Window_GameOver < Window_Command #only one column
 end
end

After that, I simply define the class like

class Window_GameOver
# ...
end

I never encountered any issues with this.

Share this post


Link to post
Share on other sites

The error will normally appear when trying to fight a troop that only has one enemy left and the rest have been defeated.

return knockout_color if actor.hp == 0

^That's the line it says the error comes from. I've looked through all of my scripts and I couldn't seem to find which one would be causing it, so I'll post the battle-related scripts I'm using ATM:

Victor Engine Basic Module

Ace Core Engine

Battle Pop-Ups

Jet's Simple Side View

Individual Equipment

Level-Up Equipment

Yanfly's Combat Log

Yanfly's Enemy Levels

Yanfly's Victory Aftermath

Mitchi's Auto Battle When Idle

Battle Start Phrase

Victor's Target Arrow

Unsigned Zero's Custom Battle Status

Share this post


Link to post
Share on other sites

The name should say it all. I don't really know where to go to ask this so i thought I'd come here and hopefully get an answer to what will probably be a painfully obvious question.

I just picked up the program about a week and a half ago and I've been figuring a lot of things out by guess and by gosh. I've downloaded most of YEA and have the class system and JP Manager installed. I've eschewed levels completely, locking all levels at 1 in the script. I did this mostly by following other people's advice and trying to puzzle out the script. I've also created "Stat" shops that hold a limited number of class-specific stat boosts using the event system (without scripts). The last thing (for now; I'm sure there will be a lot more to ask about soon) is the addition of job-specific skills that, when learned, boost a stat using a common event. The option to use the skill to provide the boost isn't right for this. It is a one-time-only stat boost to, for example, MaxHP. So, when the player spends jp to learn the skill, the class will immediately gain a bonus to the stat and the skill will be hidden from the skill lists directly aftward so it can't be selected.

I know I need to call the id of the actor who is learning the skill and place it in a variable. I also need to call the id of the class that is learning the stat-boost skill. Then I need to use those variables to add the boost to the appropriate character and class (since the YEA job system treats all classes separately). Just an FYI, I don't have any scripting experience, I just pick things up by reading people's help responses and the scripts from Yanfly so I may be thoroughly wrong but I don't think so.

So, on to the question: How in the bloody blue blazes do I use the script option in the common event contents to call those two items and stick them into variables?!? Been busting my head against the electronic wall for 2 days trying to puzzle this one out and most responses I've read don't quite cover this.

Thank you in advance for your understanding that I am thoroughly ignorant in these matters.

Edited by Supernoob

Share this post


Link to post
Share on other sites

 

 

The name should say it all. I don't really know where to go to ask this so i thought I'd come here and hopefully get an answer to what will probably be a painfully obvious question.

I just picked up the program about a week and a half ago and I've been figuring a lot of things out by guess and by gosh. I've downloaded most of YEA and have the class system and JP Manager installed. I've eschewed levels completely, locking all levels at 1 in the script. I did this mostly by following other people's advice and trying to puzzle out the script. I've also created "Stat" shops that hold a limited number of class-specific stat boosts using the event system (without scripts). The last thing (for now; I'm sure there will be a lot more to ask about soon) is the addition of job-specific skills that, when learned, boost a stat using a common event. The option to use the skill to provide the boost isn't right for this. It is a one-time-only stat boost to, for example, MaxHP. So, when the player spends jp to learn the skill, the class will immediately gain a bonus to the stat and the skill will be hidden from the skill lists directly aftward so it can't be selected.

I know I need to call the id of the actor who is learning the skill and place it in a variable. I also need to call the id of the class that is learning the stat-boost skill. Then I need to use those variables to add the boost to the appropriate character and class (since the YEA job system treats all classes separately). Just an FYI, I don't have any scripting experience, I just pick things up by reading people's help responses and the scripts from Yanfly so I may be thoroughly wrong but I don't think so.

So, on to the question: How in the bloody blue blazes do I use the script option in the common event contents to call those two items and stick them into variables?!? Been busting my head against the electronic wall for 2 days trying to puzzle this one out and most responses I've read don't quite cover this.

Thank you in advance for your understanding that I am thoroughly ignorant in these matters.

 

 

 

Response:

 

 

Not sure if this helps but you can change the value of varibales/switches with code like:


#change value of variable 15 to store the players x coordinate on the map
$game_variables.[]=(15, $game_player.x)

And you can retrieve the values from the variables with code like:

#retrieve the value from variable 15
x = $game_variables.[](15)

 

You can pass paramaters to blocks of code by using procs as explained here:

http://rgss3help.tk/.../full/Proc.html

So if you wrote a some code in the script editor like:

 

SUNSET = proc do
 $game_map.screen.start_tone_change(Tone.new(68,-34,-34,0),60)
end

 

You could have your common event evaluate that code by calling it like this:

 

SUNSET.call()

 

you can also have the proc take in parameters:

SUNSET = proc do |r,g,b,a,duration|
 $game_map.screen.start_tone_change(Tone.new(r,g,b,a),duration)
end

then just supply the arguments:

SUNSET.call(68,-34,-34,0,60)

 

Hopefully that helps it might be somewhat vague.

 

 

 

My question:

 

 

The Scene_ItemBase class has code in it that refers to what looks like local variables that are never initialized but I know that's not the case:

 

class Scene_ItemBase < Scene_MenuBase
#...
 def item_usable?
user.usable?(item) && item_effects_valid?
 end
#...
 def use_item
play_se_for_item
user.use_item(item)
use_item_to_actors
check_common_event
check_gameover
@actor_window.refresh
 end
#...
end

 

what are the user and item objects that are being referred to here?

For example this line:

user.use_item(item)

neither user nor item were passed into the method, nor are they class/instance/global variables... so they should be local variables (right?) ?

If that was the case the code would be calling methods on nil and passing around nil as an argument which doesn't make any sense.

 

 

Share this post


Link to post
Share on other sites

They are just methods.

 

def user
 $game_party.movable_members.max_by {|member| member.pha }
end

 

So in this case, `user` evaluates to some member with the highest `pha` value, whoever that might be.

 

Which allows more flexible code design because you're not hardcoding variable names.

You can easily change the functionality of the code by just re-defining the `user` method.

 

If you look at a lot of the window classes, you'll notice they treat methods as constants. Maybe in other programming languages this is a little odd, or even impossible, but it definitely makes it easier to extend them without having to do all sorts of overriding and stuff.

Edited by Tsukihime

Share this post


Link to post
Share on other sites

^Ok, thank you.

 

I'm trying to figure out a good way to have a save file hold extra information.

During gameplay, the player will be able to dynamically spawn events on the map that need to be persistent when when the map changes or when the game is saved, then reloaded.

 

So i was thinking about just writing information to a .txt file or something like that which would correspond to a specfic savefile, and then whenever the player switched to a different map I could just modify the

setup method inside Game_Map to get the extra data:

 

 

def setup(map_id)
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
@tileset_id = @map.tileset_id
@display_x = 0
@display_y = 0
referesh_vehicles
setup_events
setup_scroll
setup_parallax
setup_battleback
@need_refresh = false
 end

 

 

And when a save file was loaded I would just pickup the data from the .txt file I made. But this seems like a bad solution. Is there a better way of doing something like this?

Edited by eshra

Share this post


Link to post
Share on other sites

Why not just store the custom events in a hash in $game_system or something.

 

Or you can use my Custom Database script it dumps all of the data to your save file automatically. Just add a new variable for your custom events to all of the methods.

Edited by Tsukihime

Share this post


Link to post
Share on other sites

changing in game values : How can I do this? I'd like to change some values from the configuration part of the scripts I'm using while the game is being executed : It's gonna be from events with a script call but how can I do that (more precisely from true to false, values of an array and so on).

Share this post


Link to post
Share on other sites

I tried Event commands -> Advanced (script) ->

 

module name_modul retrieved from the script

my.new.value.to.set = new value here

end

 

but it doesn't work.

Edited by andiamo

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