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.
Modifying Module RPG: Weapon

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 88
Menu & Battle System Guru
I'm trying to modify the Weapon Class so that I can add an sp_plus statistic to each weapon but do not know how to go about it.

I tried something like this but to no avail:

Spoiler for:
Code: [Select]
module RPG
  class Weapon
    attr_accessor :maxsp
    def setup_additional_stats
      @maxsp = 0
      case @id
      when 1
        @maxsp = 5
      end
    end
  end
end
class Game_Temp
  alias setup initialize
  def initialize
    setup
    for weapon in $data_weapons
      weapon.setup_additional_stats
    end
  end
end
« Last Edit: January 15, 2008, 01:26:20 AM by blazinhandle »

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Strike 1, wrong forum.
http://rmrk.net/index.php/topic,19774.0.html

For starters, you're not aliasing the initialize method, which would most likely cause your error.

*
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
Here's how I went about adding a statistic when I needed to. First, I went into the database and stole Zeriab's module addon: http://rmrk.net/index.php/topic,21582.0.html

Then (and this might not be the best way to do it), I wrote in the additional stats like this:

Code: [Select]
attr_sec_accessor :hp_plus, 'get_additional_stats (0)'
attr_sec_accessor :sp_plus, 'get_additional_stats (1)'

and then I wrote a method in the class like this:

Code: [Select]
def get_additional_stats (parameter)
  case @id
  when 0 # Bronze Sword
    hp_add = XX
    sp_add = YY
    return [hp_add, sp_add][parameter]
  when 1 # ETC...
  end
  return 0
end

You could do that for as many stats as you want to, but like I said, it might not be the best way; it's just the way I did it.

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
Could this script perhaps do what you are looking for? http://rmrk.net/index.php/topic,18159.0.html
Either way you can also choose modern's solution ^_^