DoubleX RMMV State Triggers

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
Note


This plugin's available for commercial use


Purpose


Sets some states to trigger additional effects when conditions are met


Games using this plugin


None so far


Notetags

Spoiler




* # State Notetags:
* 1. <timing state trigger: STCX, STAX>
* - Sets a state to trigger STAX when timing and STCX are met
* - timing can be add, turn, remove or custom timings set by you
* - add means the state's just added
* - turn means the state's remaining turn's just reduced by 1
* - remove means the state's just removed
* - (v1.02a+)while means the STAX effects are active as long as the
* state's active
* - timing must only consist of alphanumeric characters
* - STCX can be set in State Trigger Condition Functions
* - STAX can be set in State Trigger Action Functions



Plugin Calls

Spoiler




* # Configuration manipulations
* 1. DoubleX_RMMV.State_Triggers.prop
* - Returns the property prop under DoubleX_RMMV.State_Triggers
* 2. DoubleX_RMMV.State_Triggers.prop = val
* - Sets the property prop under DoubleX_RMMV.State_Triggers as a
* function which will be bound to the battler upon use
* # State manipulations
* All meta.stateTriggers changes can be saved if
* DoubleX RMMV Dynamic Data is used
* 1. meta.stateTriggers[timing]
* - Returns the array of all STCX-STAX pairs of timing timing
* 2. meta.stateTriggers[timing] = [[STCX, STAX], [STCX, STAX], ...]
* - Adds a new timing with some STCX-STAX pairs or overwrites all the
* existing ones with those pairs if timing is an existing timing
* 3. meta.stateTriggers[timing] = [STCX, STAX]
* - Set the ith STCX-STAX pair as the new STCX-STAX pair
* # Battler manipulations
* (v1.02a+)1. GBB.stateTriggerTraits.call(battler, state, timing)
* - Collects all traits from all STAX meeting their corresponding
* STCX with timing timing of state applied to battler
* - GBB is DoubleX_RMMV.State_Triggers.Game_BattlerBase
* 2. GBB.execStateTriggers.call(battler, stateId, timing)
* - Executes all state triggers with timing timing of state with id
* stateId applied to battler
* - GBB is DoubleX_RMMV.State_Triggers.Game_BattlerBase





Configurations

Spoiler




/*------------------------------------------------------------------------
* State Trigger Condition Functions
* - Setups STCX used by this plugin's notetags
*------------------------------------------------------------------------*/
/* STCX are used at:
* 1. DoubleX_RMMV.State_Triggers.Game_BattlerBase
* - return ST[trigger[0]].call(battler, state); in stateTriggerTraits
* - if (ST[trigger[0]].call(this)) { ST[trigger[1]].call(this); } in
* execStateTriggers
* STCX are Javascript functions which will be bound to the battler upon use
* STCX names can only use alphanumeric characters
* state is the state using the STCX
* The below STCX are examples added to help you set your STCX
* You can freely use, rewrite and/or delete these examples
*/

// Sets the state trigger condition as always true
STC1: function(state) { return true; },

// Sets the state trigger condition as needing switch with id x to be on
STC2: function(state) { return $gameSwitches.value(x); },

// Sets the state trigger condition as always true
STC3: function(state) { return false; },

// Adds new STCX here


/*------------------------------------------------------------------------
* State Trigger Action Values
* - Setups STAX used by this plugin's notetags
*------------------------------------------------------------------------*/
/* STAX are used at:
* 1. DoubleX_RMMV.State_Triggers.Game_BattlerBase
* - return r.concat(ST[trigger[1]].call(battler, state)); in
* stateTriggerTraits
* - if (ST[trigger[0]].call(this)) { ST[trigger[1]].call(this); } in
* execStateTriggers
* STAX are Javascript functions which will be bound to the battler upon use
* STAX names can only use alphanumeric characters
* state is the state using the STAX
* If the timing using the STAX is while, the STAX must return an array of
* Trait Class
* You can refer to Game_BattlerBase in rpg_objects.js and Trait Class in
* the RMMV help html
* The below STAX are examples added to help you set your STAX
* You can freely use, rewrite and/or delete these examples
*/

/* Sets the state trigger action as what Special Effect Escape does
* This STAX's not supposed to work with the timing while as it doesn't
* return an array of Trait Class
*/
STA1: function(state) { this.hide(); },

/* Sets the state trigger action as setting the battler's hp to full
* This STAX's not supposed to work with the timing while as it doesn't
* return an array of Trait Class
*/
STA2: function(state) { this._hp = this.mhp; },

/* Sets the state trigger action as ultiplying the battler's atk by x * 100%
* This STAX's supposed to work with the timing while as it returns an array
* of Trait Class
*/
STA3: function(state) { return [{"code":21,"dataId":2,"value":x}]; }

// Adds new STAX here



Prerequisites


1. Decent Javascript coding proficiency to fully utilize this plugin


Terms Of Use


You shall keep this plugin's Plugin Info part's contents intact


You shalln't claim that this plugin's written by anyone other than DoubleX or his aliases


None of the above applies to DoubleX or his/her aliases


Changelog

Spoiler




* v1.02a(GMT 0200 14-5-2016):
* 1. Added the timing while to <timing state trigger: STCX, STAX>
* v1.01a(GMT 1300 26-2-2016):
* 1. STCX and STAX take the state using them as an argument as well
* v1.00g(GMT 0400 25-12-2015):
* 1. The aliased functions can be accessed by other custom plugins now
* 2. Exposed the state plugin calls that can access the notetag values
* 3. Increased this plugin's compactness, compatibility and readability
* v1.00f(GMT 1500 6-11-2015):
* 1. Fixed undefined this in forEach bug
* v1.00e(GMT 1400 6-11-2015):
* 1. Simplified the notetag reading mechanisms
* 2. Fixed some typos
* v1.00d(GMT 1100 5-11-2015):
* 1. Fixed undefined this under DoubleX_RMMV.State_Triggers bug
* v1.00c(GMT 0000 5-11-2015):
* 1. Fixed failing to load notetags due to nil $dataStates bug
* v1.00b(GMT 1000 4-11-2015):
* 1. Fixed several logic and syntax errors
* 2. Increased this plugin's maintainability
* v1.00a(GMT 1500 30-10-2015):
* 1. 1st version of this plugin finished



View attachment DoubleX RMMV State Triggers v102a.rar
 
Last edited by a moderator:

lolshtar

Master of Magic thatknow nospell
Veteran
Joined
Apr 13, 2013
Messages
694
Reaction score
101
First Language
French
Primarily Uses
RMMV
The name of the plugin is wrong http://puu.sh/l4i7f/65769875b6.png

I have a suggestion: trigger on damage

Also can you help me with the right script calls as how l had it setup on Ace?
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
The name of the plugin is wrong http://puu.sh/l4i7f/65769875b6.png

I have a suggestion: trigger on damage

Also can you help me with the right script calls as how l had it setup on Ace?
You can always freely change the filename of my scripts :)

But now knowing this issue, I'll change te naming convention of my upcoming plugins ;)

All STCX and STAX will be bound to the battlers upon use, so you can just treat them as battler functions.

For instance, the below RMVXA counterparts:

# Sets the state trigger condition as always true STC1 = "true" # Sets the state trigger condition as having switch with id x on STC3 = "$game_switches[x]" STC501 = "@state_turns[501] && @state_turns[501] <= 0"Can be converted to the below RMMV counterparts:

# Sets the state trigger condition as always true STC1: function() { return true; }, # Sets the state trigger condition as having switch with id x on STC3: function() { return $gameSwitches.value(x); }, STC501 = function() { return this._stateTurns[501] && this._stateTurns[501] <= 0; },The notetags will be written in the exact same way in both RMVXA and RMMV versions :D
 
Last edited by a moderator:

wrigty12

Just a QAer playing with Javascript
Veteran
Joined
Jan 11, 2014
Messages
656
Reaction score
184
First Language
English
Primarily Uses
RMMZ
For some odd reason, it is giving me an "unexpected token: . " error in console, and not running. The error points to line 117, your this._hp = this.mhp in your STA2.
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
Updates

Code:
 *      v1.00b(GMT 1000 4-11-2015):                                            *      1. Fixed several logic and syntax errors                               *      2. Increased this plugin's maintainability
 

wrigty12

Just a QAer playing with Javascript
Veteran
Joined
Jan 11, 2014
Messages
656
Reaction score
184
First Language
English
Primarily Uses
RMMZ
It now gives a "Cannot read property 'forEach' of null" for line 176 upon booting the game.
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
Updates

Code:
 *      v1.00c(GMT 0000 5-11-2015):                                            *      1. Fixed failing to load notetags due to nil $dataStates bug
 

wrigty12

Just a QAer playing with Javascript
Veteran
Joined
Jan 11, 2014
Messages
656
Reaction score
184
First Language
English
Primarily Uses
RMMZ
Error upon boot: "Cannot read property 'load_notes' of undefined" at line 180, column 21
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
Updates

Code:
 *      v1.00f(GMT 1500 6-11-2015):                                            *      1. Fixed undefined this in forEach bug                                *      v1.00e(GMT 1400 6-11-2015):                                            *      1. Simplified the notetag reading mechanisms                           *      2. Fixed some typos                                                   *      v1.00d(GMT 1100 5-11-2015):                                            *      1. Fixed undefined this under DoubleX_RMMV.State_Triggers bug
 
Last edited by a moderator:

lolshtar

Master of Magic thatknow nospell
Veteran
Joined
Apr 13, 2013
Messages
694
Reaction score
101
First Language
French
Primarily Uses
RMMV
seems there are no more errors

though id like to know what im doing wrong here

http://puu.sh/lbwA6/6102010e40.png

STA32: function()  { this.removeState(14);this.RemoveState(16);this.removeState(17); },
 

Bearsmith

Villager
Member
Joined
Nov 13, 2012
Messages
22
Reaction score
5
First Language
English
I feel like I must be missing something. I can't get this to work.

Using all the defaults, I have 

<add state trigger: STC1, STA2>in the notebox of a state. I expect that when I add the state it should use STA2, which sets HP to MHP. This isn't happening. I'm testing this in a new project with no other plugins.

EDIT: Nevermind! It works just fine. I accidentally broke something when I was reading the script. I redownloaded it and it's fine.
 
Last edited by a moderator:

Mirai Ko

Veteran
Veteran
Joined
Oct 16, 2012
Messages
64
Reaction score
15
First Language
English
 When I set STA5 to this.forceAction(189, 0), it works normally for actors, but doesn't work at all for enemies.

Should something else be set for enemies?
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
From the force action command:

// Force ActionGame_Interpreter.prototype.command339 = function() { this.iterateBattler(this._params[0], this._params[1], function(battler) { if (!battler.isDeathStateAffected()) { battler.forceAction(this._params[2], this._params[3]); BattleManager.forceAction(battler); this.setWaitMode('action'); } }.bind(this)); return true;};
It suggests that you need BattleManager.forceAction(this) as well :)
 

Mirai Ko

Veteran
Veteran
Joined
Oct 16, 2012
Messages
64
Reaction score
15
First Language
English
Ah, yes, that worked. 

 Thank you.
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
Updates

Code:
 *      v1.00g(GMT 0400 25-12-2015):                                           *      1. The aliased functions can be accessed by other custom plugins now   *      2. Exposed the state plugin calls that can access the notetag values   *      3. Increased this plugin's compactness, compatibility and readability
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
Updates

Code:
 *      v1.01a(GMT 1300 26-2-2016):                                           
 *      1. STCX and STAX take the state using them as an argument as well
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,803
Reaction score
950
First Language
Chinese
Primarily Uses
N/A
Updates

Code:
 *      v1.02a(GMT 0200 14-5-2016):                                           
 *      1. Added the timing while to <timing state trigger: STCX, STAX>
 

Latest Threads

Latest Posts

Latest Profile Posts


I ended up needing to do a chapter one world map remake. It's still WIP but coming along nicely. =D
Stream will be live shortly! I will be beginning a play-through of Resident Evil 4! Feel free to drop by!

1st iteration on castle interior in Tiled.
I've started up Pillars of Eternity. It's interesting how the game does a "select choice" cutscene using still image art for dramatic flair. I wonder if that might work for my RPGMaker project.
The self-righteous indignation of family when you expect them to pay back money you've leant to them never ceases to amaze me.

Forum statistics

Threads
107,746
Messages
1,031,832
Members
139,884
Latest member
cinar
Top