General Methods
Methods for XP
Introduction
I am posting here a bunch of methods that I thought they have appeared a several times in my scripts or they are methods that seemed to be useful under certain circumstances, but are not good enough to become part of a specific script.
Warning!
This group of methods might not be useful for the average game developer that lacks any scripting skills.
Script Calls
rand_range(any_range)
any_range.random
Returns a random number that is included in the given range. A Range object is a number range with an initial value (the lowest) and a final value (the highest). It's something like using an entire array full of consecutive numbers.
I named the second script call random because I shouldn't overwrite rand. (The script call actually needs rand!)
Using the second option might be your best choice because it doesn't create a global method which would use more memory.
$game_party.leader
Returns the current party's leader (Aluxes!?)
$game_party.subleader
Returns the current party's subleader (Basil!?)
$game_party.actors_by_hp
$game_party.actors_by_sp
$game_party.actors_by_pdef
$game_party.actors_by_mdef
$game_party.actors_by_eva
$game_party.actors_by_agi
$game_party.actors_by_dex
$game_party.actors_by_strength
$game_party.actors_by_mana
Returns the actors sorted by the chosen stat (Descending Order)
$game_player.visible?
Returns if the player's sprite is not transparent
$game_map.events[Number].visible?
Returns if the event's sprite is not transparent
$game_map.events[Number].name
Returns the chosen event's name
You can also check if a battler is hero or an enemy in a new way by calling its brand new kind method that will return either an :actor or :enemy symbol if called. This could be useful in any Game_Battler or Game_Actor or Game_Enemy or Scene_Battle script.
Script
Code:
# * General Methods XP
def rand_range(range)
rand(4) % 2 == 0 ? -rand(range.first) : rand(range.last)
end
class Range
def random() rand(4) % 2 == 0 ? -rand(self.first) : rand(self.last) end
end
class Game_Actor
def kind() :actor end
end
class Game_Enemy
def kind() :enemy end
end
class Game_Party
def leader() @actors[0] end
def subleader() @actors[1] end
def actors_by_hp() @actors.sort{|a,b| b.hp <=> a.hp } end
def actors_by_sp() @actors.sort{|a,b| b.sp <=> a.sp } end
def actors_by_pdef() @actors.sort{|a,b| b.pdef <=> a.pdef } end
def actors_by_mdef() @actors.sort{|a,b| b.mdef <=> a.mdef } end
def actors_by_eva() @actors.sort{|a,b| b.eva <=> a.eva } end
def actors_by_agi() @actors.sort{|a,b| b.agi <=> a.agi } end
def actors_by_dex() @actors.sort{|a,b| b.dex <=> a.dex } end
def actors_by_strength
@actors.sort{|a,b| b.atk + b.str <=> a.atk + a.str }
end
def actors_by_mana
@actors.sort{|a,b| b.atk + b.int <=> a.atk + a.int }
end
end
class Game_Character
def visible?() !@transparent end
end
class Game_Event
def name() @event.name end
end
Terms & Conditions
Free for use in commercial and non commercial projects.
You are free to post any methods here you consider that can be useful for scripting power users and actual scripters.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE