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
365
Reaction score
102
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 Posts

Latest Profile Posts

I think it's by time I make use of this feature in the forums. I'm never one to share profile updates or anything the sort, but hey, you gotta start somewhere! I think I'll use this place primarily to post maps actually, so here, have a goblin cave!

PqleoRp.png

Inspired largely by Wynncraft's Aseado Leaf cave
Does anyone know if Yanfly's Ace scripts are still free for use in both commercial and noncommercial projects? Can't find much except for the wordpress Terms of Use, but not sure if it's not outdated.
I just realized two of My series are beginning to look virtually identical to one another in mechanics and general themes, I never had this problem before.

This is Stifling! Must resolve this!
Lord's Reincarnation III (LR3) MOBILE is coming!!!
iu_534706_7630675.png
ScreenShot_1_20_2022_2_19_41.png
Juice FX is amazing... the portal in the middle is actually animated and moves thanks to Juice FX. so I edited part of a map I have and then drew the portal around it. threw it into Juice FX and now it's lively instead of static.

Forum statistics

Threads
118,711
Messages
1,118,106
Members
155,852
Latest member
rumnerd_frog
Top