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
154
Reaction score
130
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
364
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

At work.
Co: "This bug drove me insane. I tried a lot of things to debug, it just stuck".
Me: "How did you debug it?"
Co: *shows a complicated debugging method using breakpoints and everything*
Me: "What about ... " *casually prints a stack trace in the try/catch exception
Co: "Wait, you can do that??"
Totally original and unique OC
Harold.png
So after completing the Mass Effect Trilogy the first time as a Vanguard, I decided to replay the trilogy as a Soldier. Thus far, I've just finished the Horizon mission in ME2, and I'm already exhausted from ME2's f**k-awful enemy design.
Yeah, now Yes !!!! "boom boom "
"Fire the monsters, guards!!!"

index.php
I can't stop buying resource packs I'll never use, or engines for that matter, or free resources as my two terabyte external will attest. I am a digital hoarder I guess. Some people get drunk off the silly juice when they are bored, I just buy shiny digital nonsense I don't need.

Forum statistics

Threads
118,651
Messages
1,117,571
Members
155,753
Latest member
Esteblad
Top