Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Need two tweaks to the "Dead" State

Status
Not open for further replies.

David FoxFire

Adventurer
Xy$
0.00
The game I'm working on right now isn't going to be much into Death. Granted, a party wipe (or in my lingo, a Total Party Kill, will result in a "Game Over, press 'R' to Restart", but I'd like to have two tweaks to this state.

One, I'd like to have people heal form this state. Where you can heal someone who's 'K.O.'ed instead of using a Phoenix Down like item to get the character back in the fight. Also, at the end of combat, any characters who's been K.O.ed come back with 1 HP (and no XP for the battle, of course).

Any and all assistance for this tweak will be greatly appreciated. Thanks in advance.
 

eivl

Local Hero
Xy$
0.00
One, I'd like to have people heal form this state. Where you can heal someone who's 'K.O.'ed instead of using a Phoenix Down like item to get the character back in the fight.
Would a combination of both be an idea?
make your heal skill remove the state and then heal.
at the end of combat, any characters who's been K.O.ed come back with 1 HP
There is something called : BattleManager.processVictory
you would have to set HP to dead members here. and also remove the KO state
 

Eien Nanashi

Temporarily Goddamn Bright Yellow
Xy$
0.00
Also, at the end of combat, any characters who's been K.O.ed come back with 1 HP
I think you just need to set the Knockout state to have "Remove at Battle End" checked on.

EDIT: If the heal skill revives, it would have to target Ally (Dead). And if the ally is alive, no effect would occur, even if it heals HP...
 
Last edited:

David FoxFire

Adventurer
Xy$
0.00
Would a combination of both be an idea?
make your heal skill remove the state and then heal.

There is something called : BattleManager.processVictory
you would have to set HP to dead members here. and also remove the KO state
That'll work, have the heals set to also work on KO'ed Individuals.

And I have the Battle Manager victory plugin. I might need to code something like this:

for (each character in party) {
if (character is KOed) {
set character.HP to 1;
remove KO Status;
};
};

Also, at the end of combat, any characters who's been K.O.ed come back with 1 HP
I think you just need to set the Knockout state to have "Remove at Battle End" checked on.

EDIT: If the heal skill revives, it would have to target Ally (Dead). And if the ally is alive, no effect would occur, even if it heals HP...
Would that automatically set the HP to 1 HP?
 

Eien Nanashi

Temporarily Goddamn Bright Yellow
Xy$
0.00
Would that automatically set the HP to 1 HP?
Yes.
It also causes the dead person to run with you when you do an Escape.

...However, I have found a slight bug.
If you fail to escape and someone's dead, they get revived with 1 HP.
EDIT: This applies to every "Remove at Battle End" state, apparently... :(

EDIT2: In rpg_managers under BattleManager, there's a function called "processEscape". (line 2274)
Code:
BattleManager.processEscape = function() {
    $gameParty.removeBattleStates();
    $gameParty.performEscape();
    SoundManager.playEscape();
    var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
    if (success) {
        this.displayEscapeSuccessMessage();
        this._escaped = true;
        this.processAbort();
    } else {
        this.displayEscapeFailureMessage();
        this._escapeRatio += 0.1;
        $gameParty.clearActions();
        this.startTurn();
    }
    return success;
};
It does "$gameParty.removeBattleStates();" before it checks if your escape was successful.
I guess you'll need to move that line right under "if (success) {", so that it only removes your states IF you were successful at fleeing.

I don't really know about javascripting and plugins, but that's my guess.
EDIT3: Just tested my edit and it works.
 
Last edited:

David FoxFire

Adventurer
Xy$
0.00
Yes.
It also causes the dead person to run with you when you do an Escape.

...However, I have found a slight bug.
If you fail to escape and someone's dead, they get revived with 1 HP.
EDIT: This applies to every "Remove at Battle End" state, apparently... :(

EDIT2: In rpg_managers under BattleManager, there's a function called "processEscape". (line 2274)
Code:
BattleManager.processEscape = function() {
    $gameParty.removeBattleStates();
    $gameParty.performEscape();
    SoundManager.playEscape();
    var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
    if (success) {
        this.displayEscapeSuccessMessage();
        this._escaped = true;
        this.processAbort();
    } else {
        this.displayEscapeFailureMessage();
        this._escapeRatio += 0.1;
        $gameParty.clearActions();
        this.startTurn();
    }
    return success;
};
It does "$gameParty.removeBattleStates();" before it checks if your escape was successful.
I guess you'll need to move that line right under "if (success) {", so that it only removes your states IF you were successful at fleeing.

I don't really know about javascripting and plugins, but that's my guess.
EDIT3: Just tested my edit and it works.
If that's the case, I made the edit in my own game. Definitely needs to have this noted under "Important"
 

eivl

Local Hero
Xy$
0.00
$gameParty.removeBattleStates();
JavaScript:
Game_Battler.prototype.removeBattleStates = function() {
    this.states().forEach(function(state) {
        if (state.removeAtBattleEnd) {
            this.removeState(state.id);
        }
    }, this);
};
This is quite useful!

Just tested my edit and it works.
That is a bug, it has to be moved inside the if statement.
[doublepost=1448215768,1448215657][/doublepost]looks like everything should work now, mark @Eien Nanashi s answer as correct and @LTN Games can close the thread and move it to support i guess ;)
 

David FoxFire

Adventurer
Xy$
0.00
JavaScript:
Game_Battler.prototype.removeBattleStates = function() {
    this.states().forEach(function(state) {
        if (state.removeAtBattleEnd) {
            this.removeState(state.id);
        }
    }, this);
};
This is quite useful!


That is a bug, it has to be moved inside the if statement.
[doublepost=1448215768,1448215657][/doublepost]looks like everything should work now, mark @Eien Nanashi s answer as correct and @LTN Games can close the thread and move it to support i guess ;)
Thanks in all for the assistance, and the required move, of course.

I just have one thing: The code you mentioned, @eivl, where do i put it in? Put it in a plugin or in some Lunatic Mode note or somewhere else?
 

eivl

Local Hero
Xy$
0.00
You just need to put it in your plugin file. do you know how to alias call a method and add your own code?
 

David FoxFire

Adventurer
Xy$
0.00
You just need to put it in your plugin file. do you know how to alias call a method and add your own code?
Let me call up my Elminster plugin as a reference. I think it'll be something like this:

Code:
(function () {
    Game_Battler.prototype.removeBattleStates = function() {
        this.states().forEach(function(state) {
            if (state.removeAtBattleEnd) {
                this.removeState(state.id);
            }
        }, this);
    };
})();
And then put that into a blank Plug-in File, or add it to some other file in an unrelated spot, But I may be wrong.
 

eivl

Local Hero
Xy$
0.00
You must not do this....

Ok.. i will explain but i am traveling and i do not have the source files on me..

give me a few hours and i will explain how you do this ;)

I wrote about it in one of my javascript tutorials, but it might be difficult to connect the two!
 

David FoxFire

Adventurer
Xy$
0.00
You must not do this....

Ok.. i will explain but i am traveling and i do not have the source files on me..

give me a few hours and i will explain how you do this ;)

I wrote about it in one of my javascript tutorials, but it might be difficult to connect the two!
I knew I'd have it wrong. I'm surprised that I was able to do the array-loading plugin the way I did. I'll wait for you to connect the dots to me.
 

eivl

Local Hero
Xy$
0.00
Let us say you have a Method called :

JavaScript:
Game_Enemy.prototype.mySuperMethod= function() {
   // It has a lot of code written inside it.
};
This method is in the core file "rpg_objects.js"
Question : Can i change the core files?
Answer: No
Question: What if i find a bug and i want to fix it?
Answer: Noo!!!!!!!
Question: how do i fix it then?

Answer: well.... it depends if you want to add something new or change it to do something else.

To change it completely :
Just write this in your code
Game_Enemy.prototype.mySuperMethod= function() {
// write your new code here, and everything that was written in rpg_objects.js will be overwritten.
};[/code]

To add functions

Game_Enemy.prototype.mySuperMethod= function() {
// Something new
// It has a lot of code written inside it, but a small change to reflect the new code you just made
// More new stuff
};[/code]

Question : but what if the core files changes, do i have to update all my plugins to reflect this? Is there a way to copy the old code from the core and have it run inside my new code?

Answer: Yes, you can do that very easily by making an alias (names will vary, but it is the same thing)

JavaScript:
var _alias_mySuperMethod = Game_Enemy.prototype.mySuperMethod;
Game_Enemy.prototype.mySuperMethod= function() {
    _alias_mySuperMethod.call(this);
      // My new code with all my new changes
};
Well.. enough talking to myself.

This is how you change already existing methods, it is a very useful technique.
Hope it helps, let me know if you have anything else you need!
 

David FoxFire

Adventurer
Xy$
0.00
Okay then. Here's where I have the code at this point.

I'm going to add this script at the bottom of my Number-Crunching Plugin:

Code:
var _alias_removeBattleStates = Game_Battler.prototype.removeBattleStates;
Game_Battler.prototype.removeBattleStates = function() {
       this.states().forEach(function(state) {
           if (state.removeAtBattleEnd) {
               this.removeState(state.id);
           }
       }, this);
};
I have some code above that goes "var Elminister = Elminister || {};" I don't think it should apply here, since I'm merely adding something to rpg_objects.js
 

eivl

Local Hero
Xy$
0.00
It looks like you are not changing or adding anything to the method removeBattleStates or am i mistaken?
var Elminister = Elminister || {};

If you are using your own namespace as an object you can use it to save your information.

Elminister.removeBattleStates = Battle_Battler.prototype.removeBattleStates;

alas it looks like you do not need this in your example, but it could come in handy! ;)
 

David FoxFire

Adventurer
Xy$
0.00
All right then, I'll put it in, and when I start testing my encounters, I'll let you know :)


(The Admins can tag this as 'answered' now. Thanks to everyone.)
 
Last edited:

LTN Games

Master Mind
Resource Team
Xy$
0.01
Locking topic due to being solved, if for any reason you want it re-opened please report the post. Thanks :D
 
Status
Not open for further replies.
Top