[Ace] Help setting up a few skills with Yanfly's Lunatic Objects

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Hey! :kaohi:

I'm hoping someone with a little bit of scripting knowledge could help me creating a few different skill effects with the help of Yanfly's Lunatic Objects script. I don't really know much of anything about scripting, but from what I can tell, I think all of these should be possible. Although, let me know if otherwise.

1. A skill that checks if the enemy has one of three states, and if they do, write a value to a variable BEFORE the skill damage is calculated.
2. Simularly, a skill that checks if the user has one of a few states, and if not, the skill fails.
3. A skill that checks both if the attacker is a certain actor, and if the target is weak (over 100% elemental damage) to the skill's element, and if so, inflict them with a state.
4. A skill that, after the damage is delt, checks if the target has been killed. If so, than give the user a state. If not, kill the user.
5. A skill that uses the target's higher attack stat (ATK or MAT) against their lower defense stat (DEF or MDF).

I hope these all makes some sense. By all means, let me know if you'd like me to try and explain it better.

Thank you! :kaothx:
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
Here's a quick one for your #5 skill:
Code:
[a.atk,a.mat].max - [b.def,b.mdf].min
The first part selects the higher attack stat, the second part selects the lower defense stat. You can add in any other modifications if needed.
This doesn't require any custom scripts, just use it in your damage formulas.

Kinda sleepy now, so I will pass the rest for another time. :p
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Awesome, thanks a ton! I'll be sure to test it in the morning, and let you know if all goes well. :kaohi:
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
This should sort the other ones; let me know if you have any issues:
Code:
if $imported["YEA-LunaticObjects"]
class Scene_Battle < Scene_Base

  alias amn_scenebattle_lunaticobjext lunatic_object_extension
  def lunatic_object_extension(effect, item, user, target, line_number)
    case effect.upcase
    #----------------------------------------------------------------------
    # A skill that checks if the enemy has one of three states, and if
    # they do, write a value to a variable BEFORE the skill damage is
    # calculated
    #
    # Recommended notetag:
    #   <prepare effect: var states x>  where x is the ID of the variable
    #----------------------------------------------------------------------
    when /VAR\s*STATES\s*(\d+)/i
      if [1, 2, 3].any?{|s| target.states.include?($data_states[s]) }
      #^alter the array to include as many state IDs as you want
        $game_variables[$1] += 1
      end
    #----------------------------------------------------------------------
    # A skill that, after the damage is delt, checks if the target has been
    # killed. If so, than give the user a state. If not, kill the user.
    #
    # Recommended notetag:
    #   <during effect: kamikaze x>   where x is the ID of the state
    #----------------------------------------------------------------------
    when /KAMIKAZE\s*(\d+)\s*/i
      if target.hp == 0
        user.add_state($1.to_i)
      else
        user.hp = 0
        user.perform_collapse_effect
      end
    #----------------------------------------------------------------------
    # A skill that checks both if the attacker is a certain actor, and if
    # the target is weak (over 100% elemental damage) to the skill's element,
    # and if so, inflict them with a state
    #
    # Recommended notetag:
    #   <prepare effect: user element x y>  where x is the ID of the actor
    #   and y is the ID of the state
    #----------------------------------------------------------------------
    when /USER\s*ELEMENT\s*(\d+)\s+(\d+)/i
      if user == $data_actors[$1.to_i] && target.element_rate(item.damage.element_id) < 1.0
        target.add_state($2.to_i)
      end
    else
      amn_scenebattle_lunaticobjext(effect, item, user, target, line_number)
    end
  end
end

class Game_Battler < Game_BattlerBase
  alias amn_userstate_scenebattle_itemapply item_apply
  def item_apply(user, item)
    #----------------------------------------------------------------------
    # A skill that checks if the user has one of a few states, and if not,
    # the skill fails
    #
    # Recommended notetag:
    #   <prepare effect: user states>
    #----------------------------------------------------------------------
    if !item.prepare_effects.select{ |p| p.match(/USER\s*STATES\s*/i)}.empty? &&
      ![1, 2, 3].any?{|s| user.states.include?($data_states[s]) }
      #^alter the array to include as many state IDs as you want
      @result.clear
      @result.used = item_test(user, item)
      @result.missed = true
    else
      amn_userstate_scenebattle_itemapply(user, item)
    end
  end
end
end
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
They all seem to work great! Thank you both so much! :kaothx:
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Hey @A-Moonless-Night . I've had the chance to do a bit more thorough testing, and seem to run into a few bugs, I hope you don't mind. :kaoswt:

In order:
<prepare effect: var states x>
I've found that if the enemy doesn't have one of the states listed, it works just fine. But when an enemy does have a state (and as such, it tries to write to a variable), I get a crash from Game_Variable, line 19.

<during effect: kamikaze x>
This one's kinda ironic. On a blank project, it works like a charm! But ironically, it conflicts with the Blue Magic Sight add on you helped me with a couple of days ago. :kaoback:It crashes if the user does not kill the target. (Line 41 in the blue magic sight script [item = @subject.current_action.item ])This seems to happen no matter which I have above the other.

<prepare effect: user element x y>
I figured I was just doing something wrong, but I haven't get this one to work at all. No crashes or anything, but nothing seems to happen. I'll keep testing around with it though.

<prepare effect: user states>
This one works just fine, no issues here! :kaopride: As a side note, would having a skill failed message appear be a pretty easy addition?
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
1. Does it say what the error is? I don't have time to test thoroughly, but try changing line 18 to be $game_variables[$1.to_i]

2. Should be an easy enough fix. In the Blue Mage addon, add this line:
Code:
return unless @subject.current_action
just above
Code:
item = @subject.current_action.item
3. Simple error: change $data_actors to $game_actors and it should work.

4. Yay, glad that one is working well. Do you not get the 'there was no effect on x' message when it fails? Should be easy enough to add another message.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Alrighty, I tested out each of the fixes. 2-4 now work perfectly. (As a side note, I found that number 3 was adding the state to enemies with less than 100% damage instead, but that was an easy fix by changing < to >.)

The only one that's still giving me issues is number 1. Your solution did stop it from crashing, although it doesn't seem to do anything now.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
Sorry, your original post said 'over 100% elemental damage', so I just went off that. Easy fix, though. :)

Number one works fine for me. Replace that section with this:
Code:
    when /VAR\s*STATES\s*(\d+)/i
      p(target.states)
      if [1, 2, 3].any?{|s| target.states.include?($data_states[s]) }
      #^alter the array to include as many state IDs as you want
        $game_variables[$1.to_i] += 1
        p($game_variables[$1.to_i])
      end
Make sure you have the console running. It'll print the target's states to the console each time the skill is used, and then print the value of the variable if the target has any of the states you've put in. It should help with debugging.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Works great now! :kaopride:

Guess I messed something up when making the changes, but your copy works great! Thank you so much!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,845
Messages
1,016,961
Members
137,561
Latest member
JaCrispy85
Top