Maker VX.
Здравствуйте.
Искал я как-то раз скрипт контролирующий яды и дающий возможность использовать сразу несколько их видов. И вроде бы нашёл…
#==============================================================================
# HoT DoT
# Author: Shdwlink1993
# Version: 1.0b
# Type: Poison Control
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# HT Date 1.0b: 1/11/2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# # This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
# #
# # Note that if you share this file, even after editing it, you must still
# # give proper credit to shdwlink1993.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# ~= Function =~
#
# This script is designed to allow you to expand what poison does to your
# character. Poison now is able to affect HP or MP, and take off a fraction or
# a set amount of HP/MP.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# ~= Version History =~
#
# Version 1.0b ---------------------------------------------------- [1/11/2009]
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# ~= Customization =~
#
# Customization can be found right under where the Poison Database begins.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# ~= Compatability =~
#
# - Will not work with other Poison-editing scripts.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module SL93
def self.hotdot(id)
case id
#------------------------------------------------------------------------
# Poison Database Begins
#------------------------------------------------------------------------
# when STATE_NUMBER then return [TYPE, DAMAGE, VARIANCE, LIMIT_DRAIN]
# * STATE_NUMBER is the state you want to be affected by this.
# * TYPE refers to the thing sustaining damage.
# 1 = HP, 2 = MP. If the type is positive, the amount is a literal
# number (eg. You lose about 50 HP). If the type is negative, then
# the amount is a fraction of the maximum (eg. You lose about 50% of
# your HP).
# * DAMAGE refers to how much damage is healed/taken.
# A Positive amount hurts you and a negative amount heals you.
# * VARIANCE refers to how much the damage varies. Positive only.
# This depends in part on if the type was positive (~5 HP difference)
# or negative (~5% HP difference).
# * LIMIT_DRAIN refers to if the poison can leave you with 0 HP/SP.
# If true, then it is limited, and stops at 1. If false, then it
# isn't.
#------------------------------------------------------------------------
when 2 then return [-1, 10, 10, false] # Standard Poison
#------------------------------------------------------------------------
# Poison Database Ends
#------------------------------------------------------------------------
end
return false
end
end
class Game_Battler
def slip_damage?
return @states.any? {|i| SL93.hotdot(i) != false }
end
def slip_damage_effect
ids = []
for i in @states
ids.push(i) if SL93.hotdot(i) != false
end
for i in ids
damage = SL93.hotdot(i)[1] if SL93.hotdot(i)[0] > 0
damage = self.maxhp / SL93.hotdot(i)[1] if SL93.hotdot(i)[0] == -1
damage = self.maxsp / SL93.hotdot(i)[1] if SL93.hotdot(i)[0] == -2
if damage.abs > 0 && SL93.hotdot(i)[2] > 0
amp = [damage.abs - SL93.hotdot(i)[2], 1].max if SL93.hotdot(i)[0] > 0
amp = [damage.abs * SL93.hotdot(i)[2] / 100, 1].max if SL93.hotdot(i)[0] < 0
damage += rand(amp+1) + rand(amp+1) - amp
end
damage = damage * -1 if SL93.hotdot(i)[0] < 0
if SL93.hotdot(i)[0] == 1 || SL93.hotdot(i)[0] == -1
damage = self.hp - 1 if !SL93.hotdot(i)[3] && (0 > self.hp += damage)
self.hp += damage
elsif SL93.hotdot(i)[0] == 2 || SL93.hotdot(i)[0] == -2
damage = self.mp - 1 if !SL93.hotdot(i)[3] && (0 > self.mp += damage)
self.mp += damage
end
end
return true
end
end
class Game_Party
def on_player_walk
for actor in members
if actor.slip_damage?
actor.slip_damage_effect
$game_map.screen.start_flash(Color.new(255,0,0,64), 4)
$game_temp.next_scene = "gameover" if $game_party.all_dead?
end
end
end
end
Но я так толком и не понял, как контролировать урон. В итоге, использую остаточные знания программирования и наблюдения за кодом, я решил слегка изменить и дополнить скрипт. Вот что в итоге получилось:
module Acid
def self.hotdot(id)
case id
#------------------------------------------------------------------------
# Poison Database Begins
#------------------------------------------------------------------------
# when STATE_NUMBER then return [TYPE, DAMAGE, VARIANCE, LIMIT_DRAIN]
# * STATE_NUMBER is the state you want to be affected by this.
# *[0] TYPE refers to the thing sustaining damage.
# 1 = HP, 2 = MP. If the type is positive, the amount is a literal
# number (eg. You lose about 50 HP). If the type is negative, then
# the amount is a fraction of the maximum (eg. You lose about 50% of
# your HP).(-2 -1 1 2)
# *[1] DAMAGE refers to how much damage is healed/taken.
# A Positive amount hurts you and a negative amount heals you.
# *[2] VARIANCE refers to how much the damage varies. Positive only.
# This depends in part on if the type was positive (~5 HP difference)
# or negative (~5% HP difference). (в %-ах)
# *[3] LIMIT_DRAIN refers to if the poison can leave you with 0 HP/SP.
# If true, then it is limited, and stops at 1. If false, then it
# isn't. (0 1); хп (0 или 1)
# [4]%-ли (0 1) (да нет)
#------------------------------------------------------------------------
when 2 then return [ 1, 50, 50, 1, 1] # Standard Poison
when 27 then return [ 1, 5, 0, 1, 0] # ожог
when 31 then return [ 1, 5, 0, 1, 0] # кровотечение
when 35 then return [ 1, -25, 0, 1, 0] # dot
when 36 then return [ 0, 150, 20, 0, 1] # пиявка
#------------------------------------------------------------------------
# Poison Database Ends
#------------------------------------------------------------------------
end
return false
end
end
class Game_Battler
def slip_damage?
return @states.any? {|i| Acid.hotdot(i) != false }
end
def slip_damage_effect
ids = []
for i in @states
ids.push(i) if Acid.hotdot(i) != false
end
for i in ids
if Acid.hotdot(i)[0] == 1
if Acid.hotdot(i)[4] == 0
damage = self.maxhp * Acid.hotdot(i)[1] / 100
if Acid.hotdot(i)[2] != 0
pm = rand(2)
if pm == 1
radio = rand(Acid.hotdot(i)[2]+1)
dmg = damage * radio / 100
else radio = 0 - rand(Acid.hotdot(i)[2]+1)
dmg = damage * radio / 100
end
else dmg = 0
end
if Acid.hotdot(i)[3] == 1
if damage + dmg >= self.hp
self.hp = 1
else self.hp -= damage + dmg
end
else self.hp -= damage + dmg
end
else damage = Acid.hotdot(i)[1]
if Acid.hotdot(i)[2] != 0
pm = rand(2)
if pm == 1
radio = rand(Acid.hotdot(i)[2]+1)
dmg = damage * radio / 100
else radio = 0 - rand(Acid.hotdot(i)[2]+1)
dmg = damage * radio / 100
end
else dmg = 0
end
if Acid.hotdot(i)[3] == 1
if damage + dmg >= self.hp
self.hp = 1
else self.hp -= damage + dmg
end
else self.hp -= damage + dmg
end
end
else
if Acid.hotdot(i)[4] == 0
damage = self.maxmp * Acid.hotdot(i)[1] / 100
if Acid.hotdot(i)[2] != 0
pm = rand(2)
if pm == 1
radio = rand(Acid.hotdot(i)[2]+1)
dmg = damage * radio / 100
else radio = 0 - rand(Acid.hotdot(i)[2]+1)
dmg = damage * radio / 100
end
else dmg = 0
end
if Acid.hotdot(i)[3] == 1
if damage + dmg >= self.mp
self.mp = 1
else self.mp -= damage + dmg
end
else self.mp -= damage + dmg
end
else damage = Acid.hotdot(i)[1]
if Acid.hotdot(i)[2] != 0
pm = rand(2)
if pm == 1
radio = rand(Acid.hotdot(i)[2]+1)
dmg = damage * radio / 100
else radio = 0 - rand(Acid.hotdot(i)[2]+1)
dmg = damage * radio / 100
end
else dmg = 0
end
if Acid.hotdot(i)[3] == 1
if damage + dmg >= self.mp
self.mp = 1
else self.mp -= damage + dmg
end
else self.mp -= damage + dmg
end
end
end
end
return true
end
end
class Game_Party
def on_player_walk
for actor in members
if actor.slip_damage?
actor.slip_damage_effect
$game_map.screen.start_flash(Color.new(255,0,0,64), 4)
$game_temp.next_scene = "gameover" if $game_party.all_dead?
end
end
end
end
Теперь немного о том, как он работает. Возьму пример:
when 2 then return [ 1, 10, 0, 0, 0]
Это стандартный яд.
Число после «when » это id «состояния».
Первое число в квадратных скобках определял «цель» яда. Если там «1», то яд воздействует на жизни, если что-то иное (например «0»), то на ману.
Второе число – это урон наносимый ядом. Если число отрицательное, то цели будут восстанавливаться жизни (т.е. получается – регенерация).
Третье число – это разброс урона в процентах. Например: если урон равен – 50, а разброс – 50, то итоговый урон будет колебаться от 25 до 75.
Четвертое число – «смертельность». То есть, может ли яд убить жертву или же счётчик жизней остановится на единице. «0» – смертелен, «1» – не смертелен.
Пятое число определяет, будет ли урон наноситься в процентах или в числах. «0» – в процентах, «1» – в числах.
Я бы хотел попросить помощи у скрипторов оптимизировать/упростить код (и при возможности написать нормальную инструкцию к нему в начальных комментариях скрипта), если это возможно.
P. S.
Я не всегда могу правильно выразить свою мысль. Если что – переспрашивайте.
Кому интересен скрипт, можете брать на вооружение