States That Have a Chance of Automatically Using Skills

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
I'm requesting a script that would essentially be an add-on for Victor Sant's Passive States script (just Ctrl+F "passive," and it should be the only result). The idea is to allow for States to have a chance of using a skill at the start of a combat round, with the skill's id and % chance indicated by notetags; something like <passive state skill: x, y%> with "x" being the skill id and "y" being the chance of it occurring. Obviously, it should do this regardless of whether they actually know the skill, before turn order, and without affecting the battler's actions (actor or enemy), especially if they have any Action Times+ features.

An example would be if Eric had a passive skill (due to Victor Sant's script) called "Burst of Power," which has a 10% chance of using "ATK Up" (let's say skill 41) at the start of each round, despite him not knowing that skill. Using the previous example notetag, in the "Burst of Power" State's note box you would put <passive state skill: 41, 10%>. During a battle, you choose to Attack. The notetag makes it so that there is a 1/10 chance of Eric using skill 41, "ATK Up," at the start of each round, but even if activates that turn, he'll still Attack like you told him to.

For another example, Natalie has "Burst of Power" like Eric does, but also has the Action Times +100% feature, meaning she'll always act twice per round. During a battle with a Slime, Natalie is faster than Eric, but slower than the Slime, and you have her Attack for both of her turns. Eric's Burst of Power doesn't activate, but Natalie's does, making her use ATK Up at the round's start before actions are carried out. The Slime attacks, then Natalie attacks twice as she was instructed, and then Eric does whatever you told him to do that turn.

I'm not sure how complicated this is, but I think this could make for some interesting gameplay, and also help further differentiate classes beyond what they learn.

EDIT: Added link to Victor's script drive gallery thing. I realized that one issue would be if an actor or battler was afflicted with a State that prevented actions (Sleep, Paralysis, etc, but NOT Death). I guess just make the passive-activated skills ignore those restrictions on actions (again, not Death).
 
Last edited by a moderator:

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
This script might do the job:

http://forums.rpgmakerweb.com/index.php?/topic/38777-doublex-rmvxa-state-triggers/

Using your "Burst of Power" as an example:

<turn state trigger: STC1, STA1>Where STC1 is:

STC1 = "rand < x" # The probability of returning true is xAnd STA1 is:

STA1 = "force_action(skill_id, target_index); BattleManager.force_action(self)"Where skill_id is the id of the skill to be used, and target_index is:

-2: last target index-1: randomn(>=0): index n - 1Check the Force Action Event Commands for details.

P.S.: I don't know if that script's compatible with Victor's ones :)
 

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
My knowledge of scripting is practically nil, so this is pretty much all flying over my head. Even so, I think I got it set up right - no crashes - but it has the character use the skill at round's end, rather than at round start

 



EDIT: In addition, it always kicks in if I set the "rand < x" to anything other than 0, in which case it instead never activates. Did I do something wrong?
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
That's because turn state trigger only triggers when the turns are reduced by 1, which occurs at the end of a turn. For what you want, you would need a way to trigger it at the start of the turn. Maybe Yanfly's Lunatic states script would work for this?

Edit: Ok, it would require an edit or an add-on to pull that off, but Yanfly's Lunatic states does have the ability to flag a state to have things occur at the start of the parties turn. You would need an add-on written then to take advantage of that so that your random state can occur.

Unfortunately my knowledge of reading notetags is really poor for what you need here, so I doubt I can do it for a few weeks (at minimum) as I would have to go learn how to read notetags better first. But maybe someone can write an add - on to Yanfly's Lunatic states with this idea in mind?
 
Last edited by a moderator:

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
That's because turn state trigger only triggers when the turns are reduced by 1, which occurs at the end of a turn. For what you want, you would need a way to trigger it at the start of the turn. Maybe Yanfly's Lunatic states script would work for this?
Thanks for the reminder. I think I need to upgrade the state trigger script to support both the end and start of a turn lol
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
If you could, that would fix the problem, as Yanfly's Lunatic states script forgot the eval command so the OP cannot use the custom conditions to set it up. Not without a custom add-on script written first.
 

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
So what's with the issue where it seems to think that setting the x in "rand < x" to anything over 0 means it should always kick in?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Are you using integers or decimals? By default, rand returns a number between 0 and 1, so if you have 1 in there it always kicks in. Instead, if you want 10%, you need to use 0.10.
 

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
Shoot, I was using integers because I thought that's how it worked. Using decimals as you suggested, it works properly on that front.
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
First, use this snippet(to be part of the coming update):

class RPG::State < RPG::BaseItem #----------------------------------------------------------------------------| # New public instance variables | #----------------------------------------------------------------------------| attr_accessor :state_triggers #----------------------------------------------------------------------------| # New method: load_notetags_state_triggers | # - Loads each <timing state trigger: STCX, STAX> notetag from its notebox | #----------------------------------------------------------------------------| def load_notetags_state_triggers # Stores all timing, STCX and STAX triples from matching lines sequentially @state_triggers = {} st = "DoubleX_RMVXA::State_Triggers::" @note.split(/[\r\n]+/).each { |line| next unless line =~ /<(\w+) state trigger:\s*(\w+)\s*,\s*(\w+)\s*>/ @state_triggers[$1.to_sym] ||= [] @state_triggers[$1.to_sym].push( [eval("-> battler { battler.instance_exec { #{eval("#{st}#{$2}")} } }"), eval("-> battler { battler.instance_exec { #{eval("#{st}#{$3}")} } }")]) } # end # load_notetags_state_triggersend # RPG::State
Try to open a battle event with Condition Turn No. 1 * X and Span Turn. Add the below script call into that event:

all_battle_members.each { |battler| battler.instance_exec { @states.each { |state_id| eval_state_triggers(state_id, :turn) } }}If you want the turn start triggers to be different from the turn end triggers, use this instead:

all_battle_members.each { |battler| battler.instance_exec { @states.each { |state_id| eval_state_triggers(state_id, :custom) } }}:custom can be replaced by any symbol other than :add, :turn and :remove(it must also only consist of alphanumeric characters).

Then all the state trigger notetags to be used at the turn start need to be changed to this:

<custom state trigger: STCX, STAX>I think I've to inform users in the script info region that they can create state triggers with custom timings. Utilizing this needs decent scripting proficiency however, unless there are external helps lol

P.S.: I didn't mention that as even I didn't realize that script can have such capabilities just by tweaking minor stuffs. Now I feel incredibly dumb XD
 
Last edited by a moderator:

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
Gave me an error when I tried to battle test.

Script 'DoubleX RMXVA State Triggers' line 321: NoMethodError occurred.

 

undefined methods `each' for nil:NilClass
EDIT: I thought I had found a second bug. Turned out I just forgot to delete a test state. The above issue still applies though.
 
Last edited by a moderator:

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
Gave me an error when I tried to battle test.

EDIT: I thought I had found a second bug. Turned out I just forgot to delete a test state. The above issue still applies though.
That issue's due to an incredibly dumb mistake lol

Now try this snippet:

Code:
#------------------------------------------------------------------------------|#  * Edit class: RPG::State                                                    |#------------------------------------------------------------------------------|class RPG::State < RPG::BaseItem  #----------------------------------------------------------------------------|  #  New public instance variables                                             |  #----------------------------------------------------------------------------|  attr_accessor :state_triggers  #----------------------------------------------------------------------------|  #  New method: load_notetags_state_triggers                                  |  #  - Loads each <timing state trigger: STCX, STAX> notetag from its notebox  |  #----------------------------------------------------------------------------|  def load_notetags_state_triggers    # Stores all timing, STCX and STAX triples from matching lines sequentially    @state_triggers = { :add => [], :turn => [], :remove => [] }    st = "DoubleX_RMVXA::State_Triggers::"    @note.split(/[\r\n]+/).each { |line|      next unless line =~ /<(\w+) state trigger:\s*(\w+)\s*,\s*(\w+)\s*>/      @state_triggers[$1.to_sym] ||= []      @state_triggers[$1.to_sym].push(      [eval("-> battler { battler.instance_exec { #{eval("#{st}#{$2}")} } }"),       eval("-> battler { battler.instance_exec { #{eval("#{st}#{$3}")} } }")])    }    #  end # load_notetags_state_triggersend # RPG::State
 

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
I pasted the snippet as its own script. Then, I set up a testing state with the notetag <custom state trigger: STC7, STA4> (basically set to always activate). I made a new Battle Event page with Condition: Turn No. 1 + 1 *X, and Span: Turn, and added a Script call of

all_battle_members.each { |battler|battler.instance_exec {
@states.each { |state_id|
eval_state_triggers(state_id, :custom) }
}
}
Once I selected my actions, it gave me the error:

Script 'Game_Interpreter' line 1411: NameError occurred.

 

undefined local variable or method `all_battle_members' for #<Game_Interpreter:0x84512a0>
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
You want $game_party.battle_members, there's no such thing as all_battle_members in the interpreter, which is the class you're working inside with battle events.
 

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
Alright, so in red is the difference from before:

$game_party.battle_members { |battler|

  battler.instance_exec { 

    @states.each { |state_id| 

eval_state_triggers(state_id, :custom) }

  }

}
While testing, instead of crashing, nothing happens/there's no effect. The other states seem to still work, though.
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
You want $game_party.battle_members, there's no such thing as all_battle_members in the interpreter, which is the class you're working inside with battle events.
(Facepalmed)How could I make such an incredibly dumb mistake lol

Alright, so in red is the difference from before:

$game_party.battle_members { |battler|

  battler.instance_exec { 

    @states.each { |state_id| 

eval_state_triggers(state_id, :custom) }

  }

}
While testing, instead of crashing, nothing happens/there's no effect. The other states seem to still work, though.
The state trigger script has been updated to v1.01a:

http://forums.rpgmakerweb.com/index.php?/topic/38777-doublex-rmvxa-state-triggers/?p=385381

Now try this script call in the battle event:

$game_party.battle_members.each { |member| member.exec_state_triggers(state_id, :turn_start) }Where state_id is the id of the state to be triggered at the start of a battle turn.

Also, that state needs to use the below state trigger(s):

<turn_start state trigger: STC1, STA1>I've tested and this works in my case. Hope it works on yours too :)
 
Last edited by a moderator:

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
It does work, though the .each makes every character use it regardless of whether they have the skill/state or not.

EDIT: Did more testing. The script call definitely doesn't care if anyone actually has the skill/state or not. The script call behaves differently depending on if the activation rate is 100% or not. If it is, then everyone in the party will use the assigned skill; if it isn't, a random character(s) has a chance of using it each turn.
 
Last edited by a moderator:

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
It does work, though the .each makes every character use it regardless of whether they have the skill/state or not.

EDIT: Did more testing. The script call definitely doesn't care if anyone actually has the skill/state or not. The script call behaves differently depending on if the activation rate is 100% or not. If it is, then everyone in the party will use the assigned skill; if it isn't, a random character(s) has a chance of using it each turn.
(My bad)Try this script call instead:

Code:
$game_party.battle_members.each { |member|  next unless member.states.include?($data_states[state_id])  member.exec_state_triggers(state_id, :turn_start)}
 

Rigor Mortex

Mankind's Mirror
Veteran
Joined
Mar 14, 2012
Messages
65
Reaction score
4
First Language
English
Primarily Uses
Ran a battle test with neither of the actors having the state to check what would happen. Once the first turn actually started (i.e. following command input):

Script 'Game_Interpreter' line 1411: ArgumentError occurred. wrong number of arguments(0 for 1)
I then tried it with only one of them having it, and even with both of them having it, and it gave me the same error.
 
Last edited by a moderator:

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
Maybe you'll need to give me your demo this time :)
 

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

Latest Threads

Latest Profile Posts

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'??
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:

Forum statistics

Threads
105,854
Messages
1,017,004
Members
137,562
Latest member
tamedeathman
Top