Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: G_G on March 21, 2010, 09:01:15 am

Title: [XP] Spike Damage
Post by: G_G on March 21, 2010, 09:01:15 am
Spike Damage
Authors: game_guy
Version: 1.1
Type: Damage Add-On
Key Term: Battle Add-on



Introduction

Anytime an attacker is inflicted with a "Spike" state and attacks it'll take a part of the damage it dealt to the target. Kind of like in pokemon games.
Example: You set damage rate to 40 percent. Attacker will take 40 percent of the damage dealt to him.


Features




Screenshots

N/A


Demo

MediaFire (http://www.mediafire.com/download.php?m0qazjnmjte)


Script

Spoiler: ShowHide

#===============================================================================
# Spike States
# Author game_guy
# Version 1.1
#-------------------------------------------------------------------------------
# Intro:
# Anytime an attacker is inflicted with a "Spike" state and attacks it'll take
# a part of the damage it dealt to the target. Kind of like in pokemon games.
#
# Features:
# Deals some damage to attacker
# Set how much damage in percent
# Different percents for different states
#
# Instructions:
# SpikeStates ~ Add any state ID that will be considered a Spike state.
# DmgPercent ~ Any number. It'll the damage dealt to the target, and get the
#              percent and deal it back to the attacker.
#
# Credits:
# game_guy ~ For making it
# Pokemon ~ For inspiring me to make it/the idea
#===============================================================================
module GameGuy
  SpikeStates = [17, 18]
  DmgPercent = 40
  def self.statesdmg(id)
    case id
    # Setup State Damage
    #===================================
    # Use
    # when state_id then return percent_damage
    # when 17 then return 40
    #===================================
    when 17 then return 40
    when 18 then return 20
    end
    return 0
  end
end
class Game_Battler
  alias gg_spike_attack_effect_lat attack_effect
  def attack_effect(attacker)
    temphp = self.hp
    result = gg_spike_attack_effect_lat(attacker)
    state = 0
    GameGuy::SpikeStates.any? {|i|
    if attacker.states.include?(i)
      state = i
    end}
    if GameGuy::SpikeStates.any? {|i| attacker.states.include?(i)} && result
      temphp -= self.hp
      dmg = temphp.to_f / 100 * GameGuy.statesdmg(state)
      dmg = dmg.floor
      attacker.hp -= dmg
    end
  end
end



Instructions

In the script.


Compatibility

Not tested with SDK.
Tested with Blizz-Abs/Side View Battle System


Credits and Thanks




Author's Notes

Enjoy!
Title: Re: [XP] Spike Damage
Post by: Sase on March 21, 2010, 10:29:46 am
If you use a negative value it will heal the attacker instead?
Title: Re: [XP] Spike Damage
Post by: (Hexamin) on March 21, 2010, 10:31:46 am
Any way you can make this as a reversal?  I.E., if the player has the status, then anyone that attacks the attacker gets damaged?

Oh, and, I think it'd be a quick edit, but allowing each state to have its own damage?  State 1: 40%, State 2: 30%, etc., using whatever the user defines.

Then again, I could throw in a quick fix to implement that... using...


dmg = temphp.to_f / (GameGuy::DmgPercent * i * 5)


and setting DmgPercent to 1.  I believe that'd make it so state 1 would have a 5%, state 2 10%, state 3 15%, etc., etc., but there's probably an easier configuration of it anyway.


Good script though.  ^_^
Title: Re: [XP] Spike Damage
Post by: Aqua on March 21, 2010, 10:33:10 am
Ahahahaha...
I was looking for something like this a long time ago XP
Title: Re: [XP] Spike Damage
Post by: G_G on March 21, 2010, 11:20:15 am
Updated. You can set the damage percent to multiple states now.
Title: Re: [XP] Spike Damage
Post by: (Hexamin) on March 21, 2010, 02:32:00 pm
awww, i love you! <3 *lvlup*
Title: Re: [XP] Spike Damage
Post by: AresWarrior on May 07, 2010, 10:53:21 pm
This a great script! I have one question though. You say this works if the actor has the state inflicted. Well if I wanted to make a skill do this, how would I make it so that the skill adds the state to the actor? btw, the Demo link isn't working for me.
Title: Re: [XP] Spike Damage
Post by: G_G on May 07, 2010, 11:01:00 pm
You can do this in the database. Go to the Skills tab. Then select the skill and go to the right side where it says State Change. Check the box next to the Spike state and make sure its a + sign in the box.
Title: Re: [XP] Spike Damage
Post by: AresWarrior on May 07, 2010, 11:52:02 pm
but doesnt that make the enemy have the state and not the actor using it?
Title: Re: [XP] Spike Damage
Post by: G_G on May 08, 2010, 01:18:17 am
Change the target of the skill to the actor. But why would you want the Actor taking damage on purpose?
Title: Re: [XP] Spike Damage
Post by: Starrodkirby86 on May 08, 2010, 01:32:27 am
Like in Pokemon: Double-Edge, Take Down, etc.

High power-moves with a catch. I don't see any problem in that...? There's many good reasons...
Title: Re: [XP] Spike Damage
Post by: G_G on May 08, 2010, 08:36:15 am
Oh I see now xD I was just kind of confused.
Title: Re: [XP] Spike Damage
Post by: djskagnetti on May 01, 2012, 09:10:58 am
Hi, great script as always.
I'm making a spell called Masochist that uses your Spike Damage, when cast on an enemy it does damage equal to percentage specified to the enemy when it attacks with a basic physical attack.
As a test I put the percentage of damage at 5000%.  It works, and testing it out on some enemies that do a few hundred physical damage with about 500 hps, as expected it kills them when they hit the character.
But - the enemy dies first, and then the animation and attack damage are shown on the character.  So it's like - enemy turns into red vapor and disappears (death), then sword strike animation and damage dealt to character it was attacking.
Is there a way to make it so it does the attack animation and damage dealt to the character the monster is attacking first, and then the damage % from the Spike Damage spell is done to the monster?

Also, is there a way to show the damage on the monster the spell inflicts?
Thanks!