Custom formula ".force_action (x,y)"

MoloMowChow

Villager
Member
Joined
Jun 27, 2014
Messages
6
Reaction score
2
First Language
English
Primarily Uses
I'm trying to make a skill work in a certain manner using the Formula box in the skill Database. I want to make the character attack and deal damage based on a formula, and then follow it up with a skill depending on a condition.

First however, I simply wanted to see if I can have the character deal damage based on a flat number, and then follow up with a existing skill. The formula is exactly as such in the skill formula box:

200; a.force_action(32, -2)This is on a physical attack skill that does HP Damage with Normal Attack element. What SHOULD happen is that I deal flat 200 (or around that much) damage, and then follow-up with Skill 32 on the same enemy I targeted.

The problem is that the 200 damage deals 0 damage for some reason. But the follow-up forced action works just fine, which is another physical attack skill that deals HP damage and adds a ATK Debuff.

I tried replacing the 200 damage with a damage equation and got the same result. I am sure my enemies do no have the defence to negate 200 flat damage normally.

To make sure it wasn't because of modified scripts, I made a fresh Ace project, and all I did was recreate this skill but making the skill id 85 to make Eric do a Tackle after 200 damage. I tested against slimes modified to have 1000 HP. This time Eric once again did "No Damage", but also did not even attempt to follow up with tackle.

Anyone have an idea as to what is causing this behaviour?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
The problem is that the 200 damage deals 0 damage for some reason. But the follow-up forced action works just fine,
The damage is always the last number calculated in the damage formula.
Code:
a.force_action(32, -2);200
should work fine if the force action command is the correct one (that I can't tell)
 

MoloMowChow

Villager
Member
Joined
Jun 27, 2014
Messages
6
Reaction score
2
First Language
English
Primarily Uses
Thanks for the clarification Andar, that explains it. I was surprised despite the force action coming first in the forumla, my battler still performed the force action last, and did the 200 damage attack first. I guess that's just how it works.

Following this I continued my skill creation by attempting to add conditions to force actions, such as state checks or random chance. After a few crashes I ended up trying this:

if b.state?(3); a.force_action(133, -2);end;200Which checks if the target is inflicted with Blind. If they aren't, the flat 200 damage is all that happens. If they are blinded, than 200 damage is done followed by the force action.

The check for blind seems to work. However the one problem is that the following force action aims at the other enemy from time to time (the 200 damage attack is on blinded SlimeB, but the following force action attack is used on non-blinded SlimeA), which leads me to believe that the -2 "last target" index isn't working as it should at the moment.
 
Last edited by a moderator:

MoloMowChow

Villager
Member
Joined
Jun 27, 2014
Messages
6
Reaction score
2
First Language
English
Primarily Uses
Thanks for the link Andar. I saw that info in a different forum, but this time I actually visited Fomar0153's blog and got more info on formula scripting.

Some further testing with .force_action(x,y) I observed a few things. As some may know the "x" in the brackets represent skill id, and the "y" represents target index, with -2 being the "last target selected" and -1 means a random target.

However, it seems the -2 index doesn't always select the proper enemy the user targeted, and consistently sticks to the first enemy attacked with the skill until death. For example, I start the battle against SlimeA and SlimeB. First turn I use the skill on SlimeB, deal the initial 200 damage, and then the force action activates on the same SlimeB. However, next turn I would attack with the same skill on SlimeA, but the force action will still activate on SlimeB. Attacking SlimeA with the same skill repeatedly consistently makes the force action activate on SlimeB, which was the first target. Attacking SlimeB again with the skill makes no difference. If SlimeB dies, then the force action can start activating on SlimeA. It seems using -2 as the index is not behaving the way I'm expecting it. I couldn't find much info .force_action(x,y)'s behaviour via google either (although I did find other, interesting formula info).

Additionally, I attempted creating a custom formula script to see if it made any different too.

This is probably ruby scripting related info now, but I attempted to further customize my skill creation by creating a small script. The script is as such:

class Game_Battler < Game_BattlerBase  def arcane_blade(a,        if b.state?(3)      return a.force_action(51,-2)    else if b.state?(4)      return a.force_action(55,-2)    else      return 0;    end  endendThen I would type in the skills' formula box:

a.arcane_blade(a,;200In a nutshell, if an enemy is in "Blind" (state3) the user will cast "Fire" magic after the initial 200 dmg attack. If the enemy is inflicted with "Silence" (state4) the user will cast "Ice" magic instead after the initial 200 dmg attack. Neither state means the character will simply do 200 dmg attack and nothing else. Force_action() still exhibits the same behaviour as before, locking onto the same first target on index -2.
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
So it is ignoring this turn's target, locking onto the latest target of the previous turn? of if you use another technique on Slime 1 first the same happens?

What happens if instead of a number you use b?
 
Last edited by a moderator:

MoloMowChow

Villager
Member
Joined
Jun 27, 2014
Messages
6
Reaction score
2
First Language
English
Primarily Uses
Thanks to the help from Demintika from another forum I was able to solve the problem I was having.

#--------------------------------------------------------------------------# * Invoke Skill/Item#--------------------------------------------------------------------------def invoke_item(target, item) if rand < target.item_cnt(@subject, item) invoke_counter_attack(target, item) elsif rand < target.item_mrf(@subject, item) invoke_magic_reflection(target, item) else apply_item_effects(apply_substitute(target, item), item) end @subject.last_target_index = target.indexendAs you can see in line 587 of Scene_Battle, the last_target_index is only saved after the item effect.

Here is the full "sequence"

For each enemy, does a loop: repeats.times {invoke_item}; apply_item_effects runs target.item_apply(user, item) that runs everything from damage, skill cost, trait, etc... 

then save the last target index before go to next loop, then next target.

Example: Skill X target 2 Slime A and B; repeats 3 times

last_target_index was 3 (for example) before skill, then:

3, (apply to A), 1, (apply to A), 1, (apply to A), 1, (apply to B ), 2,(apply to B ), 2,(apply to B ), 2

(assumes A's index is 1 and B's index is 2)

For short, you just need to alias and move @subject.last_target_index = target.index to the top of invoke_item

class Scene_Battle alias rearrange_invoke_item invoke_item def invoke_item @subject.last_target_index = target.index rearrange_invoke_item endend
After adding the suggested code to my project I am able to have the follow-up skill successful activate on the proper target consistently.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,570
Latest member
fgfhdfg
Top