Mr_Mime_1983

Veteran
Veteran
Joined
Aug 22, 2021
Messages
41
Reaction score
7
First Language
en
Primarily Uses
RMMV
I am trying to make it so this code will

1. If a Target dies in battle it will be knocked out

2. It will lose one Life Point



I have got the else part of the code to work where if all party members are taken from the party it's a game over. I just cannot get the first part to work correctly I tried many combinations any help would be appreciated.

Here is my code

<Custom Respond Effect>
if ($gameParty.inBattle() && target.hp <= 0)
{
if (target.lifePoints>0)
{
// Play the death animation.
target.startAnimation(65);
// Set the target to state knockout.
target.setstate(1);
// Decrement life points
target.$gameVariables.setValue(16, -1);
}
else
{
// Play death animation
$gameVariables.setValue(15, -1);
target.startAnimation(65);
// Remove actor from party
if ($gameParty.aliveMembers().length>0)
$gameParty.removeActor(target._actorId);
if ($gameParty.aliveMembers().length<0)
} SceneManager.goto(Scene_Gameover);
}
</Custom Respond Effect>

I tried

target.$gameVariables.setValue(16, -1);

$gameVariables.setValue(16, -1);



and even the original code "target.lifePoints--;" That @ATT_Turan made for me who was the original maker of this code.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,746
Reaction score
1,612
First Language
English
Primarily Uses
RMMV
I just cannot get the first part to work correctly I tried many combinations any help would be appreciated.
I vaguely remember this...can you link to the original thread/code? Can you explain how the solution I made for you didn't work correctly?
You've made changes using incorrect JavaScript syntax, so not only won't they work, it's hard to tell what you're trying to do. For example:
// Decrement life points
target.$gameVariables.setValue(16, -1);
This is wrong in at least two ways. Game variables are their own global object, not a member of actors; and that function takes a discrete value, not a +/- operation.

So what are you trying to do? Change it from each actor having individual life points to one party-wide count?

Also, any time you're pasting or typing code, you should put it in code tags (the </> icon on the top bar) so that it preserves indentations and the contents of brackets.
 

Mr_Mime_1983

Veteran
Veteran
Joined
Aug 22, 2021
Messages
41
Reaction score
7
First Language
en
Primarily Uses
RMMV
Here is the original post
Okay, I will try to make this as clear as I can I would like it so each individual actor has their own finite set amount of life points. And when that individual actor dies in battle they will be knocked out and lose one of their life points. And then if all characters are knocked out and removed from the party it will be a game over.



I would like it so each individual actor has a finite amount of life points.

Then I plan to make items and or quests that give back life points.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,746
Reaction score
1,612
First Language
English
Primarily Uses
RMMV
Okay, I will try to make this as clear as I can
That is mostly clear, but you didn't answer the basic question - what's wrong now? Your last post in that thread is saying thank you it works, so what doesn't work? What are you asking for help to change?

The part that isn't clear is in your original thread you wanted life points to resurrect the actor in battle. Now they seem to serve no purpose - what happens to an actor when they run out of life points? What is the point?

The bit you're talking about with game over when the entire party dies doesn't require any code, that's how the game works.
 
Last edited:

Mr_Mime_1983

Veteran
Veteran
Joined
Aug 22, 2021
Messages
41
Reaction score
7
First Language
en
Primarily Uses
RMMV
Here is the original post
Okay, I will try to make this as clear as I can I would like it so each individual actor has their own finite set amount of life points. And when that individual actor dies in battle they will be knocked out and lose one of their life points. And then if all characters are knocked out and removed from the party it will be a game over.



I would like it so each individual actor has a finite amount of life points.

Then I plan to make items and or quests that give back life points.
I just got to the part of my game making where I am testing out your code so that's what took so long to get to this point I only briefly tested it.



The way your code works it seems in my game testing doring battling is a character dies they get resurrected on the spot which I do not want I want them to get knocked out instead. They do lose life points but then it seems at the beginning of the next battle again they start with the default value of life points again. I want them to permanently lose to Life Point unless I otherwise give it back.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,746
Reaction score
1,612
First Language
English
Primarily Uses
RMMV
The way your code works it seems in my game testing doring battling is a character dies they get resurrected on the spot which I do not want I want them to get knocked out instead.
That was my understanding from your description of what you wanted.
They do lose life points but then it seems at the beginning of the next battle again they start with the default value of life points again.
That shouldn't happen unless you accidentally have code running to do so. Nothing in my state code sets their value.

What you're all describing is a quick fix except the points resetting, that must be an error in an event or something you're running.
 

Mr_Mime_1983

Veteran
Veteran
Joined
Aug 22, 2021
Messages
41
Reaction score
7
First Language
en
Primarily Uses
RMMV
I'm sorry if I was not clear enough the first time but I would really appreciate it if you could fix it to where they are knocked out instead. On the bright side through all this experience I am slowly learning about this JavaScript stuff. Because I tried very hard myself to modify the code through trial and error to get it to work the way I wanted, before coming here to ask for help.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,746
Reaction score
1,612
First Language
English
Primarily Uses
RMMV
On the bright side through all this experience I am slowly learning about this JavaScript stuff. Because I tried very hard myself to modify the code through trial and error to get it to work the way I wanted, before coming here to ask for help.
That's a good thing, insofar as it's good to look for answers before just asking. But it's also tricky because you want to make sure that your trial and error involves, say, actually doing JavaScript tutorials from w3schools or something, not just trying to put together things you've seen and make stuff up.

Stuff like that weird function call I quoted in my first reply to you is moderately basic terminology that wasn't doing anything similar to what you thought or wanted.

So. You want to spend a life point when a character gets knocked out. Otherwise they get removed from the party. I already gave you the code for that, the only thing that needs to be changed is we delete the lines that heal them. I even clearly labeled every line of code, so I dunno why you went for changing other things.
Code:
<Custom Respond Effect>
if ($gameParty.inBattle() && target.hp <= 0)
{
   if (target.lifePoints>0)
        // Decrement life points
        target.lifePoints--;
    else
   {
        // Play death animation
        target.startAnimation(65);
        // Remove actor from party
        if ($gameParty.aliveMembers().length>0)
            $gameParty.removeActor(target._actorId);
    }
}
</Custom Respond Effect>

As far as the game over stuff you're talking about...I don't see why you would need any special code for that. The engine automatically calls a game over any time all of your party is dead at the same time. So unless you mean something else that you haven't said, there's no reason to do anything about that.

And then as far as the life points setting their value...I gave you the code for how to do that in the previous thread, and I explained how to use it. If they are resetting after every fight, you're not doing something right and you should post screenshots of any event in your game that has anything to do with the life points.
 
Last edited:

Mr_Mime_1983

Veteran
Veteran
Joined
Aug 22, 2021
Messages
41
Reaction score
7
First Language
en
Primarily Uses
RMMV
Thank you so much for doing revisions to the code and I will keep in mind what you said next time I go messing with code. I wanted to try to be self-sufficient but it looks like I knew just enough to mess myself up.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,746
Reaction score
1,612
First Language
English
Primarily Uses
RMMV
Now please test it - it's very simple to pop yourself to any point in the game, or rig up an enemy battle to behave exactly the way you want. So don't let two months go by and you're starting another thread about the same thing, make sure this does what you want :biggrin:
 

Mr_Mime_1983

Veteran
Veteran
Joined
Aug 22, 2021
Messages
41
Reaction score
7
First Language
en
Primarily Uses
RMMV
I did test it out and it seems to be working the way I would like now again thank you so much for your patience and time. Later on tonight or tomorrow I will test out the code for making an item to increase life points.
 

Latest Threads

Latest Posts

Latest Profile Posts

When can we get this?
RPG Maker MZ Saturn.png
Saturn port when?
I'm new to rpgmaker mv, link me some good stuff to learn.
Finally, I have graduated from college and now I can put a lot more work into my game, after having not worked on it for the better part of a year.
post so i can change my profile picture ^^
Creating Some art for a fighter game.

Forum statistics

Threads
117,067
Messages
1,104,262
Members
153,040
Latest member
oscarcancer
Top