Jump to content
Sign in to follow this  
Shadow.1.9

SUS - "Rare Candy" Vx Ace Script

Recommended Posts

SUS - "Rare Candy" Vx Ace Script

Shadow

 

Introduction

If you can forgive the mess that is the script (I did a very quick tidy-up), it does work and (I think) it makes sense. I may (or may not) do a proper tidy-up at a later date (including comments; the ones already there were written 'under the influence', but, are probably more or less correct). In the meantime, any problems? let me know.

 

Features

- Use notetags to give items function like 'Rare Candy' in 'Pokemon'

- Some simple customization options

 

How to Use

Copy and paste script into the script editor under Materials and above Main Process (Hint: press the insert button or right-click and select insert to add a slot for scripts - though pasting one after another works fine too).

Place the following notetag in notes for the item you wish to give the "Rare Candy" trait:

<rare candy>

 

Script

 

 

=begin

SUS - "Rare Candy" VX Ace Script
- Version: 1.00
- Created by Shadow

<rare candy>
Use this notetag in notes under items in the database editor to give that item
the rare candy effect.

=end

module SUS
 module RARE_CANDY

	SHOW_LEVEL_UP = true
	# Change this constant to false if you do not wish for the 'level up' effect
	# to be shown when 'rare candy' item is used

	HP_CARRY = 2  # 2 is default
	MP_CARRY = 2  # 2 is default
	# Set HP_CARRY and MP_CARRY to either 0, 1, 2 or 3.
	#   '0' will cause the respective stat to be fully restored at level up.
	#   '1' will cause the difference between max and current values of the
	#		respective stat to be maintained at level up.
	#   '2' will cause the respective stat to maintain is exact numerical value
	#		at level up.
	#   '3' will cause the ratio of current isto max of the respective stat to
	#		be maintained at level up.
	#   All whether due to 'rare candy' or not.


# WARNING: Do not edit past this point unless you know what you're doing.

	RC_TAG = /<(?:rare candy|rare_candy)>/i

 end
end

module DataManager

 #--------------------------------------------------------------------------
 # alias: Load Database
 #--------------------------------------------------------------------------
 class <<self
	alias load_database_sus_rc load_database
	# An alias simply renames something.
	# In this case I have simply renamed the original "load_database" to
	#   "load_database_sus_rc". I am doing so here simply to add to the original;
	#   as opposed to overwriting it. This means that if you have made changes
	#   to the original or have included someone esle's script which does: then
	#   they will still be included (this does not guarantee compatability).
	# Alias methods will pretty much always be followed by a definition of the
	#   original name with the original method somewhere within the definition
	#   using its new name.
 end
 def self.load_database
	# Since I have renamed the original method, other methods which use this
	#   method would no longer be able to use it (since they would still be
	#   trying to use it by it's old name). Therefore, I have re-defined the
	#   original name.
	# In order to include the original method in the new one I have used it by
	#   its new name in the line below.
	load_database_sus_rc
	for obj in $data_items
	  next if obj.nil?
	  obj.read_notes
	end
 end

end

class RPG::UsableItem < RPG::BaseItem

 alias init initialize
 def initialize
	init
	@rc_effect = false
 end

 def read_notes
	if self.note.scan(SUS::RARE_CANDY::RC_TAG)
	  @rc_effect = true
	end
 end

 attr_accessor :rc_effect

end

class Game_Battler < Game_BattlerBase

 alias item_effect_apply_sus_rc item_effect_apply
 def item_effect_apply(user, item, effect)
	item_effect_apply_sus_rc(user, item, effect) unless item.rc_effect
	self.rare_candy(SUS::RARE_CANDY::SHOW_LEVEL_UP) if item.rc_effect
 end

 def item_effect_rare_candy(user, item, effect)
	$game_party.rare_candy(SUS::RARE_CANDY::SHOW_LEVEL_UP)
 end

 alias item_effect_test_sus_rc item_effect_test
 def item_effect_test(user, item, effect)
	item_effect_test_sus_rc(user, item, effect) unless item.rc_effect
	true if item.rc_effect
 end


 alias item_user_effect_sus_rc item_user_effect
 def item_user_effect(user, item)
	item_user_effect_sus_rc(user, item)
	@result.success = true if item.rc_effect
 end

end

class Game_Actor < Game_Battler

 def rare_candy(show = true)
	change_level(@level + 1, show)
 end

 alias change_exp_sus_rc change_exp
 def change_exp(exp, show)
	hp = 0
	mp = 0
	hp = self.mhp - @hp if SUS::RARE_CANDY::HP_CARRY == 1
	mp = self.mmp - @mp if SUS::RARE_CANDY::MP_CARRY == 1
	hp = @hp / self.mhp if SUS::RARE_CANDY::HP_CARRY == 3
	mp = @mp / self.mmp if SUS::RARE_CANDY::MP_CARRY == 3
	change_exp_sus_rc(exp, show)
	@hp = self.mhp - hp unless SUS::RARE_CANDY::HP_CARRY >= 2
	@mp = self.mmp - mp unless SUS::RARE_CANDY::MP_CARRY >= 2
	@hp = self.mhp * hp if SUS::RARE_CANDY::HP_CARRY == 3
	@mp = self.mmp * mp if SUS::RARE_CANDY::HP_CARRY == 3
	refresh
 end

end


class Game_Party < Game_Unit

 def rare_candy(show)
	target_actor.rare_candy(show)
 end

end

class Scene_ItemBase < Scene_MenuBase

 alias item_effects_valid_sus_rc? item_effects_valid?
 def item_effects_valid?
	item_effects_valid_sus_rc? unless item.rc_effect
	true if item.rc_effect
 end

 alias use_item_to_actors_sus_rc use_item_to_actors
 def use_item_to_actors
	use_item_to_actors_sus_rc
	item_target_actors.each do |target|
	  item.repeats.times {
			target.item_apply(user, item)
			target.rare_candy(SUS::RARE_CANDY::SHOW_LEVEL_UP) if item.rc_effect
	  }
	end
 end

end

=begin

End of "Rare Candy" Script

=end

 

 

 

FAQ

Questions? Problems?

You can message me or email to: shadow.the.unnoticed.spectacle@gmail.com

 

Credit and Thanks

- Shadow

- Script originally requested by: DDD

 

Author's Notes

PLEASE observe copyright when using this script.

You do not need my permission to use this script, however, I do not condone it's unlawful use (e.g. Copyright infringements).

Happy Creating.

Edited by Shadow.1.9

Share this post


Link to post
Share on other sites

Very nice little script you have here. And tidying up really isnt needed as it is already pretty easy to understand. Just change the customization option to however you want and then just add notetags, very simple to do.

Share this post


Link to post
Share on other sites

And for those of us who have never played Pokemon, "Rare Candy" does what exactly? I've just googled it and I assume it causes the character to gain one level?

Share this post


Link to post
Share on other sites

I have the same problem as the guy above... I tagged my 1 item as rare candy and it worked for that item. but then made any other item you use level you up by 3... any fixes for this?!?

Share this post


Link to post
Share on other sites

As have I. I tagged one item, and every item levels a character up. When I did a battletest, oddly enough, everything BUT the Rare Candy item leveled my character.

Share this post


Link to post
Share on other sites

Without actually using the script, my deduction is that this is the issue:

def read_notes
		if self.note.scan(SUS::RARE_CANDY::RC_TAG)
		  @rc_effect = true
		end
  end

This is not doing what you may think it is doing.

 

Instead if you change:

if self.note.scan(SUS::RARE_CANDY::RC_TAG)
to

if self.note =~ SUS::RARE_CANDY::RC_TAG
it should work as intended.

 

 

Right now, what's happening is that you are trying to determine if an object is not nil. However it will never be because whether it matches the notetag or not an array will be created in that 'if' statement and therefore the 'if not nil' statement will be passed. Which means every single item ever will be an RC Item.

 

Instead, if you use the |if self.note =~ SUS::RARE_CANDY::RC_TAG|, then the code checks if the notetag was matched rather than a variable type. Which I'm pretty sure is what you were going for.

 

 

Additionally the alias you've performed in the load_database method is quite common amongst scripters for RPG Maker so you didn't really need to comment on what you were doing as we all already knew :)

Share this post


Link to post
Share on other sites

Thank you, DP3, it works as it is supposed to. (And the thing where the supposed item didn't work in battletest? I have it set to only work in the menu, so that's probably not a bug.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×