Chaos Project

RPG Maker => General Discussion => Troubleshooting / Help => Topic started by: Shek on November 27, 2013, 02:11:49 am

Title: [Resolved] How to check if you've just attacked something
Post by: Shek on November 27, 2013, 02:11:49 am
Thanks so much KK for resolving this issue:

What this does:
Checks to see if you've hit an enemy with X character using a regular attack -> Performs an action (e.g. Call common event, change variable etc)

and

Checks to see if you've hit an enemy with X character using Y skill -> Performs an action (e.g. Call common event, change variable etc)


Original Post:

I'd like to set up a rage building system, I can't seem to figure out how to check with Blizz Abs if you've just attacked an enemy.  

What I am looking for:
Within a parallel common event:
Script/command to check if you've just attacked an enemy THEN IF TRUE -> perform a common event/or change a variable/switch
(Not any specific enemy, I just want you to build rage as you hit enemies, then you can expend rage to use special attacks)

But I have no idea how to check if you're hitting an enemy or not, it's gotta be simple; I'm just clueless.
Title: Re: Question: How to check if you've just attacked something
Post by: KK20 on November 28, 2013, 01:22:40 pm
This can apply to more than just BlizzABS:

class Game_Battler
 alias atk_ef attack_effect
 def attack_effect(attacker)
   result = atk_ef(attacker)
   if result && self.is_a?(Game_Enemy) && attacker.is_a?(Game_Actor)
     case attacker.id
     # DO WHAT YOU WANT HERE
     when 1 # Aluxes
       
     when 2 # Basil
       
       #etc....
     end
   end
   return result
 end
 
 alias skill_ef skill_effect
 def skill_effect(user, skill)
   result = skill_ef(user, skill)
   if result && self.is_a?(Game_Enemy) && user.is_a?(Game_Actor)
     case user.id
     # DO WHAT YOU WANT HERE
     when 1 # Aluxes
       
     when 2 # Basil
       
       #etc....
     end
   end
   return result
 end
end
Title: Re: Question: How to check if you've just attacked something
Post by: Shek on December 01, 2013, 11:02:26 am
Splendid.  This is exactly what I was looking for!

Is there a quick way to make it so that the skills version also can differentiate between Skill.id?

+1
Title: Re: [Resolved] How to check if you've just attacked something
Post by: KK20 on December 01, 2013, 02:16:08 pm
Directly below the when ID's, you do this:

      case user.id
      # DO WHAT YOU WANT HERE
      when 1 # Aluxes
        case skill.id
        when 1 # Heal
          # DO SOMETHING
        when 2 # Greater Heal
          # DO SOMETHING
        end
      when 2 # Basil
        case skill.id
        # You know what to do now...
        end
        #etc....
      end
Title: Re: [Resolved] How to check if you've just attacked something
Post by: Shek on December 01, 2013, 02:26:15 pm
Thanks again sir! I will definitely put you in the credits of my game.  You have helped so much!

+1