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.
Weapon and Armor modifies max HP/SP

0 Members and 1 Guest are viewing this topic.

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
A script I made in 5-10 minutes or so because someone requested it.
I am to lazy to write a proper topic and to write comments.
It should be compatible to most scripts.
Spoiler for Code:
Code: [Select]
class Game_Actor
  if @stack.nil?
alias zer_ori_maxhp maxhp
alias zer_ori_maxsp maxsp
@stack = true
  end
 
  def maxhp
n = zer_ori_maxhp
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.hp_plus : 0
n += armor1 != nil ? armor1.hp_plus : 0
n += armor2 != nil ? armor2.hp_plus : 0
n += armor3 != nil ? armor3.hp_plus : 0
n += armor4 != nil ? armor4.hp_plus : 0
n = [[n, 1].max, 9999].min
return n
  end
 
  def maxsp
n = zer_ori_maxsp
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.sp_plus : 0
n += armor1 != nil ? armor1.sp_plus : 0
n += armor2 != nil ? armor2.sp_plus : 0
n += armor3 != nil ? armor3.sp_plus : 0
n += armor4 != nil ? armor4.sp_plus : 0
n = [[n, 1].max, 9999].min
return n
  end
end

module RPG
  class Weapon
attr_writer :hp_plus
attr_writer :sp_plus
def hp_plus
  return 0 if @hp_plus.nil?
  return @hp_plus
end
def sp_plus
  return 0 if @sp_plus.nil?
  return @sp_plus
end
  end
end

module RPG
  class Armor
attr_writer :hp_plus
attr_writer :sp_plus
def hp_plus
  return 0 if @hp_plus.nil?
  return @hp_plus
end
def sp_plus
  return 0 if @sp_plus.nil?
  return @sp_plus
end
  end
end

To use it just put something like this in a call script:
Code: [Select]
$data_armors[18].hp_plus = 50
$data_armors[16].sp_plus = 25
$data_weapons[4].hp_plus = 500
$data_weapons[6].sp_plus = 20

You can use it where ever you want in the game.
If you have loads to setup to start with you can insert a script like this:
Code: [Select]
class WeaponAndArmorSetup
  def self.run
    $data_armors[18].hp_plus = 50
    $data_armors[16].sp_plus = 25
    $data_weapons[4].hp_plus = 500
    $data_weapons[6].sp_plus = -20
  end
end

By default every weapon and armor adds 0 to hp and sp.
Use negative values to decrease the amount.

And put this in a call script:
Code: [Select]
WeaponAndArmorSetup.run
It will setup the weapons and armors.
« Last Edit: June 10, 2007, 11:21:15 AM by Zeriab »

*
A Random Custom Title
Rep:
Level 96
wah
Wow, nice, Zeriab. Will you teach me scripting now that you're done with your break? ;D I'll use this script for study...

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
I've been back from my break since http://rmrk.net/index.php/topic,17848.0.html
I don't really know whether or not I am a good teacher for you, but we can always try ^_^

*
A Random Custom Title
Rep:
Level 96
wah
YAY! Shinami was in the process of teaching me but he's currently occupied with a huge syntax book. He then did what my other teacher (of eventing) did and "unfortunately deleted it." I guess I can have two teachers of the same thing at once. ;D Also, I forgot to give good feedback on this. I've seen a lot (er, some) people request for this kind of things and this is nice! You just slip in a code and it works! It's a nice and easy way to set things up. Too bad you can't edit RPG Maker itself to add the option. ;9

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
Thanks ^_^

I've edited it sort out a stack error if you pressed the Key of Script Destruction, i.e. F12

*******
Rep:
Level 90
Returned from the dead.
I want items to increase my hp by 5%, 10% etc
When I type
Code: [Select]
$data_armors[33].hp_plus = *0.05
It just adds a 0.5 onto the end
What am I doing wrong? Or is there a way to multiply hp or sp?
Either way, could you help me?
Sincerely,
Your conscience.

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
Currently the script can only add/remove a static amount of hp/sp.
It is a good idea so I might add that feature to the script when I get time.

*******
Rep:
Level 90
Returned from the dead.
Sincerely,
Your conscience.