RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Need Help Editing a Script

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 82
Meow?
I'm not an English-mind so sorry for my bad grammer.

This is the original script made by scripter MoMo from Japan. The script will auto-equip a "default" weapon when you remove your hero's equipped weapon. Works flawlessly.

Spoiler for:
Code: [Select]
module MoMo_No_Weapon_Equip
  # ???????ID
  # weapon_id[????ID] = ??ID
  weapon_id = []
  weapon_id[0] = 2 # ??????(?????????????)
  weapon_id[1] = 3
 
  NO_WEAPON_ID = weapon_id
 
  module_function
  def get_no_weapon_id(actor_id)
    if NO_WEAPON_ID[actor_id] == nil
      return NO_WEAPON_ID[0]
    end
    return NO_WEAPON_ID[actor_id]
  end
end
class Game_Actor < Game_Battler
  alias game_actor_no_weapon_equip_initialize initialize
  def initialize(actor_id)
    game_actor_no_weapon_equip_initialize(actor_id)
    @no_weapon_id = MoMo_No_Weapon_Equip.get_no_weapon_id(actor_id)
  end
  alias game_actor_no_weapon_equip_equip equip
  def equip(equip_type, id)
    wep_id = @weapon_id
    if equip_type == 0
      id = 0 if id == @no_weapon_id
      game_actor_no_weapon_equip_equip(equip_type, id)
      @weapon_id = @no_weapon_id if @weapon_id == 0
      $game_party.lose_weapon(@no_weapon_id, 1) if wep_id == @no_weapon_id
    else
      game_actor_no_weapon_equip_equip(equip_type, id)
    end
  end
end


And I'm trying to make it work for armor too.
The result is as follows:

Spoiler for:
Code: [Select]
module MoMo_No_armor3_Equip
  # ???????ID
  # weapon_id[????ID] = ??ID
  armor_id = []
  armor_id[0] = 2 # ??????(?????????????)
  armor_id[1] = 3
 
  NO_ARMOR3_ID = armor_id
 
  module_function
  def get_no_armor3_id(actor_id)
    if NO_ARMOR3_ID[actor_id] == nil
      return NO_ARMOR3_ID[0]
    end
    return NO_ARMOR3_ID[actor_id]
  end
end
class Game_Actor < Game_Battler
  alias game_actor_no_armor3_equip_initialize initialize
  def initialize(actor_id)
    game_actor_no_armor3_equip_initialize(actor_id)
    @no_armor3_id = MoMo_No_armor3_Equip.get_no_armor3_id(actor_id)
  end
  alias game_actor_no_armor3_equip_equip equip
  def equip(equip_type, id)
    ar3_id = @armor3_id
    if equip_type == 0
      id = 0 if id == @no_armor3_id
      game_actor_no_armor3_equip_equip(equip_type, id)
      @armor3_id = @no_armor3_id if @armor3_id == 0
      $game_party.lose_armor(@no_armor3_id, 1) if ar3_id == @no_armor3_id
    else
      game_actor_no_armor3_equip_equip(equip_type, id)
    end
  end
end

It "worked" in a strange way...the "default" armor only appear when I change my WEAPON, not armor.

Could someone help me please?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Keeping in mind that I haven't looked at RMXP for a long time, I think your problem is that you are only running the appropriate part of the method when equipping a weapon:

Code: [Select]
    if equip_type == 0

If equip_type is 0, it means you are equipping a weapon. If you changed that to the appropriate type (by memory: 0 => Weapon, 1 => Shield, 2 => Head, 3 => Body, 4 => Accessory), then it would run when you want it to. Judging by your naming, you want it to be body armor, so try doing it with

Code: [Select]
if equip_type == 3

**
Rep: +0/-0Level 82
Meow?
Yes it worked! Thanks for your help :D