Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Ruby, RGSS & General Code Discussion
#6
My Dynamic Leveling Scriptlet

Code:
module DynamicLeveling
  EXP_PERCENT = 0.1
  def self.dynamic_level_exp(enemy, actor_level)
    lvl_bonus_penalty = enemy.level - actor_level
    exp = (enemy.exp * EXP_PERCENT).round
    total_exp = [1, enemy.exp + (lvl_bonus_penalty * exp)].max
  end
end

class Game_Enemy
  attr_accessor :level
end

Let's say you want an actor to get some experience from a couple of poor, abused ghosts.

actor.exp = DynamicLeveling.dynamic_level_exp(enemy, actor_level)

The catch here would be the need to find a way to assign them a specific level either by using an array, a hash or something else.

Oh, oh, I found some other weird stuff found in the default scripts.

Code:
def all_dead?
    # If number of party members is 0
    if $game_party.actors.size == 0
      return false
    end
    # If an actor is in the party with 0 or more HP
    for actor in @actors
      if actor.hp > 0
        return false
      end
    end
    # All members dead
    return true
  end
  #--------------------------------------------------------------------------
  # * Slip Damage Check (for map)
  #--------------------------------------------------------------------------
  def check_map_slip_damage
    for actor in @actors
      if actor.hp > 0 and actor.slip_damage?
        actor.hp -= [actor.maxhp / 100, 1].max
        if actor.hp == 0
          $game_system.se_play($data_system.actor_collapse_se)
        end
        $game_screen.start_flash(Color.new(255,0,0,128), 4)
        $game_temp.gameover = $game_party.all_dead?
      end
    end
  end

Note that this comes from Game_Party class an even so it calls itself with an external flag, i.e. $game_party.actors.size and $game_party.all_dead?, I don't really know why they thought it would ever make any sense to achieve such a terrible and useless feat.
"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.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

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! Laughing + Tongue sticking out

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
Reply }


Messages In This Thread
RE: Ruby, RGSS & General Code Discussion - by kyonides - 12-21-2012, 11:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Possible means to speed up Bitmap TONE code? DerVVulfman 7 1,870 06-11-2023, 08:22 PM
Last Post: kyonides
   RGSS scripting dissections and explinations Siletrea 97 92,481 03-18-2019, 06:46 AM
Last Post: Siletrea
   Help iwth script (RGSS Player crash) Whisper 3 7,736 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,425 11-03-2015, 06:16 AM
Last Post: kyonides
   Custom Game_Event code lags too much! MechanicalPen 4 5,961 06-27-2013, 11:22 PM
Last Post: MechanicalPen
Question  RGSS stoped to work Chaos17 5 6,980 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   [Request] Tut. for RGSS Eldur 9 10,724 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   [RUBY] Depack Thread Problem Narzew 1 4,005 07-20-2012, 01:16 PM
Last Post: Narzew
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 3,904 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Quick RGSS question - switches Ravenith 2 5,179 08-23-2009, 11:23 AM
Last Post: Ravenith



Users browsing this thread: