Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Script trouble

I was inspired by another user (I can't recall who) to modify the Game_Actor class so that it automatically equips the weapon with an id of 1, called fists, when a weapon is unequipped. Obviously I also want to make the fists disappear instead of being put in the inventory when a weapon is equipped. The weapon called fists has 0 attack, and the idea is, of course, to be able to fight unarmed. Anyway, I'm definitely on the right track because the only problem arises when I go to switch weapons. It may be the only problem, but it's a big one; the weapon that is supposed to be switched out disappears instead. What I did is quite simple. I changed this part of the script...

if id == 0 or $game_party.weapon_number(id) > 0
$game_party.gain_weapon(@weapon_id, 1)
@weapon_id = id
game_party.lose_weapon(id, 1)

to...

if id == 0
$game_party.gain_weapon(@weapon_id, 1)
@weapon_id = 1
else
@weapon_id = id
$game_party.lose_weapon(id, 1)
end

Now here's the thing. Everything I've tried to change has caused a different problem, including putting the 'or $game_party.weapon_number(id) > 0' back. The main problem that arises from changing it is the 'Fists' item appearing in the inventory in multiples. Besides looking incredibly sloppy, it just plain wouldn't make sense for that to happen, obviously. Any help would be greatly appreciated, as I've never scripted before and am surprised that I even got it working this much.
 
A simple solution would be to put
Code:
$data_weapons[0] ||= $data_weapons[1]
at the beginning of the #main method in Scene_Map. Hopefully this doesn't cause saving issues.
Make sure you put the #equip method back to default ;)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top