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

ok by this weekend I WILL finally need alpha testers for Backstage: murdered sleep because it's got enough content at this point I want to get it on Steam Early Access ASAP (2/22/2022 would be a cool release date if I can make it).

By all means volunteer here, sure, but where else should I be looking?
1643337839651.png
Randomly trying to make some butcher shop tiles for MZ :3
Current menu of Shadows of the Earth: The Vrila'an Legend. Currently taking a break from combat related mechanics. Hope i get the actor busts done before the day ends :)
Was in need for a black van, so I made one by editing that one truck in the tileset. :kaoswt2:
nFfmJca.png
I honestly haven't ever been really active in this community, even though this year will mark my 4th year of having an account and 5th or 6th of using RPG maker. I didn't do anything with RM for most of 2020 and 2021 for personal reasons, but I'm excited to get back into game making!

Forum statistics

Threads
118,771
Messages
1,118,600
Members
155,932
Latest member
RPGMVNoob
Top