Wrong number of arguments

Suddenly I get this error whenever I try to equip an item or optimize equipment. I have no idea what is causing it or why it started. :distrust:

error.jpg
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


Line 209 of Game_Actor calls Game_Party.has_item? which requires one mandatory argument and one optional argument. I bet you've added a script that changes that method and makes both arguments mandatory.


To check, do a global search for def has_item? and see what custom scripts you come up with. The default definition is this:

Code:
def has_item?(item, include_equip = false)
I bet you'll find one there that omits the = false. The easy solution will be to locate that in your custom scripts, and add it.
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

Line 209 of Game_Actor calls Game_Party.has_item? which requires one mandatory argument and one optional argument. I bet you've added a script that changes that method and makes both arguments mandatory.

To check, do a global search for def has_item? and see what custom scripts you come up with. The default definition is this:

def has_item?(item, include_equip = false)I bet you'll find one there that omits the = false. The easy solution will be to locate that in your custom scripts, and add it.
You were right, it was this snippet that was done for me that changes the player speed depending on certain equipment. How do I fix it?

Code:
#==============================================================================# ** Game_Party#==============================================================================class Game_Party < Game_Unit   def has_item?(item_type, item_id, include_equip = false)    case item_type      when :weapons        leader.weapons.include?($data_weapons[item_id])      when :armors        leader.armors.include?($data_weapons[item_id])    end  end end # Game_Party
You will need to provide a description about what that snippet is for, and how you are planning to use it.


What is item_type supposed to represent?


What is item_id based on?
You will need to provide a description about what that snippet is for, and how you are planning to use it.

What is item_type supposed to represent?

What is item_id based on?
Right, I was planning on having this armor that would increase the speed the player can dash when they wear it. Kinda like the boots in Zelda games, they allow you to run faster than you would without when you have them.
Consider asking the person that provided the snippet to check the logic, because this should be impossible to satisfy

leader.armors.include?($data_weapons[item_id])Unless you are using a script that allows you to equip weapons in armor slots, this will never be true.In any case, how are you going to use this code? What do you pass in?

The original method only accepts an item and a boolean.

Does that item provide all of the relevant information required? Or do you need two different items, one to supply the item type, and the other to supply an ID?

If the item_type and item_id is based on a single item, then you can just extract that information from the item inside the method directly.
I didn't think it'd be that complicated. All I wanted was basically an armor that made you run faster, that's it. 😮
That snippet alone will not change the speed of your player.


You should post all related scripts, otherwise we can't really help you.


We need to know where that method is called, so we can see what are the arguments passed onto the method.


But that overwritten "has_item?" method is quite a bad way to do it, regardless of what this snippet is supposed to do, so you might be better off without it.
That snippet alone will not change the speed of your player.

You should post all related scripts, otherwise we can't really help you.

We need to know where that method is called, so we can see what are the arguments passed onto the method.

But that overwritten "has_item?" method is quite a bad way to do it, regardless of what this snippet is supposed to do, so you might be better off without it.
That was what the guy did to me here saying it'd work. No other script is in any way related to the speed.
Ooh, I want to know who gave you that snippet, but I don't want you to call them out.

Changing a default method that is used by event commands and altering the parameters ... NOT a good idea. Even if it wasn't, there's a bug there that if you looked for armor, it'd look to see if the armor with that WEAPON id was equipped.

Try replacing it with this:

Code:
#==============================================================================# ** Game_Party#==============================================================================class Game_Party < Game_Unit   def has_item?(item, include_equip = false)    case item      when RPG::Weapon        leader.weapons.include?(item, include_equip)      when RPG::Armor        leader.armors.include?(item, include_equip)    end  end end # Game_Party
Now, it's early morning, and I've got to dash off to work shortly, so I haven't tested the above. Hopefully it won't give you any problems.
Ooh, I want to know who gave you that snippet, but I don't want you to call them out.

Changing a default method that is used by event commands and altering the parameters ... NOT a good idea. Even if it wasn't, there's a bug there that if you looked for armor, it'd look to see if the armor with that WEAPON id was equipped.

Try replacing it with this:

#==============================================================================# ** Game_Party#==============================================================================class Game_Party < Game_Unit def has_item?(item, include_equip = false) case item when RPG::Weapon leader.weapons.include?(item, include_equip) when RPG::Armor leader.armors.include?(item, include_equip) end end end # Game_PartyNow, it's early morning, and I've got to dash off to work shortly, so I haven't tested the above. Hopefully it won't give you any problems.
Thank you Shaz but this doesn't work, it still causes the same error. This is a link to the original request topic

http://forums.rpgmakerweb.com/index.php?/topic/40685-equipment-changes-dash-speed/?hl=speed
Are there any other instances of that method being redefined?


Are you ONLY wanting to know whether anyone in the party has winged boots equipped? You can just do that by:

Code:
$game_party.any?{|actor| actor.equips.include?($data_armors[id])}
where id is the id of the winged boots.
That snippet in that topic is hazardous to the engine.

Here, I made a snippet for you:

Spoiler
#-------------------------------------------------------------------------------# Speed altering equipments snippet# Made by: Sixth## Just note-tag your items with this note:## <speed bonus: +val># <speed bonus: -val>## Replace 'val' with the bonus percentage added/removed to/from the speed.# Always use + for positive bonuses and - for negative ones!# # Examples:## <speed bonus: +50># This makes the equip gain a "Movement Speed +50%" effect. If the player equips# it, the movement speed will be raised significantly (by 50%).## <speed bonus: -20># This makes the equip gain a "Movement Speed -20%" effect. If the player equips# it, the movement speed will be decreased by 20%.## NOTE:# These bonuses are stackable! Meaning all of your equipment's bonus will be # added together and the final value is used to determine the real bonus.# For example, if the player got an equipment with +20% speed, another with +10%,# and yet another with -15% speed effect, the final bonus will be:# 20 + 10 - 15 = 15%## You can choose which party members will affect the movement speed, the party # leader only, or the whole active party (battle members).#-------------------------------------------------------------------------------# Settings:module SpeedBonus # true = Only the leader's equips will be checked for speed bonuses. # false = All battle members' equips will be checked for speed bonuses. LeaderOnly = true # true = The bonus will only be applied when the player is running. # false = The bonus will be applied on walking and running alike. DashOnly = false # Set this setting to a switch ID. # Whenever this switch is ON, the bonus speed effects will be ignored. # Useful for evented scenes, I guess. EffectSwitch = 50 end# End of Settings! Do not edit below this line unless pink pigs are flying!class Game_CharacterBase alias add_equip_effs7643 real_move_speed def real_move_speed if (self.is_a?(Game_Player) || self.is_a?(Game_Follower)) && ((SpeedBonus:😀ashOnly == true && dash?) || SpeedBonus:😀ashOnly == false) base = add_equip_effs7643 return base if $game_switches[SpeedBonus::EffectSwitch] base += base * $game_party.speed_bonus return base else return add_equip_effs7643 end endendclass Game_Party < Game_Unit def speed_bonus bonus = 0 if SpeedBonus::LeaderOnly == true leader.equips.each do |eq| next if eq.nil? bonus += eq.speed_bonus end else battle_members.each do |mem| mem.equips.each do |eq| next if eq.nil? bonus += eq.speed_bonus end end end return bonus end endclass RPG::EquipItem < RPG::BaseItem attr_accessor :speed_bonus def speed_bonus get_speed_bonus if @speed_bonus.nil? return @speed_bonus end def get_speed_bonus @speed_bonus = 0 if @note =~ /<speed bonus: ([+\-]\d+)>/i @speed_bonus = $1.to_i * 0.01 end return @speed_bonus end end
Put it below Materials but above Main on the script list.

I was lazy to write a proper header for the script, but I added all you need to know for setting your equipment bonuses up.

Just use the note-tags on any equip-able item and you are good to go.

Note that the player's original movement speed will be the normal one, which you can manipulate with the event commands in case you need to (to slow down the player, etc).

The bonus from the equipment is added on top of that, and the amount of bonus depends on the original movement speed.

Anyway, experiment with it, it's fun. I got past a 400x400 tiled map within a second with some bonuses added on equipment, lightning fast! 😀
I hate to think what kind of speed you'd get if you had two or three things each with a 1, 2 or 3 speed bonus. Speed only goes up to 6 in the RTP, and is 4 for the player by default.
That snippet in that topic is hazardous to the engine.

Here, I made a snippet for you:

Spoiler
#-------------------------------------------------------------------------------# Speed altering equipments snippet# Made by: Sixth## Just note-tag your items with this note:## <speed bonus: +val># <speed bonus: -val>## Replace 'val' with the bonus percentage added/removed to/from the speed.# Always use + for positive bonuses and - for negative ones!# # Examples:## <speed bonus: +50># This makes the equip gain a "Movement Speed +50%" effect. If the player equips# it, the movement speed will be raised significantly (by 50%).## <speed bonus: -20># This makes the equip gain a "Movement Speed -20%" effect. If the player equips# it, the movement speed will be decreased by 20%.## NOTE:# These bonuses are stackable! Meaning all of your equipment's bonus will be # added together and the final value is used to determine the real bonus.# For example, if the player got an equipment with +20% speed, another with +10%,# and yet another with -15% speed effect, the final bonus will be:# 20 + 10 - 15 = 15%## You can choose which party members will affect the movement speed, the party # leader only, or the whole active party (battle members).#-------------------------------------------------------------------------------# Settings:module SpeedBonus # true = Only the leader's equips will be checked for speed bonuses. # false = All battle members' equips will be checked for speed bonuses. LeaderOnly = true end# End of Settings! Do not edit below this line unless pink pigs are flying!class Game_CharacterBase alias add_equip_effs7643 real_move_speed def real_move_speed if self.is_a?(Game_Player) || self.is_a?(Game_Follower) base = add_equip_effs7643 base += base * $game_party.speed_bonus return base else return add_equip_effs7643 end endendclass Game_Party < Game_Unit def speed_bonus bonus = 0 if SpeedBonus::LeaderOnly == true leader.equips.each do |eq| next if eq.nil? bonus += eq.speed_bonus end else battle_members.each do |mem| mem.equips.each do |eq| next if eq.nil? bonus += eq.speed_bonus end end end return bonus end endclass RPG::EquipItem < RPG::BaseItem attr_accessor :speed_bonus def speed_bonus get_speed_bonus if @speed_bonus.nil? return @speed_bonus end def get_speed_bonus @speed_bonus = 0 if @note =~ /<speed bonus: ([+\-]\d+)>/i @speed_bonus = $1.to_i * 0.01 end return @speed_bonus end end
Spoiler
Put it below Materials but above Main on the script list.

I was lazy to write a proper header for the script, but I added all you need to know for setting your equipment bonuses up.

Just use the note-tags on any equip-able item and you are good to go.

Note that the player's original movement speed will be the normal one, which you can manipulate with the event commands in case you need to (to slow down the player, etc).

The bonus from the equipment is added on top of that, and the amount of bonus depends on the original movement speed.

Anyway, experiment with it, it's fun. I got past a 400x400 tiled map within a second with some bonuses added on equipment, lightning fast! 😀
This is almost exactly what I'd like (and tested to work 100%!) but it seems that it affects both running and the walking. Having a huge speed bonus would make walking nearly impossible and the player "walking" into traps and hazards, so is there a way to make it dash only?
Yeah, there is a way to make it a dash only effect.


I updated the script above, you can now set it to be dash only.


Also added an option to turn off the script's effects with a switch anytime during the game. This can be useful for evented scenes.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.


at OP's request

Original thread: https://forums.rpgmakerweb.com/threads/wrong-number-of-arguments.44824/