ZakRew

Villager
Member
Joined
Aug 3, 2019
Messages
7
Reaction score
2
First Language
Russian
Primarily Uses
RMMV
Hello everyone! I tried so many times to learn scripting in RPGM but unsuccesful.. Or tutorials are bad, or I'm stupid idk...
Can someone help me to find a script?

Script mechanic:
Me
: Choose which states must be counted (poisoned, sleep, paralyze etc.)
Counter: Starts counting this states from moment when I press in Title Screen "New Game"
Counter Complete: When counter counts to needed points - Actor learns skill

Ex.:
1. Counting Poisoned state to 200
2. Actor in battles gets a poisoned state many times...
3. In any battle when counter reach "200 times get poisoned state" Actor get skill "blah-blah (skillId)"
4. Counter for that state stopped.

I nearly understand an algorithms but with syntaxis and at all with scripting I'm freaking bad. I wrote some ****ty code by tutorials and U can laugh so loud if opened a spoiler.

(function() {
var params = PluginManager.parameters('StateCounter');
var stateId = Number(params["State ID"]);
var counter = Number(params["Counter"])
var target = $gameActors.actor(1);
target.addState(params["State ID"]);

if (!stateId && target.stateId()){
counter = counter + 1;

}
if (counter = 2) {
actor.learnSkill(6);
}
})();

I hope u'll help me with it. Even if u send me in answers good tutorials that can help me - It'll be awesome!
Waiting for answers and..
the force will be with you!
 

eomereolsson

Veteran
Veteran
Joined
Sep 29, 2021
Messages
152
Reaction score
126
First Language
German
Primarily Uses
RMMV
I haven't actually tested this, so it may as well set your game on fire, but my initial attempt would be something like this:
JavaScript:
//=============================================================================
// Game_Battler
//=============================================================================
var original_addNewState = Game_Battler.prototype.addNewState;

Game_Battler.prototype.addNewState = function(stateId) {
    original_addNewState.call(this, stateId);

    if (this.isActor()) {
        if(this._myStateCountArray[stateId] >= 200) {
            this.learnSkill(stateId);
        }
        else {
            this._myStateCountArray[stateId]++;
        }
    }
};

//=============================================================================
// Game_Actor
//=============================================================================
var original_initMembers = Game_Actor.prototype.initMembers;

Game_Actor.prototype.initMembers = function() {
    original_initMembers.call(this);
    this._myStateCountArray = [];
};

For simplicity's sake the actor will simply learn the skill with the same id as the state had. You could of course expand that either by performing math with the stateId (for example learn the skill with the ID equal to the stateId + 50 or something) or even by defining in an array which state should map to which skill on an individual basis.

Good luck with your learning javascript endeavor.
 

ZakRew

Villager
Member
Joined
Aug 3, 2019
Messages
7
Reaction score
2
First Language
Russian
Primarily Uses
RMMV
Thanks for the answer) I'll try to analyze this code and understand what the different parts of the code are doing)
 

xabileug

Veteran
Veteran
Joined
Jul 1, 2014
Messages
362
Reaction score
101
you could use yanflys autostate, everytime that state is applied, a variable increases, then when variable is 200, run common event
 

ZakRew

Villager
Member
Joined
Aug 3, 2019
Messages
7
Reaction score
2
First Language
Russian
Primarily Uses
RMMV
you could use yanflys autostate, everytime that state is applied, a variable increases, then when variable is 200, run common event
This plugin is YEP_AutoPassiveStates?
 

Latest Threads

Latest Profile Posts

And here I thought I've lost my music sense. Good exercise once in a while
Made Edits to a Character Art from 'Hibiki Katakura MV Monsters' (DLC), to Look More like One of My Own Characters. :LZScheeze:

Decided to retake an old concept I was working on long ago, first change I decided to tackle on right away is the sprites. Never been fan of the default chibis, so I edited it a bit... :kaoswt:
8YavqRj.png

Not sure if this will be the final take, but I like it more than the regular one.
Need a few testers for my new plugin, any takers?
Good night (or day) to everyone! :smile:

Forum statistics

Threads
118,529
Messages
1,116,699
Members
155,558
Latest member
LuckyCatOtome
Top