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.

[XP] Way of the Fist

This is a very quick, simple script that should be useful.  It was requested awhile back- and here it is.

This script steps in when you equip "nothing".  It equips (but does not give the player) a hidden weapon (which is fully configurable per actor) that can serve as fists, or other abilities.  It's basically assigns a weapon to id 0 that is unique to each actor.

Code:
#  theory's Way of the Fist script

class Game_Actor < Game_Battler  
  #--------------------------------------------------------------------------
  # * Fists Settings
  #--------------------------------------------------------------------------  
   def natweap_id
     
    # Settings: {0 => Default Fist ID, 1 => Actor 1 Fists ID, etc}
     @Fists = {0 => 7, 1 => 7, 2 => 7}
    # End Settings
    
     natweap = @Fists[@actorid]
     if natweap == nil
       natweap = @Fists[0]
     end
     return natweap
   end
   
  #--------------------------------------------------------------------------
  # * Change Equipment
  #     equip_type : type of equipment
  #     id    : weapon or armor ID (If 0, remove equipment)
  #--------------------------------------------------------------------------
  def equip(equip_type, id)
    case equip_type
    when 0  # Weapon
      if $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1)
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end
      if id == 0
        if @weapon_id != natweap_id
          $game_party.gain_weapon(@weapon_id, 1)
        end
        if @weapon_id == nil
          @weapon_id = 0
        end
        @weapon_id = natweap_id  
      end
    when 1  # Shield
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor1_id], $data_armors[id])
        $game_party.gain_armor(@armor1_id, 1)
        @armor1_id = id
        $game_party.lose_armor(id, 1)
      end
    when 2  # Head
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor2_id], $data_armors[id])
        $game_party.gain_armor(@armor2_id, 1)
        @armor2_id = id
        $game_party.lose_armor(id, 1)
      end
    when 3  # Body
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor3_id], $data_armors[id])
        $game_party.gain_armor(@armor3_id, 1)
        @armor3_id = id
        $game_party.lose_armor(id, 1)
      end
    when 4  # Accessory
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor4_id], $data_armors[id])
        $game_party.gain_armor(@armor4_id, 1)
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end
    end
  end
end

Edited for suggestions by SephirothSpawn. Thanks.
 
I suggest using a hash vs. block of if else codes. Also, there really isn't a point in adding an actor_id argument to your natweapon_id method since it's always just going to use @actor_id

Code:
  Unarmed_Weapon_ID = {}
  Unarmed_Weapon_ID.default = 7
  def natweap_id
    return Unarmed_Weapon_ID[@actor_id]
  end
 
Nice idea, and I've been wanting something like this for a while (I actually requested something like this once...)

But...there's a few minor problems. Either I have no idea what I'm doing (which is highly possible) or there are a few glitches.

All I changed was the weapon ID that actor 1 has from 7 to 2. I testplayed when he had no weapon, and nothing happened. I know you said it only works when you unequip stuff, but this script might be useful for someone who can't equip any weapons (then again, I could just give them an unequipable weapon!) But the real problem was when I tried it out with a weapon. Actor 1 had a weapon#1 equipped, and when he unequipped it, he got weapon#2 (which is what I wanted) but then, a random number of copies (15, 32, 28 from three tries) of weapon#2 appeared in my inventory! Seems rather peculiar.

Anyway, cool script! I hope this problem is easily resolved (or maybe it's my fault...)
 
@Seph - Thanks, I'll have that adjusted in a few minutes.

@Armor King - I had the same problem when I started, but had fixed it on my end...  I'll take a look and see if I can find your problem.
Just to make sure you understand, you do NOT give them weapon 2 if that's your unequip weapon.  If you need them to start with your fists weapon, just give them a starter weapon and use an event to unequip and remove it.  This script works with event unequips as well.

I'll have an updated version sometime today.

Edit:
I've updated it to use a hash and got rid of the argument for checking.

Armor_King, I was not able to recreate your problem.  Both checks come from the same function for equipping or removing...
I can provide a demo if anyone thinks it needs one.
 
Of course- it's in the database just like any other weapon.  Change the "Fist Weapon ID" of the character you are using to the number of a weapon in the database.  Then, goto the database, select your newly appointed "fists" and choose an animation, atk, etc.
 
Lets see if I got this correct:

weapon_id = 0
This is the weapon that will be fist, hand, or slap?  So whatever I have as ID = 0 will be the weapon that is the hidden weapon?


Do I have to do this for each actor?

For example I only need one "fist" weapon for all my 13 actors.  I have no way to test this cause I'm not at home.


EDIT:  NVM I figured it out and it works great.  I did notice one small problem.  If you set the "fist" weapon as a weapon the actor can equip when you unequip that item, you get 13 of that item in the inventory.  If you keep doing it, you can get 99 fists.  However, as long as you make the weapon not able to be used normally this problem doesn't happen.

If possible could you make a demo?

Thanks,
 

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