KLastWords XP
#1
KLastWords XP

by Kyonides

Introduction

Some Minecraft-inspired avatar once made a support request where it wanted to display an actor's or enemy's last words before finally collapsing in the battlefield. Well, this scriptlet should allow you all to accomplish this very simple goal.

This is NOT a Plug & Play script at all! Confused

You will have to modify the contents of 4 CONSTANTS to make it work. Some accept ID's (1, 2, etc.) and "strings" while others only numbers, 1 or above.

For further information, please read the comments embedded in the script.

Code:
# * KLastWords XP * #
#   Scripter : Kyonides
#   v1.0.0 - 2025-08-29

# * Not a Plug & Play Script! * #

# This scriptlet lets you display a picture portraying a dying character's
# last words before collapsing on screen.
# Pictures should be placed in the Graphics/Pictures directory.
# To make this possible, you will have to add an actor's or enemy's ID and
# their respective "filenames" to the ACTORS or ENEMIES hashes as a key-value
# pair: ACTORS[ID] = "filename" or ENEMIES[ID] = "filename"
# ID stands for an integer number like 1 or above.
# The offset constants will let you place this new picture on screen very close
# to the original battler.

module KLastWords
  OFFSET_X = 16
  OFFSET_Y = -128
  ACTORS = {}
  ENEMIES = {}
  ACTORS[1] = "death1"
  ACTORS[2] = "death2"
  def self.filenames(type)
    type == :actor ? ACTORS : ENEMIES
  end
end

class Game_Actor
  def real_class
    :actor
  end
end

class Game_Enemy
  def real_class
    :enemy
  end
end

class Sprite_Battler
  alias :last_words_sprt_btlr_up :update
  def update
    last_words_sprt_btlr_up
    reset_last_words
  end

  def reset_last_words
    return unless @last_words and @_collapse_duration == 0
    @last_words = false
    @lw_sprite.bitmap.dispose
    @lw_sprite.dispose
    @viewport.dispose
  end

  def create_last_words
    filenames = KLastWords.filenames(@battler.real_class)
    @last_words = filenames.has_key?(@battler.id)
    return unless @last_words
    filename = filenames[@battler.id]
    rect = self.viewport.rect
    @viewport = Viewport.new(rect.x, rect.y, rect.width, rect.height)
    @viewport.z = 200
    @lw_sprite = Sprite.new(@viewport)
    @lw_sprite.x = self.x + KLastWords::OFFSET_X
    @lw_sprite.y = self.y + KLastWords::OFFSET_Y
    @lw_sprite.z = self.z + 1000
    @lw_sprite.bitmap = RPG::Cache.picture(filename)
  end

  def collapse
    create_last_words
    super
  end
end


Terms & Conditions

Free as in Beer beer for non-commercial games. Gamer
Include my nickname in your game credits.
That's it! Tongue sticking out
"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




Users browsing this thread: 1 Guest(s)