Author Topic: [XP] Touch Damage for Blizz-ABS  (Read 14210 times)

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
[XP] Touch Damage for Blizz-ABS
« on: February 15, 2009, 12:46:52 AM »
Touch Damage for Blizz-ABS
Authors: winkio
Version: 1.11
Type: Misc Add-on
Key Term: Blizz-ABS Plugin

Introduction

When 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.

Screenshots
no.  if you have ever played zelda or any game really, it's the same thing.


Script

Put below Blizz-ABS part 3, above main

Code: [Select]
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
# 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

Instructions

configure in the code under the enemies module

Compatibility

shouldn't have any problems at all

Credits and Thanks

  • Blizzard's ABS
  • winkio

Author's Notes
Have fun with it.
« Last Edit: December 29, 2010, 02:35:35 AM by game_guy »

Offline shdwlink1993

  • Ethereal Devastator
  • ****
  • Posts: 435
  • LV: 63
  • Gender: Male
    • View Profile
    • YouTube Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #1 on: February 15, 2009, 12:50:21 AM »
It would be databased except that "<TELL US SOMETHING ABOUT YOUR SCRIPT>" isn't what you'd call an introduction to your script.
Stuff I've made:

(click to show/hide)

"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #2 on: February 15, 2009, 12:51:54 AM »
XD I was in a hurry.

Offline shdwlink1993

  • Ethereal Devastator
  • ****
  • Posts: 435
  • LV: 63
  • Gender: Male
    • View Profile
    • YouTube Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #3 on: February 15, 2009, 01:00:21 AM »
lol. Thanks for taking the time to do that, Winkio. Happily databased.
Stuff I've made:

(click to show/hide)

"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #4 on: February 15, 2009, 01:03:19 AM »
This is a good add-on...

Offline legacyblade

  • Pretzel Man
  • Moderator
  • Chaos User
  • ***
  • Posts: 1838
  • LV: 84
  • Gender: Male
  • There is a fate worse than hell
    • View Profile
    • SpencerConrad.com
Re: [XP] Touch Damage for Blizz-ABS
« Reply #5 on: February 15, 2009, 01:11:55 AM »
Great script Winkio, I already have a use for this in my game!

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #6 on: February 15, 2009, 01:29:16 AM »
Now can you add events to this!?
Can you make special events take place instead of damage??

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #7 on: February 15, 2009, 01:33:40 AM »
it is possible, but I'm not scripting it in.  What you would do is change this line:

actor.touch_effect(battler, battler.battler)

to execute whatever event you want.  I assume you plan to do this for the zombie game?

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6585
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #8 on: February 15, 2009, 02:02:18 AM »
this is cool. power up

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #9 on: February 15, 2009, 02:08:52 AM »
Yes, I do...
Does the BABS system nullify the event codes of enemies?

Offline Reno-s--Joker

  • Astral Trancist
  • *****
  • Posts: 674
  • LV: 34
  • Gender: Female
  • Zombie account.
    • View Profile
    • My DeviantART
Re: [XP] Touch Damage for Blizz-ABS
« Reply #10 on: February 16, 2009, 06:21:23 AM »
*powers up*
This'd be really useful for those classic games where monsters seem to have spikes or poison or something all over them. :D
<333

Offline Memor-X

  • Ethereal Devastator
  • ****
  • Posts: 428
  • LV: 8
  • Gender: Male
  • "The Otherworld Awaits you"
    • View Profile
    • MHO Ultra Mega
Re: [XP] Touch Damage for Blizz-ABS
« Reply #11 on: February 25, 2009, 12:31:35 AM »
when i run into a enemy i get an error

Script 'Touch Damage for Blizz-ABS 1.0' line 103: TypeError occurred

nil can't be coerced into Fixnum

and on that line i have

      self.hp -= self.damage

and incase if it matters, i'm using SDK version 1.5

Trish: hay Angela, you should take the role, you always wanted to be an actress
Angela: yeh but what about you
Trish: i'll become one too
Angela: what? but about you being a Doll Turner
Trish: first, i'm 500 years old in a 19 year old body, i deserve a rank higher than other tuners, like Miester or something, second, i want to help you since you mean a lot to me
Angela: *imagine kissing scene between them and blushes* thank you
Trish: why are you going red? you should know i can only fix Dolls, not humans

Offline Landith

  • Astral Trancist
  • *****
  • Posts: 947
  • LV: 59
  • Gender: Male
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #12 on: February 25, 2009, 01:08:35 AM »
Yeah it's probably the SDK System messing with it. SDK tends to do that  :roll:
Unless you don't have this script below BABS

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #13 on: February 25, 2009, 01:51:08 AM »
There is definitely a conflict with one of your other scripts.  SDK I guess.  Or if you have anything else that drastically modifies game_battler...

Offline Memor-X

  • Ethereal Devastator
  • ****
  • Posts: 428
  • LV: 8
  • Gender: Male
  • "The Otherworld Awaits you"
    • View Profile
    • MHO Ultra Mega
Re: [XP] Touch Damage for Blizz-ABS
« Reply #14 on: February 26, 2009, 12:44:27 AM »
There is definitely a conflict with one of your other scripts.  SDK I guess.  Or if you have anything else that drastically modifies game_battler...

well there's Tons but i doubt it, i havn't turned on any addons yet, if only i had an Al Bhed Script like Seph's i wouldn't need the bloody SDK

Trish: hay Angela, you should take the role, you always wanted to be an actress
Angela: yeh but what about you
Trish: i'll become one too
Angela: what? but about you being a Doll Turner
Trish: first, i'm 500 years old in a 19 year old body, i deserve a rank higher than other tuners, like Miester or something, second, i want to help you since you mean a lot to me
Angela: *imagine kissing scene between them and blushes* thank you
Trish: why are you going red? you should know i can only fix Dolls, not humans

Offline Landith

  • Astral Trancist
  • *****
  • Posts: 947
  • LV: 59
  • Gender: Male
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #15 on: March 07, 2009, 04:35:53 AM »
Is there a way to make it do a skill instead of a damage?

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #16 on: March 07, 2009, 05:13:24 AM »
if you mod this script.  That would be a totally different script though.  I am only duplicating the basic touch damage that we all know.  I might add states later, but thats about it.

Offline Landith

  • Astral Trancist
  • *****
  • Posts: 947
  • LV: 59
  • Gender: Male
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #17 on: March 07, 2009, 10:45:57 PM »
Yeah, that's the main reason why I wanted the skills because of States.  :P

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #18 on: March 08, 2009, 05:26:44 AM »
once Blizz eventually updates when enemies can execute their code, youll be able to event whatever you want.  I'll add states in when I get some time, just wait.

EDIT: lol, hooray for adding one line of code and changing the config!  v1.10: states.
« Last Edit: March 08, 2009, 05:59:41 AM by winkio »

Offline Landith

  • Astral Trancist
  • *****
  • Posts: 947
  • LV: 59
  • Gender: Male
    • View Profile
Re: [XP] Touch Damage for Blizz-ABS
« Reply #19 on: March 09, 2009, 11:11:21 PM »
Thanks Winkio <3

*Powers Up*