Main Menu

[SOLVED] Yanfly Engine Melody and requiring target states

Started by The Mormegil, August 26, 2010, 02:27:22 PM

0 Members and 1 Guest are viewing this topic.

The Mormegil

I encountered a problem creating skills with Yanfly's Engine Melody. The problem is that I want to make a skill that require certain states to be upon the target in order to be used. The script allows me to require states on the user, but I found no way to requiring statuses on the target.

The skill I want to create is "Backstab", and I want it to check, once initiated, if the target is afflicted by statuses 6,8,10..16,21 or 30 (using IDs from my game). If any of these states is on the target, the skill works and deals great damage. If there are none of these states the player just wasted a turn.

The only way I can think of to accomplish this with the YEM scripts is by making three skills: "Backstab", to be used by the player, that just moves him foward and forces the target to use "Check Backstab", a skill with the <require any state: 6,8,10..16,21,30> tag that goes back and forces the player to use "Backstab!" that actually deals damage.  ??? This is just overcomplicated, and uses up three skill slots to make one attack. I was wondering if anyone could find a better way to do this, either using YEM's functions, creating new YEM "melodies" or scripting a compatible script (I don't think that's strictly required but I may be wrong).

Anyone can help me?  :-\

Terra-chan

Can't you just have the skill call a common event that does all of the checking before accomplishing the skill in one skill? I'm not really experienced in that area yet though.

I think wasting the turn is pretty lame, you should at least do normal damage imo, but that's my opinion :P


~My Projects~

~ VocaloidVX ~ Second Life Project ~
~ RPG Maker Collective ~
To support this forum, it's the first place that will gets posted some updates of mine, check it out ^_~

The Mormegil

I could, if I knew how to script well enough. But I don't know how to check enemies' statuses. If I did, I could use the IF melody function to check it, then proceed.


In fact, I tried to make a new target option (target: Backstab) that checked for the status, but well, it didn't. Here's what I tried, if anyone is intrested...

when "BACKSTAB"
   target = opponents_unit.smooth_target(@target_index)
   if target.states.include?(6||8||10||11||12||13||14||15||16||21||30)
      targets.push(target)
   end


It works... to a point. It lets me choose the target (so the first line is good. Well, that's copied and pasted from another target option so yeah), then when it needs to add it to the targets array it does not. It doesn't report errors though, so I'm a bit confused.

The Mormegil

Also, since enemy statuses are displayed on help window and Backstab has NO cost whatsoever, if the player doesn't check to see if the status is altered it's his fault and wasting a turn seems appropriate... Otherwise it would have been easier to just add it to actor's normal attack as a damage boost, right?

Shinami

Within conditional branches(event command) on page 3, you can check to see if an enemy has been inflicted with a status condition, if you feel like using common events for backstab.


When debugging scripts, it's best to get a look at the information being handled. Do you know what information "target" holds? Do you know how "targets" gets used in deciding what gets hit? That's why you use the "p" command to print out the contents of things or script your own method that dumps information into text files for you to look at while the game is running in test mode.

The Mormegil

Shinami, THANK YOU. The tip on the p function was really helpful (I didn't know, or rather, didn't realize it could be used mid-game). I tried a couple things and even if what I wrote isn't the best of solutions it gets the job done! Thank you again, and I mean it!

(If anyone is intrested, what I wrote is this:

when "BACKSTAB"
  target = opponents_unit.smooth_target(@target_index)    # to select the target
  backstab_check = false
  for key in target.state_turns.keys
    if key == 6
         backstab_check = true
      elsif key == 8
         backstab_check = true
      elsif key == 10
         backstab_check = true
      elsif key == 11
         backstab_check = true
      elsif key == 12
         backstab_check = true
      elsif key == 13
         backstab_check = true
      elsif key == 14
         backstab_check = true
      elsif key == 15
         backstab_check = true
      elsif key == 16
         backstab_check = true
      elsif key == 21
         backstab_check = true
      elsif key == 30
         backstab_check = true
     end
    end
    if backstab_check
       targets.push(target)
    end
)

Shinami

There should be a better way you can write that check with the any? method from Enumerable.


  target = opponents_unit.smooth_target(@target_index)    # to select the target
  backstab_check = false
  for key in target.state_turns.keys
    backstab_check = [6,8,10,11,12,13,14,15,16,21,30].any? {|v| v == key}
  end
  if backstab_check
    targets.push(target)
  end

any? is a method from the module Enumerable. any? will evaluate if target.state_turns.keys matches any of the specified values(hence "v" being used) and will return TRUE if any of them match. If none of them match, it'll return FALSE.

It's my first time using a built in module so if what I wrote above doesn't work, you can reference this example.

Returns FALSE when all items are false. If any item is true, immediately returns TRUE.

When using a block, evaluates the block against each item and returns FALSE if all outcomes are false.
If the block returns TRUE at any time, immediately returns TRUE.

Shinami: FYI, "block" refers to the [1,2,3] being checked since it's a "block" of data. I think. >.>
p [1,2,3].any? {|v| v > 3}   # => false
p [1,2,3].any? {|v| v > 1}   # => true



The Mormegil