Setting the Parameter to 0.

sock

Veteran
Veteran
Joined
Aug 9, 2013
Messages
53
Reaction score
4
First Language
English
Primarily Uses
N/A
Hi all. I was wondering if it were possible to set any of the base parameters (Specifically MAT) to 0.
And then when you equip a weapon, this will increase the MAT by 10. So it will say 10.

What I have tried.
-Setting the parameter MAT to 0 at lvl 1 to set the MAT where I want it. Making sure I have the correct Class set. And tested.
-Set the Specific weapon's effect to increase 'Parameter MAT' by 100%/0%/90%/110% and tested results. Results 11, 1, 9, 12
-I also did searched here on the forums. Didn't really come across what I wanted

What I discovered. -The game engine will automatically change an entry of 0 to 1 when trying to make MAT 0 in the designated Class.



What I'm trying to achieve. -I want the parameter (MAT) to say 0 when viewing the actors 'Status' in the menu screen during gameplay. The hope is to have the weapons you wield increase those parameters. For example (MAT)



Where I'm at now. -I understand trying to change the base Parameter in class to 0 wont work as by default the lowest it can be is 1, because the parameter changes by percentage based on what it already is. So having 0 would mean the item would increase the parameter by 100% of 0 which would be 0. Which is also a problem I have. Because when I want the item to be equipped I want the parameter to say 10.

I think this one can be fixed in the scripts, but my knowledge in that field is very nooby.


Thank you so much for answering my questions! I've tried to make my thread as clear and direct as possible. If there is any confusion I will try my best to make things clearer. <3

Also, feel free to critique my thread, :D. Easy to understand etc. Thanks again
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
you can't do this by default, you'll need a script that changes several things in the code.
The problem is that some of the parameter mathematics become problematical with the zero value, and you need some code to prevent those cases from breaking the engine.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
EDIT: Sorry i missread, now i see that the value is always 1 in the database.
 
Last edited:

sock

Veteran
Veteran
Joined
Aug 9, 2013
Messages
53
Reaction score
4
First Language
English
Primarily Uses
N/A
Yes, Andar... that's what I figured.

For now I'm just hoping someone might suggest a script or point me in the right direction.

EDIT: Also, I found that if you set the Parameter to 95% for the weapon and the statistic is at 1. The result be 10. It must always round up when doing the equation...
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Wouldn't just changing how it is displayed in the menu solve everything? I do not have access to the code so there are a few things I don't remember at all. If I am not mistaken the window class that is supposed to display those is something like Window_Status. Somewhere in that class there must be a method that draws the value of your actor MAT.

Instead of displaying your actor MAT you can display 0 if it is 1 in the database. That will affect the menu but not other formulae where it is used.

Code:
(actor.mat==1 ? 0 : actor.mat) # this line should be used instead of the one displaying the real MAT value
I used "actor" but that might not be the case. The script might address each element of $game_party in a different way in the cycle.

EDIT:
Ok, now I have access to the code. The class was indeed Window_Status and the code used to display parameters is this:
Code:
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #--------------------------------------------------------------------------
  def draw_parameters(x, y)
    6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  end
It uses the following method inherited from Window_Base.
Code:
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #--------------------------------------------------------------------------
  def draw_actor_param(actor, x, y, param_id)
    change_color(system_color)
    draw_text(x, y, 120, line_height, Vocab::param(param_id))
    change_color(normal_color)
    draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2) # THIS is the line used to display the numerical value
  end
You can put something like this in your script and every time your MAT parameter is 1 it will be displayed as 0 but still used as 1 in calculations (solving possible problems you have when using 0).

Code:
class Window_Base
  alias hrk_draw_actor_param_old  draw_actor_param
  def draw_actor_param(actor, x, y, param_id, use_old_one=false)
    if use_old_one
      hrk_draw_actor_param_old(actor, x, y, param_id)
    else
      change_color(system_color)
      draw_text(x, y, 120, line_height, Vocab::param(param_id))
      change_color(normal_color)
      if (param_id != 4)
        draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
      else
        draw_text(x + 120, y, 36, line_height, (actor.param(param_id)==1 ? 0 : actor.param(param_id)), 2)
      end
    end
  end
end
A more generic version to display other parameters as 0 when they are 1 is something you can easily achieve by changing the "param_id!=4" with "![numbers_go_here].include?(param_id)". Just put parameter IDs separated by commas instead of "numbers_go_here" (e.g.: [2, 3, 4, 5] will display as 0 atk, def, mat and mdf). Anyway this should be enough to solve your problem if it is just a matter of how you display them.

Keep in mind that to not mess up calculations the original MAT value will still be 1. This means that if you use a weapon that increases it by 20 then 21 will be displayed. If you can bear with that this simple edit is enough to do it. Unfortunately that is necessary because dividing by 0 might result in crashes. You can do something different and more complex but if your only goal is to show 0 instead of 1 that should suffice.

EDIT: the code as been modified a little to allow you to use the old method in an easier way (01-29-19).
 
Last edited:

sock

Veteran
Veteran
Joined
Aug 9, 2013
Messages
53
Reaction score
4
First Language
English
Primarily Uses
N/A
Wouldn't just changing how it is displayed in the menu solve everything? I do not have access to the code so there are a few things I don't remember at all. If I am not mistaken the window class that is supposed to display those is something like Window_Status. Somewhere in that class there must be a method that draws the value of your actor MAT.

Instead of displaying your actor MAT you can display 0 if it is 1 in the database. That will affect the menu but not other formulae where it is used.

Code:
(actor.mat==1 ? 0 : actor.mat) # this line should be used instead of the one displaying the real MAT value
I used "actor" but that might not be the case. The script might address each element of $game_party in a different way in the cycle.

EDIT:
Ok, now I have access to the code. The class was indeed Window_Status and the code used to display parameters is this:
Code:
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #--------------------------------------------------------------------------
  def draw_parameters(x, y)
    6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  end
It uses the following method inherited from Window_Base.
Code:
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #--------------------------------------------------------------------------
  def draw_actor_param(actor, x, y, param_id)
    change_color(system_color)
    draw_text(x, y, 120, line_height, Vocab::param(param_id))
    change_color(normal_color)
    draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2) # THIS is the line used to display the numerical value
  end
You can put something like this in your script and every time your MAT parameter is 1 it will be displayed as 0 but still used as 1 in calculations (solving possible problems you have when using 0).

Code:
class Window_Base
  alias hrk_draw_actor_param_old  draw_actor_param
  def draw_actor_param(actor, x, y, param_id)
    change_color(system_color)
    draw_text(x, y, 120, line_height, Vocab::param(param_id))
    change_color(normal_color)
    if (param_id != 4)
      draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
    else
      draw_text(x + 120, y, 36, line_height, (actor.param(param_id)==1 ? 0 : actor.param(param_id)), 2)
    end
  end
end
A more generic version to display other parameters as 0 when they are 1 is something you can easily achieve by changing the "param_id!=4" with "![numbers_go_here].include?(param_id)". Just put parameter IDs separated by commas instead of "numbers_go_here" (e.g.: [2, 3, 4, 5] will display as 0 atk, def, mat and mdf). Anyway this should be enough to solve your problem if it is just a matter of how you display them.
Thank you! Yes this works fine, it's more of a display thing anyhow! I'm totally fine with it still being 1. But to be displayed as 0. Thank you. I will try messing around with this tonight. Though, like I said, I am very noob! So I might have some more questions for you later. :/ <3 :3

EDIT: So first question... Where does it say
'alias hrk_draw_actor_param_old draw_actor_param'?
Is this something I should be adding? Because I can't find where that line already exists. And, if I am adding this, is it to be added to Window_Base underneath Draw Parameters? Or are all these I'm making from scratch and placing in 'Materials' section? Thanks for being patient....
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
So first question... Where does it say
'alias hrk_draw_actor_param_old draw_actor_param'?
Is this something I should be adding? Because I can't find where that line already exists. And, if I am adding this, is it to be added to Window_Base underneath Draw Parameters? Or are all these I'm making from scratch and placing in 'Materials' section? Thanks for being patient....
That line allows you to copy/paste the whole script in a new section below materials. It allows you to use hrk_draw_actor_param_old when you want to use the old one instead of the new one. It is by no means necessary if you do not plan to use it and no, it does not exist anywhere else.
 

sock

Veteran
Veteran
Joined
Aug 9, 2013
Messages
53
Reaction score
4
First Language
English
Primarily Uses
N/A
Code:
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #--------------------------------------------------------------------------
  def draw_parameters(x, y)
    6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  end
So this code here is the one found in Window_Status. I can find that... so. That's ok. Were not actually doing anything to this one or anything though are we?

Code:
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #--------------------------------------------------------------------------
  def draw_actor_param(actor, x, y, param_id)
    change_color(system_color)
    draw_text(x, y, 120, line_height, Vocab::param(param_id))
    change_color(normal_color)
    draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
  end
This one is in Window_Base. Just trying to get an understanding here. Are you saying copy and paste this into a new script under Materials? What confuses me, is why would I be putting this in if it's already written under Window_Base? Apologies if I sound difficult, just trying to understand better. Very very noob here.

Code:
class Window_Base
  alias hrk_draw_actor_param_old  draw_actor_param
  def draw_actor_param(actor, x, y, param_id)
    change_color(system_color)
    draw_text(x, y, 120, line_height, Vocab::param(param_id))
    change_color(normal_color)
    if (param_id != 4)
      draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
    else
      draw_text(x + 120, y, 36, line_height, (actor.param(param_id)==1 ? 0 : actor.param(param_id)), 2)
    end
  end
end
A more generic version to display other parameters as 0 when they are 1 is something you can easily achieve by changing the "param_id!=4" with "![numbers_go_here].include?(param_id)". Just put parameter IDs separated by commas instead of "numbers_go_here" (e.g.: [2, 3, 4, 5] will display as 0 atk, def, mat and mdf). Anyway this should be enough to solve your problem if it is just a matter of how you display them.
This is a little hard for me to understand, but lets say for instance. It looked like.

Code:
class Window_Base
  alias hrk_draw_actor_param_old  draw_actor_param
  def draw_actor_param(actor, x, y, param_id)
    change_color(system_color)
    draw_text(x, y, 120, line_height, Vocab::param(param_id))
    change_color(normal_color)
    if ![2,3,4,5].include?(param_id)
      draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
    else
      draw_text(x + 120, y, 36, line_height, (actor.param(param_id)==1 ? 0 : actor.param(param_id)), 2)
    end
  end
end
Would this mean it will display as 0 atk, def, mat and mdf. And if I added ,6,7] it will make Agil and Luk 0 as well? Note where I made the change underneath change_color(normal_color)

Thanks.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Are you saying copy and paste this into a new script under Materials?
No, the one you should copy/paste is the one I gave you in the end. That one was just me pointing out which part of the code is called when stats are displayed in the status window. As you said it is pointless to copy something that already exists (mostly harmful).

Would this mean it will display as 0 atk, def, mat and mdf. And if I added ,6,7] it will make Agil and Luk 0 as well? Note where I made the change underneath change_color(normal_color)
And you got it right. That means exactly that. Of course it would only display them as 0 if they are 1. If they are higher than 1 then it would display the real value.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
As an alternative, Exhydra has a script which does exactly what you want (shows 0MP) and allows you to determine which actors this applies to with a simple note tag for that actor. I cannot find an active webpage where you can get it, so I'm posting it here. If anyone does know of such a page, please let me know and I will change this to a link.

Code:
# Exhydra 29 June 2015
# When an actor has no magic skills and no MP, it still shows up as 1MAT
# This gets rid of that.
# In the actor note box, just put in '<no_mat>' and MAT will be set to
# zero for that person.
# The actor note tag <no_mat_equip> will block any MAT from gear equipped.


#==============================================================================
# ** DataManager
#==============================================================================

module DataManager
 
  #--------------------------------------------------------------------------
  # ALIAS - Load Database
  #--------------------------------------------------------------------------
  class << self
    unless method_defined?(:matk_VIy46M8n_dm_load_database)
      alias_method(:matk_VIy46M8n_dm_load_database, :load_database)
    end
  end

  def self.load_database(*args, &block)
    matk_VIy46M8n_dm_load_database(*args, &block)
    
    load_notetags_mat
  end
 
  #--------------------------------------------------------------------------
  # Load Notetags MAT
  #--------------------------------------------------------------------------
  def self.load_notetags_mat
    for obj in $data_actors
      next if obj.nil?
      obj.load_notetags_mat
    end
  end
 
end # DataManager

#==============================================================================
# ** RPG::BaseItem
#==============================================================================

class RPG::BaseItem
 
  #--------------------------------------------------------------------------
  # Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :no_mat
 
  #--------------------------------------------------------------------------
  # Load Notetags MAT
  #--------------------------------------------------------------------------
  def load_notetags_mat
    @no_mat = false

    self.note.split(/[\r\n]+/).each { |line|
      case line

      when /<no_mat>/i
        @no_mat = true

      end
    }
  end
 
end # RPG::BaseItem

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------
  # * ALIAS - Get Base Value of Parameter
  #--------------------------------------------------------------------------
  unless method_defined?(:matk_nTQssHzp_gb_param_base)
    alias_method(:matk_nTQssHzp_gb_param_base, :param_base)
  end
 
  def param_base(param_id, *args, &block)
    return 0 if param_id == 4 && actor.no_mat == true # MAT
    
    matk_nTQssHzp_gb_param_base(param_id, *args, &block)
  end
 
  #--------------------------------------------------------------------------
  # * SUPER - Get Reduced Value of Parameter
  #--------------------------------------------------------------------------
  def param_min(param_id, *args, &block)
    return 0 if param_id == 4 && actor.no_mat == true # MAT
    
    super(param_id, *args, &block)
  end
 
end # Game_Actor

As this cannot be done in the editor by default I am moving this to RGSS3 Script Requests.
 

sock

Veteran
Veteran
Joined
Aug 9, 2013
Messages
53
Reaction score
4
First Language
English
Primarily Uses
N/A
That line allows you to copy/paste the whole script in a new section below materials. It allows you to use hrk_draw_actor_param_old when you want to use the old one instead of the new one. It is by no means necessary if you do not plan to use it and no, it does not exist anywhere else.
I have another question about this. Or perhaps, where I'm at.

[\CODE]
alias hrk_draw_actor_param_old draw_actor_param
[\CODE]

This is the alias. ?. Or, an alias... ... 'hrk' can be named. Anything! (case sensitive of course) - probably actually 'anything' to be more precise. Or even better. ...'materials'?

Which is why the alias is there, because that draws from Materials... I'm ... Guessing...

Due to the fact that

[\CODE]
* To authors of scripts

* When developing scripts to be distributed to the general public,
we recommend that you use redefinitions and aliases as much as
possible, to allow the script to run just by pasting it in this position.


=end
[\CODE]

...Right?

IF SO! - Happy to name it something that I can follow. For instance 'hrk' to 'sck'... I don't know! Is this stealing? Am I looking wayy to deep into this?? Am I EVEN ALIVE ANDAR HELP ME!

...Also, how would you like to be credited in my game?
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
IF SO! - Happy to name it something that I can follow. For instance 'hrk' to 'sck'... I don't know! Is this stealing? Am I looking wayy to deep into this?? Am I EVEN ALIVE ANDAR HELP ME!
It is usually a bad practice to rename something somebody else wrote if you are planning on using the code itself as is. A lot of Terms of Use allow people to edit the script if you need to but changing the alias name is not exactly something "you need to edit" so there isn't really any purpose in doing than not wanting to "show" (I am using quotation marks because the code itself is not something shown to the public once you encrypt your game) what the other person wrote in the way he/she wrote it.

Even so that is just a way to allow you to use the old method if you ever need to. You can name it "this_is_the_old_draw_param_method" and it will still work. In this particular situation that alias is not used anywhere so changing it doesn't really make your engine act weird. When a certain alias is used somewhere it is strongly recommended to not change it otherwise the code itself is not going to work. As a general rule the reason why I add my shortened nickname to the aliased method is that while "[method_name]_old" is kinda generic and other people might have used it "hrk_[method_name]_old" is something I use and nobody else other than me would use. Why would somebody else use something that stands for "Heirukichi" in his/her own script? This acts as some sort of insurance for me (and you) lowering chances of that aliased name causing conflicts with other scripts.

In general I let other people credit me using my nickname so feel free to do the same. However keep in mind that as long as you give credits the way you name methods in the code doesn't really matters. As I said it is not something strictly forbidden in the vast majority of situations but it is still not a good practice unless you really need to do it to achieve something else.

That said feel free to do as you please. I just added a couple of lines to the original script so I don't really think of this as something I wrote. Feel free to do anything you want.

NOTE: I improved the code a little bit so that you can use the old method in a very similar way to how you use the new one. Check my previous post (There is an edit note in the post as well).
 

sock

Veteran
Veteran
Joined
Aug 9, 2013
Messages
53
Reaction score
4
First Language
English
Primarily Uses
N/A
It is usually a bad practice to rename something somebody else wrote if you are planning on using the code itself as is.
Cool. Thanks for being so understanding! Really, it was just me asking, to get a better understanding. So hopefully I can do these things myself in the future! I also had a suspicion that might be the case, and was brave enough to ask as... if there's something you don't know, is it foolish not to ask?

So yeah! I'm actually happy enough to use hrk, I was sorta impressed when I saw it. And prompted the discussion. It's a cool way to slip in a little bit of your own unique flare to tag something and be a useful prompt at the same time. :3 But for my reference alone, and trying to understand what Aliases are, and how they work... I have this question.

When you write the name of the alias. Where does it start? If I give an example... - if for instance I did want to call it "this_is_the_old_draw_param_method" (see below)

Code:
class Window_Base
  alias this_is_the_old_draw_param_method_draw_actor_param_old  draw_actor_param
  def draw_actor_param(actor, x, y, param_id, use_old_one=false)
    if use_old_one
      hrk_draw_actor_param_old(actor, x, y, param_id)
    else
      change_color(system_color)
      draw_text(x, y, 120, line_height, Vocab::param(param_id))
      change_color(normal_color)
      if (param_id != 4)
        draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
      else
        draw_text(x + 120, y, 36, line_height, (actor.param(param_id)==1 ? 0 : actor.param(param_id)), 2)
      end
    end
  end
end

Is that where the name would sit? Because the "_draw_actor_param_old" that comes after it... is that the "[method_name]_old" ?? Not sure what is meant by [method_name]_old. A tad confused here ...Or! is the whole thing the alias name?? (Including _draw_actor_param_old) Before it gets to["Doublespace"draw_actor_param] at the end of the 2nd line. Of course in this example it would crash because it's trying to find "hrk_draw_actor_etc" on the 5th line I realise that. Just asking about the name itself. :)

Can you only have 1 alias of that name before the game will crash or what not? So "hrk1" for a new/different script? Or am I on the wrong track here... :/

I am so grateful for your input and advice! And thank you so much for your time and effort! And I have jumped ahead in my learning of using scripts in this thread alone! I hope we can be friends. I'll follow your profile :) And send some likes. :) :) Cheers! And thanks again!! The update you made - Again, thank you thank you. <3
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
if there's something you don't know, is it foolish not to ask?
You are 100% correct. There is nothing wrong in asking something you do not know, especially if there is no ill intent in the question. Learning is a wonderful thing and asking questions is a good way of learning.

When you write the name of the alias. Where does it start? If I give an example... - if for instance I did want to call it "this_is_the_old_draw_param_method" (see below)
Basically an alias defines a new name for your method. When you use the "alias" keyword to rename something you need 3 things:
  1. the alias keyword
  2. a new name for the method you want to rename
  3. the current name of the method you want to rename
You put those 3 things together in the same line as follows.
Code:
alias new_name current_name
is the whole thing the alias name?? (Including _draw_actor_param_old)
Yes, the whole thing is the alias name. The _old part is just a way for me to remember that I am referring to the old method and that a new aliased method exists. I'll go deeper with a little example. Let's assume that we have a method, and a very simple one at that.

Code:
def my_method
  puts "This method only prints this message."
end
As you can imagine this method is VERY simple and it only displays a message on your console. Anyway after defining it this method does exist and each and every time you use the "my_method" line in your code this method is called and that message will be displayed. Since we are talking about aliases here let's rename this method using a different name. I want to call it "display_useless_message" instead of "my_method".

Code:
alias display_useless_message my_method
After doing this you can use "display_useless_message" instead of "my_method" to display that message. That happens because the method itself has been aliased.

  • Why do you alias methods?
There are a few reasons why you might want to alias your methods. One of them is to have a new method called wherever the old one was used without having to edit each and every line where that was called. Here is an example.

Code:
def another_useless_method
  my_method
  my_method
  my_method
  my_method
  my_method
  my_method
  my_method
  my_method
  my_method
  my_method
end

This code is COMPLETELY useless and poorly written since it repeats the same thing many times. It is useful for the sake of explaining though so I'll stick to it.

In that code the line "my_method" is repeated 10 times. If you want to use a different method instead of that one you have to edit 10 different lines. That is not exactly what I would label as "efficient".

That's where the alias keyword comes in handy. I already aliased "my_method" so I can now write a new method called "my_method" while still keeping that one intact.

Code:
def my_method
  puts "This is another useless method that only displays messages."
  puts "Inside this method the old method is called as well."
  display_useless_message # this line calls the old method to display the message
end
Now every time "my_method" is called in "another_useless_method" you call the new version of "my_method". That new version appears to be the last one I wrote so three (3) messages are displayed each time it is called (the original one plus the other two lines I added in the new version).

This time I decided to add something to the old method in the new one. You can even have the new one doing something completely different according to a switch or a variable instead.

Code:
def my_method
  if (my_variable == 0) # my_variable is just a random variable
    display_useless_message # call the old, useless method
  else
    do_something_incredibly_useful # anything can go here instead of this line
  end
end
The "do_something_incredibly_useful" method (I called it as a method here) can be literally anything. It could be something incredibly flashy or something absolutely useless. The point is not what it does but that you used the same name to do something different according to "my_variable" value. If we are talking about a RPG Maker script this allows you to use configuration settings for a script to decide if something has to act the same way it usually does with the default engine or in a whole different way.

Can you only have 1 alias of that name before the game will crash or what not? So "hrk1" for a new/different script? Or am I on the wrong track here... :/
In ruby you can overwrite methods. This means that if you define the same method twice then you are overwriting it. If you don't use an alias for a method you are overwriting then you can no longer access that method.

Code:
def check_sweets
    return 4 # this method returns 4
end

def check_sweets
  return 0 # this method returns 0
end

def how_many_sweets?
    puts "I currently have #{check_sweets} sweets in my pocket."
end
Since I overwrote the "check_sweets" method whenever I call "how_many_sweets?" it will always display 0 because that's what the new method returns. I can no longer display 4 using that method.

If a script overwrites a method then there is a high chance that it has been used somewhere in the script in its new form, not the old one. So if you overwrite it in a different script everything that used it in the previous script might act weird because the method no longer works as expected.

If you alias the method then you can prevent that from happening calling the old version whenever it is supposed to act in the old way and the new one whenever you want it to act differently. To answer your question you can use (for example) a different name when you alias that method in the second script.

Code:
alias my_first_alias my_method
def my_method
  puts "This is my first aliased method for \"my_method\"."
  my_first_alias
end

alias my_second_alias my_method
def my_method
  puts "This is my second aliased method for \"my_method\"."
  my_second_alias
end
This will work because when I defined my_method after my first alias the old method was named "my_first_alias". At the same time when I used the second alias, I just renamed "my_method" to "my_second_alias". But that method itself was already an new method based on an alias of the previous method (like Chinese boxes).

Basically calling "my_method" after that calls the new version which calls the aliased one in it, which calls the original one (aliased as well) in it. This way I used the same name ("my_method") three times but at the same time I always aliased it so that I could use it with a different call.

I hope this helps you understanding how it works.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
This part of the code:
Code:
(actor.param(param_id)==1 ? 0 : actor.param(param_id))
Will lead to confusion, a big one, even if the actual impact on gameplay is minimal.

Here's an example why:
The player checks the ATK parameter, it says 0 without a weapon equipped (assuming the base parameter is set to 0, and nothing else changes it).
The player found a giant mace that adds +10 to the ATK parameter. He will go "Kewl, lets equip it ASAP, yay!". So he does just that.
But much to the player's surprise, now the displayed ATK parameter will be 11 for some unexplained reason.

If you want to display the changes correctly, you simply just remove 1 from the real parameter and display that.
Code:
draw_text(x + 120, y, 36, line_height, actor.param(param_id) - 1, 2)
The parameter can never go below 1 by default, so the lowest displayed value will be 0, just like you wanted, and it will display the correct changes from equipment/states/etc as well.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
If you want to display the changes correctly, you simply just remove 1 from the real parameter and display that.
Code:
draw_text(x + 120, y, 36, line_height, actor.param(param_id) - 1, 2)
The parameter can never go below 1 by default, so the lowest displayed value will be 0, just like you wanted, and it will display the correct changes from equipment/states/etc as well.
This is also another way to achieve that. However this leads to confusion too because damage dealt (especially when stats are low) will be different from what you expect it to be when planning battle strategies.

As someone who appreciates strategic gameplay I'd rather like to see a value that is slightly different from what I expect in my stats rather than having something different from what I expect hen dealing damage. Even if this would only lead to increased damage there are some times when you only want to weaken your foe without killing it for some reason (for example charging TP by guarding before a boss fight) or when you don't want to deal too much damage (maybe because the boss move set changes when he goes below 50% hp? That is pretty common, and when your attack deals too much damage it might be a pain...even a single digit might make a huge difference and result in a party wipe if the boss reaches that threshold at the wrong time).

Anyway no matter what, if you are displaying something that is different from what it really is you'll have to bear one thing or the other. The only way to not encounter such issues is to display the value as it is and that won't be solved with a simple edit of that method. As Andar said it will require several edits to handle the borderline case (the on where you actually have 0 in your calculations).

In the end is up to the game designer (you) to decide which path to take. If you are dealing with very big numbers (bigger than 100) then a less than 1% variance will probably not make any difference and subtracting the value from what you are displaying might be the best option, if you are dealing with smaller numbers then probably displaying the correct value might prove to be the best option instead.

Of course if you think that in your game you don't need to handle any situation where your player might want to keep enemies alive to prolong a battle then subtracting 1 from the displayed value is your best choice. As I said I prefer knowing exactly what my stats are when I look at the status window, even if they are different from what I expect, but that is just my personal taste so of course feel free to act in the way you think is the best for your game.

Since we do not know what your plans are we can only provide you a few options and let you pick the one that best fits your needs.
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top