Save-Point
KSickItem XP - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: KSickItem XP (/thread-8334.html)



KSickItem XP - kyonides - 08-12-2021

KSickItem XP
v0.3.3

by Kyonides Arkanthes

Introduction

This is a simple scriptlet that will allow you to set as many poisonous items as you wish. Winking
You got to gain or lose an item in order to notice any difference on any of your heroes' states.
Happy with a sweat Yeah, I know that you might have found scripts that let you curse weapons or armors and the like but this one is specific for items! Grinning

It is NOT a Plug & Play script, guys! Indifferent

The Scriptlet

Code:
# * KSickItem XP
#   Scripter : Kyonides Arkanthes
#   2021-08-13 - v0.3.3

# Have you ever thought about including poisonous items in your game project?
# Now you can for sure!

# There are two ways to cure this new kind of poison:
# 1. Get rid of the item!
# 2. Use a specific curative item!

# This is NOT a Plug & Play Script at all!!

# Interpreter#command_126 method has been overwritten.

# * Script Calls * #

# * Actors Poisoned by Item ID
# $game_party.sick_actors(ItemID)

# * First Select an Actor at Position
# actor = $game_party.actors[Position]

# * Is this Item ID poisonous for this Actor?
# actor.sick_item?(ItemID)

# * Retrieve all of the poisonous items for this Actor
# actor.sick_items

# * Add a New Poisonous Item to an Actor
# - It will fail quietly if the item is not listed in ITEM_IDS
# actor.add_sick_item(ItemID)

module KSick
# Poisonous Items
# { ItemID => StateID, etc. }
  ITEM_IDS = { 5 => 10, 6 => 11 }
# Curative Items
# { ItemID => StateID, etc. }
  CURE_ITEM_IDS = { 12 => 10, 13 => 11 }
  RANDOM_CURE_ITEM_SUCCESS_RATE = 50
  RANDOM_CURE_ITEM_ID = 11
  CURE_ITEM_SUCCESS_RATE = 75
  ACTORS = {} # Target Actors - Better leave it alone
  ACTORS.default = [] # Better leave it alone
  # [ActorID] = [List of Item IDs]
  ACTORS[1] = [5,6]
end

class Game_Actor
  alias :kyon_sick_gm_actor_init :initialize
  def initialize(actor_id)
    kyon_sick_gm_actor_init(actor_id)
    @sick_items = KSick::ACTORS[actor_id].dup
  end

  def add_sick_item(sid)
    return unless KSick::ITEM_IDS[sid]
    @sick_items << sid
    @sick_items = @sick_items.uniq
  end

  def use_cure_item(cid)
    iid = 0
    if KSick::RANDOM_CURE_ITEM_ID == cid
      success = rand(100) < KSick::RANDOM_CURE_ITEM_SUCCESS_RATE
      iid = @sick_items[rand(@sick_items.size)] if success
    else
      success = rand(100) < KSick::CURE_ITEM_SUCCESS_RATE
      iid = @sick_items[KSick::CURE_ITEM_IDS[cid]] if success
    end
    return false unless success
    @sick_items.delete(iid)
    remove_state(KSick::CURE_ITEM_IDS[sid])
    true
  end

  def sick_item?(item_id) @sick_items.include?(item_id) end

  def add_sick_item_state(item_id)
    add_state(KSick::ITEM_IDS[item_id]) if sick_item?(item_id)
  end

  def remove_sick_item_state(item_id)
    remove_state(KSick::ITEM_IDS[item_id]) if sick_item?(item_id)
  end
  attr_reader :sick_items
end

class Game_Party
  alias :kyon_sick_gm_pty_git :gain_item
  alias :kyon_sick_gm_pty_lit :lose_item
  def sick_actors(item_id) @actors.select{|a| a.sick_item?(item_id) } end
  def gain_item(item_id, n)
    kyon_sick_gm_pty_git(item_id, n)
    return if @items[item_id] == 0
    sick_actors(item_id).each{|a| a.add_sick_item_state(item_id) }
  end

  def lose_item(item_id, n)
    kyon_sick_gm_pty_lit(item_id, n)
    return if @items[item_id] > 0
    sick_actors(item_id).each{|a| a.remove_sick_item_state(item_id) }
  end
end

class Interpreter
  def command_126
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    if value > 0
      $game_party.gain_item(@parameters[0], value)
    elsif value < 0
      # Need to activate the sick state removal process
      $game_party.lose_item(@parameters[0], -value)
    end
    return true
  end
end


Terms & Conditions

Include me in your game credits!
Free for use anywhere unless you are are against the open source movement. Tongue sticking out


RE: KSickItem XP - kyonides - 08-13-2021

Update

I forgot to mention this before, but the script has been updated a couple of times in the last few hours. Happy with a sweat
Just saying in case you had copied and pasted it on an empty text file... Laughing