Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Panik Value ACE
#1
Panik Value ACE
by Kyonides


Introduction

This scriptlet allows you to display a so called panic level on screen. You can change its current location by adjusting the values of the corresponding CONSTANTS found in the Panik module.

Version 1.0.2

Code:
# * Panik Value ACE
#   Scripter : Kyonides Arkanthes
#   v1.0.2 - 2022-01-02

# * This script is free as beer and speech! * #

# Display the current Panic Level on screen!
# It changes its backdrop depending on how dangerous the situation actually is.
# You can toggle it by turning a specific game switch on and off at will.
# A flash will be displayed if the Panic Level hits a certain value.
# Please adjust the values of all the CONSTANTS found below in the Panik module.

module Panik
  BACKDROP_X = 460
  BACKDROP_Y = 0
  # Pictures for Good, So so and Bad Panic Levels
  BACKDROPS = ["", "", ""]
  VAR_ID = 100
  SWITCH_ID = 1
  FONT_NAME = "Verdana"
  FONT_SIZE = 20
  # [ Red, Green, Blue ] for each Panic Level
  FONT_COLOR = [[255,255,255], [220,80,20], [255,0,0]]
  FLASH_MIN_VALUE = 90
  FLASH_COLOR = [255,0,0,128] # [ Red, Green, Blue, Opacity ]
  FLASH_DURATION = 8
end

class PanicSpriteset
  include Panik
  def initialize
    @box = Sprite.new
    @box.x = BACKDROP_X
    @box.y = BACKDROP_Y
    @board = Sprite.new
    @board.x = BACKDROP_X + 4
    @board.y = BACKDROP_Y + 4
    @sprites = [@box, @board]
    refresh_panic
    check_panic_index
    refresh_backdrop
    @board.bitmap = Bitmap.new(@box.width - 8, @box.height - 8)
    refresh_value
    self.visible = $game_switches[SWITCH_ID]
  end

  def check_panic_index
    @panic_index = case @panic_value
    when 0..49   then 2
    when 50..75  then 1
    when 75..100 then 0
    end
  end

  def refresh_panic
    @panic_value = [0, $game_variables[VAR_ID]].max
    @panic_value = [@panic_value, 100].min
  end

  def refresh_backdrop
    @last_index = @panic_index
    backdrop = BACKDROPS[@last_index]
    @box.bitmap.dispose if @box.bitmap != nil
    @box.bitmap = Cache.picture(backdrop)
  end

  def refresh_value
    @last_value = @panic_value
    bit = @board.bitmap
    bit.clear
    bit.font.name = FONT_NAME
    bit.font.size = FONT_SIZE
    r, g, b = FONT_COLOR[@panic_index]
    bit.font.color = Color.new(r, g, b, 255)
    bit.draw_text(0, 0, @board.width, @board.height, @panic_value.to_s, 1)
    return if FLASH_MIN_VALUE > @panic_value
    r, g, b, a = FLASH_COLOR
    $game_screen.start_flash(Color.new(r, g, b, a), FLASH_DURATION)
  end

  def update
    refresh_panic
    check_panic_index
    refresh_backdrop if @last_index != @panic_index
    refresh_value if @last_value != @panic_value
    self.visible = $game_switches[SWITCH_ID]
  end

  def visible=(bool)
    if @last_state != bool
      @sprites.each{|sprite| sprite.visible = bool }
    end
    @last_state = bool
  end

  def dispose
    @sprites.each do |sprite|
      sprite.bitmap.dispose
      sprite.dispose
    end
    @sprites.clear
  end
end

class Scene_Map
  alias :kyon_panik_val_scn_map_crt_spr :create_spriteset
  alias :kyon_panik_val_scn_map_dsp_spr :dispose_spriteset
  alias :kyon_panik_val_scn_map_up :update
  def create_spriteset
    kyon_panik_val_scn_map_crt_spr
    @panic_box = PanicSpriteset.new
  end
 
  def dispose_spriteset
    kyon_panik_val_scn_map_dsp_spr
    @panic_box.dispose
  end

  def update
    kyon_panik_val_scn_map_up
    @panic_box.update
  end
end


Terms & Conditions

You can find them embedded in my scriptlet. Winking
"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 }
#2
Panik Update

I have revisited my script in order to implement new minor features like letting you customize the Panik Value font color and also setting up a new flash with its corresponding color that will be displayed once for every time the Panik Value hits or exceeds the specified total panic threshold.

Don't ever let panic overcome you! Laughing
"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 }
#3
A Minor Bug Fix

I have found a miniscule bug in the class PanicSpriteset#refresh_value method so I have fixed it in version 1.0.2 of my script.
Later on I have also made a few minor code changes in order to make it easy to update the backdrop automatically.
"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: