08-09-2020, 08:29 AM
(This post was last modified: 03-05-2024, 10:46 PM by kyonides.
Edit Reason: Renamed & Updated Script
)
KDefense XP
by Kyonides Arkanthes
Introduction
Did you ever want to know how does it feel like to get truly weaken by a foe?
Now you can!
Just let my script help you create a state that will reduce your PDEF or MDEF by some points every turn till the state wears off!
Nope, the effects will last till you heal your hero or battle is over.
Don't worry! You can create a skill or an item to heal them.
The 2024 edition also lets you achieve the exact opposite of every single thing I have told you so far.
The Script
Code:
# * KDefense XP * #
# Scripter : Kyonides Arkanthes
# 2024-03-05
# This scriptlet allows you to reduce a hero's or monster's PDEF or MDEF.
# If the target was inflicted with a PDEF- or MDEF- state, it will lose some
# percent of that stat every single turn till the state wears off.
# The state's PDEF Rate or MDEF Rate will be substracted from your target'script
# PDEF or MDEF as plain points. I find it incovenient to use percents there.
# You cannot remove the effect by simply removing the state.
# Use a specific item or skill to heal your hero or wait till battle is over.
# Configure the KDefense module's Constants to let the script find your new
# states, skills and items. Set any value to 0 if you don't need it.
module KDefense
module ClearDef
PDEF_ITEM = 33
MDEF_ITEM = 34
end
module PlusDef
PDEF_STATE = 17
MDEF_STATE = 18
PDEF_SKILL = 10
MDEF_SKILL = 11
end
module MinusDef
PDEF_STATE = 19
MDEF_STATE = 20
PDEF_SKILL = 10
MDEF_SKILL = 11
end
end
class Game_Battler
include KDefense
alias :kyon_defense_gm_btl_init :initialize
alias :kyon_defense_gm_btl_rcvr :recover_all
alias :kyon_defense_gm_btl_rstb :remove_states_battle
alias :kyon_defense_gm_btl_sde :slip_damage_effect
alias :kyon_defense_gm_btl_skef :skill_effect
alias :kyon_defense_gm_btl_itef :item_effect
alias :kyon_defense_gm_btl_pdef :pdef
alias :kyon_defense_gm_btl_mdef :mdef
def initialize
kyon_defense_gm_btl_init
clear_pdef_extra
clear_mdef_extra
end
def clear_pdef_extra
@pdef_extra = 0
end
def clear_mdef_extra
@mdef_extra = 0
end
def clear_def_extra
clear_pdef_extra
clear_mdef_extra
end
def change_pdef_extra(force, state_id, clear_now)
return false unless force
add_state(state_id)
clear_pdef_extra if clear_now
true
end
def change_mdef_extra(state_id, clear_now)
return false unless force
add_state(state_id)
clear_mdef_extra if clear_now
true
end
def add_pdef_plus(force=true)
change_pdef_extra(force, PlusDef::PDEF_STATE, @pdef_extra < 0)
end
def add_mdef_plus(force=true)
change_mdef_extra(force, PlusDef::MDEF_STATE, @mdef_extra < 0)
end
def add_pdef_minus(force=true)
change_pdef_extra(force, MinusDef::PDEF_STATE, @pdef_extra > 0)
end
def add_mdef_minus(force=true)
change_mdef_extra(force, MinusDef::MDEF_STATE, @mdef_extra > 0)
end
def recover_all
kyon_defense_gm_btl_rcvr
clear_pdef_extra
clear_mdef_extra
end
def remove_states_battle
kyon_defense_gm_btl_rstb
clear_pdef_extra
clear_mdef_extra
end
def slip_damage_effect
result = kyon_defense_gm_btl_sde
if state?(PlusDef::PDEF_STATE)
@pdef_extra += $data_skills[PlusDef::PDEF_STATE].pdef_rate
result |= true
elsif state?(Minus::PDEF_STATE)
@pdef_extra -= $data_skills[MinusDef::PDEF_STATE].pdef_rate
result |= true
end
if state?(PlusDef::MDEF_STATE)
@mdef_extra += $data_skills[PlusDef::MDEF_STATE].mdef_rate
result |= true
elsif state?(MinusDef::MDEF_STATE)
@mdef_extra -= $data_skills[MinusDef::MDEF_STATE].mdef_rate
result |= true
end
result
end
def skill_effect(user, skill)
result = rand(100) < skill.hit
case skill.id
when PlusDef::PDEF_SKILL
return add_pdef_plus(result)
when PlusDef::MDEF_SKILL
return add_mdef_plus(result)
when MinusDef::PDEF_SKILL
return add_pdef_minus(result)
when MinusDef::MDEF_SKILL
return add_mdef_minus(result)
end
kyon_defense_gm_btl_skef(user, skill)
end
def item_effect(item)
case item.id
when ClearDef::PDEF_ITEM
clear_pdef_extra
return true
when ClearDef::MDEF_ITEM
clear_mdef_extra
return true
end
kyon_defense_gm_btl_itef(item)
end
def pdef
[kyon_defense_gm_btl_pdef + @pdef_extra, 0].max
end
def mdef
[kyon_defense_gm_btl_mdef + @mdef_extra, 0].max
end
attr_accessor :pdef_extra, :mdef_extra
end
Terms & Conditions
Free for use in any game.
Include my nickname in your game credits.
Mention this forum as well.
Give me a free copy of your completed game if you include at least 2 of my scripts!
"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.
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!
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
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
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!
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