[ACE] Issues with an Enemy Reactions Snippet

Ultima01

Unhinged
Veteran
Joined
Mar 13, 2013
Messages
68
Reaction score
11
First Language
English
Primarily Uses
N/A
I've been having problems with this script snippet I devised for a friend.  Said friend wanted enemies to react to getting hit with specific elements, but only if they dealt damage.  So I came up with the idea of making them react to a switch that's thrown in response to a spell dealing damage.

I've tested it, and found that the snippet nulls instead the damage outright.  Can someone help me figure out what's wrong?

 

class Game_Battler < Game_BattlerBase  def no_damage?(a, b, base_dmg, atk_mod, def_mod, switch_id)    c = ( base_dmg + ( a.atk * atk_mod ) - ( b.def * def_mod ) )    if c > 0      $game_switches[switch_id] == 1      return c    else      return 0    end  endendScript call in damage formula: 

Code:
c = no_damage(a, b, int, int, int, int); c
 

Ultima01

Unhinged
Veteran
Joined
Mar 13, 2013
Messages
68
Reaction score
11
First Language
English
Primarily Uses
N/A

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
21,991
Reaction score
11,293
First Language
English
Primarily Uses
RMVXA
CtelinAjira, please do not bump your topic unless it has been 72 hours later since your last post. You can review our forum rules here. Thank you.

Not only do you have to take into account differing time zones, different work/leisure schedules and the fact that everyone answering here is doing it in their free time and have other commitments as well, today is also the last day of IGMC and a lot of people are having to focus on that.  The 72 hour buffer is there for a good reason.
 

Funplayer

Self proclaimed sponge.
Veteran
Joined
Oct 9, 2013
Messages
120
Reaction score
34
First Language
English
Primarily Uses
I'm pretty sure the $game_switches[id] returns a true/false.

$game_switches[switch_id] == 1 this line would then do absolutely nothing, and in Ruby, quite possibly return the nothing.  If you said, $game_switches[switch_id] = 1, you would still be doing it wrong I think.

$game_switches[switch_id] = true, would be correct.
 
Last edited by a moderator:

Ultima01

Unhinged
Veteran
Joined
Mar 13, 2013
Messages
68
Reaction score
11
First Language
English
Primarily Uses
N/A
I'm pretty sure the $game_switches[id] returns a true/false.

$game_switches[switch_id] == 1 this line would then do absolutely nothing, and in Ruby, quite possibly return the nothing.  If you said, $game_switches[switch_id] = 1, you would still be doing it wrong I think.

$game_switches[switch_id] = true, would be correct.
I've made these changes, and it still doesn't do everything just right.  It's still nulling the damage.

Code:
class Game_Battler < Game_BattlerBase  def no_damage?(a, b, base_dmg, atk_mod, def_mod, switch_id)    c = ( base_dmg + ( a.atk * atk_mod ) - ( b.def * def_mod ) )    if c > 0      $game_switches[switch_id] = true      return c    else      return 0    end  endend
 

Xypher

Veteran
Veteran
Joined
Apr 1, 2012
Messages
148
Reaction score
26
Primarily Uses
try 

Code:
c = a.no_damage?(a, b, int, int, int, int); c
 
Last edited by a moderator:

Ultima01

Unhinged
Veteran
Joined
Mar 13, 2013
Messages
68
Reaction score
11
First Language
English
Primarily Uses
N/A
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
157
First Language
Serbian
Primarily Uses
N/A
I should suppose you changed those 'int' to some value, right?
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,136
Reaction score
810
First Language
Hungarian
Primarily Uses
RMVXA
Add a 'p c' line above the 'if c > 0' line (without the apostrophes).


Observe your console when you use a skill, it will print out the result of your formula.


If that formula is 0 or lower (and it most probably is), than your formula returns a lower value than you expect, which is possible if the enemy's DEF is high, and/or if the actor's ATT is too low, depending on the modifiers you use.


But if you simply write this into the damage box (random arguments):

no_damage?(a, b, 100, 1.5, 1.2, 888)It will not run, because the damage formula itself is run on the RPG::UsableItem::Damage instance, and NOT on the battler. But that class got no 'no_damage?' method defined, so it returns 0 with a rescue instead of crashing. You can test this with the 'p c' line I mentioned above. The console will not print anything when you use the skill in this case.
But if you write this:

a.no_damage?(a, b, 100, 1.5, 1.2, 888)Now, this will be run on Game_Battler, so it will not fail, but it can still return a value lower than 0. You will see the result of the damage formula printed out in this case, because the method has been executed.
Also you don't need to write the 'c = formula; c' thing. You method returns a number already, so no need to store and return that number again.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

What are your experience on trying to boost a MV project on an Android 7+ phone to a constant 60 fps? It's very hard for me(mine is 720x1440 px with Octa-core 1.8 GHz Cortex-A53 and Adreno 506), especially with an ATB system plugin. The best minimum I can get is 30+ fps :)
MZ Spoiler Thread: Blah, blah, blah, blah...
Me: :kaoslp:
Mog: Star Ocean Battle system!
Me:
:MV1:
Hosting a private game jam...might have smthng to post soon if I can fix these dang parallaxes.
Oof it's been a while...well I'm back to stay!

Forum statistics

Threads
99,245
Messages
963,370
Members
130,828
Latest member
kimtan2021
Top