Enemy uses skill despite condition becoming unappliable during the turn

Status
Not open for further replies.

t1slam

Villager
Member
Joined
Jan 13, 2020
Messages
6
Reaction score
3
First Language
russian
Primarily Uses
RMVX
I am trying to create a mechanic where enemy has to prepare itself in two steps before making powerful attack, while player being able to stop him by dealing damage during the preparation phase.

It works like that:
1. If enemy has no 'weapon prepared' and 'aiming' states enemy uses skill "prepare weapon", gaining state 'weapon prepared'.
2. if enemy has 'weapon prepared' state he then uses skill 'aim', gaining 'aiming' state.
3. if enemy has 'aiming' state he uses skill 'throw axe', losing both 'aiming' and 'weapon prepared' states.

Gaining states at first was a problem to make (inputing a.set_state(n) in formula didn't work for some reason), but Formula Effects script allowed me to do so, so that part seemingly working fine.

I made both 'weapon prepared' and 'aiming' states removable at receiving any type of damage (100%), and it seems to work - the message of falling out of state is displaying upon taking damage.

The problem is that enemy still proceeds with next step after falling out of state, required for the skill!
The steps here are:
1. Enemy uses skill 'prepare weapon', gaining state 'weapon prepared' at TURN ONE.
2. TURN ONE ends.
3. On start of the TURN TWO player character attacks enemy, who by receiving damage loses state 'weapon prepared', which is indicated by appeared message.
4. On the enemy action of TURN TWO enemy uses skill 'aim', despite having lost state 'weapon prepared', receiving 'aiming' state.
5. TURN TWO ends.

The same thing then happens with 'aiming' and then enemy successfully throws axe despite losing both intended states for skill's condition.

As i understand the enemy decides what action to take before the turn starts and then he commits the action despite if conditions are made unappliable during the same turn?

If so, and in any other case, i searched the web for similar issues but didn't find any and i'm having trouble with coming up with any type of workaround myself, so could anyone help me with the solution here?

Thank you in advance!
 
Last edited:
Joined
Oct 15, 2015
Messages
95
Reaction score
130
First Language
English
Primarily Uses
RMMV
A possibility to try is make the prepare and aiming skill have a VERY high speed so that he acts first when using those skills (that's how Guard works). As far as I know there is no way of canceling an enemy's decided move without a script.

edit: OR instead of adding the next state have the skill go to a common event with
if enemy has "prepare state"
then add "aiming state"

and have a dummy throw axe skill that goes to common event with
if enemy has "aiming state"
force action "real throw axe skill"
 
Last edited:

t1slam

Villager
Member
Joined
Jan 13, 2020
Messages
6
Reaction score
3
First Language
russian
Primarily Uses
RMVX
A possibility to try is make the prepare and aiming skill have a VERY high speed so that he acts first when using those skills (that's how Guard works). As far as I know there is no way of canceling an enemy's decided move without a script.
Thank you, that workaround can be useful and about the script - are there any known existing scripts for that or some kind of clues where to look for them?
 
Joined
Oct 15, 2015
Messages
95
Reaction score
130
First Language
English
Primarily Uses
RMMV
I don't normally use vx so I don't know the scripts, all I can offer is try google. I also edited with another option, but you ninja'd me so I don't know if you saw it. good luck.
 

t1slam

Villager
Member
Joined
Jan 13, 2020
Messages
6
Reaction score
3
First Language
russian
Primarily Uses
RMVX
I don't normally use vx so I don't know the scripts, all I can offer is try google. I also edited with another option, but you ninja'd me so I don't know if you saw it. good luck.
Thank you. Yes, i see you added events stuff, if i figure that out it will probably cover what i need to implement.
 
Last edited by a moderator:

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,247
Reaction score
1,245
First Language
Spanish
Primarily Uses
RMVXA
1. Enemy uses skill 'prepare weapon', gaining state 'weapon prepared' at TURN ONE.
2. TURN ONE ends.
3. On start of the TURN TWO player character attacks enemy, who by receiving damage loses state 'weapon prepared', which is indicated by appeared message.
4. On the enemy action of TURN TWO enemy uses skill 'aim', despite having lost state 'weapon prepared', receiving 'aiming' state.
5. TURN TWO ends.
double check the duration for each state, and the battlers resistance to said states, and the states themselves sealing (or not) determined skills.

my suggestion would be: seal all unavailable skills by default, and make the added states negate those seals.... so if by any chance the state enabling those skills is removed, the skill will be sealed again.
by default, all skills are available and you can't add skills through states, only negate them.
so.... work by double negative -> !!A == A.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,297
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
This post is being made on behalf of @kairi_key

Their post was mistakenly merged with someone else's. It is not possible to unmerge posts, so I have extracted the contents of their post and am giving it below.


EDIT
Or if you wanna use script, try searching for Enemy AI script or just AI script to help you set up specific behavior for enemies. I think there are quite a few out there.

Another way is that you can probably find a script where the skill can be used only on a certain condition. I think there is one or two out there.

And about enemy's action is that as stated in post above, it cannot be changed mid-turn once all your actions are selected unless you decided to implement a different battle system altogether.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,503
First Language
Indonesian
Primarily Uses
RMVXA
Use "Action Rating", it will filter the highest two if not three, I don't remember.

- Set the "Weapon Prepare" at the lowest rating and do not require any condition.
- Set "Aim" with the medium/highest (depends on what you need) priority and a state condition "weapon prepared". It will override "weapon prepare" action so that it will never be used.
- Set Attack at the highest priority so it will always override both actions. Depends on what you want to do, if you remove "weapon prepared" state with "aim" state, "aim" action probably could have the same rating. If attacking requires both states to exist, then set "aim" action at medium rating while attacking at highest rating.

EDIT: as for action refresh, I have these code in my enemy AI that works to refresh the enemy action because of the reason you mentioned
Code:
class Game_Action
  
  alias theo_custom_ai_prepare prepare
  def prepare
    theo_custom_ai_prepare
    # ------------------------------------------------------------------------
    # Refresh enemy action. Make sure the current action is conditionally valid.
    # Two times or more action often performed an action regardless of the current
    # action is conditionally valid or not
    # ------------------------------------------------------------------------
    if subject.enemy? && !forcing
      skill = subject.enemy_action
      set_enemy_action(skill)
    end
  end
  
end

class Game_Enemy
  def enemy_action
    action_list = enemy.actions.select {|a| action_valid?(a) }
    return if action_list.empty?
    rating_max = action_list.collect {|a| a.rating }.max
    rating_zero = rating_max - 3
    action_list.reject! {|a| a.rating <= rating_zero }
    return select_enemy_action(action_list, rating_zero)
  end
end
 
Last edited:

t1slam

Villager
Member
Joined
Jan 13, 2020
Messages
6
Reaction score
3
First Language
russian
Primarily Uses
RMVX
Hey, everyone, i haven't checked this thread after suggestion to set speed of action worked for me.

gstv87 - i think sealing doesn't work as every step is working exactly fine and the problem is that enemy does not change action DURING the turn, so in this case only script would help.

Now i see that there is a script for action refresh by TheoAllen - per its description it seems to be what i need, so i'm definitely trying it out.
 

t1slam

Villager
Member
Joined
Jan 13, 2020
Messages
6
Reaction score
3
First Language
russian
Primarily Uses
RMVX
UPDATE: TheoAllen's "Action Refresh" script works! Thank you very much for this, it is exactly what i have asked for.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,297
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@t1slam If this has resolved your query to your satisfaction, please Report your post and ask for the thread to be closed. Mods might not see an individual post but will see a Report. It also removes any ambiguity about whether it has been resolved, because sometimes the OP comes back saying, "well, actually, ..."
 

t1slam

Villager
Member
Joined
Jan 13, 2020
Messages
6
Reaction score
3
First Language
russian
Primarily Uses
RMVX
I was wondering how do i close the thread, thank you, i'll do that.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,826
Reaction score
5,218
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Hope you are all fine today~
Moderators, you must have so much patience to be able to deal with everything. I mod in a server of sorts and today we just got a message, which, despite it's helpful constructive criticism, basically stated that all of the mods were jerks and that was the only reason our server was unlikeable. So, thank you, for having patience. You are appreciated! :kaoluv:
Haired slime? Trying some different styles of art. Maybe I can make some resources with this new kind of painting.......
i love my game very much

Forum statistics

Threads
105,740
Messages
1,016,004
Members
137,424
Latest member
zxandris
Top