Touch Damage for Blizz-ABS
Authors: winkio
Version: 1.11
Type: Misc Add-on
Key Term: Blizz-ABS Plugin
IntroductionWhen you touch an enemy it hurts you. It's as simple as that.
Features
- enemies deal damage when you touch them
- configure damage and variance for each enemy individually
- no effect if you set them to not deal damage
- NEW in 1.10 - touch damage can cause states.
- NEW in 1.11 - fixed bug with Blizz-ABS 2.5 or higher.
Screenshotsno. if you have ever played zelda or any game really, it's the same thing.
ScriptPut below Blizz-ABS part 3, above main
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
# Blizz-ABS Touch Damage by Winkio
# Version: 1.11
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
#
#
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
# This script makes it so that when you touch an enemy, it deals damage to you.
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
#==============================================================================
# BlizzABS
#------------------------------------------------------------------------------
# This is the master control, configuration, utility and battle process
# module for Blizz-ABS.
#==============================================================================
module BlizzABS
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# BlizzABS::Enemies
#----------------------------------------------------------------------------
# This module provides enemy configurations.
# when ID then return [DAMAGE, VARIANCE, [STATEID_1, STATEID_2, etc.]]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module Enemies
def self.touch_damage(id)
case id
when 1 then return [40, 4, [3]]
end
return [0, 0, 0]
end
end
#============================================================================
# BlizzABS::Processor
#----------------------------------------------------------------------------
# This class provides methods for Blizz-ABS handling.
#============================================================================
class Processor
#--------------------------------------------------------------------------
# update
# Updates Blizz-ABS processes.
#--------------------------------------------------------------------------
alias update_touchd_before update
def update
update_touchd_before
update_touch_damage
end
#--------------------------------------------------------------------------
# update_touch_damage
# Updates Blizz-ABS update_touch_damage.
#--------------------------------------------------------------------------
def update_touch_damage
# iterate through all actors
($BlizzABS.actors + $BlizzABS.pets).each {|actor|
# iterate through all battlers
if actor.valid?
($game_map.battlers + $BlizzABS.battlers).each {|battler|
# if target can be hit considering all conditions
if battler.battler != nil &&
!battler.battler.is_a?(Game_Actor) &&
!battler.battler.dead? && @utils.intersection(
Rect.new(actor.real_x / 4, actor.real_y / 4, 32, 32),
Rect.new(battler.real_x / 4, battler.real_y / 4, 32, 32))
# execute attack
actor.touch_effect(battler, battler.battler)
end}
end}
end
end
end
#==============================================================================
# ** Game_Battler (part 3)
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Applying Normal Attack Effects
# attacker : battler
#--------------------------------------------------------------------------
def touch_effect(attacker)
self.critical = false
touchdata = BlizzABS::Enemies.touch_damage(attacker.id)
return false if touchdata[0] == 0
if touchdata[1] > 0
self.damage = [touchdata[0]+rand(touchdata[1])-rand(touchdata[1]), 0].max
end
if self.damage != 0
# State Removed by Shock
remove_states_shock
# Substract damage from HP
self.hp -= self.damage
# State change
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
states_plus(touchdata[2]) if touchdata[2]
return true
end
return false
end
end
#==============================================================================
# Map_Actor
#------------------------------------------------------------------------------
# This class handles a map enemy character. It supports pixel movement,
# complete AI handling, advanced sprite handling and battle handling.
#==============================================================================
class Map_Actor < Map_Battler
#----------------------------------------------------------------------------
# touch_effect
# character - the character that holds attack data (can be projectile)
# _battler - the attacking battler
# This method executes attack upon a map character.
#----------------------------------------------------------------------------
def touch_effect(character, _battler)
# stop attack if no battler assigned or still invincible
return false if @battler == nil || @blinking != nil && @blinking > 0
# stop attack if pressing CTRL in debug mode
return false if $DEBUG && @ai.group != 0 && Input.press?(Input::CTRL)
# if defending
if BlizzABS::Config::FULL_DEFEND && @ai.act.defend?
# set attacked counter
self.attacked = $BlizzABS.pixel
# request damage sprite
$BlizzABS.utils.request_damage_sprite(self, BlizzABS::Cache::TXTDefend)
# not executed
return false
end
# needed for defend emulation
@battler.current_action.kind = 0
# set own battler's action as defend action if necessary
@battler.current_action.basic = (@ai.act.defend? ? 1 : 0)
# reset hpdamage and spdamage
@battler.hpdamage, @battler.spdamage = 0, 0
# State Removed by Shock
result = @battler.touch_effect(_battler)
if result
# apply basic effects
apply_action_effect(_battler)
# request damage sprite
$BlizzABS.utils.request_damage_sprite(self)
# remove damage
@battler.damage, @battler.damage_pop = nil, false
end
# send data to obeserver if attacked by actor
$BlizzABS.AI.observe(_battler, @battler.damage) if _battler.is_a?(Game_Actor)
# delete own charge data if executed
@charge = nil if result
# return result
return result
end
end
Instructionsconfigure in the code under the enemies module
Compatibilityshouldn't have any problems at all
Credits and Thanks
Author's NotesHave fun with it.